#include "fsprobe.h"
#include "sundries.h" /* for xstrdup */
#include "nls.h"
+#include "realpath.h"
/* list of already tested filesystems by fsprobe_procfsloop_mount() */
static struct tried {
#include "fsprobe.h"
#include "mount_paths.h"
#include "nls.h"
+#include "realpath.h"
#define streq(s, t) (strcmp ((s), (t)) == 0)
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
/* dir */
if (!streq(mc->m.mnt_dir, dir)) {
- char *dr = canonicalize(mc->m.mnt_dir);
+ char *dr = canonicalize_mountpoint(mc->m.mnt_dir);
int ok = 0;
if (streq(dr, dir))
if (streq(mc->m.mnt_dir, dir))
return mc;
- cdir = canonicalize(dir);
+ cdir = canonicalize_mountpoint(dir);
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
if (streq(mc->m.mnt_dir, cdir)) {
free(cdir);
mntFILE *my_setmntent (const char *file, char *mode) { return NULL; }
void my_endmntent (mntFILE *mfp) { }
int my_addmntent (mntFILE *mfp, struct my_mntent *mnt) { return 0; }
-char *myrealpath(const char *path, char *resolved_path, int m) { return NULL; }
+
+char *canonicalize (const char *path) { return NULL; }
+char *canonicalize_mountpoint (const char *path) { return NULL; }
int
main(int argc, char **argv)
#include "mount_paths.h"
#include "env.h"
#include "nls.h"
+#include "realpath.h"
#define DO_PS_FIDDLING
struct my_mntent mnt;
mnt.mnt_fsname = canonicalize (spec);
- mnt.mnt_dir = canonicalize (node);
+ mnt.mnt_dir = canonicalize_mountpoint (node);
mnt.mnt_type = type;
mnt.mnt_opts = opts;
mnt.mnt_freq = freq;
return ret;
spec = canonicalize(spec0);
- node = canonicalize(node0);
+ node = canonicalize_mountpoint(node0);
mc0 = mtab_head();
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
# define MAXSYMLINKS 256
#endif
+
+/* 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_mountpoint (const char *path) {
+ if (path == NULL)
+ return NULL;
+
+ if (streq(path, "none") ||
+ streq(path, "proc") ||
+ streq(path, "devpts"))
+ return xstrdup(path);
+
+ return canonicalize(path);
+}
+
+char *
+canonicalize (const char *path) {
+ char canonical[PATH_MAX+2];
+
+ if (path == NULL)
+ return NULL;
+
+ if (myrealpath (path, canonical, PATH_MAX+1))
+ return xstrdup(canonical);
+
+ return xstrdup(path);
+}
+
char *
myrealpath(const char *path, char *resolved_path, int maxreslth) {
int readlinks = 0;
#endif
extern char *myrealpath(const char *path, char *resolved_path, int m);
+extern char *canonicalize (const char *path);
+extern char *canonicalize_mountpoint (const char *path);
#endif /* REALPATH_H */
return 1;
}
-/* 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 (const char *path) {
- char canonical[PATH_MAX+2];
-
- if (path == NULL)
- return NULL;
-
-#if 1
- if (streq(path, "none") ||
- streq(path, "proc") ||
- streq(path, "devpts"))
- return xstrdup(path);
-#endif
- if (myrealpath (path, canonical, PATH_MAX+1))
- return xstrdup(canonical);
-
- return xstrdup(path);
-}
-
-
/*
* Parses NAME=value, returns -1 on parse error, 0 success. The success is also
* when the 'spec' doesn't contain name=value pair (because the spec could be
/* Functions in sundries.c that are used in mount.c and umount.c */
void block_signals (int how);
-char *canonicalize (const char *path);
void error (const char *fmt, ...);
int matching_type (const char *type, const char *types);
int matching_opts (const char *options, const char *test_opts);
#include "fstab.h"
#include "env.h"
#include "nls.h"
+#include "realpath.h"
#if defined(MNT_FORCE)
/* Interesting ... it seems libc knows about MNT_FORCE and presumably