static int VolOpQuery(struct cmd_syndesc * as, void * rock) { struct state state; 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; res.payload.len = SYNC_PROTO_MAX_LEN; common_prolog(as, &state); common_volop_prolog(as, &state); do_volop(&state, FSYNC_VOL_QUERY_VOP, &res); if (!(res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS)) { printf("*** file server not compiled with demand attach extensions.\n"); printf("*** pending volume operation metadata not available.\n"); } if (res.hdr.response == SYNC_OK) { memcpy(&vop, res.payload.buf, sizeof(FSSYNC_VolOp_info)); printf("pending_vol_op = {\n"); 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}\n"); printf("\tvop = {\n"); printf("\t\tvolume = %u\n", vop.vop.volume); if (afs_strnlen(vop.vop.partName, sizeof(vop.vop.partName)) < sizeof(vop.vop.partName)) { printf("\t\tpartName = '%s'\n", vop.vop.partName); } else { printf("\t\tpartName = (illegal string)\n"); } printf("\t}\n"); printf("}\n"); } 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; }
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 VolList(struct cmd_syndesc * as, void * rock) { struct state state; common_prolog(as, &state); common_volop_prolog(as, &state); do_volop(&state, FSYNC_VOL_LISTVOLUMES, NULL); return 0; }
static int VolMove(struct cmd_syndesc * as, void * rock) { struct state state; common_prolog(as, &state); common_volop_prolog(as, &state); do_volop(&state, FSYNC_VOL_MOVE, NULL); return 0; }
static int VolBreakCBKs(struct cmd_syndesc * as, void * rock) { struct state state; common_prolog(as, &state); common_volop_prolog(as, &state); do_volop(&state, FSYNC_VOL_BREAKCBKS, NULL); return 0; }
static int VolDetach(struct cmd_syndesc * as, void * rock) { struct fssync_state state; common_prolog(as, &state); common_volop_prolog(as, &state); do_volop(&state, FSYNC_VOL_DONE, NULL); return 0; }
static int VolOnline(struct cmd_syndesc * as, void * rock) { struct fssync_state state; common_prolog(as, &state); common_volop_prolog(as, &state); if (state.vop->partName==0 || *(state.vop->partName)==0) { fprintf(stderr, "required argument -partition not given\n"); return -1; } do_volop(&state, FSYNC_VOL_ON, NULL); return 0; }
static int VolHdrQuery(struct cmd_syndesc * as, void * rock) { struct state state; SYNC_PROTO_BUF_DECL(res_buf); SYNC_response res; VolumeDiskData v; int i; res.hdr.response_len = sizeof(res.hdr); res.payload.buf = res_buf; res.payload.len = SYNC_PROTO_MAX_LEN; common_prolog(as, &state); common_volop_prolog(as, &state); do_volop(&state, FSYNC_VOL_QUERY_HDR, &res); if (res.hdr.response == SYNC_OK) { memcpy(&v, res.payload.buf, sizeof(VolumeDiskData)); printf("VolumeDiskData = {\n"); printf("\tstamp = {\n"); printf("\t\tmagic = 0x%x\n", v.stamp.magic); printf("\t\tversion = %u\n", v.stamp.version); printf("\t}\n"); printf("\tid = %u\n", v.id); printf("\tname = '%s'\n", v.name); 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); printf("\tuniquifier = %u\n", v.uniquifier); printf("\ttype = %d\n", v.type); printf("\tparentId = %u\n", v.parentId); printf("\tcloneId = %u\n", v.cloneId); printf("\tbackupId = %u\n", v.backupId); printf("\trestoredFromId = %u\n", v.restoredFromId); printf("\tneedsCallback = %d\n", v.needsCallback); printf("\tdestroyMe = %d\n", v.destroyMe); printf("\tdontSalvage = %d\n", v.dontSalvage); printf("\tmaxquota = %d\n", v.maxquota); printf("\tminquota = %d\n", v.minquota); printf("\tmaxfiles = %d\n", v.maxfiles); printf("\taccountNumber = %u\n", v.accountNumber); printf("\towner = %u\n", v.owner); printf("\tfilecount = %d\n", v.filecount); printf("\tdiskused = %d\n", v.diskused); printf("\tdayUse = %d\n", v.dayUse); for (i = 0; i < 7; i++) { printf("\tweekUse[%d] = %d\n", i, v.weekUse[i]); } printf("\tdayUseDate = %u\n", v.dayUseDate); printf("\tcreationDate = %u\n", v.creationDate); printf("\taccessDate = %u\n", v.accessDate); printf("\tupdateDate = %u\n", v.updateDate); printf("\texpirationDate = %u\n", v.expirationDate); printf("\tbackupDate = %u\n", v.backupDate); printf("\tcopyDate = %u\n", v.copyDate); #ifdef OPENAFS_VOL_STATS printf("\tstat_initialized = %d\n", v.stat_initialized); #else printf("\tmtd = '%s'\n", v.motd); #endif printf("}\n"); } return 0; }
static int VolQuery(struct cmd_syndesc * as, void * rock) { struct state state; SYNC_PROTO_BUF_DECL(res_buf); SYNC_response res; Volume v; int hi, lo; res.hdr.response_len = sizeof(res.hdr); res.payload.buf = res_buf; res.payload.len = SYNC_PROTO_MAX_LEN; common_prolog(as, &state); common_volop_prolog(as, &state); do_volop(&state, FSYNC_VOL_QUERY, &res); if (res.hdr.response == SYNC_OK) { memcpy(&v, res.payload.buf, sizeof(Volume)); printf("volume = {\n"); printf("\thashid = %u\n", v.hashid); printf("\theader = 0x%x\n", v.header); printf("\tdevice = %d\n", v.device); printf("\tpartition = 0x%x\n", v.partition); printf("\tlinkHandle = 0x%x\n", v.linkHandle); printf("\tnextVnodeUnique = %u\n", v.nextVnodeUnique); printf("\tdiskDataHandle = 0x%x\n", v.diskDataHandle); printf("\tvnodeHashOffset = %u\n", v.vnodeHashOffset); printf("\tshuttingDown = %d\n", v.shuttingDown); printf("\tgoingOffline = %d\n", v.goingOffline); printf("\tcacheCheck = %u\n", v.cacheCheck); printf("\tnUsers = %d\n", v.nUsers); printf("\tneedsPutBack = %d\n", v.needsPutBack); printf("\tspecialStatus = %d\n", v.specialStatus); 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\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\tbitmapSize = %u\n", v.vnodeIndex[vLarge].bitmapSize); printf("\t\tbitmapOffset = %u\n", v.vnodeIndex[vLarge].bitmapOffset); printf("\t}\n"); #ifdef AFS_DEMAND_ATTACH_FS if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) { printf("\tupdateTime = %u\n", v.updateTime); printf("\tattach_state = %s\n", vol_state_to_string(v.attach_state)); printf("\tattach_flags = %s\n", vol_flags_to_string(v.attach_flags)); printf("\tnWaiters = %d\n", v.nWaiters); printf("\tchainCacheCheck = %d\n", v.chainCacheCheck); /* online salvage structure */ printf("\tsalvage = {\n"); printf("\t\tprio = %u\n", v.salvage.prio); printf("\t\treason = %d\n", v.salvage.reason); printf("\t\trequested = %d\n", v.salvage.requested); printf("\t\tscheduled = %d\n", v.salvage.scheduled); printf("\t}\n"); /* statistics structure */ printf("\tstats = {\n"); printf("\t\thash_lookups = {\n"); SplitInt64(v.stats.hash_lookups,hi,lo); printf("\t\t\thi = %u\n", hi); printf("\t\t\tlo = %u\n", lo); printf("\t\t}\n"); printf("\t\thash_short_circuits = {\n"); SplitInt64(v.stats.hash_short_circuits,hi,lo); printf("\t\t\thi = %u\n", hi); printf("\t\t\tlo = %u\n", lo); printf("\t\t}\n"); printf("\t\thdr_loads = {\n"); SplitInt64(v.stats.hdr_loads,hi,lo); printf("\t\t\thi = %u\n", hi); printf("\t\t\tlo = %u\n", lo); printf("\t\t}\n"); printf("\t\thdr_gets = {\n"); SplitInt64(v.stats.hdr_gets,hi,lo); printf("\t\t\thi = %u\n", hi); printf("\t\t\tlo = %u\n", lo); printf("\t\t}\n"); printf("\t\tattaches = %u\n", v.stats.attaches); printf("\t\tsoft_detaches = %u\n", v.stats.soft_detaches); printf("\t\tsalvages = %u\n", v.stats.salvages); printf("\t\tvol_ops = %u\n", v.stats.vol_ops); printf("\t\tlast_attach = %u\n", v.stats.last_attach); printf("\t\tlast_get = %u\n", v.stats.last_get); printf("\t\tlast_promote = %u\n", v.stats.last_promote); printf("\t\tlast_hdr_get = %u\n", v.stats.last_hdr_get); printf("\t\tlast_hdr_load = %u\n", v.stats.last_hdr_load); printf("\t\tlast_salvage = %u\n", v.stats.last_salvage); printf("\t\tlast_salvage_req = %u\n", v.stats.last_salvage_req); printf("\t\tlast_vol_op = %u\n", v.stats.last_vol_op); printf("\t}\n"); /* VLRU state */ printf("\tvlru = {\n"); printf("\t\tidx = %d (%s)\n", v.vlru.idx, vlru_idx_to_string(v.vlru.idx)); printf("\t}\n"); /* volume op state */ printf("\tpending_vol_op = 0x%x\n", v.pending_vol_op); } #else /* !AFS_DEMAND_ATTACH_FS */ if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) { printf("*** server asserted demand attach extensions. fssync-debug not built to\n"); printf("*** recognize those extensions. please recompile fssync-debug if you need\n"); printf("*** to dump dafs extended state\n"); } #endif /* !AFS_DEMAND_ATTACH_FS */ printf("}\n"); } return 0; }