lscp: support opening mounted filesystem by directory pathname
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,
Signature · 3 lines
dexen deVries [[[↓][→]]]
Quoted 1 line
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 [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): 201103021113.32637.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Hi,
Quoted 4 lines · dexen deVries
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
Quoted 17 lines
Signature · 3 lines
dexen deVries [[[↓][→]]]Quoted 1 line
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 [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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 12 lines · On Wednesday 02 of March 2011 12:23:45 you wrote:
Hi,
Quoted 5 lines · dexen deVries
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 [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): 201103021343.54036.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 16 lines · dexen deVries
Quoted 12 lines · On Wednesday 02 of March 2011 12:23:45 you wrote:
Hi,
Quoted 5 lines · dexen deVries
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.
Quoted 8 lines
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 tonilfs_open(). In my understanding, that'd be the cleanest way of using it.However, the current behavior of
nilfs_open()(or more exactly, ofnilfs_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.
Quoted 2 lines
Perhaps I should try to fix
nilfs_find_fs()rather than putstat()andS_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
Quoted 5 lines
--
dexen deVries[[[↓][→]]]
Quoted 8 lines
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
--
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]
PATCH 1/8 lscp: support opening mounted filesystem by directory pathname
--- bin/lscp.c | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-)
bin/lscp.c +27 -5
@@ -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,12 +332,14 @@ int main(int argc, char *argv[]) {struct nilfs *nilfs;struct nilfs_cpstat cpstat; -char *dev, *progname; +struct stat statbuf; +char *dev, *dir, *pathname, *progname;int c, mode, rvs, status, ret;#ifdef _GNU_SOURCEint option_index;#endif /* _GNU_SOURCE */ + dev = dir =NULL ; mode =NILFS_CHECKPOINT ; rvs =0 ; opterr =0 ;/* prevent error message */
@@ -384,15 +394,27 @@ 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 ); +if (pathname) { + ret =stat (pathname, &statbuf); +if (ret ==-1 ) { +fprintf (stderr,"%s: cannot open %s: %s\n" , + progname, pathname,strerror (errno)); +exit (EXIT_FAILURE ); + } +if (S_ISDIR (statbuf.st_mode)) + dir = pathname; +else + dev = pathname; + } + nilfs =nilfs_open (dev, dir,NILFS_OPEN_RDONLY );if (nilfs ==NULL ) {fprintf (stderr,"%s: %s: cannot open NILFS\n" , - progname, dev); + progname, pathname);exit (EXIT_FAILURE ); }
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): 1299156472-4707-1-git-send-email-dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 2/8 chcp: support opening mounted filesystem by directory pathname
--- bin/chcp.c | 35 +++++++++++++++++++++++++++++------ 1 files changed, 29 insertions(+), 6 deletions(-)
bin/chcp.c +29 -6
@@ -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
@@ -76,13 +84,15 @@ int main(int argc, char *argv[]) {struct nilfs *nilfs;nilfs_cno_t cno; -char *dev, *modestr, *progname, *endptr; -int c, mode, status; +struct stat statbuf; +char *dev, *dir, *pathname, *modestr, *progname, *endptr; +int c, mode, status, ret;unsigned long val;#ifdef _GNU_SOURCEint option_index;#endif /* _GNU_SOURCE */ + dev = dir =NULL ; opterr =0 ;if ((progname =strrchr (argv[0 ],'/' )) ==NULL )
@@ -117,14 +127,14 @@ int main(int argc, char *argv[])exit (1 ); }else if (optind == argc -2 ) { modestr = argv[optind++]; - dev =NULL ; + pathname =NULL ; }else { modestr = argv[optind++]; val =strtoul (argv[optind], &endptr,CHCP_BASE );if (*endptr =='\0' ) - dev =NULL ; + pathname =NULL ;else - dev = argv[optind++]; + pathname = argv[optind++]; }if (strcmp (modestr,CHCP_MODE_CP ) ==0 )
@@ -137,7 +147,20 @@ int main(int argc, char *argv[])exit (1 ); } - nilfs =nilfs_open (dev,NULL ,NILFS_OPEN_RDWR ); + +if (pathname) { + ret =stat (pathname, &statbuf); +if (ret ==-1 ) { +fprintf (stderr,"%s: cannot open %s: %s\n" , + progname, pathname,strerror (errno)); +exit (EXIT_FAILURE ); + } +if (S_ISDIR (statbuf.st_mode)) + dir = pathname; +else + dev = pathname; + } + nilfs =nilfs_open (dev, dir,NILFS_OPEN_RDWR );if (nilfs ==NULL ) {fprintf (stderr,"%s: %s: cannot open NILFS\n" , progname, dev);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
PATCH 3/8 dumpseg: support opening mounted filesystem by directory pathname
In reply to a message not in the archive--- bin/dumpseg.c | 35 +++++++++++++++++++++++++++++------ 1 files changed, 29 insertions(+), 6 deletions(-)
bin/dumpseg.c +29 -6
@@ -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
@@ -169,17 +177,19 @@ static void dumpseg_print_segment(struct nilfs *nilfs,int main (int argc,char *argv[]) {struct nilfs *nilfs; +struct stat statbuf;__u64 segnum; -char *dev, *endptr, *progname; +char *dev, *dir, *pathname, *endptr, *progname;void *seg;ssize_t segsize; -int c, i, status; +int c, i, status, ret;unsigned long val;#ifdef _GNU_SOURCEint option_index;#endif /* _GNU_SOURCE */ opterr =0 ; + dev = dir =NULL ;if ((progname =strrchr (argv[0 ],'/' )) ==NULL ) progname = argv[0 ];
@@ -214,14 +224,27 @@ int main(int argc, char *argv[]) }else { val =strtoul (argv[optind], &endptr,DUMPSEG_BASE );if (*endptr =='\0' ) - dev =NULL ; + pathname =NULL ;else - dev = argv[optind++]; + pathname = argv[optind++]; } - nilfs =nilfs_open (dev,NULL ,NILFS_OPEN_RAW ); + +if (pathname) { + ret =stat (pathname, &statbuf); +if (ret ==-1 ) { +fprintf (stderr,"%s: cannot open %s: %s\n" , + progname, pathname,strerror (errno)); +exit (EXIT_FAILURE ); + } +if (S_ISDIR (statbuf.st_mode)) + dir = pathname; +else + dev = pathname; + } + nilfs =nilfs_open (dev, dir,NILFS_OPEN_RAW );if (nilfs ==NULL ) { -fprintf (stderr,"%s: %s: cannot open NILFS\n" , progname, dev); +fprintf (stderr,"%s: %s: cannot open NILFS\n" , progname, pathname);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
PATCH 4/8 lssu: support opening mounted filesystem by directory pathname
In reply to a message not in the archive--- bin/lssu.c | 34 ++++++++++++++++++++++++++++------ 1 files changed, 28 insertions(+), 6 deletions(-)
bin/lssu.c +28 -6
@@ -27,6 +27,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
@@ -138,14 +146,16 @@ static int lssu_list_suinfo(struct nilfs *nilfs, int all)int main (int argc,char *argv[]) {struct nilfs *nilfs; -char *dev, *progname; -int c, all, status; +struct stat statbuf; +char *dev, *dir, *pathname, *progname; +int c, all, status, ret;#ifdef _GNU_SOURCEint option_index;#endif /* _GNU_SOURCE */ all =0 ; opterr =0 ; + dev = dir =NULL ; progname =strrchr (argv[0 ],'/' );if (progname ==NULL ) progname = argv[0 ];
@@ -184,18 +194,30 @@ int main(int argc, char *argv[]) }if (optind > argc -1 ) { - dev =NULL ; + pathname =NULL ; }else if (optind == argc -1 ) { - dev = argv[optind++]; + pathname = argv[optind++]; }else {fprintf (stderr,"%s: too many arguments\n" , progname);exit (1 ); } - nilfs =nilfs_open (dev,NULL ,NILFS_OPEN_RDONLY ); +if (pathname) { + ret =stat (pathname, &statbuf); +if (ret ==-1 ) { +fprintf (stderr,"%s: cannot open %s: %s\n" , + progname, pathname,strerror (errno)); +exit (EXIT_FAILURE ); + } +if (S_ISDIR (statbuf.st_mode)) + dir = pathname; +else + dev = pathname; + } + nilfs =nilfs_open (dev, dir,NILFS_OPEN_RDONLY );if (nilfs ==NULL ) {fprintf (stderr,"%s: %s: cannot open NILFS\n" , - progname, dev); + progname, pathname);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
PATCH 5/8 mkcp: support opening mounted filesystem by directory pathname
In reply to a message not in the archive--- bin/mkcp.c | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-)
bin/mkcp.c +29 -7
@@ -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
@@ -68,15 +76,17 @@ const static struct option long_option[] = {int main (int argc,char *argv[]) {struct nilfs *nilfs; +struct stat statbuf;nilfs_cno_t cno; -char *dev, *progname; -int ss, c, status; +char *dev, *dir, *pathname, *progname; +int ss, c, status, ret;#ifdef _GNU_SOURCEint option_index;#endif /* _GNU_SOURCE */ ss =0 ; opterr =0 ; + dev = dir =NULL ;if ((progname =strrchr (argv[0 ],'/' )) ==NULL ) progname = argv[0 ];else
@@ -111,13 +121,25 @@ int main(int argc, char *argv[])fprintf (stderr,"%s: too many arguments\n" , progname);exit (1 ); }else if (optind > argc -1 ) - dev =NULL ; + pathname =NULL ;else - dev = argv[optind]; - - nilfs =nilfs_open (dev,NULL ,NILFS_OPEN_RDWR ); + pathname = argv[optind]; + +if (pathname) { + ret =stat (pathname, &statbuf); +if (ret ==-1 ) { +fprintf (stderr,"%s: cannot open %s: %s\n" , + progname, pathname,strerror (errno)); +exit (EXIT_FAILURE ); + } +if (S_ISDIR (statbuf.st_mode)) + dir = pathname; +else + dev = pathname; + } + nilfs =nilfs_open (dev, dir,NILFS_OPEN_RDWR );if (nilfs ==NULL ) { -fprintf (stderr,"%s: %s: cannot open NILFS\n" , progname, dev); +fprintf (stderr,"%s: %s: cannot open NILFS\n" , progname, pathname);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
PATCH 6/8 rmcp: support opening mounted filesystem by directory pathname
In reply to a message not in the archive--- bin/rmcp.c | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-)
bin/rmcp.c +29 -7
@@ -27,6 +27,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
@@ -129,9 +137,10 @@ static int rmcp_remove_range(struct nilfs *nilfs,int main (int argc,char *argv[]) { -char *dev; +char *dev, *dir, *pathname;struct nilfs *nilfs;struct nilfs_cpstat cpstat; +struct stat statbuf;nilfs_cno_t start, end, oldest;size_t nsnapshots, nss, ndel;int c, status, ret;
@@ -140,6 +149,7 @@ int main(int argc, char *argv[])#endif /* _GNU_SOURCE */ opterr =0 ; + dev = dir =NULL ;if ((progname =strrchr (argv[0 ],'/' )) ==NULL ) progname = argv[0 ];else
@@ -179,24 +189,36 @@ int main(int argc, char *argv[])fprintf (stderr,"%s: too few arguments\n" , progname);exit (1 ); }else if (optind == argc -1 ) { - dev =NULL ; + pathname =NULL ; }else {if (nilfs_parse_cno_range (argv[optind], &start, &end,RMCP_BASE ) <0 ) - dev = argv[optind++]; + pathname = argv[optind++];else - dev =NULL ; + pathname =NULL ; } - nilfs =nilfs_open (dev,NULL ,NILFS_OPEN_RDWR ); +if (pathname) { + ret =stat (pathname, &statbuf); +if (ret ==-1 ) { +fprintf (stderr,"%s: cannot open %s: %s\n" , + progname, pathname,strerror (errno)); +exit (EXIT_FAILURE ); + } +if (S_ISDIR (statbuf.st_mode)) + dir = pathname; +else + dev = pathname; + } + nilfs =nilfs_open (dev, dir,NILFS_OPEN_RDWR );if (nilfs ==NULL ) { -fprintf (stderr,"%s: %s: cannot open NILFS\n" , progname, dev); +fprintf (stderr,"%s: %s: cannot open NILFS\n" , progname, pathname);exit (1 ); }if (nilfs_get_cpstat (nilfs, &cpstat) <0 ) {fprintf (stderr,"%s: %s: cannot get checkpoint status: %s\n" , - progname, dev,strerror (errno)); + progname, pathname,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
PATCH 7/8 bin/*: update inline help to indicate possibility of accessing filesystem by mountpoint pathname
In reply to a message not in the archive--- bin/chcp.c | 2 +- bin/dumpseg.c | 2 +- bin/lscp.c | 2 +- bin/lssu.c | 2 +- bin/mkcp.c | 2 +- bin/rmcp.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
bin/chcp.c +1 -1
@@ -71,7 +71,7 @@ const static struct option long_option[] = { };#define CHCP_USAGE \ - "Usage: %s [OPTION]... " CHCP_MODE_CP "|" CHCP_MODE_SS" [DEVICE] CNO...\n" \ + "Usage: %s [OPTION]... " CHCP_MODE_CP "|" CHCP_MODE_SS" [DEVICE|MOUNTPOINT] CNO...\n" \ " -h, --help\t\tdisplay this help and exit\n" \ " -V, --version\t\tdisplay version and exit\n"#else /* !_GNU_SOURCE */
bin/dumpseg.c +1 -1
@@ -66,7 +66,7 @@ const static struct option long_option[] = { };#define DUMPSEG_USAGE \ - "Usage: %s [OPTION]... [DEVICE] SEGNUM...\n" \ + "Usage: %s [OPTION]... [DEVICE|MOUNTPOINT] SEGNUM...\n" \ " -h, --help\t\tdisplay this help and exit\n" \ " -V, --version\t\tdisplay version and exit\n"#else /* !_GNU_SOURCE */
bin/lscp.c +1 -1
@@ -72,7 +72,7 @@ const static struct option long_option[] = { {"version", no_argument, NULL, 'V'}, {NULL, 0, NULL, 0} }; -#define LSCP_USAGE "Usage: %s [OPTION]... [DEVICE]\n" \ +#define LSCP_USAGE "Usage: %s [OPTION]... [DEVICE|MOUNTPOINT]\n" \ " -b, --show-block-count\t\tshow block count\n"\ " -g, --show-increment\t\tshow increment count\n"\ " -r, --reverse\t\treverse order\n" \
bin/lssu.c +1 -1
@@ -63,7 +63,7 @@ const static struct option long_option[] = { {NULL, 0, NULL, 0} }; -#define LSSU_USAGE "Usage: %s [OPTION]... [DEVICE]\n" \ +#define LSSU_USAGE "Usage: %s [OPTION]... [DEVICE|MOUNTPOINT]\n" \ " -a, --all\t\tdo not hide clean segments\n" \ " -i, --index\t\tstart index\n" \ " -n, --lines\t\toutput lines\n" \
bin/mkcp.c +1 -1
@@ -64,7 +64,7 @@ const static struct option long_option[] = { {NULL, 0, NULL, 0} }; -#define MKCP_USAGE "Usage: %s [OPTION] [DEVICE]\n" \ +#define MKCP_USAGE "Usage: %s [OPTION] [DEVICE|MOUNTPOINT]\n" \ " -s, --snapshot\tcreate a snapshot\n" \ " -h, --help\t\tdisplay this help and exit\n" \ " -V, --version\t\tdisplay version and exit\n"
bin/rmcp.c +1 -1
@@ -69,7 +69,7 @@ const static struct option long_options[] = { {NULL, 0, NULL, 0} };#define RMCP_USAGE \ - "Usage: %s [OPTION]... [DEVICE] CNO...\n" \ + "Usage: %s [OPTION]... [DEVICE|MOUNTPOINT] CNO...\n" \ " -f, --force\t\tignore snapshots or nonexistent checkpoints\n" \ " -i, --interactive\tprompt before any removal\n" \ " -h, --help\t\tdisplay this help and exit\n" \
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
PATCH 8/8 update manpages to indicate open-by-mountpoint
In reply to a message not in the archive--- man/chcp.8 | 8 +++++--- man/dumpseg.8 | 14 +++++++------- man/lscp.1 | 8 ++++---- man/lssu.1 | 10 +++++----- man/mkcp.8 | 8 ++++---- man/rmcp.8 | 10 +++++----- 6 files changed, 30 insertions(+), 28 deletions(-)
man/chcp.8 +5 -3
@@ -6,11 +6,12 @@ chcp \- change mode of NILFS2 checkpoints .SH SYNOPSIS .B chcp -[\fIoptions\fP] \fBcp\fP | \fBss\fP [\fIdevice\fP] \fIcheckpoint-number\fP ... +[\fIoptions\fP] \fBcp\fP | \fBss\fP [\fIdevice\fP | \fImountpoint\fP] +\fIcheckpoint-number\fP ... .SH DESCRIPTION .B chcp is a utility to change the mode of the given checkpoints for the NILFS2 -file system found in \fIdevice\fP. +file system found in \fIdevice\fP or mounted at \fImountpoint\fP. .B chcp changes checkpoints to snapshots, or vice versa. The target checkpoints are specified with one or more checkpoint numbers. When
@@ -18,7 +19,8 @@ checkpoints are specified with one or more checkpoint numbers. When \fI/proc/mounts\fP. .PP This command is valid only for mounted NILFS2 file systems, and -will fail if the \fIdevice\fP has no active mounts. +will fail if the \fIdevice\fP has no active mounts and \fImountpoint\fP +is not a mounted NILFS2 filesystem. .SH OPTIONS .TP \fB\-h\fR, \fB\-\-help\fR
man/dumpseg.8 +7 -7
@@ -9,16 +9,16 @@ dumpseg \- print segment information of NILFS2 [\fB\-hV\fP] .sp .B dumpseg -[\fIdevice\fP] \fIsegment-number\fP ... +[\fIdevice\fP | \fImountpoint\fP] \fIsegment-number\fP ... .SH DESCRIPTION The .B dumpseg -program is an analysis tool for on-disk logs of a NILFS2 file system -found in \fIdevice\fP. It displays the configuration of every log -stored in the segments specified by one or more \fIsegment-numbers\fP. -The term segment here means a contiguous lump of disk blocks giving an -allocation unit of NILFS2 disk space. When \fIdevice\fP is omitted, -it tries to find an active NILFS2 file system from \fI/proc/mounts\fP. +program is an analysis tool for on-disk logs of a NILFS2 file system found in +\fIdevice\fP or mounted at \fImountpoint\fP. It displays the configuration of +every log stored in the segments specified by one or more +\fIsegment-numbers\fP. The term segment here means a contiguous lump of disk +blocks giving an allocation unit of NILFS2 disk space. When \fIdevice\fP is +omitted, it tries to find an active NILFS2 file system from \fI/proc/mounts\fP. .PP .B dumpseg is a tool for debugging rather than administration. To list a summary
man/lscp.1 +4 -4
@@ -6,12 +6,12 @@ lscp \- list NILFS2 checkpoints .SH SYNOPSIS .B lscp -[\fIoptions\fP] [\fIdevice\fP] +[\fIoptions\fP] [\fIdevice\fP | \fImountpoint\fP] .SH DESCRIPTION .B lscp -is a utility for displaying checkpoints or snapshots of the NILFS2 -file system found in \fIdevice\fP. When \fIdevice\fP is omitted, -\fI/proc/mounts\fP is examined to find a NILFS2 file system. +is a utility for displaying checkpoints or snapshots of the NILFS2 file system +found in \fIdevice\fP or mounted at \fImountpoint\fP. When \fIdevice\fP is +omitted, \fI/proc/mounts\fP is examined to find a NILFS2 file system. .PP This command will fail if the \fIdevice\fP has no active mounts of a NILFS2 file system.
man/lssu.1 +5 -5
@@ -6,13 +6,13 @@ lssu \- list usage state of NILFS2 segments .SH SYNOPSIS .B lssu -[\fIoptions\fP] [\fIdevice\fP] +[\fIoptions\fP] [\fIdevice\fP | \fImountpoint\fP] .SH DESCRIPTION .B lssu -is a utility for displaying usage state of NILFS2 segments in -\fIdevice\fP, where a segment is contiguous lump of disk blocks and -an allocation unit of NILFS2 disk space. When \fIdevice\fP is -omitted, \fI/proc/mounts\fP is examined to find a NILFS2 file system. +is a utility for displaying usage state of NILFS2 segments in \fIdevice\fP or +mounted at \fImountpoint\fP, where a segment is contiguous lump of disk blocks +and an allocation unit of NILFS2 disk space. When \fIdevice\fP is omitted, +\fI/proc/mounts\fP is examined to find a NILFS2 file system. .PP This command will fail if the \fIdevice\fP has no active mounts of a NILFS2 file system.
man/mkcp.8 +4 -4
@@ -6,12 +6,12 @@ mkcp \- make a NILFS2 checkpoint .SH SYNOPSIS .B mkcp -[\fIoptions\fP] [\fIdevice\fP] +[\fIoptions\fP] [\fIdevice\fP | \fImountpoint\fP] .SH DESCRIPTION .B mkcp -is a utility for making a checkpoint or snapshot for the NILFS2 file -system found in \fIdevice\fP. When \fIdevice\fP is omitted, it tries -to find a NILFS2 file system from \fI/proc/mounts\fP. +is a utility for making a checkpoint or snapshot for the NILFS2 file system +found in \fIdevice\fP or mounted at \fImountpoint\fP. When \fIdevice\fP is +omitted, it tries to find a NILFS2 file system from \fI/proc/mounts\fP. .PP This command is valid only for mounted NILFS2 file systems, and will fail if the \fIdevice\fP has no active mounts.
man/rmcp.8 +5 -5
@@ -6,13 +6,13 @@ rmcp \- remove NILFS2 checkpoints .SH SYNOPSIS .B rmcp -[\fIoptions\fP] [\fIdevice\fP] \fIcheckpoint-range\fP ... +[\fIoptions\fP] [\fIdevice\fP | \fImountpoint\fP] \fIcheckpoint-range\fP ... .SH DESCRIPTION .B rmcp -is a utility for removing checkpoints from the NILFS2 file system -found in \fIdevice\fP. The checkpoints which user wants to remove are -specified with one or more \fIcheckpoint-ranges\fP. When \fIdevice\fP -is omitted, rmcp tries to find a NILFS2 file system from +is a utility for removing checkpoints from the NILFS2 file system found in +\fIdevice\fP or mounted at \fImountpoint\fP. The checkpoints which user wants +to remove are specified with one or more \fIcheckpoint-ranges\fP. When +\fIdevice\fP is omitted, rmcp tries to find a NILFS2 file system from \fI/proc/mounts\fP. .PP The \fIcheckpoint-range\fP must be provided with one or two integers
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
Hi,
Thank you for posting this series. I'll queue it up in nilfs-utils-devel tree.
By the way, may I add your "Signed-off-by:" line to these patches?
FYI, you can do it yourself as follows:
1) Register E-mail address and user name to ~/.gitconfig:
$ git config --global --add user.name "dexen deVries" $ git config --global --add user.email "dexen.devries@..."
2) Convert the series to separate patches
$ git format-patch -o <work-directory> <branch-base>..<branch-head>
3) Apply the series with sign option
$ git checkout -b <new-branch-name> <branch-base> $ git am -s <work-directory>/*.patch
Usually, we add a sob line with "git commit -s" when committing each patch.
Thanks,
Ryusuke Konishi
Quoted 78 lines · dexen deVries
--- bin/lscp.c | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-)bin/lscp.c +27
-5@@ -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,12 +332,14 @@ int main(int argc, char *argv[]) {struct nilfs *nilfs;struct nilfs_cpstat cpstat; -char *dev, *progname; +struct stat statbuf; +char *dev, *dir, *pathname, *progname;int c, mode, rvs, status, ret;#ifdef _GNU_SOURCEint option_index;#endif /* _GNU_SOURCE */ + dev = dir =NULL ; mode =NILFS_CHECKPOINT ; rvs =0 ; opterr =0 ;/* prevent error message */ @@ -384,15 +394,27 @@ 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 ); +if (pathname) { + ret =stat (pathname, &statbuf); +if (ret ==-1 ) { +fprintf (stderr,"%s: cannot open %s: %s\n" , + progname, pathname,strerror (errno)); +exit (EXIT_FAILURE ); + } +if (S_ISDIR (statbuf.st_mode)) + dir = pathname; +else + dev = pathname; + } + nilfs =nilfs_open (dev, dir,NILFS_OPEN_RDONLY );if (nilfs ==NULL ) {fprintf (stderr,"%s: %s: cannot open NILFS\n" , - progname, dev); + progname, pathname);exit (EXIT_FAILURE ); }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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,
Quoted 4 lines · On Thursday 03 of March 2011 17:15:11 you wrote:
Thank you for posting this series. I'll queue it up in nilfs-utils-devel tree.
By the way, may I add your "Signed-off-by:" line to these patches?
Sure.
I'll fix that in my clone and push out to Github. Will it be enough if I sent a Pull Request from Github to the list rather than submit individual patches as mails?
It's the first time I'm trying to contribute to opensource; thanks for being patient :-)
Regards,
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): 201103031723.22583.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 7 lines · dexen deVries
Hi,
Quoted 3 lines · On Thursday 03 of March 2011 17:15:11 you wrote:
Thank you for posting this series. I'll queue it up in nilfs-utils-devel tree.
Quoted 8 lines
Quoted 1 line
By the way, may I add your "Signed-off-by:" line to these patches?
Sure.
I'll fix that in my clone and push out to Github. Will it be enough if I sent a Pull Request from Github to the list rather than submit individual patches as mails?
Usually we post every patch to the list every time we modified the series for convenience of reference and review. But, I think a pull request is enough if just adding a sob line.
By the way, can you enhance the series so that the directory argument works for any directories in the filesystem rather than just a mount point?
We know the directory argument of "df" command works like that.
$ cd; df . Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 .... ... .. ... /
This semantics seems more convenient especially for snapshot tools.
Any idea?
Quoted 2 lines
It's the first time I'm trying to contribute to opensource; thanks for being patient :-)
It's my pleasure. Keep it coming :)
Thanks,
Ryusuke Konishi
Quoted 14 lines
Regards,
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
--
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]
Quoted 3 lines · On Thursday 03 of March 2011 18:16:03 you wrote:
By the way, can you enhance the series so that the directory argument works for any directories in the filesystem rather than just a mount point?
That actually was aim at some point -- to let indicate filesystem by any object on it. However, I can't find a reliable way. If you can hint one, I'll gladly implement.
First idea was to use stat's (struct stat).st_dev, but it seems there is no standard way of translating (minor, major) into filesystem from userspace. There's a kernel function for that, but not exposed through syscall. There is a custom library function by HP, but it doesn't feel very reasonable to rely on it.
Second idea was to process pathname by combination of realpath() and stripping segments -- but it turns out dot-dot semantics are broken in POSIX OSes [1] making that way unreliable.
One caveat is that a device would not indicate the filesystem it belongs to, but a filesystem on a partition/device it addresses.
Another caveat is that processing a NILFS2 stored in a file (say, a HDD image) would require some specialized syntax.
While those may not sound very serious for interactive use, I believe that our tools would become too unreliable for scripts in some edge cases.
Thus I gave up ;-)
A minimalistic version -- only lstat() [sic] with S_ISDIR() -- would work, but that's not very much of a progress to me.
[1] http://doc.cat-v.org/plan_9/4th_edition/papers/lexnames
Signature · 7 lines
dexen deVries ``One can't proceed from the informal to the formal by formal means.'' -- 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): 201103031931.32310.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 29 lines · dexen deVries
Quoted 3 lines · On Thursday 03 of March 2011 18:16:03 you wrote:
By the way, can you enhance the series so that the directory argument works for any directories in the filesystem rather than just a mount point?
That actually was aim at some point -- to let indicate filesystem by any object on it. However, I can't find a reliable way. If you can hint one, I'll gladly implement.
First idea was to use stat's (struct stat).st_dev, but it seems there is no standard way of translating (minor, major) into filesystem from userspace. There's a kernel function for that, but not exposed through syscall. There is a custom library function by HP, but it doesn't feel very reasonable to rely on it.
Second idea was to process pathname by combination of
realpath()and stripping segments -- but it turns out dot-dot semantics are broken in POSIX OSes [1] making that way unreliable.One caveat is that a device would not indicate the filesystem it belongs to, but a filesystem on a partition/device it addresses.
Another caveat is that processing a NILFS2 stored in a file (say, a HDD image) would require some specialized syntax.
While those may not sound very serious for interactive use, I believe that our tools would become too unreliable for scripts in some edge cases.
Quoted 7 lines
Thus I gave up ;-)
A minimalistic version -- only
lstat()[sic] withS_ISDIR()-- would work, but that's not very much of a progress to me.
I understood your point.
IMO, you don't worry about the ".." semantics breakage so serious. The current nilfs tools are comparing pathnames using canonicalized paths. If we really attend to the issue, all tools and libraries in nilfs-utils should be rethought together.
So, let's go ahead.
Quoted 2 lines
One caveat is that a device would not indicate the filesystem it belongs to, but a filesystem on a partition/device it addresses.
In the new directory semantics, we needs to decide if a given directory argument belongs to a mount point in the mtab entries.
This matching check needs to know whether the given directory crosses over a filesystem boundary starting from each mount point. And, this needs testing if each intermediate directory is a mount point or not.
"mountpoint" command judges this by comparing device ids and inode numbers for each directory with its parent.
Since tools doesn't know existing mount points unless they parse /proc/mounts individually, I think it's better to extend nilfs_find_fs() and nilfs_open() to allow the new semantics.
You may as well add an extra open flag to nilfs_open (for instance, NILFS_OPEN_ALLOW_SUBDIRS) which changes the meaning of the directory argument slightly so that the mount point to which the given directory belongs is selected.
Any thoughts?
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]
2011/3/4 Ryusuke Konishi <[email protected]>:
Quoted 9 lines
In the new directory semantics, we needs to decide if a given directory argument belongs to a mount point in the mtab entries.
This matching check needs to know whether the given directory crosses over a filesystem boundary starting from each mount point. And, this needs testing if each intermediate directory is a mount point or not.
"mountpoint" command judges this by comparing device ids and inode numbers for each directory with its parent.
BTW, we can test if a given nilfs2 directory is a mount point or not with its inode number. The nilfs2 mount point always has inode number 2 (=NILFS_ROOT_INO) and no other directories have this inode number.
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