openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/libmount/src/monitor.c
int mnt_monitor_enable_userspace(struct libmnt_monitor* mn, int enable,
                                 const char* filename)
{
    struct monitor_entry* me;
    int rc = 0;

    if (!mn)
        return -EINVAL;

    me = monitor_get_entry(mn, MNT_MONITOR_TYPE_USERSPACE);
    if (me)
    {
        rc = monitor_modify_epoll(mn, me, enable);
        if (!enable)
            userspace_monitor_close_fd(mn, me);
        return rc;
    }
    if (!enable)
        return 0;

    DBG(MONITOR, ul_debugobj(mn, "allocate new userspace monitor"));

    if (!filename)
        filename = mnt_get_utab_path(); /* /run/mount/utab */
    if (!filename)
    {
        DBG(MONITOR,
            ul_debugobj(mn, "failed to get userspace mount table path"));
        return -EINVAL;
    }

    me = monitor_new_entry(mn);
    if (!me)
        goto err;

    me->type = MNT_MONITOR_TYPE_USERSPACE;
    me->opers = &userspace_opers;
    me->events = EPOLLIN;
    me->path = strdup(filename);
    if (!me->path)
        goto err;

    return monitor_modify_epoll(mn, me, TRUE);
err:
    rc = -errno;
    free_monitor_entry(me);
    DBG(MONITOR,
        ul_debugobj(mn, "failed to allocate userspace monitor [rc=%d]", rc));
    return rc;
}
/**
 * mnt_monitor_enable_userspace:
 * @mn: monitor
 * @enable: 0 or 1
 * @filename: overwrites default
 *
 * Enables or disables userspace monitoring. If the userspace monitor does not
 * exist and enable=1 then allocates new resources necessary for the monitor.
 *
 * If the top-level monitor has been already created (by mnt_monitor_get_fd()
 * or mnt_monitor_wait()) then it's updated according to @enable.
 *
 * The @filename is used only the first time when you enable the monitor. It's
 * impossible to have more than one userspace monitor. The recommended is to
 * use NULL as filename.
 *
 * The userspace monitor is unsupported for systems with classic regular
 * /etc/mtab file.
 *
 * Return: 0 on success and <0 on error
 */
@mn: monitor
@enable: 0 or 1
@filename: overwrites default

Enables or disables userspace monitoring. If the userspace monitor does not
exist and enable=1 then allocates new resources necessary for the monitor.

If the top-level monitor has been already created (by mnt_monitor_get_fd()
or mnt_monitor_wait()) then it's updated according to @enable.

The @filename is used only the first time when you enable the monitor. It's
impossible to have more than one userspace monitor. The recommended is to
use NULL as filename.

The userspace monitor is unsupported for systems with classic regular
/etc/mtab file.

0 on success and <0 on error
@mn : monitor @enable : 0 or 1 @filename : overwrites default Enables or disables userspace monitoring . If the userspace monitor does not exist and enable = 1 then allocates new resources necessary for the monitor . If the top - level monitor has been already created ( by mnt_monitor_get_fd () or mnt_monitor_wait () ) then it ' s updated according to @enable . The @filename is used only the first time when you enable the monitor . It ' s impossible to have more than one userspace monitor . The recommended is to use NULL as filename . The userspace monitor is unsupported for systems with classic regular / etc / mtab file . 0 on success and <0 on error
int mnt_monitor_enable_userspace(struct libmnt_monitor* mn, int enable,
                                 const char* filename)
{
    struct monitor_entry* me;
    int rc = 0;
    if (!mn)
        return -EINVAL;
    me = monitor_get_entry(mn, MNT_MONITOR_TYPE_USERSPACE);
    if (me)
    {
        rc = monitor_modify_epoll(mn, me, enable);
        if (!enable)
            userspace_monitor_close_fd(mn, me);
        return rc;
    }
    if (!enable)
        return 0;
    DBG(MONITOR, ul_debugobj(mn, "allocate new userspace monitor"));
    if (!filename)
        filename = mnt_get_utab_path(); 
    if (!filename)
    {
        DBG(MONITOR,
            ul_debugobj(mn, "failed to get userspace mount table path"));
        return -EINVAL;
    }
    me = monitor_new_entry(mn);
    if (!me)
        goto err;
    me->type = MNT_MONITOR_TYPE_USERSPACE;
    me->opers = &userspace_opers;
    me->events = EPOLLIN;
    me->path = strdup(filename);
    if (!me->path)
        goto err;
    return monitor_modify_epoll(mn, me, TRUE);
err:
    rc = -errno;
    free_monitor_entry(me);
    DBG(MONITOR,
        ul_debugobj(mn, "failed to allocate userspace monitor [rc=%d]", rc));
    return rc;
}
int mnt_monitor_enable_userspace ( struct libmnt_monitor * mn , int enable , const char * filename ) { struct monitor_entry * me ; int rc = 0 ; if ( ! mn ) return - EINVAL ; me = monitor_get_entry ( mn , MNT_MONITOR_TYPE_USERSPACE ) ; if ( me ) { rc = monitor_modify_epoll ( mn , me , enable ) ; if ( ! enable ) userspace_monitor_close_fd ( mn , me ) ; return rc ; } if ( ! enable ) return 0 ; DBG ( MONITOR , ul_debugobj ( mn , " " ) ) ; if ( ! filename ) filename = mnt_get_utab_path ( ) ; if ( ! filename ) { DBG ( MONITOR , ul_debugobj ( mn , " " ) ) ; return - EINVAL ; } me = monitor_new_entry ( mn ) ; if ( ! me ) goto err ; me -> type = MNT_MONITOR_TYPE_USERSPACE ; me -> opers = & userspace_opers ; me -> events = EPOLLIN ; me -> path = strdup ( filename ) ; if ( ! me -> path ) goto err ; return monitor_modify_epoll ( mn , me , TRUE ) ; err : rc = - errno ; free_monitor_entry ( me ) ; DBG ( MONITOR , ul_debugobj ( mn , " " , rc ) ) ; return rc ; }
mnt_monitor_enable_userspace:
 @mn: monitor
 @enable: 0 or 1
 @filename: overwrites default
mnt_monitor_enable_userspace : @mn : monitor @enable : 0 or 1 @filename : overwrites default
/* /run/mount/utab */