Tables update

Tables update — userspace mount information management

Synopsis

struct              libmnt_update;
void                mnt_free_update                     (struct libmnt_update *upd);
struct libmnt_update * mnt_new_update                   (void);
int                 mnt_update_force_rdonly             (struct libmnt_update *upd,
                                                         int rdonly);
const char *        mnt_update_get_filename             (struct libmnt_update *upd);
struct libmnt_fs *  mnt_update_get_fs                   (struct libmnt_update *upd);
unsigned long       mnt_update_get_mflags               (struct libmnt_update *upd);
int                 mnt_update_is_ready                 (struct libmnt_update *upd);
int                 mnt_update_set_fs                   (struct libmnt_update *upd,
                                                         unsigned long  mountflags,
                                                         const char *target,
                                                         struct libmnt_fs *fs);
int                 mnt_update_table                    (struct libmnt_update *upd,
                                                         struct libmnt_lock *lc);

Description

The struct libmnt_update provides abstraction to manage mount options in userspace independently on system configuration. This low-level API works on system with and without /etc/mtab. On systems without the regular /etc/mtab file are userspace mount options (e.g. user=) stored to the /run/mount/utab file.

It's recommended to use high-level struct libmnt_context API.

Details

struct libmnt_update

struct libmnt_update;

/etc/mtab or utab update description


mnt_free_update ()

void                mnt_free_update                     (struct libmnt_update *upd);

Deallocates struct libmnt_update handler.

upd :

update

mnt_new_update ()

struct libmnt_update * mnt_new_update                   (void);

Returns :

newly allocated update handler

mnt_update_force_rdonly ()

int                 mnt_update_force_rdonly             (struct libmnt_update *upd,
                                                         int rdonly);

upd :

update

rdonly :

is read-only?

Returns :

0 on success and negative number in case of error.

mnt_update_get_filename ()

const char *        mnt_update_get_filename             (struct libmnt_update *upd);

This function returns file name (e.g. /etc/mtab) for the up-dated file.

upd :

update

Returns :

pointer to filename that will be updated or NULL in case of error.

mnt_update_get_fs ()

struct libmnt_fs *  mnt_update_get_fs                   (struct libmnt_update *upd);

upd :

update

Returns :

update filesystem entry or NULL

mnt_update_get_mflags ()

unsigned long       mnt_update_get_mflags               (struct libmnt_update *upd);

upd :

update

Returns :

mount flags as was set by mnt_update_set_fs()

mnt_update_is_ready ()

int                 mnt_update_is_ready                 (struct libmnt_update *upd);

upd :

update handler

Returns :

1 if entry described by upd is successfully prepared and will be written to mtab/utab file.

mnt_update_set_fs ()

int                 mnt_update_set_fs                   (struct libmnt_update *upd,
                                                         unsigned long  mountflags,
                                                         const char *target,
                                                         struct libmnt_fs *fs);

upd :

update handler

mountflags :

MS_* flags

target :

umount target, must be NULL for mount

fs :

mount filesystem description, must be NULL for umount

Returns :

<0 in case on error, 0 on success, 1 if update is unnecessary.

mnt_update_table ()

int                 mnt_update_table                    (struct libmnt_update *upd,
                                                         struct libmnt_lock *lc);

High-level API to update /etc/mtab (or private /run/mount/utab file).

The lc lock is optional and will be created if necessary. Note that the automatically created lock blocks all signals.

See also mnt_lock_block_signals() and mnt_context_get_lock().

upd :

update

lc :

lock or NULL

Returns :

0 on success, negative number on error.