diff options
author | Karel Zak | 2012-04-18 10:09:49 +0200 |
---|---|---|
committer | Karel Zak | 2012-04-18 10:09:49 +0200 |
commit | d78907784617b91a5fd609874fd7480119245b4b (patch) | |
tree | e0a9e5e0098672f1edf0e6ad8ecd616e62235325 /sys-utils/mount.c | |
parent | libmount: add mnt_context_get_options() (diff) | |
download | kernel-qcow2-util-linux-d78907784617b91a5fd609874fd7480119245b4b.tar.gz kernel-qcow2-util-linux-d78907784617b91a5fd609874fd7480119245b4b.tar.xz kernel-qcow2-util-linux-d78907784617b91a5fd609874fd7480119245b4b.zip |
mount: (new) be more pedantic about --make-*
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/mount.c')
-rw-r--r-- | sys-utils/mount.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/sys-utils/mount.c b/sys-utils/mount.c index d1e2e16c7..f5df087ea 100644 --- a/sys-utils/mount.c +++ b/sys-utils/mount.c @@ -789,37 +789,37 @@ int main(int argc, char **argv) mnt_context_enable_sloppy(cxt, TRUE); break; case 'B': - oper = MS_BIND; + oper |= MS_BIND; break; case 'M': - oper = MS_MOVE; + oper |= MS_MOVE; break; case 'R': - oper = (MS_BIND | MS_REC); + oper |= (MS_BIND | MS_REC); break; case MOUNT_OPT_SHARED: - oper = MS_SHARED; + oper |= MS_SHARED; break; case MOUNT_OPT_SLAVE: - oper = MS_SLAVE; + oper |= MS_SLAVE; break; case MOUNT_OPT_PRIVATE: - oper = MS_PRIVATE; + oper |= MS_PRIVATE; break; case MOUNT_OPT_UNBINDABLE: - oper = MS_UNBINDABLE; + oper |= MS_UNBINDABLE; break; case MOUNT_OPT_RSHARED: - oper = (MS_SHARED | MS_REC); + oper |= (MS_SHARED | MS_REC); break; case MOUNT_OPT_RSLAVE: - oper = (MS_SLAVE | MS_REC); + oper |= (MS_SLAVE | MS_REC); break; case MOUNT_OPT_RPRIVATE: - oper = (MS_PRIVATE | MS_REC); + oper |= (MS_PRIVATE | MS_REC); break; case MOUNT_OPT_RUNBINDABLE: - oper = (MS_UNBINDABLE | MS_REC); + oper |= (MS_UNBINDABLE | MS_REC); break; default: usage(stderr); @@ -885,6 +885,12 @@ int main(int argc, char **argv) usage(stderr); if (oper) { + if (!is_power_of_2(oper)) + errx(MOUNT_EX_USAGE, _("propagation flags (--make-* or --bind options) are mutually exclusive")); + + if (oper != MS_BIND && mnt_context_get_options(cxt)) + errx(MOUNT_EX_USAGE, _("propagation flags (--make-* options) cannot be mixed with another mount options")); + /* MS_PROPAGATION operations, let's set the mount flags */ mnt_context_set_mflags(cxt, oper); |