fs-getfid-20060123
authorDerrick Brashear <shadow@dementia.org>
Mon, 23 Jan 2006 21:04:31 +0000 (21:04 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 23 Jan 2006 21:04:31 +0000 (21:04 +0000)
add a fs subcommand to get a fid

src/venus/fs.c

index 90adc78..83ef0c2 100644 (file)
@@ -69,7 +69,7 @@ static char tspace[1024];
 static struct ubik_client *uclient;
 
 static int GetClientAddrsCmd(), SetClientAddrsCmd(), FlushMountCmd();
-static int RxStatProcCmd(), RxStatPeerCmd();
+static int RxStatProcCmd(), RxStatPeerCmd(), GetFidCmd();
 
 extern char *hostutil_GetNameByINet();
 extern struct hostent *hostutil_GetHostByName();
@@ -3437,6 +3437,11 @@ defect 3069
     ts = cmd_CreateSyntax("setcbaddr", CallBackRxConnCmd, 0, "configure callback connection address");
     cmd_AddParm(ts, "-addr", CMD_SINGLE, CMD_OPTIONAL, "host name or address");
 
+    /* try to find volume location information */
+    ts = cmd_CreateSyntax("getfid", GetFidCmd, 0,
+                         "get fid for file(s)");
+    cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
+
     code = cmd_Dispatch(argc, argv);
     if (rxInitDone)
        rx_Finalize();
@@ -3794,3 +3799,25 @@ RxStatPeerCmd(struct cmd_syndesc *as, char *arock)
     return 0;
 }
 
+static int
+GetFidCmd(struct cmd_syndesc *as, char *arock)
+{
+    struct ViceIoctl blob;
+    struct cmd_item *ti;
+    for (ti = as->parms[0].items; ti; ti = ti->next) {
+      struct VenusFid vfid;
+      
+      blob.out_size = sizeof(struct VenusFid);
+      blob.out = (char *) &vfid;
+      blob.in_size = 0;
+      
+      if (0 == pioctl(ti->data, VIOCGETFID, &blob, 1)) {
+       printf("File %s (%u.%u.%u) contained in volume %u\n",
+              ti->data, vfid.Fid.Volume, vfid.Fid.Vnode, vfid.Fid.Unique,
+              vfid.Fid.Volume);
+      }
+    }
+
+    return 0;
+}
+