[PATCH] nilfs_cleanerd: support relative pathnames in arguments

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

 



canonicalize pathnames of device & directory before daemonize() to support relative pathnames

Signed-off-by: dexen deVries <dexen.devries@xxxxxxxxx>
---
 sbin/cleanerd/cleanerd.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/sbin/cleanerd/cleanerd.c b/sbin/cleanerd/cleanerd.c
index 1f03cfb..3d58916 100644
--- a/sbin/cleanerd/cleanerd.c
+++ b/sbin/cleanerd/cleanerd.c
@@ -1343,6 +1343,7 @@ static int nilfs_cleanerd_clean_loop(struct nilfs_cleanerd *cleanerd)
 int main(int argc, char *argv[])
 {
 	char *progname, *conffile;
+	char canonical[PATH_MAX + 2];
 	const char *dev, *dir;
 	char *endptr;
 	int status, nofork, c;
@@ -1406,6 +1407,12 @@ int main(int argc, char *argv[])
 	if (optind < argc)
 		dir = argv[optind++];
 
+	if (dev && myrealpath(dev, canonical, sizeof(canonical)))
+		dev = strdup(canonical);
+
+	if (dir && myrealpath(dir, canonical, sizeof(canonical)))
+		dir = strdup(canonical);
+
 	if (daemonize(0, 0, nofork) < 0) {
 		fprintf(stderr, "%s: %s\n", progname, strerror(errno));
 		exit(1);
-- 
1.7.4.1

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


[Index of Archives]     [Linux Filesystem Development]     [Linux BTRFS]     [Linux CIFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux