summaryrefslogtreecommitdiffstats
path: root/mount/sundries.c
diff options
context:
space:
mode:
authorKarel Zak2009-02-03 22:12:03 +0100
committerKarel Zak2009-02-11 23:55:51 +0100
commit74a9c6f7b709cb2c3e3863cb91ed1c869a25da84 (patch)
treed34c59a70ec060a556f0c22174bf3c21c5be7f24 /mount/sundries.c
parentblkid: fix typo (syntax error) (diff)
downloadkernel-qcow2-util-linux-74a9c6f7b709cb2c3e3863cb91ed1c869a25da84.tar.gz
kernel-qcow2-util-linux-74a9c6f7b709cb2c3e3863cb91ed1c869a25da84.tar.xz
kernel-qcow2-util-linux-74a9c6f7b709cb2c3e3863cb91ed1c869a25da84.zip
mount: move realpath.c code to lib/
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/sundries.c')
-rw-r--r--mount/sundries.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/mount/sundries.c b/mount/sundries.c
index fad8eaec6..bdaf11722 100644
--- a/mount/sundries.c
+++ b/mount/sundries.c
@@ -11,9 +11,11 @@
#include <stdio.h>
#include <string.h>
#include <mntent.h> /* for MNTTYPE_SWAP */
+
+#include "canonicalize.h"
+
#include "fstab.h"
#include "sundries.h"
-#include "realpath.h"
#include "xmalloc.h"
#include "nls.h"
@@ -276,3 +278,47 @@ parse_spec(const char *spec, char **name, char **value)
return 0;
}
+int
+is_pseudo_fs(const char *type)
+{
+ if (type == NULL || *type == '/')
+ return 0;
+ if (streq(type, "none") ||
+ streq(type, "proc") ||
+ streq(type, "tmpfs") ||
+ streq(type, "sysfs") ||
+ streq(type, "devpts"))
+ return 1;
+ return 0;
+}
+
+/* Make a canonical pathname from PATH. Returns a freshly malloced string.
+ It is up the *caller* to ensure that the PATH is sensible. i.e.
+ canonicalize ("/dev/fd0/.") returns "/dev/fd0" even though ``/dev/fd0/.''
+ is not a legal pathname for ``/dev/fd0''. Anything we cannot parse
+ we return unmodified. */
+char *
+canonicalize_spec (const char *path)
+{
+ char *res;
+
+ if (path == NULL)
+ return NULL;
+ if (is_pseudo_fs(path))
+ return xstrdup(path);
+
+ res = canonicalize_path(path);
+ if (!res)
+ die(EX_SYSERR, _("not enough memory"));
+ return res;
+}
+
+char *canonicalize (const char *path)
+{
+ char *res = canonicalize_path(path);
+
+ if (!res)
+ die(EX_SYSERR, _("not enough memory"));
+ return res;
+}
+