[Ocfs2-tools-commits] smushran commits r1189 - in trunk/debugfs.ocfs2: . include
svn-commits@oss.oracle.com
svn-commits at oss.oracle.com
Mon May 1 20:33:50 CDT 2006
Author: smushran
Signed-off-by: mfasheh
Date: 2006-05-01 20:33:49 -0500 (Mon, 01 May 2006)
New Revision: 1189
Modified:
trunk/debugfs.ocfs2/commands.c
trunk/debugfs.ocfs2/find_inode_paths.c
trunk/debugfs.ocfs2/include/find_inode_paths.h
Log:
findpath command returns one path for a given inode#/lockname
ncheck command returns all paths for the given inode#/lockname
Signed-off-by: mfasheh
Modified: trunk/debugfs.ocfs2/commands.c
===================================================================
--- trunk/debugfs.ocfs2/commands.c 2006-04-29 10:24:12 UTC (rev 1188)
+++ trunk/debugfs.ocfs2/commands.c 2006-05-02 01:33:49 UTC (rev 1189)
@@ -24,7 +24,8 @@
*/
#include <main.h>
-#define SYSTEM_FILE_NAME_MAX 40
+#define SYSTEM_FILE_NAME_MAX 40
+#define MAX_BLOCKS 50
typedef void (*PrintFunc) (void *buf);
typedef gboolean (*WriteFunc) (char **data, void *buf);
@@ -81,6 +82,8 @@
{ "?", do_help },
{ "lcd", do_lcd },
{ "locate", do_locate },
+ { "ncheck", do_locate },
+ { "findpath", do_locate },
{ "logdump", do_logdump },
{ "ls", do_ls },
{ "open", do_open },
@@ -250,25 +253,41 @@
/*
* process_inodestr_args()
+ * args: arguments starting from command
+ * count: max space available in blkno
+ * blkno: block nums extracted
+ * RETURN: number of blknos
*
*/
-static int process_inodestr_args(char **args, uint64_t *blkno)
+static int process_inodestr_args(char **args, int count, uint64_t *blkno)
{
+ uint64_t *p;
+ int i;
+
if (check_device_open())
return -1;
- if (!args[1] || inodestr_to_inode(args[1], blkno)) {
- fprintf(stderr, "usage: %s <inode#>\n", args[0]);
- return -1;
+ if (count < 1)
+ return 0;
+
+ for (i = 1, p = blkno; i < count + 1; ++i, ++p) {
+ if (!args[i] || inodestr_to_inode(args[i], p))
+ break;
+ if (*p >= gbls.max_blocks) {
+ fprintf(stderr, "%s: Block number %"PRIu64" is "
+ "larger than volume size\n", args[0], *p);
+ return -1;
+ }
}
- if (*blkno >= gbls.max_blocks) {
- fprintf(stderr, "%s: Block number is larger than volume size\n",
- args[0]);
+ --i;
+
+ if (!i) {
+ fprintf(stderr, "usage: %s <inode#>\n", args[0]);
return -1;
}
- return 0;
+ return i;
}
/*
@@ -588,13 +607,15 @@
printf ("dump [-p] <filespec> <outfile>\t\tDumps file to outfile on a mounted fs\n");
printf ("encode <filespec>\t\t\tShow lock name\n");
printf ("extent <block#>\t\t\t\tShow extent block\n");
+ printf ("findpath <block#>\t\t\tList one pathname of the inode/lockname\n");
printf ("fs_locks [-l]\t\t\t\tShow live fs locking state\n");
printf ("group <block#>\t\t\t\tShow chain group\n");
printf ("help, ?\t\t\t\t\tThis information\n");
printf ("lcd <directory>\t\t\t\tChange directory on a mounted flesystem\n");
- printf ("locate <filespec>\t\t\tList all paths to the inode\n");
+ printf ("locate <block#> ...\t\t\tList all pathnames of the inode(s)/lockname(s)\n");
printf ("logdump <slot#>\t\t\t\tPrints journal file for the node slot\n");
printf ("ls [-l] <filespec>\t\t\tList directory\n");
+ printf ("ncheck <block#> ...\t\t\tList all pathnames of the inode(s)/lockname(s)\n");
printf ("open <device>\t\t\t\tOpen a device\n");
printf ("quit, q\t\t\t\t\tExit the program\n");
printf ("rdump [-v] <filespec> <outdir>\t\tRecursively dumps from src to a dir on a mounted filesystem\n");
@@ -897,7 +918,7 @@
errcode_t ret = 0;
int index = 0;
- if (process_inodestr_args(args, &blkno))
+ if (process_inodestr_args(args, 1, &blkno) != 1)
return ;
buf = gbls.blockbuf;
@@ -933,7 +954,7 @@
FILE *out;
errcode_t ret = 0;
- if (process_inodestr_args(args, &blkno))
+ if (process_inodestr_args(args, 1, &blkno) != 1)
return ;
buf = gbls.blockbuf;
@@ -1135,12 +1156,18 @@
*/
static void do_locate(char **args)
{
- uint64_t blkno;
-
- if (process_inode_args(args, &blkno))
+ uint64_t blkno[MAX_BLOCKS];
+ int count = 0;
+ int findall = 1;
+
+ count = process_inodestr_args(args, MAX_BLOCKS, blkno);
+ if (count < 1)
return ;
- find_inode_paths(gbls.fs, args, blkno, stdout);
+ if (!strncasecmp(args[0], "findpath", 8))
+ findall = 0;
+
+ find_inode_paths(gbls.fs, args, findall, count, blkno, stdout);
}
/*
Modified: trunk/debugfs.ocfs2/find_inode_paths.c
===================================================================
--- trunk/debugfs.ocfs2/find_inode_paths.c 2006-04-29 10:24:12 UTC (rev 1188)
+++ trunk/debugfs.ocfs2/find_inode_paths.c 2006-05-02 01:33:49 UTC (rev 1189)
@@ -32,8 +32,10 @@
FILE *out;
ocfs2_filesys *fs;
char *path;
- int found;
- uint64_t inode;
+ uint32_t found;
+ uint32_t count;
+ int findall;
+ uint64_t *inode;
};
static int walk_tree_func(struct ocfs2_dir_entry *dentry, int offset,
@@ -42,6 +44,8 @@
errcode_t ret;
int len, oldval;
int reti = 0;
+ int i = 0;
+ int print = 0;
char *old_path, *path;
struct walk_path *wp = priv_data;
@@ -71,11 +75,22 @@
oldval = 0;
- if (dentry->inode == wp->inode) {
- dump_inode_path (wp->out, dentry->inode, path);
- ++wp->found;
+ for (i = 0; i < wp->count; ++i) {
+ if (dentry->inode == wp->inode[i]) {
+ if (!print)
+ dump_inode_path (wp->out, dentry->inode, path);
+ ++wp->found;
+ ++print;
+ }
}
+ if (!wp->findall) {
+ if (wp->found >= wp->count) {
+ ocfs2_free(&path);
+ return OCFS2_DIRENT_ABORT;
+ }
+ }
+
if (dentry->file_type == OCFS2_FT_DIR) {
old_path = wp->path;
wp->path = path;
@@ -93,18 +108,45 @@
return reti;
}
-errcode_t find_inode_paths(ocfs2_filesys *fs, char **args, uint64_t blkno,
- FILE *out)
+errcode_t find_inode_paths(ocfs2_filesys *fs, char **args, int findall,
+ uint32_t count, uint64_t *blknos, FILE *out)
{
errcode_t ret = 0;
struct walk_path wp;
+ int i;
+ int printroot = 0;
+ int printsysd = 0;
wp.argv0 = args[0];
wp.out = out;
+ wp.count = count;
+ wp.inode = blknos;
+ wp.findall = findall;
wp.found = 0;
- wp.inode = blkno;
wp.fs = fs;
+ /* Compare with root and sysdir */
+ for (i = 0; i < count; ++i) {
+ if (blknos[i] == fs->fs_root_blkno) {
+ if (!printroot)
+ dump_inode_path (out, blknos[i], "/");
+ ++wp.found;
+ ++printroot;
+ }
+ if (blknos[i] == fs->fs_sysdir_blkno) {
+ if (!printsysd)
+ dump_inode_path (out, blknos[i], "//");
+ ++wp.found;
+ ++printsysd;
+ }
+ }
+
+ if (!findall) {
+ if (wp.found >= wp.count)
+ goto bail;
+ }
+
+
/* Walk system dir */
wp.path = "//";
ret = ocfs2_dir_iterate(fs,
Modified: trunk/debugfs.ocfs2/include/find_inode_paths.h
===================================================================
--- trunk/debugfs.ocfs2/include/find_inode_paths.h 2006-04-29 10:24:12 UTC (rev 1188)
+++ trunk/debugfs.ocfs2/include/find_inode_paths.h 2006-05-02 01:33:49 UTC (rev 1189)
@@ -25,7 +25,7 @@
#ifndef _FIND_INODE_PATH_H_
#define _FIND_INODE_PATH_H_
-errcode_t find_inode_paths(ocfs2_filesys *fs, char **args, uint64_t blkno,
- FILE *out);
+errcode_t find_inode_paths(ocfs2_filesys *fs, char **args, int findall,
+ uint32_t count, uint64_t *blkno, FILE *out);
#endif /* _FIND_INODE_PATH_H_ */
More information about the Ocfs2-tools-commits
mailing list