static const char *progname = "volinfo";
+/* Command line options */
+typedef enum {
+ P_ONLINE,
+ P_VNODE,
+ P_DATE,
+ P_INODE,
+ P_ITIME,
+ P_PART,
+ P_VOLUMEID,
+ P_HEADER,
+ P_SIZEONLY,
+ P_FIXHEADER,
+ P_SAVEINODES,
+ P_ORPHANED,
+ P_FILENAMES
+} volinfo_parm_t;
+
/* Modes */
static int DumpInfo = 1; /**< Dump volume information, defualt mode*/
static int DumpHeader = 0; /**< Dump volume header files info */
}
#endif
- if (as->parms[0].items) { /* -online */
+ if (as->parms[P_ONLINE].items) {
fprintf(stderr, "%s: -online not supported\n", progname);
return 1;
}
- if (as->parms[1].items) { /* -vnode */
+ if (as->parms[P_VNODE].items) {
DumpVnodes = 1;
}
- if (as->parms[2].items) { /* -date */
+ if (as->parms[P_DATE].items) {
DumpDate = 1;
}
- if (as->parms[3].items) { /* -inode */
+ if (as->parms[P_INODE].items) {
DumpInodeNumber = 1;
}
- if (as->parms[4].items) { /* -itime */
+ if (as->parms[P_ITIME].items) {
InodeTimes = 1;
}
- if ((ti = as->parms[5].items)) { /* -part */
+ if ((ti = as->parms[P_PART].items)) {
partNameOrId = ti->data;
}
- if ((ti = as->parms[6].items)) { /* -volumeid */
+ if ((ti = as->parms[P_VOLUMEID].items)) {
volumeId = strtoul(ti->data, NULL, 10);
}
- if (as->parms[7].items) { /* -header */
+ if (as->parms[P_HEADER].items) {
DumpHeader = 1;
}
- if (as->parms[8].items) { /* -sizeOnly */
+ if (as->parms[P_SIZEONLY].items) {
ShowSizes = 1;
}
- if (as->parms[9].items) { /* -FixHeader */
+ if (as->parms[P_FIXHEADER].items) {
FixHeader = 1;
}
- if (as->parms[10].items) { /* -saveinodes */
+ if (as->parms[P_SAVEINODES].items) {
SaveInodes = 1;
}
- if (as->parms[11].items) { /* -orphaned */
+ if (as->parms[P_ORPHANED].items) {
ShowOrphaned = 1;
}
#if defined(AFS_NAMEI_ENV)
- if (as->parms[12].items) { /* -filenames */
+ if (as->parms[P_FILENAMES].items) {
PrintFileNames = 1;
}
#endif
free(vp);
}
+
/**
* volinfo program entry
*/
struct cmd_syndesc *ts;
afs_int32 code;
- ts = cmd_CreateSyntax(NULL, handleit, NULL, "Dump volume's internal state");
- cmd_AddParm(ts, "-online", CMD_FLAG, CMD_OPTIONAL,
- "Get info from running fileserver");
- cmd_AddParm(ts, "-vnode", CMD_FLAG, CMD_OPTIONAL, "Dump vnode info");
- cmd_AddParm(ts, "-date", CMD_FLAG, CMD_OPTIONAL,
- "Also dump vnode's mod date");
- cmd_AddParm(ts, "-inode", CMD_FLAG, CMD_OPTIONAL,
- "Also dump vnode's inode number");
- cmd_AddParm(ts, "-itime", CMD_FLAG, CMD_OPTIONAL,
- "Dump special inode's mod times");
- cmd_AddParm(ts, "-part", CMD_LIST, CMD_OPTIONAL,
- "AFS partition name or id (default current partition)");
- cmd_AddParm(ts, "-volumeid", CMD_LIST, CMD_OPTIONAL, "Volume id");
- cmd_AddParm(ts, "-header", CMD_FLAG, CMD_OPTIONAL,
- "Dump volume's header info");
- cmd_AddParm(ts, "-sizeOnly", CMD_FLAG, CMD_OPTIONAL,
- "Dump volume's size");
- cmd_AddParm(ts, "-fixheader", CMD_FLAG, CMD_OPTIONAL,
- "Try to fix header");
- cmd_AddParm(ts, "-saveinodes", CMD_FLAG, CMD_OPTIONAL,
- "Try to save all inodes");
- cmd_AddParm(ts, "-orphaned", CMD_FLAG, CMD_OPTIONAL,
- "List all dir/files without a parent");
+ ts = cmd_CreateSyntax(NULL, handleit, NULL,
+ "Dump volume's internal state");
+ cmd_AddParmAtOffset(ts, "-online", CMD_FLAG, CMD_OPTIONAL,
+ "Get info from running fileserver", P_ONLINE);
+ cmd_AddParmAtOffset(ts, "-vnode", CMD_FLAG, CMD_OPTIONAL,
+ "Dump vnode info", P_VNODE);
+ cmd_AddParmAtOffset(ts, "-date", CMD_FLAG, CMD_OPTIONAL,
+ "Also dump vnode's mod date", P_DATE);
+ cmd_AddParmAtOffset(ts, "-inode", CMD_FLAG, CMD_OPTIONAL,
+ "Also dump vnode's inode number", P_INODE);
+ cmd_AddParmAtOffset(ts, "-itime", CMD_FLAG, CMD_OPTIONAL,
+ "Dump special inode's mod times", P_ITIME);
+ cmd_AddParmAtOffset(ts, "-part", CMD_LIST, CMD_OPTIONAL,
+ "AFS partition name or id (default current partition)",
+ P_PART);
+ cmd_AddParmAtOffset(ts, "-volumeid", CMD_LIST, CMD_OPTIONAL, "Volume id",
+ P_VOLUMEID);
+ cmd_AddParmAtOffset(ts, "-header", CMD_FLAG, CMD_OPTIONAL,
+ "Dump volume's header info", P_HEADER);
+ cmd_AddParmAtOffset(ts, "-sizeonly", CMD_FLAG, CMD_OPTIONAL,
+ "Dump volume's size", P_SIZEONLY);
+ cmd_AddParmAtOffset(ts, "-fixheader", CMD_FLAG, CMD_OPTIONAL,
+ "Try to fix header", P_FIXHEADER);
+ cmd_AddParmAtOffset(ts, "-saveinodes", CMD_FLAG, CMD_OPTIONAL,
+ "Try to save all inodes", P_SAVEINODES);
+ cmd_AddParmAtOffset(ts, "-orphaned", CMD_FLAG, CMD_OPTIONAL,
+ "List all dir/files without a parent", P_ORPHANED);
#if defined(AFS_NAMEI_ENV)
- cmd_AddParm(ts, "-filenames", CMD_FLAG, CMD_OPTIONAL, "Also dump vnode's namei filename");
+ cmd_AddParmAtOffset(ts, "-filenames", CMD_FLAG, CMD_OPTIONAL,
+ "Also dump vnode's namei filename", P_FILENAMES);
#endif
+
+ /* For compatibility with older versions. */
+ cmd_AddParmAlias(ts, P_SIZEONLY, "-sizeOnly");
+
code = cmd_Dispatch(argc, argv);
return code;
}