* [PATCH] xfs_admin: exit gracefully for non-XFS fileststems
@ 2009-01-25 5:03 Christoph Hellwig
2009-01-25 5:56 ` Josef 'Jeff' Sipek
2009-01-29 21:43 ` Eric Sandeen
0 siblings, 2 replies; 3+ messages in thread
From: Christoph Hellwig @ 2009-01-25 5:03 UTC (permalink / raw)
To: xfs
Exit gracefully if the magic number doesn't match xfs in xfs_admin
and xfs_ncheck. This is implemented by a new -C option to xfs_db
which makes it exit with a useful error message in case the filesystem
doesn't match the XFS superblock magic number.
Reported-by: Dick Middleton <dick@lingbrae.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: xfsprogs-dev/db/init.c
===================================================================
--- xfsprogs-dev.orig/db/init.c 2009-01-24 19:04:48.517429102 +0100
+++ xfsprogs-dev/db/init.c 2009-01-24 19:11:03.003555709 +0100
@@ -42,7 +42,7 @@ static void
usage(void)
{
fprintf(stderr, _(
- "Usage: %s [-frxV] [-p prog] [-l logdev] [-c cmd]... device\n"),
+ "Usage: %s [-CfrxV] [-p prog] [-l logdev] [-c cmd]... device\n"),
progname);
exit(1);
}
@@ -55,10 +55,14 @@ init(
xfs_sb_t *sbp;
void *bufp = NULL;
int c;
+ int check = 0;
progname = basename(argv[0]);
- while ((c = getopt(argc, argv, "c:fip:rxVl:")) != EOF) {
+ while ((c = getopt(argc, argv, "c:Cfip:rxVl:")) != EOF) {
switch (c) {
+ case 'C':
+ check = 1;
+ break;
case 'c':
cmdline = xrealloc(cmdline, (ncmdline+1)*sizeof(char*));
cmdline[ncmdline++] = optarg;
@@ -118,6 +122,11 @@ init(
sbp = &xmount.m_sb;
if (sbp->sb_magicnum != XFS_SB_MAGIC) {
+ if (check) {
+ fprintf(stderr, _("%s: not an XFS filesystem\n"),
+ progname);
+ exit(1);
+ }
fprintf(stderr, _("%s: unexpected XFS SB magic number 0x%08x\n"),
progname, sbp->sb_magicnum);
}
Index: xfsprogs-dev/db/xfs_admin.sh
===================================================================
--- xfsprogs-dev.orig/db/xfs_admin.sh 2009-01-24 19:11:26.867554445 +0100
+++ xfsprogs-dev/db/xfs_admin.sh 2009-01-24 19:13:55.950426543 +0100
@@ -30,7 +30,7 @@ shift $OPTIND
case $# in
1) if [ -n "$DB_OPTS" ]
then
- eval xfs_db -x -p xfs_admin $DB_OPTS $1
+ eval xfs_db -x -p xfs_admin -C $DB_OPTS $1
status=$?
fi
if [ -n "$REPAIR_OPTS" ]
Index: xfsprogs-dev/db/xfs_ncheck.sh
===================================================================
--- xfsprogs-dev.orig/db/xfs_ncheck.sh 2009-01-24 19:14:34.903429336 +0100
+++ xfsprogs-dev/db/xfs_ncheck.sh 2009-01-24 19:14:42.105429164 +0100
@@ -25,7 +25,7 @@ done
set -- extra $@
shift $OPTIND
case $# in
- 1) xfs_db$DBOPTS -r -p xfs_ncheck -c "blockget -ns" -c "ncheck$OPTS" $1
+ 1) xfs_db$DBOPTS -r -p xfs_ncheck -C -c "blockget -ns" -c "ncheck$OPTS" $1
status=$?
;;
*) echo $USAGE 1>&2
Index: xfsprogs-dev/db/xfs_ncheck64.sh
===================================================================
--- xfsprogs-dev.orig/db/xfs_ncheck64.sh 2009-01-24 19:14:34.924457708 +0100
+++ xfsprogs-dev/db/xfs_ncheck64.sh 2009-01-24 19:14:52.707429049 +0100
@@ -24,7 +24,7 @@ done
set -- extra $@
shift $OPTIND
case $# in
- 1) xfs_db64$DBOPTS -r -p xfs_ncheck64 -c "blockget -ns" -c "ncheck$OPTS" $1
+ 1) xfs_db64$DBOPTS -r -p xfs_ncheck64 -C -c "blockget -ns" -c "ncheck$OPTS" $1
status=$?
;;
*) echo $USAGE 1>&2
Index: xfsprogs-dev/man/man8/xfs_db.8
===================================================================
--- xfsprogs-dev.orig/man/man8/xfs_db.8 2009-01-24 19:15:16.855428751 +0100
+++ xfsprogs-dev/man/man8/xfs_db.8 2009-01-24 19:17:21.689554003 +0100
@@ -11,6 +11,8 @@ xfs_db \- debug an XFS filesystem
] [
.B \-f
] [
+.B \-C
+] [
.B \-l
.I logdev
] [
@@ -32,6 +34,10 @@ that run
.PP
.SH OPTIONS
.TP
+.B \-C
+Check the superblock magic number and exit gracefully if the filesystem is not
+an XFS filesystem.
+.TP
.BI \-c " cmd"
.B xfs_db
commands may be run interactively (the default) or as arguments
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] xfs_admin: exit gracefully for non-XFS fileststems
2009-01-25 5:03 [PATCH] xfs_admin: exit gracefully for non-XFS fileststems Christoph Hellwig
@ 2009-01-25 5:56 ` Josef 'Jeff' Sipek
2009-01-29 21:43 ` Eric Sandeen
1 sibling, 0 replies; 3+ messages in thread
From: Josef 'Jeff' Sipek @ 2009-01-25 5:56 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
On Sun, Jan 25, 2009 at 06:03:42AM +0100, Christoph Hellwig wrote:
> Exit gracefully if the magic number doesn't match xfs in xfs_admin
> and xfs_ncheck. This is implemented by a new -C option to xfs_db
> which makes it exit with a useful error message in case the filesystem
> doesn't match the XFS superblock magic number.
>
>
> Reported-by: Dick Middleton <dick@lingbrae.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
...
> Index: xfsprogs-dev/man/man8/xfs_db.8
> ===================================================================
> --- xfsprogs-dev.orig/man/man8/xfs_db.8 2009-01-24 19:15:16.855428751 +0100
> +++ xfsprogs-dev/man/man8/xfs_db.8 2009-01-24 19:17:21.689554003 +0100
...
> @@ -32,6 +34,10 @@ that run
> .PP
> .SH OPTIONS
> .TP
> +.B \-C
> +Check the superblock magic number and exit gracefully if the filesystem is not
> +an XFS filesystem.
Obviously, the 'C' is supposed to stand for "check". I think that's
misleading. xfs_db _always_ checks the SB magic. This option just changes
the the behavior on a mis-match. In a way, I think this flag belongs into
the "verbose/quiet" category. It really is
--you-really-want-to-work-with-xfs-volumes-only...I guess it's a don't-force
flag.
I can't think of a good letter for it at the moment.
Josef 'Jeff' Sipek.
--
Hegh QaQ law'
quvHa'ghach QaQ puS
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs_admin: exit gracefully for non-XFS fileststems
2009-01-25 5:03 [PATCH] xfs_admin: exit gracefully for non-XFS fileststems Christoph Hellwig
2009-01-25 5:56 ` Josef 'Jeff' Sipek
@ 2009-01-29 21:43 ` Eric Sandeen
1 sibling, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2009-01-29 21:43 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
Christoph Hellwig wrote:
> Exit gracefully if the magic number doesn't match xfs in xfs_admin
> and xfs_ncheck. This is implemented by a new -C option to xfs_db
> which makes it exit with a useful error message in case the filesystem
> doesn't match the XFS superblock magic number.
>
>
> Reported-by: Dick Middleton <dick@lingbrae.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
I guess I'd rather see this the reverse, and require a flag to allow
xfs_db to work on something that doesn't look like xfs - err on the side
of safety (hm but I suppose db is usually in read-only mode...)
Addresses jeffpc's criticism too, to some degree; you can use -F to mean
"force" or "foreign" :) before xfs_db will touch the fs.
So I think I personally like it better with the inverse, where it always
exits on bad magic unless you explicitly tell it otherwise. Making the
error message reference the option might be nice ("Use -F to ignore this
error" or somesuch)
-Eric
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-01-29 21:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-25 5:03 [PATCH] xfs_admin: exit gracefully for non-XFS fileststems Christoph Hellwig
2009-01-25 5:56 ` Josef 'Jeff' Sipek
2009-01-29 21:43 ` Eric Sandeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox