All of lore.kernel.org
 help / color / mirror / Atom feed
From: dexen deVries <dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] lscp: support opening mounted filesystem by directory pathname
Date: Wed, 2 Mar 2011 10:56:08 +0100	[thread overview]
Message-ID: <201103021056.08672.dexen.devries@gmail.com> (raw)

[-- 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


             reply	other threads:[~2011-03-02  9:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-02  9:56 dexen deVries [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-03-02 10:13 [PATCH] lscp: support opening mounted filesystem by directory pathname 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201103021056.08672.dexen.devries@gmail.com \
    --to=dexen.devries-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.