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/tab_update.c
int mnt_update_set_filename(struct libmnt_update* upd, const char* filename,
                            int userspace_only)
{
    const char* path = NULL;
    int rw = 0;

    if (!upd)
        return -EINVAL;

    /* filename explicitly defined */
    if (filename)
    {
        char* p = strdup(filename);
        if (!p)
            return -ENOMEM;

        upd->userspace_only = userspace_only;
        free(upd->filename);
        upd->filename = p;
    }

    if (upd->filename)
        return 0;

        /* detect tab filename -- /etc/mtab or /run/mount/utab
         */
#ifdef USE_LIBMOUNT_SUPPORT_MTAB
    mnt_has_regular_mtab(&path, &rw);
#endif
    if (!rw)
    {
        path = NULL;
        mnt_has_regular_utab(&path, &rw);
        if (!rw)
            return -EACCES;
        upd->userspace_only = TRUE;
    }
    upd->filename = strdup(path);
    if (!upd->filename)
        return -ENOMEM;

    return 0;
}
/*
 * Returns 0 on success, <0 in case of error.
 */
Returns 0 on success, <0 in case of error.
Returns 0 on success <0 in case of error .
int mnt_update_set_filename(struct libmnt_update* upd, const char* filename,
                            int userspace_only)
{
    const char* path = NULL;
    int rw = 0;
    if (!upd)
        return -EINVAL;
    if (filename)
    {
        char* p = strdup(filename);
        if (!p)
            return -ENOMEM;
        upd->userspace_only = userspace_only;
        free(upd->filename);
        upd->filename = p;
    }
    if (upd->filename)
        return 0;
#ifdef USE_LIBMOUNT_SUPPORT_MTAB
    mnt_has_regular_mtab(&path, &rw);
#endif
    if (!rw)
    {
        path = NULL;
        mnt_has_regular_utab(&path, &rw);
        if (!rw)
            return -EACCES;
        upd->userspace_only = TRUE;
    }
    upd->filename = strdup(path);
    if (!upd->filename)
        return -ENOMEM;
    return 0;
}
int mnt_update_set_filename ( struct libmnt_update * upd , const char * filename , int userspace_only ) { const char * path = NULL ; int rw = 0 ; if ( ! upd ) return - EINVAL ; if ( filename ) { char * p = strdup ( filename ) ; if ( ! p ) return - ENOMEM ; upd -> userspace_only = userspace_only ; free ( upd -> filename ) ; upd -> filename = p ; } if ( upd -> filename ) return 0 ; #ifdef USE_LIBMOUNT_SUPPORT_MTAB mnt_has_regular_mtab ( & path , & rw ) ; #endif if ( ! rw ) { path = NULL ; mnt_has_regular_utab ( & path , & rw ) ; if ( ! rw ) return - EACCES ; upd -> userspace_only = TRUE ; } upd -> filename = strdup ( path ) ; if ( ! upd -> filename ) return - ENOMEM ; return 0 ; }
Returns 0 on success, <0 in case of error.
Returns 0 on success <0 in case of error .
/* filename explicitly defined */ /* detect tab filename -- /etc/mtab or /run/mount/utab
         */