#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
#include <stdlib.h>
#include <stdio.h>
#include <afs/afsint.h>
#include <afs/assert.h>
-
#include <fcntl.h>
#ifndef AFS_NT40_ENV
#endif
#include <afs/cmd.h>
+#include <afs/dir.h>
#include <afs/afsutil.h>
#include <afs/fileutil.h>
static int VolBreakCBKs(struct cmd_syndesc * as, void * rock);
static int VolMove(struct cmd_syndesc * as, void * rock);
static int VolList(struct cmd_syndesc * as, void * rock);
+static int VolLeaveOff(struct cmd_syndesc * as, void * rock);
+static int VolForceAttach(struct cmd_syndesc * as, void * rock);
+static int VolForceError(struct cmd_syndesc * as, void * rock);
static int VolQuery(struct cmd_syndesc * as, void * rock);
static int VolHdrQuery(struct cmd_syndesc * as, void * rock);
static int VolOpQuery(struct cmd_syndesc * as, void * rock);
{
struct cmd_syndesc *ts;
int err = 0;
- int i;
- extern char cml_version_number[];
/* Initialize directory paths */
if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
VOLOP_PARMS_DECL(ts);
cmd_CreateAlias(ts, "ls");
+ ts = cmd_CreateSyntax("leaveoff", VolLeaveOff, 0, "leave volume offline (FSYNC_VOL_LEAVE_OFF opcode)");
+ VOLOP_PARMS_DECL(ts);
+
+ ts = cmd_CreateSyntax("attach", VolForceAttach, 0, "force full attachment (FSYNC_VOL_ATTACH opcode)");
+ VOLOP_PARMS_DECL(ts);
+
+ ts = cmd_CreateSyntax("error", VolForceError, 0, "force into hard error state (FSYNC_VOL_FORCE_ERROR opcode)");
+ VOLOP_PARMS_DECL(ts);
+
ts = cmd_CreateSyntax("query", VolQuery, NULL, "get volume structure (FSYNC_VOL_QUERY opcode)");
VOLOP_PARMS_DECL(ts);
cmd_CreateAlias(ts, "qry");
common_volop_prolog(struct cmd_syndesc * as, struct state * state)
{
register struct cmd_item *ti;
- char pname[100], *temp;
state->vop = (struct volop_state *) calloc(1, sizeof(struct volop_state));
assert(state->vop != NULL);
res->hdr.reason, reason_code_to_string(res->hdr.reason));
VDisconnectFS();
+
+ return 0;
+
}
return 0;
}
+static int
+VolLeaveOff(struct cmd_syndesc * as, void * rock)
+{
+ struct state state;
+
+ common_prolog(as, &state);
+ common_volop_prolog(as, &state);
+
+ do_volop(&state, FSYNC_VOL_LEAVE_OFF, NULL);
+
+ return 0;
+}
+
+static int
+VolForceAttach(struct cmd_syndesc * as, void * rock)
+{
+ struct state state;
+
+ common_prolog(as, &state);
+ common_volop_prolog(as, &state);
+
+ do_volop(&state, FSYNC_VOL_ATTACH, NULL);
+
+ return 0;
+}
+
+static int
+VolForceError(struct cmd_syndesc * as, void * rock)
+{
+ struct state state;
+
+ common_prolog(as, &state);
+ common_volop_prolog(as, &state);
+
+ do_volop(&state, FSYNC_VOL_FORCE_ERROR, NULL);
+
+ return 0;
+}
+
#ifdef AFS_DEMAND_ATTACH_FS
static char *
vol_state_to_string(VolState state)
SYNC_PROTO_BUF_DECL(res_buf);
SYNC_response res;
Volume v;
+#ifdef AFS_DEMAND_ATTACH_FS
int hi, lo;
+#endif
res.hdr.response_len = sizeof(res.hdr);
res.payload.buf = res_buf;
printf("volume = {\n");
printf("\thashid = %u\n", v.hashid);
- printf("\theader = 0x%x\n", v.header);
+ printf("\theader = %p\n", v.header);
printf("\tdevice = %d\n", v.device);
- printf("\tpartition = 0x%x\n", v.partition);
- printf("\tlinkHandle = 0x%x\n", v.linkHandle);
+ printf("\tpartition = %p\n", v.partition);
+ printf("\tlinkHandle = %p\n", v.linkHandle);
printf("\tnextVnodeUnique = %u\n", v.nextVnodeUnique);
- printf("\tdiskDataHandle = 0x%x\n", v.diskDataHandle);
+ printf("\tdiskDataHandle = %p\n", v.diskDataHandle);
printf("\tvnodeHashOffset = %u\n", v.vnodeHashOffset);
printf("\tshuttingDown = %d\n", v.shuttingDown);
printf("\tgoingOffline = %d\n", v.goingOffline);
printf("\tupdateTime = %u\n", v.updateTime);
printf("\tvnodeIndex[vSmall] = {\n");
- printf("\t\thandle = 0x%x\n", v.vnodeIndex[vSmall].handle);
- printf("\t\tbitmap = 0x%x\n", v.vnodeIndex[vSmall].bitmap);
+ printf("\t\thandle = %p\n", v.vnodeIndex[vSmall].handle);
+ printf("\t\tbitmap = %p\n", v.vnodeIndex[vSmall].bitmap);
printf("\t\tbitmapSize = %u\n", v.vnodeIndex[vSmall].bitmapSize);
printf("\t\tbitmapOffset = %u\n", v.vnodeIndex[vSmall].bitmapOffset);
printf("\t}\n");
printf("\tvnodeIndex[vLarge] = {\n");
- printf("\t\thandle = 0x%x\n", v.vnodeIndex[vLarge].handle);
- printf("\t\tbitmap = 0x%x\n", v.vnodeIndex[vLarge].bitmap);
+ printf("\t\thandle = %p\n", v.vnodeIndex[vLarge].handle);
+ printf("\t\tbitmap = %p\n", v.vnodeIndex[vLarge].bitmap);
printf("\t\tbitmapSize = %u\n", v.vnodeIndex[vLarge].bitmapSize);
printf("\t\tbitmapOffset = %u\n", v.vnodeIndex[vLarge].bitmapOffset);
printf("\t}\n");
printf("\t}\n");
/* volume op state */
- printf("\tpending_vol_op = 0x%x\n", v.pending_vol_op);
+ printf("\tpending_vol_op = %p\n", v.pending_vol_op);
}
#else /* !AFS_DEMAND_ATTACH_FS */
if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) {
printf("\tid = %u\n", v.id);
printf("\tname = '%s'\n", v.name);
- printf("\tinUse = %d\n", v.inUse);
+ if (v.inUse != 0) {
+ printf("\tinUse = %d (%s)\n", v.inUse, program_type_to_string(v.inUse));
+ } else {
+ printf("\tinUse = %d (no)\n", v.inUse);
+ }
printf("\tinService = %d\n", v.inService);
printf("\tblessed = %d\n", v.blessed);
printf("\tneedsSalvaged = %d\n", v.needsSalvaged);
SYNC_PROTO_BUF_DECL(res_buf);
SYNC_response res;
FSSYNC_VolOp_info vop;
- int i;
res.hdr.response_len = sizeof(res.hdr);
res.payload.buf = res_buf;
printf("\tcom = {\n");
printf("\t\tproto_version = %u\n", vop.com.proto_version);
+ printf("\t\tpkt_seq = %u\n", vop.com.pkt_seq);
+ printf("\t\tcom_seq = %u\n", vop.com.com_seq);
printf("\t\tprogramType = %d (%s)\n",
vop.com.programType, program_type_to_string(vop.com.programType));
+ printf("\t\tpid = %d\n", vop.com.pid);
+ printf("\t\ttid = %d\n", vop.com.tid);
printf("\t\tcommand = %d (%s)\n",
vop.com.command, command_code_to_string(vop.com.command));
printf("\t\treason = %d (%s)\n",
vop.com.reason, reason_code_to_string(vop.com.reason));
printf("\t\tcommand_len = %u\n", vop.com.command_len);
- printf("\t\tflags = 0x%x\n", vop.com.flags);
+ printf("\t\tflags = 0x%lux\n", afs_printable_uint32_lu(vop.com.flags));
printf("\t}\n");
printf("\tvop = {\n");
vn_prolog(struct cmd_syndesc * as, struct state * state)
{
register struct cmd_item *ti;
- char pname[100], *temp;
state->vop = (struct volop_state *) calloc(1, sizeof(struct volop_state));
assert(state->vop != NULL);
SYNC_PROTO_BUF_DECL(res_buf);
SYNC_response res;
Vnode v;
- int hi, lo;
res.hdr.response_len = sizeof(res.hdr);
res.payload.buf = res_buf;
printf("vnode = {\n");
printf("\tvid_hash = {\n");
- printf("\t\tnext = 0x%lx\n", v.vid_hash.next);
- printf("\t\tprev = 0x%lx\n", v.vid_hash.prev);
+ printf("\t\tnext = %p\n", v.vid_hash.next);
+ printf("\t\tprev = %p\n", v.vid_hash.prev);
printf("\t}\n");
- printf("\thashNext = 0x%lx\n", v.hashNext);
- printf("\tlruNext = 0x%lx\n", v.lruNext);
- printf("\tlruPrev = 0x%lx\n", v.lruPrev);
+ printf("\thashNext = %p\n", v.hashNext);
+ printf("\tlruNext = %p\n", v.lruNext);
+ printf("\tlruPrev = %p\n", v.lruPrev);
printf("\thashIndex = %hu\n", v.hashIndex);
printf("\tchanged_newTime = %u\n", (unsigned int) v.changed_newTime);
printf("\tchanged_oldTime = %u\n", (unsigned int) v.changed_oldTime);
printf("\tdelete = %u\n", (unsigned int) v.delete);
printf("\tvnodeNumber = %u\n", v.vnodeNumber);
- printf("\tvolumePtr = 0x%lx\n", v.volumePtr);
+ printf("\tvolumePtr = %p\n", v.volumePtr);
printf("\tnUsers = %u\n", v.nUsers);
printf("\tcacheCheck = %u\n", v.cacheCheck);
}
#endif /* !AFS_DEMAND_ATTACH_FS */
- printf("\twriter = %u\n", v.writer);
- printf("\tvcp = 0x%lx\n", v.vcp);
- printf("\thandle = 0x%lx\n", v.handle);
+ printf("\tvcp = %p\n", v.vcp);
+ printf("\thandle = %p\n", v.handle);
printf("\tdisk = {\n");
printf("\t\ttype = %u\n", v.disk.type);
printf("\t\tserverModifyTime = %u\n", v.disk.serverModifyTime);
printf("\t\tgroup = %d\n", v.disk.group);
printf("\t\tvn_ino_hi = %d\n", v.disk.vn_ino_hi);
- printf("\t\treserved6 = %u\n", v.disk.reserved6);
+ printf("\t\tvn_length_hi = %u\n", v.disk.vn_length_hi);
printf("\t}\n");
printf("}\n");
static void
print_vol_stats_general(VolPkgStats * stats)
{
+#ifdef AFS_DEMAND_ATTACH_FS
int i;
+#endif
afs_uint32 hi, lo;
printf("VolPkgStats = {\n");
print_vol_stats_viceP(struct DiskPartitionStats64 * stats)
{
printf("DiskPartitionStats64 = {\n");
- printf("\tfree = %lld\n", stats->free);
- printf("\tminFree = %lld\n", stats->minFree);
- printf("\ttotalUsable = %lld\n", stats->totalUsable);
- printf("\tf_files = %lld\n", stats->f_files);
+ printf("\tfree = %" AFS_INT64_FMT "\n", stats->free);
+ printf("\tminFree = %" AFS_INT64_FMT "\n", stats->minFree);
+ printf("\ttotalUsable = %" AFS_INT64_FMT "\n", stats->totalUsable);
+ printf("\tf_files = %" AFS_INT64_FMT "\n", stats->f_files);
#ifdef AFS_DEMAND_ATTACH_FS
printf("\tvol_list_len = %d\n", stats->vol_list_len);
#endif
static void
print_vol_stats_hash(struct VolumeHashChainStats * stats)
{
+#ifdef AFS_DEMAND_ATTACH_FS
afs_uint32 hi, lo;
+#endif
printf("DiskPartitionStats = {\n");
printf("\ttable_size = %d\n", stats->table_size);