All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Reisner <d@falconindy.com>
To: util-linux@vger.kernel.org
Cc: Dave Reisner <dreisner@archlinux.org>
Subject: [PATCH 2/2] mountpoint: support symbolic and relative paths
Date: Mon, 10 Oct 2011 19:14:16 -0400	[thread overview]
Message-ID: <1318288456-22940-2-git-send-email-dreisner@archlinux.org> (raw)
In-Reply-To: <1318288456-22940-1-git-send-email-dreisner@archlinux.org>

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

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
---
 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 cfaf053..49141fb 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 e075b83..2565107 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


  reply	other threads:[~2011-10-10 23:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10 23:14 [PATCH 1/2] mountpoint: refactor exit path Dave Reisner
2011-10-10 23:14 ` Dave Reisner [this message]
2011-10-11  9:34   ` [PATCH 2/2] mountpoint: support symbolic and relative paths Karel Zak
2011-10-11  7:07 ` [PATCH 1/2] mountpoint: refactor exit path Voelker, Bernhard
2011-10-11  7:44   ` Karel Zak
2011-10-11  7:55     ` Voelker, Bernhard
2011-10-11  8:14       ` Karel Zak
2011-10-11  9:06 ` Karel Zak
2011-10-11  9:31   ` Karel Zak
  -- strict thread matches above, loose matches on Subject: below --
2011-10-09 15:12 Dave Reisner
2011-10-09 15:12 ` [PATCH 2/2] mountpoint: support symbolic and relative paths Dave Reisner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1318288456-22940-2-git-send-email-dreisner@archlinux.org \
    --to=d@falconindy.com \
    --cc=dreisner@archlinux.org \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.