linux-nilfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lscp: support opening mounted filesystem by directory pathname
@ 2011-03-02  9:56 dexen deVries
  0 siblings, 0 replies; 5+ messages in thread
From: dexen deVries @ 2011-03-02  9:56 UTC (permalink / raw)
  To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: Text/Plain, Size: 376 bytes --]

I wonder if submission as an attachment will work alright.

-- 
dexen deVries

[[[↓][→]]]

> how does a C compiler get to be that big? what is all that code doing?

iterators, string objects, and a full set of C macros that ensure
boundary conditions and improve interfaces.

ron minnich, in response to Charles Forsyth

http://9fans.net/archive/2011/02/90

[-- Attachment #2: 0001-lscp-support-opening-mounted-filesystem-by-directory.patch --]
[-- Type: text/x-patch, Size: 1716 bytes --]

From d680318225635932b633210a97d39dac09fe44ec Mon Sep 17 00:00:00 2001
From: dexen deVries <dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Wed, 2 Mar 2011 10:53:11 +0100
Subject: [PATCH] lscp: support opening mounted filesystem by directory pathname

---
 bin/lscp.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/bin/lscp.c b/bin/lscp.c
index df9a0af..44e9dcb 100644
--- a/bin/lscp.c
+++ b/bin/lscp.c
@@ -28,6 +28,14 @@
 #include "config.h"
 #endif	/* HAVE_CONFIG_H */
 
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif	/* HAVE_SYS_TYPES_H */
+
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif	/* HAVE_SYS_STAT_H */
+
 #include <stdio.h>
 
 #if HAVE_STDLIB_H
@@ -324,7 +332,8 @@ int main(int argc, char *argv[])
 {
 	struct nilfs *nilfs;
 	struct nilfs_cpstat cpstat;
-	char *dev, *progname;
+	struct stat statbuf;
+	char *pathname, *progname;
 	int c, mode, rvs, status, ret;
 #ifdef _GNU_SOURCE
 	int option_index;
@@ -384,15 +393,19 @@ int main(int argc, char *argv[])
 		fprintf(stderr, "%s: too many arguments\n", progname);
 		exit(1);
 	} else if (optind == argc - 1) {
-		dev = argv[optind++];
+		pathname = argv[optind++];
 	} else {
-		dev = NULL;
+		pathname = NULL;
 	}
 
-	nilfs = nilfs_open(dev, NULL, NILFS_OPEN_RDONLY);
+	stat(pathname, &statbuf);
+	if (S_ISDIR(statbuf.st_mode))
+		nilfs = nilfs_open(NULL, pathname, NILFS_OPEN_RDONLY);
+	else
+		nilfs = nilfs_open(pathname, NULL, NILFS_OPEN_RDONLY);
 	if (nilfs == NULL) {
 		fprintf(stderr, "%s: %s: cannot open NILFS\n",
-			progname, dev);
+			progname, pathname);
 		exit(EXIT_FAILURE);
 	}
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] lscp: support opening mounted filesystem by directory pathname
@ 2011-03-02 10:13 dexen deVries
       [not found] ` <201103021113.32637.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: dexen deVries @ 2011-03-02 10:13 UTC (permalink / raw)
  To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA

The patch I've submited may be a wrong solution; perhaps instead the algorithm 
of nilfs_find_fs() (around lib/nilfs.c:179,211) should be improved.

Regards,
-- 
dexen deVries

[[[↓][→]]]

> how does a C compiler get to be that big? what is all that code doing?

iterators, string objects, and a full set of C macros that ensure
boundary conditions and improve interfaces.

ron minnich, in response to Charles Forsyth

http://9fans.net/archive/2011/02/90
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] lscp: support opening mounted filesystem by directory pathname
       [not found] ` <201103021113.32637.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2011-03-02 11:23   ` Ryusuke Konishi
       [not found]     ` <20110302.202345.74569955.ryusuke-sG5X7nlA6pw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Ryusuke Konishi @ 2011-03-02 11:23 UTC (permalink / raw)
  To: dexen.devries-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA

Hi,
On Wed, 2 Mar 2011 11:13:32 +0100, dexen deVries wrote:
> The patch I've submited may be a wrong solution; perhaps instead the algorithm 
> of nilfs_find_fs() (around lib/nilfs.c:179,211) should be improved.
> 
> Regards,

Well, allowing directory pathname for nilfs commands seems a good idea
to me.  Why not apply it to other commands except nilfs_cleanerd ?

I think you can simply the callsite of nilfs_open() just like follows:

  char *dev = NULL, *dir = NULL;

  ...
  stat(pathname, &statbuf);
  if (S_ISDIR(statbuf.st_mode))
        dir = pathname;
  else
        dev = pathname;

  nilfs = nilfs_open(dev, dir, NILFS_OPEN_RDONLY);
  ...


