#include <roken.h>
-#include <sys/types.h>
#include <ctype.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#ifdef AFS_NT40_ENV
-#include <fcntl.h>
-#else
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/uio.h>
-#include <netinet/in.h>
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-#include <afs/afs_assert.h>
+
#include <rx/xdr.h>
#include <rx/rx.h>
#include <afs/afsint.h>
#include <afs/vnode.h>
#include <afs/volume.h>
#include <afs/partition.h>
-#include "dump.h"
#include <afs/daemon_com.h>
#include <afs/fssync.h>
#include <afs/acl.h>
#include <afs/com_err.h>
#include <afs/vol_prototypes.h>
+
+#include "dump.h"
#include "volser.h"
#include "volint.h"
#include "dumpstuff.h"
return ((iod_Write(iodp, tbuffer, 2) == 2) ? 0 : VOLSERDUMPERROR);
}
-#define putint32(p, v) *p++ = v>>24, *p++ = v>>16, *p++ = v>>8, *p++ = v
-#define putshort(p, v) *p++ = v>>8, *p++ = v
+#define afs_putint32(p, v) *p++ = v>>24, *p++ = v>>16, *p++ = v>>8, *p++ = v
+#define afs_putshort(p, v) *p++ = v>>8, *p++ = v
static int
DumpDouble(struct iod *iodp, char tag, afs_uint32 value1,
char tbuffer[9];
byte *p = (unsigned char *)tbuffer;
*p++ = tag;
- putint32(p, value1);
- putint32(p, value2);
+ afs_putint32(p, value1);
+ afs_putint32(p, value2);
return ((iod_Write(iodp, tbuffer, 9) == 9) ? 0 : VOLSERDUMPERROR);
}
char tbuffer[5];
byte *p = (unsigned char *)tbuffer;
*p++ = tag;
- putint32(p, value);
+ afs_putint32(p, value);
return ((iod_Write(iodp, tbuffer, 5) == 5) ? 0 : VOLSERDUMPERROR);
}
int code = 0;
byte *p = (unsigned char *)tbuffer;
*p++ = tag;
- putshort(p, nelem);
+ afs_putshort(p, nelem);
code = iod_Write(iodp, tbuffer, 3);
if (code != 3)
return VOLSERDUMPERROR;
p = (unsigned char *)tbuffer;
v = *array++; /*this was register */
- putint32(p, v);
+ afs_putint32(p, v);
code = iod_Write(iodp, tbuffer, 4);
if (code != 4)
return VOLSERDUMPERROR;
afs_ino_str_t stmp;
#ifndef AFS_NT40_ENV
struct afs_stat status;
+#else
+ LARGE_INTEGER fileSize;
#endif
- afs_sfsize_t size;
#ifdef AFS_AIX_ENV
#include <sys/statfs.h>
#if defined(AFS_AIX52_ENV)
#endif
#ifdef AFS_NT40_ENV
- howBig = _filelength(handleP->fd_fd);
+ if (!GetFileSizeEx(handleP->fd_fd, &fileSize)) {
+ Log("DumpFile: GetFileSizeEx returned error code %d on descriptor %d\n", GetLastError(), handleP->fd_fd);
+ return VOLSERDUMPERROR;
+ }
+ howBig = fileSize.QuadPart;
howMany = 4096;
#else
#endif /* AFS_NT40_ENV */
- size = FDH_SIZE(handleP);
- SplitInt64(size, hi, lo);
+ SplitInt64(howBig, hi, lo);
if (hi == 0L) {
code = DumpInt32(iodp, 'f', lo);
} else {
return VOLSERDUMPERROR;
}
- for (nbytes = size; (nbytes && !error); nbytes -= howMany) {
+ for (nbytes = howBig; (nbytes && !error); nbytes -= howMany) {
if (nbytes < howMany)
howMany = nbytes;
/* Now seek over the data we could not get. An error here means we
* can't do the next read.
*/
- howFar = (size_t)((size - nbytes) + howMany);
+ howFar = (size_t)((howBig - nbytes) + howMany);
}
/* Now write the data out */
(size <=
vcp->diskSize ? 0 : size - vcp->diskSize) >> vcp->logSize;
if (nVnodes > 0) {
- if (DoLogging) {
- Log("RestoreVolume ProcessIndex: Set up %d inodes for volume %d\n",
- nVnodes, V_id(vp));
- }
Buf = malloc(nVnodes * sizeof(afs_foff_t));
if (Buf == NULL) {
STREAM_CLOSE(afile);
}
offset += vcp->diskSize;
}
- if (DoLogging) {
- Log("RestoreVolume ProcessIndex: found %d inodes\n", cnt);
- }
*Bufp = Buf;
*sizep = nVnodes;
}
vol.cloneId = cookie->clone;
vol.parentId = cookie->parent;
+ V_needsSalvaged(vp) = 0;
+
tdelo = delo;
while (1) {
if (ReadVnodes(iodp, vp, 0, b1, s1, b2, s2, tdelo)) {
clean:
ClearVolumeStats(&vol);
+ if (V_needsSalvaged(vp)) {
+ /* needsSalvaged may have been set while we tried to write volume data.
+ * prevent it from getting overwritten. */
+ vol.needsSalvaged = V_needsSalvaged(vp);
+ }
CopyVolumeHeader(&vol, &V_disk(vp));
V_destroyMe(vp) = 0;
VUpdateVolume(&vupdate, vp);
struct VnodeClassInfo *vcp;
IHandle_t *tmpH;
FdHandle_t *fdP;
- Inode nearInode;
+ Inode nearInode AFS_UNUSED;
afs_int32 critical = 0;
tag = iod_getc(iodp);
if (!ReadInt32(iodp, &vnode->uniquifier))
return VOLSERREAD_DUMPERROR;
- if (DoLogging) {
- Log("ReadVnodes: setup %d/%d\n", vnodeNumber, vnode->uniquifier);
- }
while ((tag = iod_getc(iodp)) > D_MAX && tag != EOF) {
haveStuff = 1;
if (critical)
if (!VALID_INO(ino)) {
Log("1 Volser: ReadVnodes: IH_CREATE: %s - restore aborted\n",
afs_error_message(errno));
+ V_needsSalvaged(vp) = 1;
return VOLSERREAD_DUMPERROR;
}
nearInode = ino;
Log("1 Volser: ReadVnodes: IH_OPEN: %s - restore aborted\n",
afs_error_message(errno));
IH_RELEASE(tmpH);
+ V_needsSalvaged(vp) = 1;
return VOLSERREAD_DUMPERROR;
}
vnodeLength =
Log("1 Volser: ReadVnodes: IDEC inode %llu\n",
(afs_uintmax_t) ino);
IH_DEC(V_linkHandle(vp), ino, V_parentId(vp));
+ V_needsSalvaged(vp) = 1;
return VOLSERREAD_DUMPERROR;
}
break;
if (fdP == NULL) {
Log("1 Volser: ReadVnodes: Error opening vnode index: %s; restore aborted\n",
afs_error_message(errno));
+ V_needsSalvaged(vp) = 1;
return VOLSERREAD_DUMPERROR;
}
if (FDH_PREAD(fdP, &oldvnode, sizeof(oldvnode), vnodeIndexOffset(vcp, vnodeNumber)) ==
Log("1 Volser: ReadVnodes: Error writing vnode index: %s; restore aborted\n",
afs_error_message(errno));
FDH_REALLYCLOSE(fdP);
+ V_needsSalvaged(vp) = 1;
return VOLSERREAD_DUMPERROR;
}
FDH_CLOSE(fdP);