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_force_rdonly(struct libmnt_update* upd, int rdonly)
{
    int rc = 0;

    if (!upd || !upd->fs)
        return -EINVAL;

    if (rdonly && (upd->mountflags & MS_RDONLY))
        return 0;
    if (!rdonly && !(upd->mountflags & MS_RDONLY))
        return 0;

    if (!upd->userspace_only)
    {
        /* /etc/mtab -- we care about VFS options there */
        const char* o = mnt_fs_get_options(upd->fs);
        char* n = o ? strdup(o) : NULL;

        if (n)
            mnt_optstr_remove_option(&n, rdonly ? "rw" : "ro");
        if (!mnt_optstr_prepend_option(&n, rdonly ? "ro" : "rw", NULL))
            rc = mnt_fs_set_options(upd->fs, n);

        free(n);
    }

    if (rdonly)
        upd->mountflags &= ~MS_RDONLY;
    else
        upd->mountflags |= MS_RDONLY;

    return rc;
}
/**
 * mnt_update_force_rdonly:
 * @upd: update
 * @rdonly: is read-only?
 *
 * Returns: 0 on success and negative number in case of error.
 */


0 on success and negative number in case of error.
0 on success and negative number in case of error .
int mnt_update_force_rdonly(struct libmnt_update* upd, int rdonly)
{
    int rc = 0;
    if (!upd || !upd->fs)
        return -EINVAL;
    if (rdonly && (upd->mountflags & MS_RDONLY))
        return 0;
    if (!rdonly && !(upd->mountflags & MS_RDONLY))
        return 0;
    if (!upd->userspace_only)
    {
        const char* o = mnt_fs_get_options(upd->fs);
        char* n = o ? strdup(o) : NULL;
        if (n)
            mnt_optstr_remove_option(&n, rdonly ? "rw" : "ro");
        if (!mnt_optstr_prepend_option(&n, rdonly ? "ro" : "rw", NULL))
            rc = mnt_fs_set_options(upd->fs, n);
        free(n);
    }
    if (rdonly)
        upd->mountflags &= ~MS_RDONLY;
    else
        upd->mountflags |= MS_RDONLY;
    return rc;
}
int mnt_update_force_rdonly ( struct libmnt_update * upd , int rdonly ) { int rc = 0 ; if ( ! upd || ! upd -> fs ) return - EINVAL ; if ( rdonly && ( upd -> mountflags & MS_RDONLY ) ) return 0 ; if ( ! rdonly && ! ( upd -> mountflags & MS_RDONLY ) ) return 0 ; if ( ! upd -> userspace_only ) { const char * o = mnt_fs_get_options ( upd -> fs ) ; char * n = o ? strdup ( o ) : NULL ; if ( n ) mnt_optstr_remove_option ( & n , rdonly ? " " : " " ) ; if ( ! mnt_optstr_prepend_option ( & n , rdonly ? " " : " " , NULL ) ) rc = mnt_fs_set_options ( upd -> fs , n ) ; free ( n ) ; } if ( rdonly ) upd -> mountflags &= ~ MS_RDONLY ; else upd -> mountflags |= MS_RDONLY ; return rc ; }
mnt_update_force_rdonly:
 @upd: update
 @rdonly: is read-only?
mnt_update_force_rdonly : @upd : update @rdonly : is read - only?
/* /etc/mtab -- we care about VFS options there */