Thanks,
Ryusuke Konishi

> -- 
> dexen deVries
> 
> [[[↓][→]]]
> 
> > how does a C compiler get to be that big? what is all that code doing?
> 
> iterators, string objects, and a full set of C macros that ensure
> boundary conditions and improve interfaces.
> 
> ron minnich, in response to Charles Forsyth
> 
> http://9fans.net/archive/2011/02/90
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] lscp: support opening mounted filesystem by directory pathname
       [not found]     ` <20110302.202345.74569955.ryusuke-sG5X7nlA6pw@public.gmane.org>
@ 2011-03-02 12:43       ` dexen deVries
       [not found]         ` <201103021343.54036.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: dexen deVries @ 2011-03-02 12:43 UTC (permalink / raw)
  To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA

On Wednesday 02 of March 2011 12:23:45 you wrote:
> Hi,
> 
> On Wed, 2 Mar 2011 11:13:32 +0100, dexen deVries wrote:
> > The patch I've submited may be a wrong solution; perhaps instead the
> > algorithm of nilfs_find_fs() (around lib/nilfs.c:179,211) should be
> > improved.
> > 
> > Regards,
> 
> Well, allowing directory pathname for nilfs commands seems a good idea
> to me.  Why not apply it to other commands except nilfs_cleanerd ?
> 

Goot point, I'm on it right now.

Reading through sbin/cleanerd/cleanerd.c, it seems it doesn't make any 
distinction between dev and dir, just supplies program's argument as both dev 
and dir arguments to nilfs_open(). In my understanding, that'd be the cleanest 
way of using it. 

However, the current behavior of nilfs_open() (or more exactly, of 
nilfs_find_fs()) doesn't support that semantics -- if dev is passed, it kind of 
ignores the dir argument. Perhaps I should try to fix nilfs_find_fs() rather 
than put stat() and S_ISDIR() in every program?

--
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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] lscp: support opening mounted filesystem by directory pathname
       [not found]         ` <201103021343.54036.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2011-03-02 14:21           ` Ryusuke Konishi
  0 siblings, 0 replies; 5+ messages in thread
From: Ryusuke Konishi @ 2011-03-02 14:21 UTC (permalink / raw)
  To: dexen.devries-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA

On Wed, 2 Mar 2011 13:43:53 +0100, dexen deVries wrote:
> On Wednesday 02 of March 2011 12:23:45 you wrote:
> > Hi,
> > 
> > On Wed, 2 Mar 2011 11:13:32 +0100, dexen deVries wrote:
> > > The patch I've submited may be a wrong solution; perhaps instead the
> > > algorithm of nilfs_find_fs() (around lib/nilfs.c:179,211) should be
> > > improved.
> > > 
> > > Regards,
> > 
> > Well, allowing directory pathname for nilfs commands seems a good idea
> > to me.  Why not apply it to other commands except nilfs_cleanerd ?
> > 
> 
> Goot point, I'm on it right now.
> 
> Reading through sbin/cleanerd/cleanerd.c, it seems it doesn't make any 
> distinction between dev and dir, just supplies program's argument as both dev 
> and dir arguments to nilfs_open(). In my understanding, that'd be the cleanest 
> way of using it. 
> 
> However, the current behavior of nilfs_open() (or more exactly, of 
> nilfs_find_fs()) doesn't support that semantics -- if dev is passed, it kind of 
> ignores the dir argument.

No, nilfs_find_fs() compares both dev and dir arguments if both are
given.  Actually nilfs_cleanerd needs the dir argument because two
writable mounts can coexist on the same device when bind mounts are
used, and cleanerd has to be attached on exactly the same mount point.

> Perhaps I should try to fix nilfs_find_fs() rather 
> than put stat() and S_ISDIR() in every program?

I'd like to avoid changing interface of nilfs_open.  You can add a
wrapper function to libnilfs if you don't prefer to insert stat() and
S_ISDIR() in every program.

Thanks,
Ryusuke Konishi
 
> --
> 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-03-02 14:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-02  9:56 [PATCH] lscp: support opening mounted filesystem by directory pathname dexen deVries
  -- strict thread matches above, loose matches on Subject: below --
2011-03-02 10:13 dexen deVries
     [not found] ` <201103021113.32637.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-03-02 11:23   ` Ryusuke Konishi
     [not found]     ` <20110302.202345.74569955.ryusuke-sG5X7nlA6pw@public.gmane.org>
2011-03-02 12:43       ` dexen deVries
     [not found]         ` <201103021343.54036.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-03-02 14:21           ` Ryusuke Konishi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).