From 6498ece0e777ae1aeab1319a21abec7457fb940f Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 15 Jan 2013 13:55:29 +0100 Subject: libmount: allow to use propagation flags in fstab Linux kernel does not allow to change more than one propagation flag by one mount(2) syscall. The flags also cannot be mixed with another mount options. It means that the propagation flags cannot be stored in /etc/fstab, manual "mount --make-* " is always necessary after successful mount. Painful... This patch implements additional mount(2) after previous successful mount(2) (or exec /sbin/mount.). For example: mount /dev/sda1 /A -o private,unbindable,ro or fstab entry: /dev/sda1 /A auto ro,private,unbindable is implemented by three mount(2) calls: - 1st mounts /dev/sda1 with MS_RDONLY - 2nd sets MS_PRIVATE flag - 3rd sets MS_UNBINDABLE flag. It's the same as as to manually call: mount /dev/sda1 /A -o ro mount --make-private /A mount --make-unbindable /A This solution is not atomic, and umount(2) is not called if propagation flags are not successfully applied, only error is returned. This change does not affect libmount API, so one beautiful day when mount(2) syscall will be improved we can drop this nasty patch. Signed-off-by: Karel Zak --- libmount/src/optmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libmount/src/optmap.c') diff --git a/libmount/src/optmap.c b/libmount/src/optmap.c index 68217cebe..7c0a23508 100644 --- a/libmount/src/optmap.c +++ b/libmount/src/optmap.c @@ -111,6 +111,16 @@ static const struct libmnt_optmap linux_flags_map[] = #ifdef MS_STRICTATIME { "strictatime", MS_STRICTATIME }, /* Strict atime semantics */ { "nostrictatime", MS_STRICTATIME, MNT_INVERT }, /* kernel default atime */ +#endif +#ifdef MS_PROPAGATION + { "unbindable", MS_UNBINDABLE, MNT_NOHLPS | MNT_NOMTAB }, /* Unbindable */ + { "runbindable", MS_UNBINDABLE | MS_REC, MNT_NOHLPS | MNT_NOMTAB }, + { "private", MS_PRIVATE, MNT_NOHLPS | MNT_NOMTAB }, /* Private */ + { "rprivate", MS_PRIVATE | MS_REC, MNT_NOHLPS | MNT_NOMTAB }, + { "slave", MS_SLAVE, MNT_NOHLPS | MNT_NOMTAB }, /* Slave */ + { "rslave", MS_SLAVE | MS_REC, MNT_NOHLPS | MNT_NOMTAB }, + { "shared", MS_SHARED, MNT_NOHLPS | MNT_NOMTAB }, /* Shared */ + { "rshared", MS_SHARED | MS_REC, MNT_NOHLPS | MNT_NOMTAB }, #endif { NULL, 0, 0 } }; -- cgit v1.2.3-55-g7522