Top |
void | mnt_free_lock () |
int | mnt_lock_file () |
struct libmnt_lock * | mnt_new_lock () |
void | mnt_unlock_file () |
int | mnt_lock_block_signals () |
The mtab lock is backwards compatible with the standard linux /etc/mtab locking. Note, it's necessary to use the same locking schema in all applications that access the file.
int
mnt_lock_file (struct libmnt_lock *ml
);
Creates a lock file (e.g. /etc/mtab~). Note that this function may
use alarm()
.
Your application always has to call mnt_unlock_file()
before exit.
Traditional mtab locking scheme:
create linkfile (e.g. /etc/mtab~.$PID)
link linkfile --> lockfile (e.g. /etc/mtab~.$PID --> /etc/mtab~)
a) link()
success: setups F_SETLK lock (see fcnlt(2))
b) link()
failed: wait (max 30s) on F_SETLKW lock, goto 2.
Note that when the lock is used by mnt_update_table()
interface then libmount
uses flock()
for private library file /run/mount/utab. The fcnlt(2) is used only
for backwardly compatible stuff like /etc/mtab.
struct libmnt_lock * mnt_new_lock (const char *datafile
,pid_t id
);
void
mnt_unlock_file (struct libmnt_lock *ml
);
Unlocks the file. The function could be called independently of the lock status (for example from exit(3)).