# pragma GCC diagnostic warning "-Wformat"
#endif
+#include <roken.h>
+
#include <ctype.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef AFS_NT40_ENV
-#include <fcntl.h>
-#include <time.h>
-#include <io.h>
-#else
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#endif
-#include <afs/cmd.h>
+#include <afs/cmd.h>
#include <rx/xdr.h>
#include <afs/afsint.h>
#include <afs/nfs.h>
#include <afs/dir.h>
#include <afs/com_err.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef _AIX
-#include <time.h>
-#endif
-
-#include <dirent.h>
-
#include "volser.h"
#include "volint.h"
#include "dump.h"
-#define putint32(p, v) *p++ = v>>24, *p++ = v>>16, *p++ = v>>8, *p++ = v
-#define putshort(p, v) *p++ = v>>8, *p++ = v
-
-#ifdef O_LARGEFILE
-#define afs_stat stat64
-#define afs_fstat fstat64
-#define afs_open open64
-#else /* !O_LARGEFILE */
-#define afs_stat stat
-#define afs_fstat fstat
-#define afs_open open
-#endif /* !O_LARGEFILE */
+#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
int VolumeChanged; /* needed by physio - leave alone */
int verbose = 0;
/* Forward Declarations */
-void HandleVolume(struct DiskPartition64 *partP, char *name, char *filename, int fromtime);
-Volume *AttachVolume(struct DiskPartition64 *dp, char *volname,
- struct VolumeHeader *header);
+static void HandleVolume(struct DiskPartition64 *partP, char *name,
+ char *filename, int fromtime);
+static Volume *AttachVolume(struct DiskPartition64 *dp, char *volname,
+ struct VolumeHeader *header);
static void DoMyVolDump(Volume * vp, struct DiskPartition64 *dp,
char *dumpfile, int fromtime);
char name[VMAXPATHLEN];
-int
+static int
ReadHdr1(IHandle_t * ih, char *to, int size, u_int magic, u_int version)
{
int code;
}
-Volume *
+static Volume *
AttachVolume(struct DiskPartition64 * dp, char *volname,
struct VolumeHeader * header)
{
vp->shuttingDown = 0;
vp->goingOffline = 0;
vp->nUsers = 1;
- vp->header = (struct volHeader *)calloc(1, sizeof(*vp->header));
+ vp->header = calloc(1, sizeof(*vp->header));
ec = ReadHdr1(V_diskDataHandle(vp), (char *)&V_disk(vp),
sizeof(V_disk(vp)), VOLUMEINFOMAGIC, VOLUMEINFOVERSION);
if (!ec) {
exit(1);
}
- (void)afs_snprintf(name1, sizeof name1, VFORMAT, (unsigned long)volumeId);
+ snprintf(name1, sizeof name1, VFORMAT, (unsigned long)volumeId);
HandleVolume(partP, name1, fileName, fromtime);
return 0;
}
-void
+static void
HandleVolume(struct DiskPartition64 *dp, char *name, char *filename, int fromtime)
{
struct VolumeHeader header;
afs_int32 n;
- (void)afs_snprintf(headerName, sizeof headerName, "%s" OS_DIRSEP "%s",
- VPartitionPath(dp), name);
+ snprintf(headerName, sizeof headerName, "%s" OS_DIRSEP "%s",
+ VPartitionPath(dp), name);
if ((fd = afs_open(headerName, O_RDONLY)) == -1
|| afs_fstat(fd, &status) == -1) {
fprintf(stderr, "Cannot read volume header %s\n", name);
}
DoMyVolDump(vp, dp, filename, fromtime);
+
+ free(vp);
}
char tbuffer[9];
byte *p = (unsigned char *)tbuffer;
*p++ = tag;
- putint32(p, value1);
- putint32(p, value2);
+ afs_putint32(p, value1);
+ afs_putint32(p, value2);
res = write(dumpfd, tbuffer, 9);
return ((res == 9) ? 0 : VOLSERDUMPERROR);
char tbuffer[5];
byte *p = (unsigned char *)tbuffer;
*p++ = tag;
- putint32(p, value);
+ afs_putint32(p, value);
return ((write(dumpfd, tbuffer, 5) == 5) ? 0 : VOLSERDUMPERROR);
}
int code = 0;
byte *p = (unsigned char *)tbuffer;
*p++ = tag;
- putshort(p, nelem);
+ afs_putshort(p, nelem);
code = write(dumpfd, tbuffer, 3);
if (code != 3)
return VOLSERDUMPERROR;
p = (unsigned char *)tbuffer;
v = *array++; /*this was register */
- putint32(p, v);
+ afs_putint32(p, v);
code = write(dumpfd, 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
fprintf(stderr, "dumping file for vnode %d\n", vnode);
#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