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
From d680318225635932b633210a97d39dac09fe44ec Mon Sep 17 00:00:00 2001 From: dexen deVries <dexen.devries@xxxxxxxxx> 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