2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
14 #include <sys/types.h>
22 #include <sys/param.h>
25 #include <netinet/in.h>
29 #ifdef AFS_PTHREAD_ENV
31 #else /* AFS_PTHREAD_ENV */
32 #include <afs/assert.h>
33 #endif /* AFS_PTHREAD_ENV */
36 #include <afs/afsint.h>
38 #include <afs/errors.h>
41 #include <afs/ihandle.h>
42 #include <afs/vnode.h>
43 #include <afs/volume.h>
44 #include <afs/partition.h>
46 #include <afs/daemon_com.h>
47 #include <afs/fssync.h>
49 #include <afs/com_err.h>
50 #include <afs/vol_prototypes.h>
53 #include "dumpstuff.h"
57 #define afs_stat stat64
58 #define afs_fstat fstat64
59 #else /* !O_LARGEFILE */
61 #define afs_fstat fstat
62 #endif /* !O_LARGEFILE */
63 #endif /* !AFS_NT40_ENV */
65 /*@printflike@*/ extern void Log(const char *format, ...);
70 /* Forward Declarations */
71 static int DumpDumpHeader(register struct iod *iodp, register Volume * vp,
73 static int DumpPartial(register struct iod *iodp, register Volume * vp,
74 afs_int32 fromtime, int dumpAllDirs);
75 static int DumpVnodeIndex(register struct iod *iodp, Volume * vp,
76 VnodeClass class, afs_int32 fromtime,
78 static int DumpVnode(register struct iod *iodp, struct VnodeDiskObject *v,
79 int volid, int vnodeNumber, int dumpEverything);
80 static int ReadDumpHeader(register struct iod *iodp, struct DumpHeader *hp);
81 static int ReadVnodes(register struct iod *iodp, Volume * vp, int incremental,
82 afs_int32 * Lbuf, afs_int32 s1, afs_int32 * Sbuf,
83 afs_int32 s2, afs_int32 delo);
84 static afs_fsize_t volser_WriteFile(int vn, struct iod *iodp,
85 FdHandle_t * handleP, int tag,
88 static int SizeDumpDumpHeader(register struct iod *iodp, register Volume * vp,
90 register struct volintSize *size);
91 static int SizeDumpPartial(register struct iod *iodp, register Volume * vp,
92 afs_int32 fromtime, int dumpAllDirs,
93 register struct volintSize *size);
94 static int SizeDumpVnodeIndex(register struct iod *iodp, Volume * vp,
95 VnodeClass class, afs_int32 fromtime,
97 register struct volintSize *size);
98 static int SizeDumpVnode(register struct iod *iodp, struct VnodeDiskObject *v,
99 int volid, int vnodeNumber, int dumpEverything,
100 register struct volintSize *size);
103 iod_Init(register struct iod *iodp, register struct rx_call *call)
106 iodp->haveOldChar = 0;
108 iodp->calls = (struct rx_call **)0;
112 iod_InitMulti(struct iod *iodp, struct rx_call **calls, int ncalls,
117 iodp->haveOldChar = 0;
118 iodp->ncalls = ncalls;
120 iodp->call = (struct rx_call *)0;
123 /* N.B. iod_Read doesn't check for oldchar (see previous comment) */
124 #define iod_Read(iodp, buf, nbytes) rx_Read((iodp)->call, buf, nbytes)
126 /* For the single dump case, it's ok to just return the "bytes written"
127 * that rx_Write returns, since all the callers of iod_Write abort when
128 * the returned value is less than they expect. For the multi dump case,
129 * I don't think we want half the replicas to go bad just because one
130 * connection timed out, but if they all time out, then we should give up.
133 iod_Write(struct iod *iodp, char *buf, int nbytes)
138 assert((iodp->call && iodp->ncalls == 1 && !iodp->calls)
139 || (!iodp->call && iodp->ncalls >= 1 && iodp->calls));
142 code = rx_Write(iodp->call, buf, nbytes);
146 for (i = 0; i < iodp->ncalls; i++) {
147 if (iodp->calls[i] && !iodp->codes[i]) {
148 code = rx_Write(iodp->calls[i], buf, nbytes);
149 if (code != nbytes) { /* everything gets merged into a single error */
150 iodp->codes[i] = VOLSERDUMPERROR; /* but that's exactly what the */
151 } /* standard dump does, anyways */
156 } /* for all calls */
165 iod_ungetc(struct iod *iodp, int achar)
167 iodp->oldChar = achar;
168 iodp->haveOldChar = 1;
172 iod_getc(register struct iod *iodp)
176 if (iodp->haveOldChar) {
177 iodp->haveOldChar = 0;
178 return iodp->oldChar;
180 if (iod_Read(iodp, &t, 1) == 1)
186 ReadShort(register struct iod *iodp, register unsigned short *sp)
195 *sp = (b1 << 8) | b0;
200 ReadInt32(register struct iod *iodp, afs_uint32 * lp)
202 afs_uint32 register b3, b2, b1, b0;
215 *lp = (((((b3 << 8) | b2) << 8) | b1) << 8) | b0;
220 ReadString(register struct iod *iodp, register char *to, register int maxa)
229 if ((*to++ = c = iod_getc(iodp)) == 0 || c == EOF)
233 while ((c = iod_getc(iodp)) && c != EOF);
239 ReadByteString(register struct iod *iodp, register byte * to,
243 *to++ = iod_getc(iodp);
247 ReadVolumeHeader(register struct iod *iodp, VolumeDiskData * vol)
251 memset(vol, 0, sizeof(*vol));
252 while ((tag = iod_getc(iodp)) > D_MAX && tag != EOF) {
255 if (!ReadInt32(iodp, &vol->id))
256 return VOLSERREAD_DUMPERROR;
259 if (!ReadInt32(iodp, &trash))
260 return VOLSERREAD_DUMPERROR;
263 ReadString(iodp, vol->name, sizeof(vol->name));
264 /*this means the name of the retsored volume could be possibly different. In conjunction with SAFSVolSignalRestore */
267 vol->inService = iod_getc(iodp);
270 vol->blessed = iod_getc(iodp);
273 if (!ReadInt32(iodp, &vol->uniquifier))
274 return VOLSERREAD_DUMPERROR;
277 vol->type = iod_getc(iodp);
280 if (!ReadInt32(iodp, &vol->parentId))
281 return VOLSERREAD_DUMPERROR;
284 if (!ReadInt32(iodp, &vol->cloneId))
285 return VOLSERREAD_DUMPERROR;
288 if (!ReadInt32(iodp, (afs_uint32 *) & vol->maxquota))
289 return VOLSERREAD_DUMPERROR;
292 if (!ReadInt32(iodp, (afs_uint32 *) & vol->minquota))
293 return VOLSERREAD_DUMPERROR;
296 if (!ReadInt32(iodp, (afs_uint32 *) & vol->diskused))
297 return VOLSERREAD_DUMPERROR; /* Bogus: should calculate this */
300 if (!ReadInt32(iodp, (afs_uint32 *) & vol->filecount))
301 return VOLSERREAD_DUMPERROR;
304 if (!ReadInt32(iodp, &vol->accountNumber))
305 return VOLSERREAD_DUMPERROR;
308 if (!ReadInt32(iodp, &vol->owner))
309 return VOLSERREAD_DUMPERROR;
312 if (!ReadInt32(iodp, &vol->creationDate))
313 return VOLSERREAD_DUMPERROR;
316 if (!ReadInt32(iodp, &vol->accessDate))
317 return VOLSERREAD_DUMPERROR;
320 if (!ReadInt32(iodp, &vol->updateDate))
321 return VOLSERREAD_DUMPERROR;
324 if (!ReadInt32(iodp, &vol->expirationDate))
325 return VOLSERREAD_DUMPERROR;
328 if (!ReadInt32(iodp, &vol->backupDate))
329 return VOLSERREAD_DUMPERROR;
332 ReadString(iodp, vol->offlineMessage,
333 sizeof(vol->offlineMessage));
337 * Detailed volume statistics are never stored in dumps,
338 * so we just restore either the null string if this volume
339 * had already been set to store statistics, or the old motd
340 * contents otherwise. It doesn't matter, since this field
341 * will soon get initialized anyway.
343 ReadString(iodp, (char *)(vol->stat_reads), VMSGSIZE);
346 unsigned short length;
349 if (!ReadShort(iodp, &length))
350 return VOLSERREAD_DUMPERROR;
351 for (i = 0; i < length; i++) {
352 if (!ReadInt32(iodp, &data))
353 return VOLSERREAD_DUMPERROR;
354 if (i < sizeof(vol->weekUse) / sizeof(vol->weekUse[0]))
355 vol->weekUse[i] = data;
360 if (!ReadInt32(iodp, &vol->dayUseDate))
361 return VOLSERREAD_DUMPERROR;
364 if (!ReadInt32(iodp, (afs_uint32 *) & vol->dayUse))
365 return VOLSERREAD_DUMPERROR;
368 if (!ReadInt32(iodp, (afs_uint32 *) &trash/*volUpdateCounter*/))
369 return VOLSERREAD_DUMPERROR;
373 iod_ungetc(iodp, tag);
378 DumpTag(register struct iod *iodp, register int tag)
383 return ((iod_Write(iodp, &p, 1) == 1) ? 0 : VOLSERDUMPERROR);
388 DumpByte(register struct iod *iodp, char tag, byte value)
391 register byte *p = (unsigned char *)tbuffer;
394 return ((iod_Write(iodp, tbuffer, 2) == 2) ? 0 : VOLSERDUMPERROR);
397 #define putint32(p, v) *p++ = v>>24, *p++ = v>>16, *p++ = v>>8, *p++ = v
398 #define putshort(p, v) *p++ = v>>8, *p++ = v
401 DumpDouble(register struct iod *iodp, char tag, register afs_uint32 value1,
402 register afs_uint32 value2)
405 register byte *p = (unsigned char *)tbuffer;
409 return ((iod_Write(iodp, tbuffer, 9) == 9) ? 0 : VOLSERDUMPERROR);
413 DumpInt32(register struct iod *iodp, char tag, register afs_uint32 value)
416 register byte *p = (unsigned char *)tbuffer;
419 return ((iod_Write(iodp, tbuffer, 5) == 5) ? 0 : VOLSERDUMPERROR);
423 DumpArrayInt32(register struct iod *iodp, char tag,
424 register afs_uint32 * array, register int nelem)
427 register afs_uint32 v;
429 register byte *p = (unsigned char *)tbuffer;
432 code = iod_Write(iodp, tbuffer, 3);
434 return VOLSERDUMPERROR;
436 p = (unsigned char *)tbuffer;
437 v = *array++; /*this was register */
440 code = iod_Write(iodp, tbuffer, 4);
442 return VOLSERDUMPERROR;
448 DumpShort(register struct iod *iodp, char tag, unsigned int value)
451 register byte *p = (unsigned char *)tbuffer;
455 return ((iod_Write(iodp, tbuffer, 3) == 3) ? 0 : VOLSERDUMPERROR);
459 DumpBool(register struct iod *iodp, char tag, unsigned int value)
462 register byte *p = (unsigned char *)tbuffer;
465 return ((iod_Write(iodp, tbuffer, 2) == 2) ? 0 : VOLSERDUMPERROR);
469 DumpString(register struct iod *iodp, char tag, register char *s)
473 code = iod_Write(iodp, &tag, 1);
475 return VOLSERDUMPERROR;
477 code = iod_Write(iodp, s, n);
479 return VOLSERDUMPERROR;
484 DumpByteString(register struct iod *iodp, char tag, register byte * bs,
489 code = iod_Write(iodp, &tag, 1);
491 return VOLSERDUMPERROR;
492 code = iod_Write(iodp, (char *)bs, nbytes);
494 return VOLSERDUMPERROR;
499 DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP)
501 int code = 0, error = 0;
503 afs_int32 offset = 0;
504 afs_sfsize_t n, nbytes, howMany, howBig;
505 afs_foff_t lcode = 0;
508 struct afs_stat status;
512 #include <sys/statfs.h>
513 #if defined(AFS_AIX52_ENV) && defined(AFS_LARGEFILE_ENV)
514 struct statfs64 tstatfs;
515 #else /* !AFS_AIX52_ENV || !AFS_LARGEFILE_ENV */
516 struct statfs tstatfs;
517 #endif /* !AFS_AIX52_ENV || !AFS_LARGEFILE_ENV */
522 howBig = _filelength(handleP->fd_fd);
526 afs_fstat(handleP->fd_fd, &status);
527 howBig = status.st_size;
530 /* Unfortunately in AIX valuable fields such as st_blksize are
531 * gone from the stat structure.
533 #if defined(AFS_AIX52_ENV) && defined(AFS_LARGEFILE_ENV)
534 statfs_code = fstatfs64(handleP->fd_fd, &tstatfs);
535 #else /* !AFS_AIX52_ENV || !AFS_LARGEFILE_ENV */
536 statfs_code = fstatfs(handleP->fd_fd, &tstatfs);
537 #endif /* !AFS_AIX52_ENV || !AFS_LARGEFILE_ENV */
538 if (statfs_code != 0) {
539 Log("DumpFile: fstatfs returned error code %d on descriptor %d\n", errno, handleP->fd_fd);
540 return VOLSERDUMPERROR;
542 howMany = (afs_sfsize_t) tstatfs.f_bsize;
544 howMany = status.st_blksize;
545 #endif /* AFS_AIX_ENV */
546 #endif /* AFS_NT40_ENV */
549 size = FDH_SIZE(handleP);
550 #ifdef AFS_LARGEFILE_ENV
553 SplitInt64(size, hi, lo);
555 code = DumpInt32(iodp, 'f', lo);
557 code = DumpDouble(iodp, 'h', hi, lo);
560 #else /* !AFS_LARGEFILE_ENV */
561 code = DumpInt32(iodp, 'f', size);
562 #endif /* !AFS_LARGEFILE_ENV */
564 return VOLSERDUMPERROR;
567 p = (unsigned char *)malloc((size_t)howMany);
569 Log("1 Volser: DumpFile: not enough memory to allocate %u bytes\n", howMany);
570 return VOLSERDUMPERROR;
573 for (nbytes = size; (nbytes && !error); nbytes -= howMany) {
574 if (nbytes < howMany)
577 /* Read the data - unless we know we can't */
578 n = (lcode ? 0 : FDH_READ(handleP, p, (size_t)howMany));
580 /* If read any good data and we null padded previously, log the
581 * amount that we had null padded.
583 if ((n > 0) && pad) {
584 Log("1 Volser: DumpFile: Null padding file %d bytes at offset %u\n", pad, offset);
588 /* If didn't read enough data, null padd the rest of the buffer. This
589 * can happen if, for instance, the media has some bad spots. We don't
590 * want to quit the dump, so we start null padding.
593 /* Record the read error */
596 Log("1 Volser: DumpFile: Error %d reading inode %s for vnode %d\n", errno, PrintInode(NULL, handleP->fd_ih->ih_ino), vnode);
598 Log("1 Volser: DumpFile: Error reading inode %s for vnode %d\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode);
601 /* Pad the rest of the buffer with zeros. Remember offset we started
602 * padding. Keep total tally of padding.
604 memset(p + n, 0, howMany - n);
606 offset = (howBig - nbytes) + n;
607 pad += (howMany - n);
609 /* Now seek over the data we could not get. An error here means we
610 * can't do the next read.
612 lcode = FDH_SEEK(handleP, (size_t)((size - nbytes) + howMany), SEEK_SET);
613 if (lcode != ((size - nbytes) + howMany)) {
615 Log("1 Volser: DumpFile: Error %d seeking in inode %s for vnode %d\n", errno, PrintInode(NULL, handleP->fd_ih->ih_ino), vnode);
617 Log("1 Volser: DumpFile: Error seeking in inode %s for vnode %d\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode);
625 /* Now write the data out */
626 if (iod_Write(iodp, (char *)p, (size_t)howMany) != howMany)
627 error = VOLSERDUMPERROR;
628 #ifndef AFS_PTHREAD_ENV
633 if (pad) { /* Any padding we hadn't reported yet */
634 Log("1 Volser: DumpFile: Null padding file: %d bytes at offset %u\n",
643 DumpVolumeHeader(register struct iod *iodp, register Volume * vp)
646 static char nullString[1] = ""; /*The ``contents'' of motd */
649 code = DumpTag(iodp, D_VOLUMEHEADER);
651 code = DumpInt32(iodp, 'i', V_id(vp));
654 code = DumpInt32(iodp, 'v', V_stamp(vp).version);
656 code = DumpString(iodp, 'n', V_name(vp));
658 code = DumpBool(iodp, 's', V_inService(vp));
660 code = DumpBool(iodp, 'b', V_blessed(vp));
662 code = DumpInt32(iodp, 'u', V_uniquifier(vp));
664 code = DumpByte(iodp, 't', (byte) V_type(vp));
666 code = DumpInt32(iodp, 'p', V_parentId(vp));
669 code = DumpInt32(iodp, 'c', V_cloneId(vp));
671 code = DumpInt32(iodp, 'q', V_maxquota(vp));
673 code = DumpInt32(iodp, 'm', V_minquota(vp));
675 code = DumpInt32(iodp, 'd', V_diskused(vp));
677 code = DumpInt32(iodp, 'f', V_filecount(vp));
679 code = DumpInt32(iodp, 'a', V_accountNumber(vp));
681 code = DumpInt32(iodp, 'o', V_owner(vp));
683 code = DumpInt32(iodp, 'C', V_creationDate(vp)); /* Rw volume creation date */
685 code = DumpInt32(iodp, 'A', V_accessDate(vp));
687 code = DumpInt32(iodp, 'U', V_updateDate(vp));
689 code = DumpInt32(iodp, 'E', V_expirationDate(vp));
691 code = DumpInt32(iodp, 'B', V_backupDate(vp)); /* Rw volume backup clone date */
693 code = DumpString(iodp, 'O', V_offlineMessage(vp));
695 * We do NOT dump the detailed volume statistics residing in the old
696 * motd field, since we cannot tell from the info in a dump whether
697 * statistics data has been put there. Instead, we dump a null string,
698 * just as if that was what the motd contained.
701 code = DumpString(iodp, 'M', nullString);
704 DumpArrayInt32(iodp, 'W', (afs_uint32 *) V_weekUse(vp),
705 sizeof(V_weekUse(vp)) / sizeof(V_weekUse(vp)[0]));
707 code = DumpInt32(iodp, 'D', V_dayUseDate(vp));
709 code = DumpInt32(iodp, 'Z', V_dayUse(vp));
714 DumpEnd(register struct iod *iodp)
716 return (DumpInt32(iodp, D_DUMPEND, DUMPENDMAGIC));
719 /* Guts of the dump code */
721 /* Dump a whole volume */
723 DumpVolume(register struct rx_call *call, register Volume * vp,
724 afs_int32 fromtime, int dumpAllDirs)
728 register struct iod *iodp = &iod;
729 iod_Init(iodp, call);
732 code = DumpDumpHeader(iodp, vp, fromtime);
735 code = DumpPartial(iodp, vp, fromtime, dumpAllDirs);
737 /* hack follows. Errors should be handled quite differently in this version of dump than they used to be.*/
738 if (rx_Error(iodp->call)) {
739 Log("1 Volser: DumpVolume: Rx call failed during dump, error %d\n",
740 rx_Error(iodp->call));
741 return VOLSERDUMPERROR;
744 code = DumpEnd(iodp);
749 /* Dump a volume to multiple places*/
751 DumpVolMulti(struct rx_call **calls, int ncalls, Volume * vp,
752 afs_int32 fromtime, int dumpAllDirs, int *codes)
756 iod_InitMulti(&iod, calls, ncalls, codes);
759 code = DumpDumpHeader(&iod, vp, fromtime);
761 code = DumpPartial(&iod, vp, fromtime, dumpAllDirs);
763 code = DumpEnd(&iod);
767 /* A partial dump (no dump header) */
769 DumpPartial(register struct iod *iodp, register Volume * vp,
770 afs_int32 fromtime, int dumpAllDirs)
774 code = DumpVolumeHeader(iodp, vp);
776 code = DumpVnodeIndex(iodp, vp, vLarge, fromtime, dumpAllDirs);
778 code = DumpVnodeIndex(iodp, vp, vSmall, fromtime, 0);
783 DumpVnodeIndex(register struct iod *iodp, Volume * vp, VnodeClass class,
784 afs_int32 fromtime, int forcedump)
786 register int code = 0;
787 register struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
788 char buf[SIZEOF_LARGEDISKVNODE];
789 struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
790 StreamHandle_t *file;
794 register int vnodeIndex, nVnodes;
796 fdP = IH_OPEN(vp->vnodeIndex[class].handle);
798 file = FDH_FDOPEN(fdP, "r+");
799 assert(file != NULL);
800 size = OS_SIZE(fdP->fd_fd);
802 nVnodes = (size / vcp->diskSize) - 1;
804 assert((nVnodes + 1) * vcp->diskSize == size);
805 assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
809 nVnodes && STREAM_READ(vnode, vcp->diskSize, 1, file) == 1 && !code;
810 nVnodes--, vnodeIndex++) {
811 flag = forcedump || (vnode->serverModifyTime >= fromtime);
812 /* Note: the >= test is very important since some old volumes may not have
813 * a serverModifyTime. For an epoch dump, this results in 0>=0 test, which
814 * does dump the file! */
817 DumpVnode(iodp, vnode, V_id(vp),
818 bitNumberToVnodeNumber(vnodeIndex, class), flag);
819 #ifndef AFS_PTHREAD_ENV
821 IOMGR_Poll(); /* if we dont' xfr data, but scan instead, could lose conn */
830 DumpDumpHeader(register struct iod *iodp, register Volume * vp,
834 int UseLatestReadOnlyClone = 1;
835 afs_int32 dumpTimes[2];
836 iodp->device = vp->device;
837 iodp->parentId = V_parentId(vp);
838 iodp->dumpPartition = vp->partition;
840 code = DumpDouble(iodp, D_DUMPHEADER, DUMPBEGINMAGIC, DUMPVERSION);
844 UseLatestReadOnlyClone ? V_id(vp) : V_parentId(vp));
846 code = DumpString(iodp, 'n', V_name(vp));
847 dumpTimes[0] = fromtime;
848 dumpTimes[1] = V_backupDate(vp); /* Until the time the clone was made */
850 code = DumpArrayInt32(iodp, 't', (afs_uint32 *) dumpTimes, 2);
855 DumpVnode(register struct iod *iodp, struct VnodeDiskObject *v, int volid,
856 int vnodeNumber, int dumpEverything)
862 if (!v || v->type == vNull)
865 code = DumpDouble(iodp, D_VNODE, vnodeNumber, v->uniquifier);
869 code = DumpByte(iodp, 't', (byte) v->type);
871 code = DumpShort(iodp, 'l', v->linkCount); /* May not need this */
873 code = DumpInt32(iodp, 'v', v->dataVersion);
875 code = DumpInt32(iodp, 'm', v->unixModifyTime);
877 code = DumpInt32(iodp, 'a', v->author);
879 code = DumpInt32(iodp, 'o', v->owner);
880 if (!code && v->group)
881 code = DumpInt32(iodp, 'g', v->group); /* default group is 0 */
883 code = DumpShort(iodp, 'b', v->modeBits);
885 code = DumpInt32(iodp, 'p', v->parent);
887 code = DumpInt32(iodp, 's', v->serverModifyTime);
888 if (v->type == vDirectory) {
889 acl_HtonACL(VVnodeDiskACL(v));
892 DumpByteString(iodp, 'A', (byte *) VVnodeDiskACL(v),
895 if (VNDISK_GET_INO(v)) {
896 IH_INIT(ihP, iodp->device, iodp->parentId, VNDISK_GET_INO(v));
899 Log("1 Volser: DumpVnode: dump: Unable to open inode %llu for vnode %u (volume %i); not dumped, error %d\n", (afs_uintmax_t) VNDISK_GET_INO(v), vnodeNumber, volid, errno);
901 return VOLSERREAD_DUMPERROR;
903 code = DumpFile(iodp, vnodeNumber, fdP);
912 ProcessIndex(Volume * vp, VnodeClass class, afs_int32 ** Bufp, int *sizep,
915 int i, nVnodes, offset, code;
919 StreamHandle_t *afile;
921 struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
922 char buf[SIZEOF_LARGEDISKVNODE], zero[SIZEOF_LARGEDISKVNODE];
923 register struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
925 memset(zero, 0, sizeof(zero)); /* zero out our proto-vnode */
926 fdP = IH_OPEN(vp->vnodeIndex[class].handle);
929 afile = FDH_FDOPEN(fdP, "r+");
933 for (i = 0; i < *sizep; i++) {
936 STREAM_SEEK(afile, Buf[i], 0);
937 code = STREAM_READ(vnode, vcp->diskSize, 1, afile);
939 if (vnode->type != vNull && VNDISK_GET_INO(vnode)) {
942 Log("RestoreVolume %u Cleanup: Removing old vnode=%u inode=%llu size=unknown\n",
943 V_id(vp), bitNumberToVnodeNumber(i, class),
944 (afs_uintmax_t) VNDISK_GET_INO(vnode));
946 IH_DEC(V_linkHandle(vp), VNDISK_GET_INO(vnode),
950 STREAM_SEEK(afile, Buf[i], 0);
951 (void)STREAM_WRITE(zero, vcp->diskSize, 1, afile); /* Zero it out */
957 Log("RestoreVolume Cleanup: Removed %d inodes for volume %d\n",
960 STREAM_FLUSH(afile); /* ensure 0s are on the disk */
961 OS_SYNC(afile->str_fd);
963 size = OS_SIZE(fdP->fd_fd);
967 vcp->diskSize ? 0 : size - vcp->diskSize) >> vcp->logSize;
970 Log("RestoreVolume ProcessIndex: Set up %d inodes for volume %d\n",
973 Buf = (afs_int32 *) malloc(nVnodes * sizeof(afs_int32));
979 memset((char *)Buf, 0, nVnodes * sizeof(afs_int32));
980 STREAM_SEEK(afile, offset = vcp->diskSize, 0);
982 code = STREAM_READ(vnode, vcp->diskSize, 1, afile);
986 if (vnode->type != vNull && VNDISK_GET_INO(vnode)) {
987 Buf[(offset >> vcp->logSize) - 1] = offset;
990 offset += vcp->diskSize;
993 Log("RestoreVolume ProcessIndex: found %d inodes\n", cnt);
1006 RestoreVolume(register struct rx_call *call, Volume * avp, int incremental,
1007 struct restoreCookie *cookie)
1010 struct DumpHeader header;
1011 afs_uint32 endMagic;
1012 Error error = 0, vupdate;
1013 register Volume *vp;
1015 register struct iod *iodp = &iod;
1016 afs_int32 *b1 = NULL, *b2 = NULL;
1017 int s1 = 0, s2 = 0, delo = 0, tdelo;
1020 iod_Init(iodp, call);
1024 if (!ReadDumpHeader(iodp, &header)) {
1025 Log("1 Volser: RestoreVolume: Error reading header file for dump; aborted\n");
1026 return VOLSERREAD_DUMPERROR;
1028 if (iod_getc(iodp) != D_VOLUMEHEADER) {
1029 Log("1 Volser: RestoreVolume: Volume header missing from dump; not restored\n");
1030 return VOLSERREAD_DUMPERROR;
1032 if (ReadVolumeHeader(iodp, &vol) == VOLSERREAD_DUMPERROR)
1033 return VOLSERREAD_DUMPERROR;
1036 delo = ProcessIndex(vp, vLarge, &b1, &s1, 0);
1038 delo = ProcessIndex(vp, vSmall, &b2, &s2, 0);
1040 Log("1 Volser: RestoreVolume: ProcessIndex failed; not restored\n");
1041 error = VOLSERREAD_DUMPERROR;
1045 strncpy(vol.name, cookie->name, VOLSER_OLDMAXVOLNAME);
1046 vol.type = cookie->type;
1047 vol.cloneId = cookie->clone;
1048 vol.parentId = cookie->parent;
1052 if (ReadVnodes(iodp, vp, 0, b1, s1, b2, s2, tdelo)) {
1053 error = VOLSERREAD_DUMPERROR;
1056 tag = iod_getc(iodp);
1057 if (tag != D_VOLUMEHEADER)
1060 if (ReadVolumeHeader(iodp, &vol) == VOLSERREAD_DUMPERROR) {
1061 error = VOLSERREAD_DUMPERROR;
1065 if (tag != D_DUMPEND || !ReadInt32(iodp, &endMagic)
1066 || endMagic != DUMPENDMAGIC) {
1067 Log("1 Volser: RestoreVolume: End of dump not found; restore aborted\n");
1068 error = VOLSERREAD_DUMPERROR;
1073 if (iod_getc(iodp) != EOF) {
1074 Log("1 Volser: RestoreVolume: Unrecognized postamble in dump; restore aborted\n");
1075 error = VOLSERREAD_DUMPERROR;
1080 delo = ProcessIndex(vp, vLarge, &b1, &s1, 1);
1082 delo = ProcessIndex(vp, vSmall, &b2, &s2, 1);
1084 error = VOLSERREAD_DUMPERROR;
1090 ClearVolumeStats(&vol);
1091 CopyVolumeHeader(&vol, &V_disk(vp));
1092 V_destroyMe(vp) = 0;
1093 VUpdateVolume(&vupdate, vp);
1095 Log("1 Volser: RestoreVolume: Unable to rewrite volume header; restore aborted\n");
1096 error = VOLSERREAD_DUMPERROR;
1100 /* Free the malloced space above */
1109 ReadVnodes(register struct iod *iodp, Volume * vp, int incremental,
1110 afs_int32 * Lbuf, afs_int32 s1, afs_int32 * Sbuf, afs_int32 s2,
1113 afs_int32 vnodeNumber;
1114 char buf[SIZEOF_LARGEDISKVNODE];
1116 struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
1117 struct VnodeDiskObject oldvnode;
1120 struct VnodeClassInfo *vcp;
1125 tag = iod_getc(iodp);
1126 V_pref(vp, nearInode);
1127 while (tag == D_VNODE) {
1129 memset(buf, 0, sizeof(buf));
1130 if (!ReadInt32(iodp, (afs_uint32 *) & vnodeNumber))
1133 if (!ReadInt32(iodp, &vnode->uniquifier))
1134 return VOLSERREAD_DUMPERROR;
1137 Log("ReadVnodes: setup %d/%d\n", vnodeNumber, vnode->uniquifier);
1139 while ((tag = iod_getc(iodp)) > D_MAX && tag != EOF) {
1143 vnode->type = (VnodeType) iod_getc(iodp);
1148 if (!ReadShort(iodp, &tlc))
1149 return VOLSERREAD_DUMPERROR;
1150 vnode->linkCount = (signed int)tlc;
1154 if (!ReadInt32(iodp, &vnode->dataVersion))
1155 return VOLSERREAD_DUMPERROR;
1158 if (!ReadInt32(iodp, &vnode->unixModifyTime))
1159 return VOLSERREAD_DUMPERROR;
1162 if (!ReadInt32(iodp, &vnode->serverModifyTime))
1163 return VOLSERREAD_DUMPERROR;
1166 if (!ReadInt32(iodp, &vnode->author))
1167 return VOLSERREAD_DUMPERROR;
1170 if (!ReadInt32(iodp, &vnode->owner))
1171 return VOLSERREAD_DUMPERROR;
1174 if (!ReadInt32(iodp, (afs_uint32 *) & vnode->group))
1175 return VOLSERREAD_DUMPERROR;
1178 unsigned short modeBits;
1179 if (!ReadShort(iodp, &modeBits))
1180 return VOLSERREAD_DUMPERROR;
1181 vnode->modeBits = (unsigned int)modeBits;
1185 if (!ReadInt32(iodp, &vnode->parent))
1186 return VOLSERREAD_DUMPERROR;
1189 ReadByteString(iodp, (byte *) VVnodeDiskACL(vnode),
1190 VAclDiskSize(vnode));
1191 acl_NtohACL(VVnodeDiskACL(vnode));
1193 #ifdef AFS_LARGEFILE_ENV
1199 afs_fsize_t vnodeLength;
1202 IH_CREATE(V_linkHandle(vp), V_device(vp),
1203 VPartitionPath(V_partition(vp)), nearInode,
1204 V_parentId(vp), vnodeNumber,
1205 vnode->uniquifier, vnode->dataVersion);
1206 if (!VALID_INO(ino)) {
1207 Log("1 Volser: ReadVnodes: IH_CREATE: %s - restore aborted\n",
1208 afs_error_message(errno));
1209 return VOLSERREAD_DUMPERROR;
1212 VNDISK_SET_INO(vnode, ino);
1213 IH_INIT(tmpH, vp->device, V_parentId(vp), ino);
1214 fdP = IH_OPEN(tmpH);
1216 Log("1 Volser: ReadVnodes: IH_OPEN: %s - restore aborted\n",
1217 afs_error_message(errno));
1219 return VOLSERREAD_DUMPERROR;
1222 volser_WriteFile(vnodeNumber, iodp, fdP, tag, &error);
1223 VNDISK_SET_LEN(vnode, vnodeLength);
1224 FDH_REALLYCLOSE(fdP);
1227 Log("1 Volser: ReadVnodes: IDEC inode %llu\n",
1228 (afs_uintmax_t) ino);
1229 IH_DEC(V_linkHandle(vp), ino, V_parentId(vp));
1230 return VOLSERREAD_DUMPERROR;
1237 class = vnodeIdToClass(vnodeNumber);
1238 vcp = &VnodeClassInfo[class];
1240 /* Mark this vnode as in this dump - so we don't delete it later */
1242 idx = (vnodeIndexOffset(vcp, vnodeNumber) >> vcp->logSize) - 1;
1243 if (class == vLarge) {
1244 if (Lbuf && (idx < s1))
1247 if (Sbuf && (idx < s2))
1253 FdHandle_t *fdP = IH_OPEN(vp->vnodeIndex[class].handle);
1255 Log("1 Volser: ReadVnodes: Error opening vnode index; restore aborted\n");
1256 return VOLSERREAD_DUMPERROR;
1258 if (FDH_SEEK(fdP, vnodeIndexOffset(vcp, vnodeNumber), SEEK_SET) <
1260 Log("1 Volser: ReadVnodes: Error seeking into vnode index; restore aborted\n");
1261 FDH_REALLYCLOSE(fdP);
1262 return VOLSERREAD_DUMPERROR;
1264 if (FDH_READ(fdP, &oldvnode, sizeof(oldvnode)) ==
1266 if (oldvnode.type != vNull && VNDISK_GET_INO(&oldvnode)) {
1267 IH_DEC(V_linkHandle(vp), VNDISK_GET_INO(&oldvnode),
1271 vnode->vnodeMagic = vcp->magic;
1272 if (FDH_SEEK(fdP, vnodeIndexOffset(vcp, vnodeNumber), SEEK_SET) <
1274 Log("1 Volser: ReadVnodes: Error seeking into vnode index; restore aborted\n");
1275 FDH_REALLYCLOSE(fdP);
1276 return VOLSERREAD_DUMPERROR;
1278 if (FDH_WRITE(fdP, vnode, vcp->diskSize) != vcp->diskSize) {
1279 Log("1 Volser: ReadVnodes: Error writing vnode index; restore aborted\n");
1280 FDH_REALLYCLOSE(fdP);
1281 return VOLSERREAD_DUMPERROR;
1286 iod_ungetc(iodp, tag);
1292 /* called with disk file only. Note that we don't have to worry about rx_Read
1293 * needing to read an ungetc'd character, since the ReadInt32 will have read
1297 volser_WriteFile(int vn, struct iod *iodp, FdHandle_t * handleP, int tag,
1302 afs_fsize_t filesize;
1303 afs_fsize_t written = 0;
1304 register afs_uint32 size = 8192;
1305 register afs_fsize_t nbytes;
1310 #ifdef AFS_64BIT_ENV
1312 afs_uint32 filesize_high = 0L, filesize_low = 0L;
1313 #ifdef AFS_LARGEFILE_ENV
1315 if (!ReadInt32(iodp, &filesize_high)) {
1320 #endif /* !AFS_LARGEFILE_ENV */
1321 if (!ReadInt32(iodp, &filesize_low)) {
1325 FillInt64(filesize, filesize_high, filesize_low);
1327 #else /* !AFS_64BIT_ENV */
1328 if (!ReadInt32(iodp, &filesize)) {
1332 #endif /* !AFS_64BIT_ENV */
1333 p = (unsigned char *)malloc(size);
1338 for (nbytes = filesize; nbytes; nbytes -= size) {
1342 if ((code = iod_Read(iodp, p, size)) != size) {
1343 Log("1 Volser: WriteFile: Error reading dump file %d size=%llu nbytes=%u (%d of %u); restore aborted\n", vn, (afs_uintmax_t) filesize, nbytes, code, size);
1347 lcode = FDH_WRITE(handleP, p, size);
1350 if (lcode != size) {
1351 Log("1 Volser: WriteFile: Error writing (%d,%u) bytes to vnode %d; restore aborted\n", (int)(lcode>>32), (int)(lcode & 0xffffffff), vn);
1361 ReadDumpHeader(register struct iod *iodp, struct DumpHeader *hp)
1364 afs_uint32 beginMagic;
1365 if (iod_getc(iodp) != D_DUMPHEADER || !ReadInt32(iodp, &beginMagic)
1366 || !ReadInt32(iodp, (afs_uint32 *) & hp->version)
1367 || beginMagic != DUMPBEGINMAGIC)
1371 while ((tag = iod_getc(iodp)) > D_MAX) {
1372 unsigned short arrayLength;
1376 if (!ReadInt32(iodp, &hp->volumeId))
1380 ReadString(iodp, hp->volumeName, sizeof(hp->volumeName));
1383 if (!ReadShort(iodp, &arrayLength))
1385 hp->nDumpTimes = (arrayLength >> 1);
1386 for (i = 0; i < hp->nDumpTimes; i++)
1387 if (!ReadInt32(iodp, (afs_uint32 *) & hp->dumpTimes[i].from)
1388 || !ReadInt32(iodp, (afs_uint32 *) & hp->dumpTimes[i].to))
1393 if (!hp->volumeId || !hp->nDumpTimes) {
1396 iod_ungetc(iodp, tag);
1401 /* ----- Below are the calls that calculate dump size ----- */
1404 SizeDumpVolumeHeader(register struct iod *iodp, register Volume * vp,
1405 register struct volintSize *v_size)
1408 static char nullString[1] = ""; /*The ``contents'' of motd */
1411 /* if (!code) code = DumpTag(iodp, D_VOLUMEHEADER); */
1412 FillInt64(addvar,0, 1);
1413 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1414 /* if (!code) {code = DumpInt32(iodp, 'i',V_id(vp));} */
1415 FillInt64(addvar,0, 5);
1416 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1417 /* if (!code) code = DumpInt32(iodp, 'v',V_stamp(vp).version); */
1418 FillInt64(addvar,0, 5);
1419 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1420 /* if (!code) code = DumpString(iodp, 'n',V_name(vp)); */
1421 FillInt64(addvar,0, (2 + strlen(V_name(vp))));
1422 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1423 /* if (!code) code = DumpBool(iodp, 's',V_inService(vp)); */
1424 FillInt64(addvar,0, 2);
1425 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1426 /* if (!code) code = DumpBool(iodp, 'b',V_blessed(vp)); */
1427 FillInt64(addvar,0, 2);
1428 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1429 /* if (!code) code = DumpInt32(iodp, 'u',V_uniquifier(vp)); */
1430 FillInt64(addvar,0, 5);
1431 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1432 /* if (!code) code = DumpByte(iodp, 't',(byte)V_type(vp)); */
1433 FillInt64(addvar,0, 2);
1434 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1435 /* if (!code){ code = DumpInt32(iodp, 'p',V_parentId(vp));} */
1436 FillInt64(addvar,0, 5);
1437 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1438 /* if (!code) code = DumpInt32(iodp, 'c',V_cloneId(vp)); */
1439 FillInt64(addvar,0, 5);
1440 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1441 /* if (!code) code = DumpInt32(iodp, 'q',V_maxquota(vp)); */
1442 FillInt64(addvar,0, 5);
1443 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1444 /* if (!code) code = DumpInt32(iodp, 'm',V_minquota(vp)); */
1445 FillInt64(addvar,0, 5);
1446 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1447 /* if (!code) code = DumpInt32(iodp, 'd',V_diskused(vp)); */
1448 FillInt64(addvar,0, 5);
1449 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1450 /* if (!code) code = DumpInt32(iodp, 'f',V_filecount(vp)); */
1451 FillInt64(addvar,0, 5);
1452 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1453 /* if (!code) code = DumpInt32(iodp, 'a', V_accountNumber(vp)); */
1454 FillInt64(addvar,0, 5);
1455 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1456 /* if (!code) code = DumpInt32(iodp, 'o', V_owner(vp)); */
1457 FillInt64(addvar,0, 5);
1458 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1459 /* if (!code) code = DumpInt32(iodp, 'C',V_creationDate(vp)); /\* Rw volume creation date *\/ */
1460 FillInt64(addvar,0, 5);
1461 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1462 /* if (!code) code = DumpInt32(iodp, 'A',V_accessDate(vp)); */
1463 FillInt64(addvar,0, 5);
1464 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1465 /* if (!code) code = DumpInt32(iodp, 'U',V_updateDate(vp)); */
1466 FillInt64(addvar,0, 5);
1467 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1468 /* if (!code) code = DumpInt32(iodp, 'E',V_expirationDate(vp)); */
1469 FillInt64(addvar,0, 5);
1470 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1471 /* if (!code) code = DumpInt32(iodp, 'B',V_backupDate(vp)); /\* Rw volume backup clone date *\/ */
1472 FillInt64(addvar,0, 5);
1473 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1474 /* if (!code) code = DumpString(iodp, 'O',V_offlineMessage(vp)); */
1475 FillInt64(addvar,0, (2 + strlen(V_offlineMessage(vp))));
1476 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1478 /* * We do NOT dump the detailed volume statistics residing in the old */
1479 /* * motd field, since we cannot tell from the info in a dump whether */
1480 /* * statistics data has been put there. Instead, we dump a null string, */
1481 /* * just as if that was what the motd contained. */
1483 /* if (!code) code = DumpString(iodp, 'M', nullString); */
1484 FillInt64(addvar,0, (2 + strlen(nullString)));
1485 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1486 /* if (!code) code = DumpArrayInt32(iodp, 'W', (afs_uint32 *)V_weekUse(vp), sizeof(V_weekUse(vp))/sizeof(V_weekUse(vp)[0])); */
1487 FillInt64(addvar,0, (3 + 4 * (sizeof(V_weekUse(vp)) / sizeof(V_weekUse(vp)[0]))));
1488 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1489 /* if (!code) code = DumpInt32(iodp, 'D', V_dayUseDate(vp)); */
1490 FillInt64(addvar,0, 5);
1491 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1492 /* if (!code) code = DumpInt32(iodp, 'Z', V_dayUse(vp)); */
1493 FillInt64(addvar,0, 5);
1494 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1499 SizeDumpEnd(register struct iod *iodp, register struct volintSize *v_size)
1503 FillInt64(addvar,0, 5);
1504 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1509 SizeDumpVolume(register struct rx_call *call, register Volume * vp,
1510 afs_int32 fromtime, int dumpAllDirs,
1511 register struct volintSize *v_size)
1514 register struct iod *iodp = (struct iod *)0;
1515 /* iod_Init(iodp, call); */
1518 code = SizeDumpDumpHeader(iodp, vp, fromtime, v_size);
1520 code = SizeDumpPartial(iodp, vp, fromtime, dumpAllDirs, v_size);
1522 code = SizeDumpEnd(iodp, v_size);
1528 SizeDumpDumpHeader(register struct iod *iodp, register Volume * vp,
1529 afs_int32 fromtime, register struct volintSize *v_size)
1532 /* int UseLatestReadOnlyClone = 1; */
1533 /* afs_int32 dumpTimes[2]; */
1535 /* iodp->device = vp->device; */
1536 /* iodp->parentId = V_parentId(vp); */
1537 /* iodp->dumpPartition = vp->partition; */
1539 ZeroInt64(v_size->dump_size); /* initialize the size */
1540 /* if (!code) code = DumpDouble(iodp, D_DUMPHEADER, DUMPBEGINMAGIC, DUMPVERSION); */
1541 FillInt64(addvar,0, 9);
1542 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1543 /* if (!code) code = DumpInt32(iodp, 'v', UseLatestReadOnlyClone? V_id(vp): V_parentId(vp)); */
1544 FillInt64(addvar,0, 5);
1545 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1546 /* if (!code) code = DumpString(iodp, 'n',V_name(vp)); */
1547 FillInt64(addvar,0, (2 + strlen(V_name(vp))));
1548 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1549 /* dumpTimes[0] = fromtime; */
1550 /* dumpTimes[1] = V_backupDate(vp); /\* Until the time the clone was made *\/ */
1551 /* if (!code) code = DumpArrayInt32(iodp, 't', (afs_uint32 *)dumpTimes, 2); */
1552 FillInt64(addvar,0, (3 + 4 * 2));
1553 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1558 SizeDumpVnode(register struct iod *iodp, struct VnodeDiskObject *v, int volid,
1559 int vnodeNumber, int dumpEverything,
1560 register struct volintSize *v_size)
1565 if (!v || v->type == vNull)
1567 /* if (!code) code = DumpDouble(iodp, D_VNODE, vnodeNumber, v->uniquifier); */
1568 FillInt64(addvar,0, 9);
1569 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1570 if (!dumpEverything)
1572 /* if (!code) code = DumpByte(iodp, 't',(byte)v->type); */
1573 FillInt64(addvar,0, 2);
1574 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1575 /* if (!code) code = DumpShort(iodp, 'l', v->linkCount); /\* May not need this *\/ */
1576 FillInt64(addvar,0, 3);
1577 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1578 /* if (!code) code = DumpInt32(iodp, 'v', v->dataVersion); */
1579 FillInt64(addvar,0, 5);
1580 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1581 /* if (!code) code = DumpInt32(iodp, 'm', v->unixModifyTime); */
1582 FillInt64(addvar,0, 5);
1583 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1584 /* if (!code) code = DumpInt32(iodp, 'a', v->author); */
1585 FillInt64(addvar,0, 5);
1586 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1587 /* if (!code) code = DumpInt32(iodp, 'o', v->owner); */
1588 FillInt64(addvar,0, 5);
1589 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1590 /* if (!code && v->group) code = DumpInt32(iodp, 'g', v->group); /\* default group is 0 *\/ */
1592 FillInt64(addvar,0, 5);
1593 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1595 /* if (!code) code = DumpShort(iodp, 'b', v->modeBits); */
1596 FillInt64(addvar,0, 3);
1597 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1598 /* if (!code) code = DumpInt32(iodp, 'p', v->parent); */
1599 FillInt64(addvar,0, 5);
1600 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1601 /* if (!code) code = DumpInt32(iodp, 's', v->serverModifyTime); */
1602 FillInt64(addvar,0, 5);
1603 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1604 if (v->type == vDirectory) {
1605 /* acl_HtonACL(VVnodeDiskACL(v)); */
1606 /* if (!code) code = DumpByteString(iodp, 'A', (byte *) VVnodeDiskACL(v), VAclDiskSize(v)); */
1607 FillInt64(addvar,0, (1 + VAclDiskSize(v)));
1608 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1611 if (VNDISK_GET_INO(v)) {
1612 FillInt64(addvar,0, (v->length + 5));
1613 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1618 /* A partial dump (no dump header) */
1620 SizeDumpPartial(register struct iod *iodp, register Volume * vp,
1621 afs_int32 fromtime, int dumpAllDirs,
1622 register struct volintSize *v_size)
1626 code = SizeDumpVolumeHeader(iodp, vp, v_size);
1629 SizeDumpVnodeIndex(iodp, vp, vLarge, fromtime, dumpAllDirs,
1632 code = SizeDumpVnodeIndex(iodp, vp, vSmall, fromtime, 0, v_size);
1637 SizeDumpVnodeIndex(register struct iod *iodp, Volume * vp, VnodeClass class,
1638 afs_int32 fromtime, int forcedump,
1639 register struct volintSize *v_size)
1641 register int code = 0;
1642 register struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
1643 char buf[SIZEOF_LARGEDISKVNODE];
1644 struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
1645 StreamHandle_t *file;
1649 register int vnodeIndex, nVnodes;
1651 fdP = IH_OPEN(vp->vnodeIndex[class].handle);
1652 assert(fdP != NULL);
1653 file = FDH_FDOPEN(fdP, "r+");
1654 assert(file != NULL);
1655 size = OS_SIZE(fdP->fd_fd);
1657 nVnodes = (size / vcp->diskSize) - 1;
1659 assert((nVnodes + 1) * vcp->diskSize == size);
1660 assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
1663 for (vnodeIndex = 0;
1664 nVnodes && STREAM_READ(vnode, vcp->diskSize, 1, file) == 1 && !code;
1665 nVnodes--, vnodeIndex++) {
1666 flag = forcedump || (vnode->serverModifyTime >= fromtime);
1667 /* Note: the >= test is very important since some old volumes may not have
1668 * a serverModifyTime. For an epoch dump, this results in 0>=0 test, which
1669 * does dump the file! */
1672 SizeDumpVnode(iodp, vnode, V_id(vp),
1673 bitNumberToVnodeNumber(vnodeIndex, class), flag,