if (!spec)
return NULL;
+ if (is_pseudo_fs(spec))
+ return xstrdup(spec);
+
if (parse_spec(spec, &name, &value) != 0)
return NULL; /* parse error */
if (!spec)
return NULL;
+ if (is_pseudo_fs(spec))
+ return xstrdup(spec);
if (parse_spec(spec, &name, &value) != 0)
return NULL; /* parse error */
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
/* dir */
if (!streq(mc->m.mnt_dir, dir)) {
- char *dr = canonicalize_mountpoint(mc->m.mnt_dir);
+ char *dr = canonicalize(mc->m.mnt_dir);
int ok = 0;
if (streq(dr, dir))
/* spec */
if (!streq(mc->m.mnt_fsname, spec)) {
- char *fs = canonicalize(mc->m.mnt_fsname);
+ char *fs = canonicalize_spec(mc->m.mnt_fsname);
int ok = 0;
if (streq(fs, spec))
if (streq(mc->m.mnt_dir, dir))
return mc;
- cdir = canonicalize_mountpoint(dir);
+ cdir = canonicalize(dir);
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
if (streq(mc->m.mnt_dir, cdir)) {
free(cdir);
return mc;
}
- cspec = canonicalize(spec);
+ cspec = canonicalize_spec(spec);
mc = getfs_by_devname(cspec);
free(cspec);
strncmp(mc->m.mnt_fsname, "UUID=", 5) == 0)
continue;
- fs = canonicalize(mc->m.mnt_fsname);
+ fs = canonicalize_spec(mc->m.mnt_fsname);
if (streq(fs, devname)) {
free(fs);
return mc;
int my_addmntent (mntFILE *mfp, struct my_mntent *mnt) { return 0; }
char *canonicalize (const char *path) { return NULL; }
-char *canonicalize_mountpoint (const char *path) { return NULL; }
+char *canonicalize_spec (const char *path) { return NULL; }
+int is_pseudo_fs(const char *type) { return 0; };
int
main(int argc, char **argv)
printf (" type %s", me->mnt_type);
if (me->mnt_opts != NULL)
printf (" (%s)", me->mnt_opts);
- if (list_with_volumelabel) {
+ if (list_with_volumelabel && is_pseudo_fs(me->mnt_type) == 0) {
const char *devname = fsprobe_get_devname(me->mnt_fsname);
if (devname) {
}
static int
-already (const char *spec, const char *node) {
+already (const char *spec0, const char *node0) {
struct mntentchn *mc;
int ret = 1;
+ char *spec = canonicalize_spec(spec0);
+ char *node = canonicalize(node0);
if ((mc = getmntfile(node)) != NULL)
error (_("mount: according to mtab, "
spec, mc->m.mnt_dir);
else
ret = 0;
+
+ free(spec);
+ free(node);
+
return ret;
}
char *node;
int res = 0;
- node = canonicalize_mountpoint(node0);
+ node = canonicalize(node0);
/* Search for mountpoint node in mtab,
* procceed if any of these has the loop option set or
const char *opts, int flags, int freq, int pass) {
struct my_mntent mnt;
- mnt.mnt_fsname = canonicalize (spec);
- mnt.mnt_dir = canonicalize_mountpoint (node);
+ mnt.mnt_fsname = is_pseudo_fs(type) ? xstrdup(spec) : canonicalize(spec);
+ mnt.mnt_dir = canonicalize (node);
mnt.mnt_type = type;
mnt.mnt_opts = opts;
mnt.mnt_freq = freq;
if (!spec)
return ret;
- node = canonicalize_mountpoint(node0);
+ node = canonicalize(node0);
mc0 = mtab_head();
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
# define MAXSYMLINKS 256
#endif
+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.
is not a legal pathname for ``/dev/fd0''. Anything we cannot parse
we return unmodified. */
char *
-canonicalize_mountpoint (const char *path) {
+canonicalize_spec (const char *path)
+{
if (path == NULL)
return NULL;
-
- if (streq(path, "none") ||
- streq(path, "proc") ||
- streq(path, "devpts"))
+ if (is_pseudo_fs(path))
return xstrdup(path);
-
return canonicalize(path);
}
extern char *myrealpath(const char *path, char *resolved_path, int m);
extern char *canonicalize (const char *path);
-extern char *canonicalize_mountpoint (const char *path);
+extern char *canonicalize_spec (const char *path);
+extern int is_pseudo_fs(const char *type);
#endif /* REALPATH_H */