Tables update

Tables update — userspace mount information management

Functions

Types and Values

struct libmnt_update

Description

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

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

Functions

mnt_free_update ()

void
mnt_free_update (struct libmnt_update *upd);

Deallocates struct libmnt_update handler.

Parameters

upd

update

 

mnt_new_update ()

struct libmnt_update *
mnt_new_update (void);

Returns

newly allocated update handler


mnt_table_replace_file ()

int
mnt_table_replace_file (struct libmnt_table *tb,
                        const char *filename);

This function replaces file by the new content from tb .

Parameters

tb

parsed file (e.g. fstab)

 

filename

target

 

Returns

0 on success, negative number on error.


mnt_table_write_file ()

int
mnt_table_write_file (struct libmnt_table *tb,
                      FILE *file);

This function writes tb to file .

Parameters

tb

parsed file (e.g. fstab)

 

file

target

 

Returns

0 on success, negative number on error.


mnt_update_force_rdonly ()

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

Parameters

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 the file name (e.g. /etc/mtab) of the up-dated file.

Parameters

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);

Parameters

upd

update

 

Returns

update filesystem entry or NULL


mnt_update_get_mflags ()

unsigned long
mnt_update_get_mflags (struct libmnt_update *upd);

Parameters

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);

Parameters

upd

update handler

 

Returns

1 if entry described by upd is successfully prepared and will be written to the 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);

Parameters

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 an automatically created lock blocks all signals.

See also mnt_lock_block_signals() and mnt_context_get_lock().

Parameters

upd

update

 

lc

lock or NULL

 

Returns

0 on success, negative number on error.

Types and Values

struct libmnt_update

struct libmnt_update;

/etc/mtab or utab update description