[Ocfs2-tools-commits] smushran commits r506 - trunk/debugfs.ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Dec 22 13:00:47 CST 2004
Author: smushran
Date: 2004-12-22 13:00:45 -0600 (Wed, 22 Dec 2004)
New Revision: 506
Modified:
trunk/debugfs.ocfs2/commands.c
trunk/debugfs.ocfs2/utils.c
Log:
In debugfs, // at the start of the filespec denotes sysdir
Modified: trunk/debugfs.ocfs2/commands.c
===================================================================
--- trunk/debugfs.ocfs2/commands.c 2004-12-22 04:17:23 UTC (rev 505)
+++ trunk/debugfs.ocfs2/commands.c 2004-12-22 19:00:45 UTC (rev 506)
@@ -170,7 +170,7 @@
return -1;
if (!opts) {
- fprintf(stderr, "usage: %s <filepath>\n", args[0]);
+ fprintf(stderr, "usage: %s <filespec>\n", args[0]);
return -1;
}
@@ -241,16 +241,11 @@
if (check_device_open())
return -1;
- if (!args[1]) {
+ if (!args[1] || inodestr_to_inode(args[1], blkno)) {
fprintf(stderr, "usage: %s <inode#>\n", args[0]);
return -1;
}
- if (inodestr_to_inode(args[1], blkno)) {
- fprintf(stderr, "usage: %s <inode#>\n", args[0]);
- return -1;
- }
-
if (*blkno >= gbls.max_blocks) {
fprintf(stderr, "%s: Block number is larger than volume size\n",
args[0]);
@@ -277,9 +272,9 @@
else
fprintf(stderr, "%s: Invalid node number\n", args[0]);
} else
- fprintf(stderr, "usage: %s [nodenum]\n", args[0]);
+ fprintf(stderr, "usage: %s <nodenum>\n", args[0]);
} else
- fprintf(stderr, "usage: %s [nodenum]\n", args[0]);
+ fprintf(stderr, "usage: %s <nodenum>\n", args[0]);
return -1;
}
@@ -386,7 +381,7 @@
do_close (NULL);
if (dev == NULL) {
- fprintf (stderr, "usage: %s [device]\n", args[0]);
+ fprintf (stderr, "usage: %s <device>\n", args[0]);
return ;
}
@@ -570,15 +565,15 @@
printf ("open <device>\t\t\t\tOpen a device\n");
printf ("close\t\t\t\t\tClose a device\n");
printf ("stats [-h]\t\t\t\tShow superblock\n");
- printf ("stat <filepath>\t\t\t\tShow inode\n");
+ printf ("stat <filespec>\t\t\t\tShow inode\n");
// printf ("pwd\t\t\t\tPrint working directory\n");
- printf ("ls [-l] <filepath>\t\t\tList directory\n");
- printf ("cd <filepath>\t\t\t\tChange directory\n");
- printf ("lcd <filepath>\t\t\t\tChange directory on a mounted fs\n");
- printf ("chroot <filepath>\t\t\tChange root\n");
- printf ("cat <filepath>\t\t\t\tPrints file on stdout\n");
- printf ("dump [-p] <filepath> <outfile>\t\tDumps file to outfile on a mounted fs\n");
- printf ("rdump [-v] <filepath> <outdir>\t\tRecursively dumps from src to a dir on a mounted fs\n");
+ printf ("ls [-l] <filespec>\t\t\tList directory\n");
+ printf ("cd <filespec>\t\t\t\tChange directory\n");
+ printf ("lcd <filespec>\t\t\t\tChange directory on a mounted fs\n");
+ printf ("chroot <filespec>\t\t\tChange root\n");
+ printf ("cat <filespec>\t\t\t\tPrints file on stdout\n");
+ printf ("dump [-p] <filespec> <outfile>\t\tDumps file to outfile on a mounted fs\n");
+ printf ("rdump [-v] <filespec> <outdir>\t\tRecursively dumps from src to a dir on a mounted fs\n");
printf ("logdump <node#>\t\t\t\tPrints journal file for the node\n");
printf ("extent <inode#>\t\t\t\tShow extent block\n");
printf ("group <inode#>\t\t\t\tShow chain group\n");
@@ -750,7 +745,7 @@
uint64_t blkno;
int preserve = 0;
int ind;
- const char *dump_usage = "Usage: dump [-p] <file> <output_file>";
+ const char *dump_usage = "usage: dump [-p] <filespec> <out_file>";
char *in_fn;
char *out_fn;
errcode_t ret;
@@ -774,7 +769,7 @@
out_fn = args[ind + 1];
if (!in_fn || !out_fn) {
- fprintf(stderr, "usage: dump <file> <output_file>\n");
+ fprintf(stderr, "%s\n", dump_usage);
return ;
}
Modified: trunk/debugfs.ocfs2/utils.c
===================================================================
--- trunk/debugfs.ocfs2/utils.c 2004-12-22 04:17:23 UTC (rev 505)
+++ trunk/debugfs.ocfs2/utils.c 2004-12-22 19:00:45 UTC (rev 506)
@@ -265,12 +265,16 @@
* This routine is used whenever a command needs to turn a string into
* an inode.
*
+ * Code based on similar function in e2fsprogs-1.32/debugfs/util.c
+ *
* Copyright (C) 1993, 1994 Theodore Ts'o. This file may be
* redistributed under the terms of the GNU Public License.
*/
errcode_t string_to_inode(ocfs2_filesys *fs, uint64_t root_blkno,
uint64_t cwd_blkno, char *str, uint64_t *blkno)
{
+ uint64_t root = root_blkno;
+
/*
* If the string is of the form <ino>, then treat it as an
* inode number.
@@ -279,12 +283,12 @@
return 0;
/* // is short for system directory */
- if (!strcmp(str, "//")) {
- *blkno = fs->fs_sysdir_blkno;
- return 0;
+ if (!strncmp(str, "//", 2)) {
+ root = fs->fs_sysdir_blkno;
+ ++str;
}
- return ocfs2_namei(fs, root_blkno, cwd_blkno, str, blkno);
+ return ocfs2_namei(fs, root, cwd_blkno, str, blkno);
}
/*
More information about the Ocfs2-tools-commits
mailing list