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>
16 #include <sys/types.h>
23 #include <sys/param.h>
26 #include <netinet/in.h>
37 #ifdef AFS_PTHREAD_ENV
39 #else /* AFS_PTHREAD_ENV */
40 #include <afs/assert.h>
41 #endif /* AFS_PTHREAD_ENV */
44 #include <afs/afsint.h>
46 #include <afs/errors.h>
49 #include <afs/ihandle.h>
50 #include <afs/vnode.h>
51 #include <afs/volume.h>
52 #include <afs/partition.h>
54 #include <afs/fssync.h>
61 #define afs_stat stat64
62 #define afs_fstat fstat64
63 #else /* !O_LARGEFILE */
65 #define afs_fstat fstat
66 #endif /* !O_LARGEFILE */
67 #endif /* !AFS_NT40_ENV */
69 /*@printflike@*/ extern void Log(const char *format, ...);
73 /* This iod stuff is a silly little package to emulate the old qi_in stuff, which
74 emulated the stdio stuff. There is a big assumption here, that the
75 rx_Read will never be called directly, by a routine like readFile, when
76 there is an old character that was pushed back with iod_ungetc. This
77 is really bletchy, and is here for compatibility only. Eventually,
78 we should define a volume format that doesn't require
79 the pushing back of characters (i.e. characters should not double both
80 as an end marker and a begin marker) */
82 struct rx_call *call; /* call to which to write, might be an array */
83 int device; /* dump device ID for volume */
84 int parentId; /* dump parent ID for volume */
85 struct DiskPartition *dumpPartition; /* Dump partition. */
86 struct rx_call **calls; /* array of pointers to calls */
87 int ncalls; /* how many calls/codes in array */
88 int *codes; /* one return code for each call */
89 char haveOldChar; /* state for pushing back a character */
94 /* Forward Declarations */
95 static int DumpDumpHeader(register struct iod *iodp, register Volume * vp,
97 static int DumpPartial(register struct iod *iodp, register Volume * vp,
98 afs_int32 fromtime, int dumpAllDirs);
99 static int DumpVnodeIndex(register struct iod *iodp, Volume * vp,
100 VnodeClass class, afs_int32 fromtime,
102 static int DumpVnode(register struct iod *iodp, struct VnodeDiskObject *v,
103 int volid, int vnodeNumber, int dumpEverything);
104 static int ReadDumpHeader(register struct iod *iodp, struct DumpHeader *hp);
105 static int ReadVnodes(register struct iod *iodp, Volume * vp, int incremental,
106 afs_int32 * Lbuf, afs_int32 s1, afs_int32 * Sbuf,
107 afs_int32 s2, afs_int32 delo);
108 static afs_fsize_t volser_WriteFile(int vn, struct iod *iodp,
109 FdHandle_t * handleP, int tag,
112 static int SizeDumpDumpHeader(register struct iod *iodp, register Volume * vp,
114 register struct volintSize *size);
115 static int SizeDumpPartial(register struct iod *iodp, register Volume * vp,
116 afs_int32 fromtime, int dumpAllDirs,
117 register struct volintSize *size);
118 static int SizeDumpVnodeIndex(register struct iod *iodp, Volume * vp,
119 VnodeClass class, afs_int32 fromtime,
121 register struct volintSize *size);
122 static int SizeDumpVnode(register struct iod *iodp, struct VnodeDiskObject *v,
123 int volid, int vnodeNumber, int dumpEverything,
124 register struct volintSize *size);
127 iod_Init(register struct iod *iodp, register struct rx_call *call)
130 iodp->haveOldChar = 0;
132 iodp->calls = (struct rx_call **)0;
136 iod_InitMulti(struct iod *iodp, struct rx_call **calls, int ncalls,
141 iodp->haveOldChar = 0;
142 iodp->ncalls = ncalls;
144 iodp->call = (struct rx_call *)0;
147 /* N.B. iod_Read doesn't check for oldchar (see previous comment) */
148 #define iod_Read(iodp, buf, nbytes) rx_Read((iodp)->call, buf, nbytes)
150 /* For the single dump case, it's ok to just return the "bytes written"
151 * that rx_Write returns, since all the callers of iod_Write abort when
152 * the returned value is less than they expect. For the multi dump case,
153 * I don't think we want half the replicas to go bad just because one
154 * connection timed out, but if they all time out, then we should give up.
157 iod_Write(struct iod *iodp, char *buf, int nbytes)
162 assert((iodp->call && iodp->ncalls == 1 && !iodp->calls)
163 || (!iodp->call && iodp->ncalls >= 1 && iodp->calls));
166 code = rx_Write(iodp->call, buf, nbytes);
170 for (i = 0; i < iodp->ncalls; i++) {
171 if (iodp->calls[i] && !iodp->codes[i]) {
172 code = rx_Write(iodp->calls[i], buf, nbytes);
173 if (code != nbytes) { /* everything gets merged into a single error */
174 iodp->codes[i] = VOLSERDUMPERROR; /* but that's exactly what the */
175 } /* standard dump does, anyways */
180 } /* for all calls */
189 iod_ungetc(struct iod *iodp, int achar)
191 iodp->oldChar = achar;
192 iodp->haveOldChar = 1;
196 iod_getc(register struct iod *iodp)
200 if (iodp->haveOldChar) {
201 iodp->haveOldChar = 0;
202 return iodp->oldChar;
204 if (iod_Read(iodp, &t, 1) == 1)
210 ReadShort(register struct iod *iodp, register unsigned short *sp)
215 *sp = (b1 << 8) | b0;
220 ReadInt32(register struct iod *iodp, afs_uint32 * lp)
222 afs_uint32 register b3, b2, b1, b0;
227 *lp = (((((b3 << 8) | b2) << 8) | b1) << 8) | b0;
232 ReadString(register struct iod *iodp, register char *to, register int maxa)
236 if ((*to++ = iod_getc(iodp)) == 0)
240 while ((c = iod_getc(iodp)) && c != EOF);
246 ReadByteString(register struct iod *iodp, register byte * to,
250 *to++ = iod_getc(iodp);
254 ReadVolumeHeader(register struct iod *iodp, VolumeDiskData * vol)
258 memset(vol, 0, sizeof(*vol));
259 while ((tag = iod_getc(iodp)) > D_MAX && tag != EOF) {
262 if (!ReadInt32(iodp, &vol->id))
263 return VOLSERREAD_DUMPERROR;
266 if (!ReadInt32(iodp, &trash))
267 return VOLSERREAD_DUMPERROR;
270 ReadString(iodp, vol->name, sizeof(vol->name));
271 /*this means the name of the retsored volume could be possibly different. In conjunction with SAFSVolSignalRestore */
274 vol->inService = iod_getc(iodp);
277 vol->blessed = iod_getc(iodp);
280 if (!ReadInt32(iodp, &vol->uniquifier))
281 return VOLSERREAD_DUMPERROR;
284 vol->type = iod_getc(iodp);
287 if (!ReadInt32(iodp, &vol->parentId))
288 return VOLSERREAD_DUMPERROR;
291 if (!ReadInt32(iodp, &vol->cloneId))
292 return VOLSERREAD_DUMPERROR;
295 if (!ReadInt32(iodp, (afs_uint32 *) & vol->maxquota))
296 return VOLSERREAD_DUMPERROR;
299 if (!ReadInt32(iodp, (afs_uint32 *) & vol->minquota))
300 return VOLSERREAD_DUMPERROR;
303 if (!ReadInt32(iodp, (afs_uint32 *) & vol->diskused))
304 return VOLSERREAD_DUMPERROR; /* Bogus: should calculate this */
307 if (!ReadInt32(iodp, (afs_uint32 *) & vol->filecount))
308 return VOLSERREAD_DUMPERROR;
311 if (!ReadInt32(iodp, &vol->accountNumber))
312 return VOLSERREAD_DUMPERROR;
315 if (!ReadInt32(iodp, &vol->owner))
316 return VOLSERREAD_DUMPERROR;
319 if (!ReadInt32(iodp, &vol->creationDate))
320 return VOLSERREAD_DUMPERROR;
323 if (!ReadInt32(iodp, &vol->accessDate))
324 return VOLSERREAD_DUMPERROR;
327 if (!ReadInt32(iodp, &vol->updateDate))
328 return VOLSERREAD_DUMPERROR;
331 if (!ReadInt32(iodp, &vol->expirationDate))
332 return VOLSERREAD_DUMPERROR;
335 if (!ReadInt32(iodp, &vol->backupDate))
336 return VOLSERREAD_DUMPERROR;
339 ReadString(iodp, vol->offlineMessage,
340 sizeof(vol->offlineMessage));
344 * Detailed volume statistics are never stored in dumps,
345 * so we just restore either the null string if this volume
346 * had already been set to store statistics, or the old motd
347 * contents otherwise. It doesn't matter, since this field
348 * will soon get initialized anyway.
350 ReadString(iodp, (char *)(vol->stat_reads), VMSGSIZE);
353 unsigned short length;
356 if (!ReadShort(iodp, &length))
357 return VOLSERREAD_DUMPERROR;
358 for (i = 0; i < length; i++) {
359 if (!ReadInt32(iodp, &data))
360 return VOLSERREAD_DUMPERROR;
361 if (i < sizeof(vol->weekUse) / sizeof(vol->weekUse[0]))
362 vol->weekUse[i] = data;
367 if (!ReadInt32(iodp, &vol->dayUseDate))
368 return VOLSERREAD_DUMPERROR;
371 if (!ReadInt32(iodp, (afs_uint32 *) & vol->dayUse))
372 return VOLSERREAD_DUMPERROR;
375 if (!ReadInt32(iodp, (afs_uint32 *) & vol->volUpdateCounter))
376 return VOLSERREAD_DUMPERROR;
380 iod_ungetc(iodp, tag);
385 DumpTag(register struct iod *iodp, register int tag)
390 return ((iod_Write(iodp, &p, 1) == 1) ? 0 : VOLSERDUMPERROR);
395 DumpByte(register struct iod *iodp, char tag, byte value)
398 register byte *p = (unsigned char *)tbuffer;
401 return ((iod_Write(iodp, tbuffer, 2) == 2) ? 0 : VOLSERDUMPERROR);
404 #define putint32(p, v) *p++ = v>>24, *p++ = v>>16, *p++ = v>>8, *p++ = v
405 #define putshort(p, v) *p++ = v>>8, *p++ = v
408 DumpDouble(register struct iod *iodp, char tag, register afs_uint32 value1,
409 register afs_uint32 value2)
412 register byte *p = (unsigned char *)tbuffer;
416 return ((iod_Write(iodp, tbuffer, 9) == 9) ? 0 : VOLSERDUMPERROR);
420 DumpInt32(register struct iod *iodp, char tag, register afs_uint32 value)
423 register byte *p = (unsigned char *)tbuffer;
426 return ((iod_Write(iodp, tbuffer, 5) == 5) ? 0 : VOLSERDUMPERROR);
430 DumpArrayInt32(register struct iod *iodp, char tag,
431 register afs_uint32 * array, register int nelem)
434 register afs_uint32 v;
436 register byte *p = (unsigned char *)tbuffer;
439 code = iod_Write(iodp, tbuffer, 3);
441 return VOLSERDUMPERROR;
443 p = (unsigned char *)tbuffer;
444 v = *array++; /*this was register */
447 code = iod_Write(iodp, tbuffer, 4);
449 return VOLSERDUMPERROR;
455 DumpShort(register struct iod *iodp, char tag, unsigned int value)
458 register byte *p = (unsigned char *)tbuffer;
462 return ((iod_Write(iodp, tbuffer, 3) == 3) ? 0 : VOLSERDUMPERROR);
466 DumpBool(register struct iod *iodp, char tag, unsigned int value)
469 register byte *p = (unsigned char *)tbuffer;
472 return ((iod_Write(iodp, tbuffer, 2) == 2) ? 0 : VOLSERDUMPERROR);
476 DumpString(register struct iod *iodp, char tag, register char *s)
480 code = iod_Write(iodp, &tag, 1);
482 return VOLSERDUMPERROR;
484 code = iod_Write(iodp, s, n);
486 return VOLSERDUMPERROR;
491 DumpByteString(register struct iod *iodp, char tag, register byte * bs,
496 code = iod_Write(iodp, &tag, 1);
498 return VOLSERDUMPERROR;
499 code = iod_Write(iodp, (char *)bs, nbytes);
501 return VOLSERDUMPERROR;
506 DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP)
508 int code = 0, lcode = 0, error = 0;
509 afs_int32 pad = 0, offset;
510 afs_sfsize_t n, nbytes, howMany, howBig;
513 struct afs_stat status;
517 #include <sys/statfs.h>
518 struct statfs tstatfs;
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 fstatfs(handleP->fd_fd, &tstatfs);
534 howMany = tstatfs.f_bsize;
536 howMany = status.st_blksize;
537 #endif /* AFS_AIX_ENV */
538 #endif /* AFS_NT40_ENV */
541 size = FDH_SIZE(handleP);
542 #ifdef AFS_LARGEFILE_ENV
545 SplitInt64(size, hi, lo);
547 code = DumpInt32(iodp, 'f', lo);
549 code = DumpDouble(iodp, 'h', hi, lo);
552 #else /* !AFS_LARGEFILE_ENV */
553 code = DumpInt32(iodp, 'f', size);
554 #endif /* !AFS_LARGEFILE_ENV */
556 return VOLSERDUMPERROR;
559 p = (unsigned char *)malloc(howMany);
561 Log("1 Volser: DumpFile: no memory");
562 return VOLSERDUMPERROR;
565 for (nbytes = size; (nbytes && !error); nbytes -= howMany) {
566 if (nbytes < howMany)
569 /* Read the data - unless we know we can't */
570 n = (lcode ? 0 : FDH_READ(handleP, p, howMany));
572 /* If read any good data and we null padded previously, log the
573 * amount that we had null padded.
575 if ((n > 0) && pad) {
576 Log("1 Volser: DumpFile: Null padding file %d bytes at offset %u\n", pad, offset);
580 /* If didn't read enough data, null padd the rest of the buffer. This
581 * can happen if, for instance, the media has some bad spots. We don't
582 * want to quit the dump, so we start null padding.
585 /* Record the read error */
588 Log("1 Volser: DumpFile: Error %d reading inode %s for vnode %d\n", errno, PrintInode(NULL, handleP->fd_ih->ih_ino), vnode);
590 Log("1 Volser: DumpFile: Error reading inode %s for vnode %d\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode);
593 /* Pad the rest of the buffer with zeros. Remember offset we started
594 * padding. Keep total tally of padding.
596 memset(p + n, 0, howMany - n);
598 offset = (howBig - nbytes) + n;
599 pad += (howMany - n);
601 /* Now seek over the data we could not get. An error here means we
602 * can't do the next read.
604 lcode = FDH_SEEK(handleP, ((size - nbytes) + howMany), SEEK_SET);
605 if (lcode != ((size - nbytes) + howMany)) {
607 Log("1 Volser: DumpFile: Error %d seeking in inode %s for vnode %d\n", errno, PrintInode(NULL, handleP->fd_ih->ih_ino), vnode);
609 Log("1 Volser: DumpFile: Error seeking in inode %s for vnode %d\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode);
617 /* Now write the data out */
618 if (iod_Write(iodp, (char *)p, howMany) != howMany)
619 error = VOLSERDUMPERROR;
620 #ifndef AFS_PTHREAD_ENV
625 if (pad) { /* Any padding we hadn't reported yet */
626 Log("1 Volser: DumpFile: Null padding file: %d bytes at offset %u\n",
635 DumpVolumeHeader(register struct iod *iodp, register Volume * vp)
638 static char nullString[1] = ""; /*The ``contents'' of motd */
641 code = DumpTag(iodp, D_VOLUMEHEADER);
643 code = DumpInt32(iodp, 'i', V_id(vp));
646 code = DumpInt32(iodp, 'v', V_stamp(vp).version);
648 code = DumpString(iodp, 'n', V_name(vp));
650 code = DumpBool(iodp, 's', V_inService(vp));
652 code = DumpBool(iodp, 'b', V_blessed(vp));
654 code = DumpInt32(iodp, 'u', V_uniquifier(vp));
656 code = DumpByte(iodp, 't', (byte) V_type(vp));
658 code = DumpInt32(iodp, 'p', V_parentId(vp));
661 code = DumpInt32(iodp, 'c', V_cloneId(vp));
663 code = DumpInt32(iodp, 'q', V_maxquota(vp));
665 code = DumpInt32(iodp, 'm', V_minquota(vp));
667 code = DumpInt32(iodp, 'd', V_diskused(vp));
669 code = DumpInt32(iodp, 'f', V_filecount(vp));
671 code = DumpInt32(iodp, 'a', V_accountNumber(vp));
673 code = DumpInt32(iodp, 'o', V_owner(vp));
675 code = DumpInt32(iodp, 'C', V_creationDate(vp)); /* Rw volume creation date */
677 code = DumpInt32(iodp, 'A', V_accessDate(vp));
679 code = DumpInt32(iodp, 'U', V_updateDate(vp));
681 code = DumpInt32(iodp, 'E', V_expirationDate(vp));
683 code = DumpInt32(iodp, 'B', V_backupDate(vp)); /* Rw volume backup clone date */
685 code = DumpString(iodp, 'O', V_offlineMessage(vp));
687 * We do NOT dump the detailed volume statistics residing in the old
688 * motd field, since we cannot tell from the info in a dump whether
689 * statistics data has been put there. Instead, we dump a null string,
690 * just as if that was what the motd contained.
693 code = DumpString(iodp, 'M', nullString);
696 DumpArrayInt32(iodp, 'W', (afs_uint32 *) V_weekUse(vp),
697 sizeof(V_weekUse(vp)) / sizeof(V_weekUse(vp)[0]));
699 code = DumpInt32(iodp, 'D', V_dayUseDate(vp));
701 code = DumpInt32(iodp, 'Z', V_dayUse(vp));
703 code = DumpInt32(iodp, 'V', V_volUpCounter(vp));
708 DumpEnd(register struct iod *iodp)
710 return (DumpInt32(iodp, D_DUMPEND, DUMPENDMAGIC));
713 /* Guts of the dump code */
715 /* Dump a whole volume */
717 DumpVolume(register struct rx_call *call, register Volume * vp,
718 afs_int32 fromtime, int dumpAllDirs)
722 register struct iod *iodp = &iod;
723 iod_Init(iodp, call);
726 code = DumpDumpHeader(iodp, vp, fromtime);
729 code = DumpPartial(iodp, vp, fromtime, dumpAllDirs);
731 /* hack follows. Errors should be handled quite differently in this version of dump than they used to be.*/
732 if (rx_Error(iodp->call)) {
733 Log("1 Volser: DumpVolume: Rx call failed during dump, error %d\n",
734 rx_Error(iodp->call));
735 return VOLSERDUMPERROR;
738 code = DumpEnd(iodp);
743 /* Dump a volume to multiple places*/
745 DumpVolMulti(struct rx_call **calls, int ncalls, Volume * vp,
746 afs_int32 fromtime, int dumpAllDirs, int *codes)
750 iod_InitMulti(&iod, calls, ncalls, codes);
753 code = DumpDumpHeader(&iod, vp, fromtime);
755 code = DumpPartial(&iod, vp, fromtime, dumpAllDirs);
757 code = DumpEnd(&iod);
761 /* A partial dump (no dump header) */
763 DumpPartial(register struct iod *iodp, register Volume * vp,
764 afs_int32 fromtime, int dumpAllDirs)
768 code = DumpVolumeHeader(iodp, vp);
770 code = DumpVnodeIndex(iodp, vp, vLarge, fromtime, dumpAllDirs);
772 code = DumpVnodeIndex(iodp, vp, vSmall, fromtime, 0);
777 DumpVnodeIndex(register struct iod *iodp, Volume * vp, VnodeClass class,
778 afs_int32 fromtime, int forcedump)
780 register int code = 0;
781 register struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
782 char buf[SIZEOF_LARGEDISKVNODE];
783 struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
784 StreamHandle_t *file;
788 register int vnodeIndex, nVnodes;
790 fdP = IH_OPEN(vp->vnodeIndex[class].handle);
792 file = FDH_FDOPEN(fdP, "r+");
793 assert(file != NULL);
794 size = OS_SIZE(fdP->fd_fd);
796 nVnodes = (size / vcp->diskSize) - 1;
798 assert((nVnodes + 1) * vcp->diskSize == size);
799 assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
803 nVnodes && STREAM_READ(vnode, vcp->diskSize, 1, file) == 1 && !code;
804 nVnodes--, vnodeIndex++) {
805 flag = forcedump || (vnode->serverModifyTime >= fromtime);
806 /* Note: the >= test is very important since some old volumes may not have
807 * a serverModifyTime. For an epoch dump, this results in 0>=0 test, which
808 * does dump the file! */
811 DumpVnode(iodp, vnode, V_id(vp),
812 bitNumberToVnodeNumber(vnodeIndex, class), flag);
813 #ifndef AFS_PTHREAD_ENV
815 IOMGR_Poll(); /* if we dont' xfr data, but scan instead, could lose conn */
824 DumpDumpHeader(register struct iod *iodp, register Volume * vp,
828 int UseLatestReadOnlyClone = 1;
829 afs_int32 dumpTimes[2];
830 iodp->device = vp->device;
831 iodp->parentId = V_parentId(vp);
832 iodp->dumpPartition = vp->partition;
834 code = DumpDouble(iodp, D_DUMPHEADER, DUMPBEGINMAGIC, DUMPVERSION);
838 UseLatestReadOnlyClone ? V_id(vp) : V_parentId(vp));
840 code = DumpString(iodp, 'n', V_name(vp));
841 dumpTimes[0] = fromtime;
842 dumpTimes[1] = V_backupDate(vp); /* Until the time the clone was made */
844 code = DumpArrayInt32(iodp, 't', (afs_uint32 *) dumpTimes, 2);
849 DumpVnode(register struct iod *iodp, struct VnodeDiskObject *v, int volid,
850 int vnodeNumber, int dumpEverything)
856 if (!v || v->type == vNull)
859 code = DumpDouble(iodp, D_VNODE, vnodeNumber, v->uniquifier);
863 code = DumpByte(iodp, 't', (byte) v->type);
865 code = DumpShort(iodp, 'l', v->linkCount); /* May not need this */
867 code = DumpInt32(iodp, 'v', v->dataVersion);
869 code = DumpInt32(iodp, 'm', v->unixModifyTime);
871 code = DumpInt32(iodp, 'a', v->author);
873 code = DumpInt32(iodp, 'o', v->owner);
874 if (!code && v->group)
875 code = DumpInt32(iodp, 'g', v->group); /* default group is 0 */
877 code = DumpShort(iodp, 'b', v->modeBits);
879 code = DumpInt32(iodp, 'p', v->parent);
881 code = DumpInt32(iodp, 's', v->serverModifyTime);
882 if (v->type == vDirectory) {
883 acl_HtonACL(VVnodeDiskACL(v));
886 DumpByteString(iodp, 'A', (byte *) VVnodeDiskACL(v),
889 if (VNDISK_GET_INO(v)) {
890 IH_INIT(ihP, iodp->device, iodp->parentId, VNDISK_GET_INO(v));
893 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);
895 return VOLSERREAD_DUMPERROR;
897 code = DumpFile(iodp, vnodeNumber, fdP);
906 ProcessIndex(Volume * vp, VnodeClass class, afs_int32 ** Bufp, int *sizep,
909 int i, nVnodes, offset, code, index = 0;
913 StreamHandle_t *afile;
915 struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
916 char buf[SIZEOF_LARGEDISKVNODE], zero[SIZEOF_LARGEDISKVNODE];
917 register struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
919 memset(zero, 0, sizeof(zero)); /* zero out our proto-vnode */
920 fdP = IH_OPEN(vp->vnodeIndex[class].handle);
923 afile = FDH_FDOPEN(fdP, "r+");
927 for (i = 0; i < *sizep; i++) {
930 STREAM_SEEK(afile, Buf[i], 0);
931 code = STREAM_READ(vnode, vcp->diskSize, 1, afile);
933 if (vnode->type != vNull && VNDISK_GET_INO(vnode)) {
936 Log("RestoreVolume %u Cleanup: Removing old vnode=%u inode=%llu size=unknown\n",
937 V_id(vp), bitNumberToVnodeNumber(i, class),
938 (afs_uintmax_t) VNDISK_GET_INO(vnode));
940 IH_DEC(V_linkHandle(vp), VNDISK_GET_INO(vnode),
944 STREAM_SEEK(afile, Buf[i], 0);
945 (void)STREAM_WRITE(zero, vcp->diskSize, 1, afile); /* Zero it out */
951 Log("RestoreVolume Cleanup: Removed %d inodes for volume %d\n",
954 STREAM_FLUSH(afile); /* ensure 0s are on the disk */
955 OS_SYNC(afile->str_fd);
957 size = OS_SIZE(fdP->fd_fd);
961 vcp->diskSize ? 0 : size - vcp->diskSize) >> vcp->logSize;
963 Buf = (afs_int32 *) malloc(nVnodes * sizeof(afs_int32));
966 memset((char *)Buf, 0, nVnodes * sizeof(afs_int32));
967 STREAM_SEEK(afile, offset = vcp->diskSize, 0);
969 code = STREAM_READ(vnode, vcp->diskSize, 1, afile);
973 if (vnode->type != vNull && VNDISK_GET_INO(vnode)) {
974 Buf[(offset >> vcp->logSize) - 1] = offset;
977 offset += vcp->diskSize;
990 RestoreVolume(register struct rx_call *call, Volume * avp, int incremental,
991 struct restoreCookie *cookie)
994 struct DumpHeader header;
996 Error error = 0, vupdate;
999 register struct iod *iodp = &iod;
1000 afs_int32 *b1 = 0, *b2 = 0;
1001 int s1 = 0, s2 = 0, delo = 0, tdelo;
1004 iod_Init(iodp, call);
1007 if (!ReadDumpHeader(iodp, &header)) {
1008 Log("1 Volser: RestoreVolume: Error reading header file for dump; aborted\n");
1009 return VOLSERREAD_DUMPERROR;
1011 if (iod_getc(iodp) != D_VOLUMEHEADER) {
1012 Log("1 Volser: RestoreVolume: Volume header missing from dump; not restored\n");
1013 return VOLSERREAD_DUMPERROR;
1015 if (ReadVolumeHeader(iodp, &vol) == VOLSERREAD_DUMPERROR)
1016 return VOLSERREAD_DUMPERROR;
1018 delo = ProcessIndex(vp, vLarge, &b1, &s1, 0);
1020 delo = ProcessIndex(vp, vSmall, &b2, &s2, 0);
1029 strncpy(vol.name, cookie->name, VOLSER_OLDMAXVOLNAME);
1030 vol.type = cookie->type;
1031 vol.cloneId = cookie->clone;
1032 vol.parentId = cookie->parent;
1037 if (ReadVnodes(iodp, vp, 0, b1, s1, b2, s2, tdelo)) {
1038 error = VOLSERREAD_DUMPERROR;
1041 tag = iod_getc(iodp);
1042 if (tag != D_VOLUMEHEADER)
1044 if (ReadVolumeHeader(iodp, &vol) == VOLSERREAD_DUMPERROR) {
1045 error = VOLSERREAD_DUMPERROR;
1050 if (tag != D_DUMPEND || !ReadInt32(iodp, &endMagic)
1051 || endMagic != DUMPENDMAGIC) {
1052 Log("1 Volser: RestoreVolume: End of dump not found; restore aborted\n");
1053 error = VOLSERREAD_DUMPERROR;
1058 if (iod_getc(iodp) != EOF) {
1059 Log("1 Volser: RestoreVolume: Unrecognized postamble in dump; restore aborted\n");
1060 error = VOLSERREAD_DUMPERROR;
1065 ProcessIndex(vp, vLarge, &b1, &s1, 1);
1066 ProcessIndex(vp, vSmall, &b2, &s2, 1);
1070 ClearVolumeStats(&vol);
1071 CopyVolumeHeader(&vol, &V_disk(vp));
1072 V_destroyMe(vp) = 0;
1073 VUpdateVolume(&vupdate, vp);
1075 Log("1 Volser: RestoreVolume: Unable to rewrite volume header; restore aborted\n");
1076 error = VOLSERREAD_DUMPERROR;
1080 /* Free the malloced space above */
1089 ReadVnodes(register struct iod *iodp, Volume * vp, int incremental,
1090 afs_int32 * Lbuf, afs_int32 s1, afs_int32 * Sbuf, afs_int32 s2,
1093 afs_int32 vnodeNumber;
1094 char buf[SIZEOF_LARGEDISKVNODE];
1096 struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
1097 struct VnodeDiskObject oldvnode;
1100 struct VnodeClassInfo *vcp;
1105 tag = iod_getc(iodp);
1106 V_pref(vp, nearInode);
1107 while (tag == D_VNODE) {
1109 memset(buf, 0, sizeof(buf));
1110 if (!ReadInt32(iodp, (afs_uint32 *) & vnodeNumber))
1113 ReadInt32(iodp, &vnode->uniquifier);
1114 while ((tag = iod_getc(iodp)) > D_MAX && tag != EOF) {
1118 vnode->type = (VnodeType) iod_getc(iodp);
1123 ReadShort(iodp, &tlc);
1124 vnode->linkCount = (signed int)tlc;
1128 ReadInt32(iodp, &vnode->dataVersion);
1131 ReadInt32(iodp, &vnode->unixModifyTime);
1134 ReadInt32(iodp, &vnode->serverModifyTime);
1137 ReadInt32(iodp, &vnode->author);
1140 ReadInt32(iodp, &vnode->owner);
1143 ReadInt32(iodp, (afs_uint32 *) & vnode->group);
1146 unsigned short modeBits;
1147 ReadShort(iodp, &modeBits);
1148 vnode->modeBits = (unsigned int)modeBits;
1152 ReadInt32(iodp, &vnode->parent);
1155 ReadByteString(iodp, (byte *) VVnodeDiskACL(vnode),
1156 VAclDiskSize(vnode));
1157 acl_NtohACL(VVnodeDiskACL(vnode));
1159 #ifdef AFS_LARGEFILE_ENV
1165 afs_fsize_t vnodeLength;
1168 IH_CREATE(V_linkHandle(vp), V_device(vp),
1169 VPartitionPath(V_partition(vp)), nearInode,
1170 V_parentId(vp), vnodeNumber,
1171 vnode->uniquifier, vnode->dataVersion);
1172 if (!VALID_INO(ino)) {
1173 perror("unable to allocate inode");
1174 Log("1 Volser: ReadVnodes: Restore aborted\n");
1175 return VOLSERREAD_DUMPERROR;
1178 VNDISK_SET_INO(vnode, ino);
1179 IH_INIT(tmpH, vp->device, V_parentId(vp), ino);
1180 fdP = IH_OPEN(tmpH);
1183 return VOLSERREAD_DUMPERROR;
1186 volser_WriteFile(vnodeNumber, iodp, fdP, tag, &error);
1187 VNDISK_SET_LEN(vnode, vnodeLength);
1188 FDH_REALLYCLOSE(fdP);
1191 Log("1 Volser: ReadVnodes: IDEC inode %llu\n",
1192 (afs_uintmax_t) ino);
1193 IH_DEC(V_linkHandle(vp), ino, V_parentId(vp));
1194 return VOLSERREAD_DUMPERROR;
1201 class = vnodeIdToClass(vnodeNumber);
1202 vcp = &VnodeClassInfo[class];
1204 /* Mark this vnode as in this dump - so we don't delete it later */
1206 idx = (vnodeIndexOffset(vcp, vnodeNumber) >> vcp->logSize) - 1;
1207 if (class == vLarge) {
1208 if (Lbuf && (idx < s1))
1211 if (Sbuf && (idx < s2))
1217 FdHandle_t *fdP = IH_OPEN(vp->vnodeIndex[class].handle);
1219 Log("1 Volser: ReadVnodes: Error opening vnode index; restore aborted\n");
1220 return VOLSERREAD_DUMPERROR;
1222 if (FDH_SEEK(fdP, vnodeIndexOffset(vcp, vnodeNumber), SEEK_SET) <
1224 Log("1 Volser: ReadVnodes: Error seeking into vnode index; restore aborted\n");
1225 FDH_REALLYCLOSE(fdP);
1226 return VOLSERREAD_DUMPERROR;
1228 if (FDH_READ(fdP, &oldvnode, sizeof(oldvnode)) ==
1230 if (oldvnode.type != vNull && VNDISK_GET_INO(&oldvnode)) {
1231 IH_DEC(V_linkHandle(vp), VNDISK_GET_INO(&oldvnode),
1235 vnode->vnodeMagic = vcp->magic;
1236 if (FDH_SEEK(fdP, vnodeIndexOffset(vcp, vnodeNumber), SEEK_SET) <
1238 Log("1 Volser: ReadVnodes: Error seeking into vnode index; restore aborted\n");
1239 FDH_REALLYCLOSE(fdP);
1240 return VOLSERREAD_DUMPERROR;
1242 if (FDH_WRITE(fdP, vnode, vcp->diskSize) != vcp->diskSize) {
1243 Log("1 Volser: ReadVnodes: Error writing vnode index; restore aborted\n");
1244 FDH_REALLYCLOSE(fdP);
1245 return VOLSERREAD_DUMPERROR;
1250 iod_ungetc(iodp, tag);
1257 /* called with disk file only. Note that we don't have to worry about rx_Read
1258 * needing to read an ungetc'd character, since the ReadInt32 will have read
1262 volser_WriteFile(int vn, struct iod *iodp, FdHandle_t * handleP, int tag,
1266 afs_fsize_t filesize;
1267 afs_fsize_t written = 0;
1268 register afs_uint32 size = 8192;
1269 register afs_fsize_t nbytes;
1274 #ifdef AFS_64BIT_ENV
1276 afs_uint32 filesize_high = 0L, filesize_low = 0L;
1277 #ifdef AFS_LARGEFILE_ENV
1279 if (!ReadInt32(iodp, &filesize_high)) {
1284 #endif /* !AFS_LARGEFILE_ENV */
1285 if (!ReadInt32(iodp, &filesize_low)) {
1289 FillInt64(filesize, filesize_high, filesize_low);
1291 #else /* !AFS_64BIT_ENV */
1292 if (!ReadInt32(iodp, &filesize)) {
1296 #endif /* !AFS_64BIT_ENV */
1297 p = (unsigned char *)malloc(size);
1302 for (nbytes = filesize; nbytes; nbytes -= size) {
1306 if ((code = iod_Read(iodp, p, size)) != size) {
1307 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);
1311 code = FDH_WRITE(handleP, p, size);
1315 Log("1 Volser: WriteFile: Error creating file in volume; restore aborted\n");
1325 ReadDumpHeader(register struct iod *iodp, struct DumpHeader *hp)
1328 afs_uint32 beginMagic;
1329 if (iod_getc(iodp) != D_DUMPHEADER || !ReadInt32(iodp, &beginMagic)
1330 || !ReadInt32(iodp, (afs_uint32 *) & hp->version)
1331 || beginMagic != DUMPBEGINMAGIC)
1335 while ((tag = iod_getc(iodp)) > D_MAX) {
1336 unsigned short arrayLength;
1340 if (!ReadInt32(iodp, &hp->volumeId))
1344 ReadString(iodp, hp->volumeName, sizeof(hp->volumeName));
1347 if (!ReadShort(iodp, &arrayLength))
1349 hp->nDumpTimes = (arrayLength >> 1);
1350 for (i = 0; i < hp->nDumpTimes; i++)
1351 if (!ReadInt32(iodp, (afs_uint32 *) & hp->dumpTimes[i].from)
1352 || !ReadInt32(iodp, (afs_uint32 *) & hp->dumpTimes[i].to))
1357 if (!hp->volumeId || !hp->nDumpTimes) {
1360 iod_ungetc(iodp, tag);
1365 /* ----- Below are the calls that calculate dump size ----- */
1368 SizeDumpVolumeHeader(register struct iod *iodp, register Volume * vp,
1369 register struct volintSize *v_size)
1372 static char nullString[1] = ""; /*The ``contents'' of motd */
1375 /* if (!code) code = DumpTag(iodp, D_VOLUMEHEADER); */
1376 FillInt64(addvar,0, 1);
1377 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1378 /* if (!code) {code = DumpInt32(iodp, 'i',V_id(vp));} */
1379 FillInt64(addvar,0, 5);
1380 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1381 /* if (!code) code = DumpInt32(iodp, 'v',V_stamp(vp).version); */
1382 FillInt64(addvar,0, 5);
1383 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1384 /* if (!code) code = DumpString(iodp, 'n',V_name(vp)); */
1385 FillInt64(addvar,0, (2 + strlen(V_name(vp))));
1386 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1387 /* if (!code) code = DumpBool(iodp, 's',V_inService(vp)); */
1388 FillInt64(addvar,0, 2);
1389 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1390 /* if (!code) code = DumpBool(iodp, 'b',V_blessed(vp)); */
1391 FillInt64(addvar,0, 2);
1392 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1393 /* if (!code) code = DumpInt32(iodp, 'u',V_uniquifier(vp)); */
1394 FillInt64(addvar,0, 5);
1395 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1396 /* if (!code) code = DumpByte(iodp, 't',(byte)V_type(vp)); */
1397 FillInt64(addvar,0, 2);
1398 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1399 /* if (!code){ code = DumpInt32(iodp, 'p',V_parentId(vp));} */
1400 FillInt64(addvar,0, 5);
1401 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1402 /* if (!code) code = DumpInt32(iodp, 'c',V_cloneId(vp)); */
1403 FillInt64(addvar,0, 5);
1404 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1405 /* if (!code) code = DumpInt32(iodp, 'q',V_maxquota(vp)); */
1406 FillInt64(addvar,0, 5);
1407 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1408 /* if (!code) code = DumpInt32(iodp, 'm',V_minquota(vp)); */
1409 FillInt64(addvar,0, 5);
1410 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1411 /* if (!code) code = DumpInt32(iodp, 'd',V_diskused(vp)); */
1412 FillInt64(addvar,0, 5);
1413 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1414 /* if (!code) code = DumpInt32(iodp, 'f',V_filecount(vp)); */
1415 FillInt64(addvar,0, 5);
1416 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1417 /* if (!code) code = DumpInt32(iodp, 'a', V_accountNumber(vp)); */
1418 FillInt64(addvar,0, 5);
1419 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1420 /* if (!code) code = DumpInt32(iodp, 'o', V_owner(vp)); */
1421 FillInt64(addvar,0, 5);
1422 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1423 /* if (!code) code = DumpInt32(iodp, 'C',V_creationDate(vp)); /\* Rw volume creation date *\/ */
1424 FillInt64(addvar,0, 5);
1425 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1426 /* if (!code) code = DumpInt32(iodp, 'A',V_accessDate(vp)); */
1427 FillInt64(addvar,0, 5);
1428 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1429 /* if (!code) code = DumpInt32(iodp, 'U',V_updateDate(vp)); */
1430 FillInt64(addvar,0, 5);
1431 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1432 /* if (!code) code = DumpInt32(iodp, 'E',V_expirationDate(vp)); */
1433 FillInt64(addvar,0, 5);
1434 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1435 /* if (!code) code = DumpInt32(iodp, 'B',V_backupDate(vp)); /\* Rw volume backup clone date *\/ */
1436 FillInt64(addvar,0, 5);
1437 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1438 /* if (!code) code = DumpString(iodp, 'O',V_offlineMessage(vp)); */
1439 FillInt64(addvar,0, (2 + strlen(V_offlineMessage(vp))));
1440 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1442 /* * We do NOT dump the detailed volume statistics residing in the old */
1443 /* * motd field, since we cannot tell from the info in a dump whether */
1444 /* * statistics data has been put there. Instead, we dump a null string, */
1445 /* * just as if that was what the motd contained. */
1447 /* if (!code) code = DumpString(iodp, 'M', nullString); */
1448 FillInt64(addvar,0, (2 + strlen(nullString)));
1449 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1450 /* if (!code) code = DumpArrayInt32(iodp, 'W', (afs_uint32 *)V_weekUse(vp), sizeof(V_weekUse(vp))/sizeof(V_weekUse(vp)[0])); */
1451 FillInt64(addvar,0, (3 + 4 * (sizeof(V_weekUse(vp)) / sizeof(V_weekUse(vp)[0]))));
1452 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1453 /* if (!code) code = DumpInt32(iodp, 'D', V_dayUseDate(vp)); */
1454 FillInt64(addvar,0, 5);
1455 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1456 /* if (!code) code = DumpInt32(iodp, 'Z', V_dayUse(vp)); */
1457 FillInt64(addvar,0, 5);
1458 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1459 /* if (!code) code = DumpInt32(iodp, 'V', V_volUpCounter(vp)); */
1460 FillInt64(addvar,0, 5);
1461 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1466 SizeDumpEnd(register struct iod *iodp, register struct volintSize *v_size)
1470 FillInt64(addvar,0, 5);
1471 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1476 SizeDumpVolume(register struct rx_call *call, register Volume * vp,
1477 afs_int32 fromtime, int dumpAllDirs,
1478 register struct volintSize *v_size)
1481 register struct iod *iodp = (struct iod *)0;
1482 /* iod_Init(iodp, call); */
1485 code = SizeDumpDumpHeader(iodp, vp, fromtime, v_size);
1487 code = SizeDumpPartial(iodp, vp, fromtime, dumpAllDirs, v_size);
1489 code = SizeDumpEnd(iodp, v_size);
1495 SizeDumpDumpHeader(register struct iod *iodp, register Volume * vp,
1496 afs_int32 fromtime, register struct volintSize *v_size)
1499 int UseLatestReadOnlyClone = 1;
1500 /* afs_int32 dumpTimes[2]; */
1502 /* iodp->device = vp->device; */
1503 /* iodp->parentId = V_parentId(vp); */
1504 /* iodp->dumpPartition = vp->partition; */
1506 ZeroInt64(v_size->dump_size); /* initialize the size */
1507 /* if (!code) code = DumpDouble(iodp, D_DUMPHEADER, DUMPBEGINMAGIC, DUMPVERSION); */
1508 FillInt64(addvar,0, 9);
1509 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1510 /* if (!code) code = DumpInt32(iodp, 'v', UseLatestReadOnlyClone? V_id(vp): V_parentId(vp)); */
1511 FillInt64(addvar,0, 5);
1512 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1513 /* if (!code) code = DumpString(iodp, 'n',V_name(vp)); */
1514 FillInt64(addvar,0, (2 + strlen(V_name(vp))));
1515 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1516 /* dumpTimes[0] = fromtime; */
1517 /* dumpTimes[1] = V_backupDate(vp); /\* Until the time the clone was made *\/ */
1518 /* if (!code) code = DumpArrayInt32(iodp, 't', (afs_uint32 *)dumpTimes, 2); */
1519 FillInt64(addvar,0, (3 + 4 * 2));
1520 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1525 SizeDumpVnode(register struct iod *iodp, struct VnodeDiskObject *v, int volid,
1526 int vnodeNumber, int dumpEverything,
1527 register struct volintSize *v_size)
1532 if (!v || v->type == vNull)
1534 /* if (!code) code = DumpDouble(iodp, D_VNODE, vnodeNumber, v->uniquifier); */
1535 FillInt64(addvar,0, 9);
1536 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1537 if (!dumpEverything)
1539 /* if (!code) code = DumpByte(iodp, 't',(byte)v->type); */
1540 FillInt64(addvar,0, 2);
1541 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1542 /* if (!code) code = DumpShort(iodp, 'l', v->linkCount); /\* May not need this *\/ */
1543 FillInt64(addvar,0, 3);
1544 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1545 /* if (!code) code = DumpInt32(iodp, 'v', v->dataVersion); */
1546 FillInt64(addvar,0, 5);
1547 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1548 /* if (!code) code = DumpInt32(iodp, 'm', v->unixModifyTime); */
1549 FillInt64(addvar,0, 5);
1550 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1551 /* if (!code) code = DumpInt32(iodp, 'a', v->author); */
1552 FillInt64(addvar,0, 5);
1553 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1554 /* if (!code) code = DumpInt32(iodp, 'o', v->owner); */
1555 FillInt64(addvar,0, 5);
1556 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1557 /* if (!code && v->group) code = DumpInt32(iodp, 'g', v->group); /\* default group is 0 *\/ */
1559 FillInt64(addvar,0, 5);
1560 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1562 /* if (!code) code = DumpShort(iodp, 'b', v->modeBits); */
1563 FillInt64(addvar,0, 3);
1564 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1565 /* if (!code) code = DumpInt32(iodp, 'p', v->parent); */
1566 FillInt64(addvar,0, 5);
1567 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1568 /* if (!code) code = DumpInt32(iodp, 's', v->serverModifyTime); */
1569 FillInt64(addvar,0, 5);
1570 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1571 if (v->type == vDirectory) {
1572 /* acl_HtonACL(VVnodeDiskACL(v)); */
1573 /* if (!code) code = DumpByteString(iodp, 'A', (byte *) VVnodeDiskACL(v), VAclDiskSize(v)); */
1574 FillInt64(addvar,0, (1 + VAclDiskSize(v)));
1575 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1578 if (VNDISK_GET_INO(v)) {
1579 FillInt64(addvar,0, (v->length + 5));
1580 AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
1585 /* A partial dump (no dump header) */
1587 SizeDumpPartial(register struct iod *iodp, register Volume * vp,
1588 afs_int32 fromtime, int dumpAllDirs,
1589 register struct volintSize *v_size)
1593 code = SizeDumpVolumeHeader(iodp, vp, v_size);
1596 SizeDumpVnodeIndex(iodp, vp, vLarge, fromtime, dumpAllDirs,
1599 code = SizeDumpVnodeIndex(iodp, vp, vSmall, fromtime, 0, v_size);
1604 SizeDumpVnodeIndex(register struct iod *iodp, Volume * vp, VnodeClass class,
1605 afs_int32 fromtime, int forcedump,
1606 register struct volintSize *v_size)
1608 register int code = 0;
1609 register struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
1610 char buf[SIZEOF_LARGEDISKVNODE];
1611 struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
1612 StreamHandle_t *file;
1616 register int vnodeIndex, nVnodes;
1618 fdP = IH_OPEN(vp->vnodeIndex[class].handle);
1619 assert(fdP != NULL);
1620 file = FDH_FDOPEN(fdP, "r+");
1621 assert(file != NULL);
1622 size = OS_SIZE(fdP->fd_fd);
1624 nVnodes = (size / vcp->diskSize) - 1;
1626 assert((nVnodes + 1) * vcp->diskSize == size);
1627 assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
1630 for (vnodeIndex = 0;
1631 nVnodes && STREAM_READ(vnode, vcp->diskSize, 1, file) == 1 && !code;
1632 nVnodes--, vnodeIndex++) {
1633 flag = forcedump || (vnode->serverModifyTime >= fromtime);
1634 /* Note: the >= test is very important since some old volumes may not have
1635 * a serverModifyTime. For an epoch dump, this results in 0>=0 test, which
1636 * does dump the file! */
1639 SizeDumpVnode(iodp, vnode, V_id(vp),
1640 bitNumberToVnodeNumber(vnodeIndex, class), flag,