From: Karel Zak Date: Thu, 3 Dec 2009 14:30:53 +0000 (+0100) Subject: mount: add --no-canonicalize option X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45fc569a75d4e83a045027acf8e2eda08638fa0d;p=util-linux mount: add --no-canonicalize option For example the /sbin/mount.fuse command calls mount -i -f /dev/foo /absolut/path and it does not make sense to canonicalize already absolute paths. The new --no-canonicalize option allows to avoid unwanted readlink() calls. Signed-off-by: Karel Zak --- diff --git a/mount/mount.8 b/mount/mount.8 index 57b3571c..66f92563 100644 --- a/mount/mount.8 +++ b/mount/mount.8 @@ -449,6 +449,13 @@ Mount without writing in This is necessary for example when .I /etc is on a read-only filesystem. +.IP "\fB\-\-no\-canonicalize\fP" +Don't canonicalize paths. The mount command canonicalizes all paths +(from command line or fstab) and stores canonicalized paths to the +.IR /etc/mtab +file. This option can be used together with the +.B \-f +flag for already canonicalized absolut paths. .IP "\fB\-p, \-\-pass\-fd \fInum\fP" In case of a loop mount with encryption, read the passphrase from file descriptor diff --git a/mount/mount.c b/mount/mount.c index 3eafa92a..f3f8910e 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -1924,6 +1924,7 @@ static struct option longopts[] = { { "make-rslave", 0, 0, 141 }, { "make-rprivate", 0, 0, 142 }, { "make-runbindable", 0, 0, 143 }, + { "no-canonicalize", 0, 0, 144 }, { "internal-only", 0, 0, 'i' }, { NULL, 0, 0, 0 } }; @@ -2216,7 +2217,9 @@ main(int argc, char *argv[]) { case 143: mounttype = (MS_UNBINDABLE | MS_REC); break; - + case 144: + nocanonicalize = 1; + break; case '?': default: usage (stderr, EX_USAGE); diff --git a/mount/sundries.c b/mount/sundries.c index 5c33b113..1d9eb88e 100644 --- a/mount/sundries.c +++ b/mount/sundries.c @@ -21,6 +21,7 @@ int mount_quiet; int verbose; +int nocanonicalize; char *progname; char * @@ -270,9 +271,9 @@ canonicalize_spec (const char *path) { char *res; - if (path == NULL) + if (!path) return NULL; - if (is_pseudo_fs(path)) + if (nocanonicalize || is_pseudo_fs(path)) return xstrdup(path); res = canonicalize_path(path); @@ -283,8 +284,14 @@ canonicalize_spec (const char *path) char *canonicalize (const char *path) { - char *res = canonicalize_path(path); + char *res; + if (!path) + return NULL; + else if (nocanonicalize) + return xstrdup(path); + + res = canonicalize_path(path); if (!res) die(EX_SYSERR, _("not enough memory")); return res; diff --git a/mount/sundries.h b/mount/sundries.h index 6d576e9d..3b6a4644 100644 --- a/mount/sundries.h +++ b/mount/sundries.h @@ -16,6 +16,7 @@ /* global mount, umount, and losetup variables */ extern int mount_quiet; extern int verbose; +extern int nocanonicalize; extern char *progname; #define streq(s, t) (strcmp ((s), (t)) == 0)