From f92dc20fcb9bb9f15ac95e0e3d6ae96ecfb59619 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 4 Oct 2007 15:07:30 +0200 Subject: [PATCH] mount: cleanup "none" fstype usage * disable to call /sbin/mount.none * rewrite fstype to "none" for MS_BIND and MS_MOVE * add notes about "none" to fstab.5 and mount.8 Signed-off-by: Karel Zak --- mount/fstab.5 | 3 +++ mount/mount.8 | 5 +++++ mount/mount.c | 9 ++++++--- mount/umount.c | 5 ++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mount/fstab.5 b/mount/fstab.5 index a7978b5f..6109b5ee 100644 --- a/mount/fstab.5 +++ b/mount/fstab.5 @@ -142,6 +142,9 @@ An entry .I ignore causes the line to be ignored. This is useful to show disk partitions which are currently unused. +An entry +.I none +is useful for bind or move mounts. The fourth field, .RI ( fs_mntops ), diff --git a/mount/mount.8 b/mount/mount.8 index 01001ade..54b11d46 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 fstab entry is: +.RS +.br +.B "/olddir /newdir none bind" +.RE After this call the same contents is accessible in two places. One can also remount a single file (on a single file). diff --git a/mount/mount.c b/mount/mount.c index 5bc2b30c..2e458cad 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -624,7 +624,10 @@ check_special_mountprog(const char *spec, const char *node, const char *type, in if (!external_allowed) return 0; - if (type && strlen(type) < 100) { + if (type == NULL || strcmp(type, "none") == 0) + return 0; + + if (strlen(type) < 100) { sprintf(mountprog, "/sbin/mount.%s", type); if (stat(mountprog, &statbuf) == 0) { if (verbose) @@ -719,8 +722,8 @@ guess_fstype_and_mount(const char *spec, const char *node, const char **types, if (*types && strcasecmp (*types, "auto") == 0) *types = NULL; - if (!*types && (flags & (MS_BIND | MS_MOVE))) - *types = "none"; /* random, but not "bind" */ + if (flags & (MS_BIND | MS_MOVE)) + *types = "none"; if (!*types && !(flags & MS_REMOUNT)) { *types = guess_fstype_by_devname(spec); diff --git a/mount/umount.c b/mount/umount.c index 32216198..6af43546 100644 --- a/mount/umount.c +++ b/mount/umount.c @@ -94,7 +94,10 @@ check_special_umountprog(const char *spec, const char *node, if (!external_allowed) return 0; - if (type && strlen(type) < 100) { + if (type == NULL || strcmp(type, "none") == 0) + return 0; + + if (strlen(type) < 100) { sprintf(umountprog, "/sbin/umount.%s", type); if (stat(umountprog, &statbuf) == 0) { res = fork(); -- 2.39.5