Skip to contentSkip to conversation

nilfs_cleanerd not started for mount with relative pathname

PATCH In review dexen deVries 2 participants 5 messages Mar 2, 2011 – Mar 7, 2011 4 messages not in the archive NILFS2 filesystem

lore
Share & tools
lore
#0 lore raw

Hi,

when testing my other patches, the following came up:

with absolute pathname:

# mount /dev/sdb2 /mnt/x
# ps ax | grep [n]ilfs_cleanerd
30408 ?        Ss     0:00 /sbin/nilfs_cleanerd -n /dev/sdb2 /mnt/x

with relative mountpoint pathname:

# umount /mnt/x
# cd /mnt
# mount /dev/sdb2 x
# ps ax | grep [n]ilfs_cleanerd
((no such process))

with relative device pathname:

# umount /mnt/x
# cd /dev
# mount sdb2 /mnt/x
# ps ax | grep [n]ilfs_cleanerd
((no such process))

This is due to chdir(ROOTDIR) in daemonize(); currently daemonize is always called with nochdir == 0. Should I hardcode it to nochdir == 1 or canonicalize the dev' and dir' arguments with myrealpath()?

Signature · 12 lines
dexen deVries

[[[↓][→]]]

47. As Will Rogers would have said, "There is no such thing as a free 
variable."

(Alan Perlis, `Epigrams on Programming')
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 201103021812.31515.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 25 lines · dexen deVries

Hi,

when testing my other patches, the following came up:

with absolute pathname:

# mount /dev/sdb2 /mnt/x
# ps ax | grep [n]ilfs_cleanerd
30408 ?        Ss     0:00 /sbin/nilfs_cleanerd -n /dev/sdb2 /mnt/x

with relative mountpoint pathname:

# umount /mnt/x
# cd /mnt
# mount /dev/sdb2 x
# ps ax | grep [n]ilfs_cleanerd
((no such process))

with relative device pathname:

# umount /mnt/x
# cd /dev
# mount sdb2 /mnt/x
# ps ax | grep [n]ilfs_cleanerd
((no such process))
Quoted 3 lines

This is due to chdir(ROOTDIR) in daemonize(); currently daemonize is always called with nochdir == 0. Should I hardcode it to nochdir == 1 or canonicalize the dev' and dir' arguments with myrealpath()?

It sounds like cleanerd needs a fix.
I'll take a look and answer to you tomorrow.

Thanks,
Ryusuke Konishi
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Hi,

Quoted 30 lines · Ryusuke Konishi
Quoted 25 lines · dexen deVries

Hi,

when testing my other patches, the following came up:

with absolute pathname:

# mount /dev/sdb2 /mnt/x
# ps ax | grep [n]ilfs_cleanerd
30408 ?        Ss     0:00 /sbin/nilfs_cleanerd -n /dev/sdb2 /mnt/x

with relative mountpoint pathname:

# umount /mnt/x
# cd /mnt
# mount /dev/sdb2 x
# ps ax | grep [n]ilfs_cleanerd
((no such process))

with relative device pathname:

# umount /mnt/x
# cd /dev
# mount sdb2 /mnt/x
# ps ax | grep [n]ilfs_cleanerd
((no such process))
Quoted 3 lines

This is due to chdir(ROOTDIR) in daemonize(); currently daemonize is always called with nochdir == 0. Should I hardcode it to nochdir == 1 or canonicalize the dev' and dir' arguments with myrealpath()?

Quoted 5 lines

It sounds like cleanerd needs a fix.
I'll take a look and answer to you tomorrow.

Thanks,
Ryusuke Konishi

This was actually a cleanerd bug. (Good catch)

Cleanerd should canonicalize the dev and dir arguments before calling the daemonize function as you pointed out.

Would you like to have a go at this ?

Thanks,
Ryusuke Konishi
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

PATCH 1/1 nilfs_cleanerd: support relative pathnames in arguments

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

---
 sbin/cleanerd/cleanerd.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
sbin/cleanerd/cleanerd.c +7 -0
index 1f03cfb..3d58916 100644
@@ -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);
Signature · 6 lines
1.7.4.1

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

A message that is not in the archive (sent off-list or not yet received): 1299447018-19088-1-git-send-email-dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#8 lore raw

Re: [PATCH] nilfs_cleanerd: support relative pathnames in arguments

Quoted 6 lines · dexen deVries

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

---
 sbin/cleanerd/cleanerd.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

Thanks.

I applied the patch with a minor amendment.

Ryusuke Konishi

Quoted 32 lines
sbin/cleanerd/cleanerd.c +7 -0
index 1f03cfb..3d58916 100644
@@ -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);
Signature · 6 lines
1.7.4.1

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

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