[PATCH 2/2] mountpoint: support symbolic and relative paths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use our own canonicalize library to resolve a provided path before
checking if its a mountpoint.

Signed-off-by: Dave Reisner <dreisner@xxxxxxxxxxxxx>
---
Unless I've missed something, this should bring u-l's mountpoint to feature
parity with sysvinit's.

 sys-utils/Makefile.am  |    1 +
 sys-utils/mountpoint.c |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/sys-utils/Makefile.am b/sys-utils/Makefile.am
index 8059ee6..34108da 100644
--- a/sys-utils/Makefile.am
+++ b/sys-utils/Makefile.am
@@ -44,6 +44,7 @@ flock_SOURCES = flock.c $(top_srcdir)/lib/strutils.c
 
 if BUILD_MOUNTPOINT
 bin_PROGRAMS += mountpoint
+mountpoint_SOURCES = mountpoint.c $(top_srcdir)/lib/canonicalize.c
 mountpoint_LDADD = $(ul_libmount_la)
 mountpoint_CFLAGS = $(AM_CFLAGS) -I$(ul_libmount_incdir)
 dist_man_MANS += mountpoint.1
diff --git a/sys-utils/mountpoint.c b/sys-utils/mountpoint.c
index e021c70..204f061 100644
--- a/sys-utils/mountpoint.c
+++ b/sys-utils/mountpoint.c
@@ -37,6 +37,7 @@
 #include "nls.h"
 #include "xalloc.h"
 #include "c.h"
+#include "canonicalize.h"
 
 static int quiet;
 
@@ -147,7 +148,8 @@ int main(int argc, char **argv)
 	if (optind + 1 != argc)
 		usage(stderr);
 
-	spec = argv[optind++];
+	/* resolve relative paths to absolute */
+	spec = canonicalize_path(argv[optind++]);
 
 	if (stat(spec, &st)) {
 		if (!quiet)
@@ -179,5 +181,6 @@ int main(int argc, char **argv)
 	}
 
 finish:
+	free(spec);
 	return rc;
 }
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux