static int DumpDumpHeader(int dumpfd, register Volume * vp, afs_int32 fromtime) { int code = 0; afs_int32 dumpTimes[2]; if (verbose) fprintf(stderr, "dumping dump header\n"); if (!code) code = DumpDouble(dumpfd, D_DUMPHEADER, DUMPBEGINMAGIC, DUMPVERSION); if (!code) code = DumpInt32(dumpfd, 'v', V_id(vp)); if (!code) code = DumpString(dumpfd, 'n', V_name(vp)); dumpTimes[0] = fromtime; dumpTimes[1] = V_backupDate(vp); /* Until the time the clone was made */ if (!code) code = DumpArrayInt32(dumpfd, 't', (afs_uint32 *) dumpTimes, 2); return code; }
void PrintHeader(Volume * vp) { Vdiskused = V_diskused(vp); if (dsizeOnly || saveinodes) return; printf("Volume header for volume %u (%s)\n", V_id(vp), V_name(vp)); printf("stamp.magic = %x, stamp.version = %u\n", V_stamp(vp).magic, V_stamp(vp).version); printf ("inUse = %d, inService = %d, blessed = %d, needsSalvaged = %d, dontSalvage = %d\n", V_inUse(vp), V_inService(vp), V_blessed(vp), V_needsSalvaged(vp), V_dontSalvage(vp)); printf ("type = %d (%s), uniquifier = %u, needsCallback = %d, destroyMe = %x\n", V_type(vp), typestring(V_type(vp)), V_uniquifier(vp), V_needsCallback(vp), V_destroyMe(vp)); printf ("id = %u, parentId = %u, cloneId = %u, backupId = %u, restoredFromId = %u\n", V_id(vp), V_parentId(vp), V_cloneId(vp), V_backupId(vp), V_restoredFromId(vp)); printf ("maxquota = %d, minquota = %d, maxfiles = %d, filecount = %d, diskused = %d\n", V_maxquota(vp), V_minquota(vp), V_maxfiles(vp), V_filecount(vp), V_diskused(vp)); printf("creationDate = %s, copyDate = %s\n", date(V_creationDate(vp)), date(V_copyDate(vp))); printf("backupDate = %s, expirationDate = %s\n", date(V_backupDate(vp)), date(V_expirationDate(vp))); printf("accessDate = %s, updateDate = %s\n", date(V_accessDate(vp)), date(V_updateDate(vp))); printf("owner = %u, accountNumber = %u\n", V_owner(vp), V_accountNumber(vp)); printf ("dayUse = %u; week = (%u, %u, %u, %u, %u, %u, %u), dayUseDate = %s\n", V_dayUse(vp), V_weekUse(vp)[0], V_weekUse(vp)[1], V_weekUse(vp)[2], V_weekUse(vp)[3], V_weekUse(vp)[4], V_weekUse(vp)[5], V_weekUse(vp)[6], date(V_dayUseDate(vp))); printf("volUpdateCounter = %u\n", V_volUpCounter(vp)); }
void HandleVolume(struct DiskPartition64 *dp, char *name) { struct VolumeHeader header; struct VolumeDiskHeader diskHeader; struct afs_stat status, stat; int fd; Volume *vp; IHandle_t *ih; char headerName[1024]; if (online) { printf("volinfo: -online not supported\n"); exit(1); } else { afs_int32 n; (void)afs_snprintf(headerName, sizeof headerName, "%s/%s", VPartitionPath(dp), name); if ((fd = afs_open(headerName, O_RDONLY)) == -1 || afs_fstat(fd, &status) == -1) { printf("Volinfo: Cannot read volume header %s\n", name); close(fd); exit(1); } n = read(fd, &diskHeader, sizeof(diskHeader)); if (n != sizeof(diskHeader) || diskHeader.stamp.magic != VOLUMEHEADERMAGIC) { printf("Volinfo: Error reading volume header %s\n", name); exit(1); } if (diskHeader.stamp.version != VOLUMEHEADERVERSION) { printf ("Volinfo: Volume %s, version number is incorrect; volume needs salvage\n", name); exit(1); } DiskToVolumeHeader(&header, &diskHeader); if (dheader) { FdHandle_t *fdP; afs_sfsize_t size = 0; afs_sfsize_t code; if (afs_fstat(fd, &stat) == -1) { perror("stat"); exit(1); } if (!dsizeOnly && !saveinodes) { size = stat.st_size; printf("Volume header (size = %d):\n", (int)size); printf("\tstamp\t= 0x%x\n", header.stamp.version); printf("\tVolId\t= %u\n", header.id); } IH_INIT(ih, dp->device, header.parent, header.volumeInfo); fdP = IH_OPEN(ih); if (fdP == NULL) { perror("opening volume info"); exit(1); } code = FDH_SIZE(fdP); if (code == -1) { perror("fstat"); exit(1); } FDH_REALLYCLOSE(fdP); IH_RELEASE(ih); size += code; if (!dsizeOnly && !saveinodes) { printf("\tparent\t= %u\n", header.parent); printf("\tInfo inode\t= %s (size = %d)\n", PrintInode(NULL, header.volumeInfo), (int)code); } IH_INIT(ih, dp->device, header.parent, header.smallVnodeIndex); fdP = IH_OPEN(ih); if (fdP == NULL) { perror("opening small vnode index"); exit(1); } code = FDH_SIZE(fdP); if (code == -1) { perror("fstat"); exit(1); } FDH_REALLYCLOSE(fdP); IH_RELEASE(ih); size += code; if (!dsizeOnly && !saveinodes) { printf("\tSmall inode\t= %s (size = %d)\n", PrintInode(NULL, header.smallVnodeIndex), (int)code); } IH_INIT(ih, dp->device, header.parent, header.largeVnodeIndex); fdP = IH_OPEN(ih); if (fdP == NULL) { perror("opening large vnode index"); exit(1); } code = FDH_SIZE(fdP); if (code == -1) { perror("fstat"); exit(1); } FDH_REALLYCLOSE(fdP); IH_RELEASE(ih); size += code; if (!dsizeOnly && !saveinodes) { printf("\tLarge inode\t= %s (size = %d)\n", PrintInode(NULL, header.largeVnodeIndex), (int)code); #ifndef AFS_NT40_ENV printf("Total aux volume size = %d\n\n", (int)size); #endif } #ifdef AFS_NAMEI_ENV IH_INIT(ih, dp->device, header.parent, header.linkTable); fdP = IH_OPEN(ih); if (fdP == NULL) { perror("opening link table index"); exit(1); } code = FDH_SIZE(fdP); if (code == -1) { perror("fstat"); exit(1); } FDH_REALLYCLOSE(fdP); IH_RELEASE(ih); size += code; if (!dsizeOnly && !saveinodes) { printf("\tLink inode\t= %s (size = %d)\n", PrintInode(NULL, header.linkTable), (int)code); printf("Total aux volume size = %d\n\n", (int)size); } #endif Vauxsize = size; Vauxsize_k = size / 1024; } close(fd); vp = AttachVolume(dp, name, &header); if (!vp) { printf("Volinfo: Error attaching volume header %s\n", name); return; } } PrintHeader(vp); if (DumpVnodes) { if (!dsizeOnly && !saveinodes) printf("\nLarge vnodes (directories)\n"); PrintVnodes(vp, vLarge); if (!dsizeOnly && !saveinodes) { printf("\nSmall vnodes(files, symbolic links)\n"); fflush(stdout); } if (saveinodes) printf("Saving all volume files to current directory ...\n"); PrintVnodes(vp, vSmall); } if (dsizeOnly) { totvolsize = Vauxsize_k + Vvnodesize_k; if (saveinodes) printf ("Volume-Id\t Volsize Auxsize Inodesize AVolsize SizeDiff (VolName)\n"); printf("%u\t%9d%9d%10d%10d%9d\t%24s\n", V_id(vp), Vdiskused, Vauxsize_k, Vvnodesize_k, totvolsize, totvolsize - Vdiskused, V_name(vp)); } free(vp->header); free(vp); }
static int DumpVolumeHeader(int dumpfd, register Volume * vp) { int code = 0; if (verbose) fprintf(stderr, "dumping volume header\n"); if (!code) code = DumpTag(dumpfd, D_VOLUMEHEADER); if (!code) code = DumpInt32(dumpfd, 'i', V_id(vp)); if (!code) code = DumpInt32(dumpfd, 'v', V_stamp(vp).version); if (!code) code = DumpString(dumpfd, 'n', V_name(vp)); if (!code) code = DumpBool(dumpfd, 's', V_inService(vp)); if (!code) code = DumpBool(dumpfd, 'b', V_blessed(vp)); if (!code) code = DumpInt32(dumpfd, 'u', V_uniquifier(vp)); if (!code) code = DumpByte(dumpfd, 't', (byte) V_type(vp)); if (!code) code = DumpInt32(dumpfd, 'p', V_parentId(vp)); if (!code) code = DumpInt32(dumpfd, 'c', V_cloneId(vp)); if (!code) code = DumpInt32(dumpfd, 'q', V_maxquota(vp)); if (!code) code = DumpInt32(dumpfd, 'm', V_minquota(vp)); if (!code) code = DumpInt32(dumpfd, 'd', V_diskused(vp)); if (!code) code = DumpInt32(dumpfd, 'f', V_filecount(vp)); if (!code) code = DumpInt32(dumpfd, 'a', V_accountNumber(vp)); if (!code) code = DumpInt32(dumpfd, 'o', V_owner(vp)); if (!code) code = DumpInt32(dumpfd, 'C', V_creationDate(vp)); /* Rw volume creation date */ if (!code) code = DumpInt32(dumpfd, 'A', V_accessDate(vp)); if (!code) code = DumpInt32(dumpfd, 'U', V_updateDate(vp)); if (!code) code = DumpInt32(dumpfd, 'E', V_expirationDate(vp)); if (!code) code = DumpInt32(dumpfd, 'B', V_backupDate(vp)); /* Rw volume backup clone date */ if (!code) code = DumpString(dumpfd, 'O', V_offlineMessage(vp)); /* * We do NOT dump the detailed volume statistics residing in the old * motd field, since we cannot tell from the info in a dump whether * statistics data has been put there. Instead, we dump a null string, * just as if that was what the motd contained. */ if (!code) code = DumpString(dumpfd, 'M', ""); if (!code) code = DumpArrayInt32(dumpfd, 'W', (afs_uint32 *) V_weekUse(vp), sizeof(V_weekUse(vp)) / sizeof(V_weekUse(vp)[0])); if (!code) code = DumpInt32(dumpfd, 'D', V_dayUseDate(vp)); if (!code) code = DumpInt32(dumpfd, 'Z', V_dayUse(vp)); if (!code) code = DumpInt32(dumpfd, 'V', V_volUpCounter(vp)); return code; }