From db98b697fe4e1b38ac5e73d60dd101b2506e12a4 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Mon, 23 Jan 2006 21:04:31 +0000 Subject: [PATCH] fs-getfid-20060123 add a fs subcommand to get a fid --- src/venus/fs.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/venus/fs.c b/src/venus/fs.c index 90adc78..83ef0c2 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -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; +} + -- 1.9.4