From 6a99c0b286384c98a012620a94fbc50a7c1adcbb Mon Sep 17 00:00:00 2001 From: maximilian attems Date: Fri, 25 Jul 2008 09:29:25 +0200 Subject: [PATCH] mount: add shortoptions for bind, move and rbind Reserving uppercase letters for mount operations: --move | -M --bind | -B --rbind | -R Add lowercase for the most needed mount operation that happen in initramfs: mount -M /sys /root/sys Note, we still have shared-subtree operations (--make-{slave,private,...}) without short options. [kzak@redhat.com: minor change in mount.8] Signed-off-by: maximilian attems Signed-off-by: Karel Zak --- mount/mount.8 | 23 +++++++++++++++++++++-- mount/mount.c | 26 +++++++++++++------------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/mount/mount.8 b/mount/mount.8 index 524ed28c..7487923d 100644 --- a/mount/mount.8 +++ b/mount/mount.8 @@ -108,6 +108,11 @@ file hierarchy somewhere else. The call is .br .B "mount --bind olddir newdir" .RE +or shortoption +.RS +.br +.B "mount -B olddir newdir" +.RE or fstab entry is: .RS .br @@ -123,6 +128,11 @@ a second place using .br .B "mount --rbind olddir newdir" .RE +or shortoption +.RS +.br +.B "mount -R olddir newdir" +.RE .\" available since Linux 2.4.11. Note that the filesystem mount options will remain the same as those @@ -135,6 +145,11 @@ to another place. The call is .br .B "mount --move olddir newdir" .RE +or shortoption +.RS +.br +.B "mount -M olddir newdir" +.RE Since Linux 2.6.15 it is possible to mark a mount and its submounts as shared, private, slave or unbindable. A shared mount provides ability to create mirrors @@ -787,11 +802,15 @@ For more details see .BR selinux (8) .RE .TP -.B \-\-bind +.B \-B, \-\-bind Remount a subtree somewhere else (so that its contents are available in both places). See above. .TP -.B \-\-move +.B \-R, \-\-rbind +Remount a subtree and all possible submounts somewhere else (so that its +contents are available in both places). See above. +.TP +.B \-M, \-\-move Move a subtree to some other place. See above. .SH "FILESYSTEM SPECIFIC MOUNT OPTIONS" diff --git a/mount/mount.c b/mount/mount.c index 8bf6154c..39a9bd85 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -1671,10 +1671,10 @@ static struct option longopts[] = { { "test-opts", 1, 0, 'O' }, { "pass-fd", 1, 0, 'p' }, { "types", 1, 0, 't' }, - { "bind", 0, 0, 128 }, - { "move", 0, 0, 133 }, + { "bind", 0, 0, 'B' }, + { "move", 0, 0, 'M' }, { "guess-fstype", 1, 0, 134 }, - { "rbind", 0, 0, 135 }, + { "rbind", 0, 0, 'R' }, { "make-shared", 0, 0, 136 }, { "make-slave", 0, 0, 137 }, { "make-private", 0, 0, 138 }, @@ -1861,12 +1861,15 @@ main(int argc, char *argv[]) { initproctitle(argc, argv); #endif - while ((c = getopt_long (argc, argv, "afFhilL:no:O:p:rsU:vVwt:", + while ((c = getopt_long (argc, argv, "aBfFhilL:Mno:O:p:rRsU:vVwt:", longopts, NULL)) != -1) { switch (c) { case 'a': /* mount everything in fstab */ ++mount_all; break; + case 'B': /* bind */ + mounttype = MS_BIND; + break; case 'f': /* fake: don't actually call mount(2) */ ++fake; break; @@ -1885,6 +1888,9 @@ main(int argc, char *argv[]) { case 'L': label = optarg; break; + case 'M': /* move */ + mounttype = MS_MOVE; + break; case 'n': /* do not write /etc/mtab */ ++nomtab; break; @@ -1901,6 +1907,9 @@ main(int argc, char *argv[]) { readonly = 1; readwrite = 0; break; + case 'R': /* rbind */ + mounttype = (MS_BIND | MS_REC); + break; case 's': /* allow sloppy mount options */ sloppy = 1; break; @@ -1923,12 +1932,6 @@ main(int argc, char *argv[]) { case 0: break; - case 128: /* bind */ - mounttype = MS_BIND; - break; - case 133: /* move */ - mounttype = MS_MOVE; - break; case 134: /* undocumented, may go away again: call: mount --guess-fstype device @@ -1940,9 +1943,6 @@ main(int argc, char *argv[]) { printf("%s\n", fstype ? fstype : "unknown"); exit(fstype ? 0 : EX_FAIL); } - case 135: - mounttype = (MS_BIND | MS_REC); - break; case 136: mounttype = MS_SHARED; -- 2.39.5