-$Id: CHANGES,v 1.112 2001/04/12 13:14:14 stelian Exp $
+$Id: CHANGES,v 1.113 2001/04/27 15:22:47 stelian Exp $
Changes between versions 0.4b21 and 0.4b22 (released ????????????????)
======================================================================
3 file descriptors per dump process (and there is one dump
process per tape).
+11. Fixed dump large file system support, by explicit use of
+ open64/lseek64/etc functions (explicit use needed because
+ e2fsprogs libraries don't behave well when compiled with
+ FILE_OFFSET_BITS=64).
+
Changes between versions 0.4b20 and 0.4b21 (released January 13, 2001)
======================================================================
--- /dev/null
+/*
+ * Ported to Linux's Second Extended File System as part of the
+ * dump and restore backup suit
+ * Stelian Pop <pop@noos.fr> - AlcĂ´ve <www.alcove.fr>, 2000
+ *
+ * $Id: compatlfs.h,v 1.1 2001/04/27 15:22:47 stelian Exp $
+ */
+
+/*-
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _COMPATLFS_H_
+#define _COMPATLFS_H_
+
+#include <config.h>
+
+#ifdef USE_LFS
+
+#define _LARGEFILE64_SOURCE
+#define OPEN open64
+#define LSEEK lseek64
+#define STAT stat64
+#define LSTAT lstat64
+#define FTRUNCATE ftruncate64
+
+#else
+
+#define OPEN open
+#define LSEEK lseek
+#define STAT stat
+#define LSTAT lstat
+#define FTRUNCATE ftruncate
+
+#endif /* USE_LFS */
+
+#endif /* !_COMPATLFS_H_ */
*/
#include <config.h>
+#include <compatlfs.h>
#include <stdio.h>
#include <sys/param.h>
#include <string.h>
int fd;
struct ext2_super_block e2sb;
- fd = open(device, O_RDONLY);
+ fd = OPEN(device, O_RDONLY);
if (fd < 0)
return 1;
- if (lseek(fd, EXT2_SUPER_OFFSET, SEEK_SET) != EXT2_SUPER_OFFSET ||
+ if (LSEEK(fd, EXT2_SUPER_OFFSET, SEEK_SET) != EXT2_SUPER_OFFSET ||
read(fd, (char *) &e2sb, EXT2_SUPER_SIZE) != EXT2_SUPER_SIZE ||
ext2magic(e2sb) != EXT2_SUPER_MAGIC) {
close(fd);
/* Define this is you want old style F script (no arguments) */
#undef OLD_STYLE_FSCRIPT
-/* Define this to 64 if you want Large File System support */
-#undef _FILE_OFFSET_BITS
+/* Define this if you want Large File System support */
+#undef USE_LFS
/* Define this if you have zlib compression library */
#undef HAVE_ZLIB
if test "$enableval" = "yes"
then
cat >> confdefs.h <<\EOF
-#define _FILE_OFFSET_BITS 64
+#define USE_LFS 1
EOF
fi
[ --enable-largefile enable Large File System support (your glibc needs to support it)],
if test "$enableval" = "yes"
then
- AC_DEFINE(_FILE_OFFSET_BITS,64)
+ AC_DEFINE(USE_LFS)
fi
,
echo "Not enabling Large File System support"
%define _sbindir /sbin
# XXX --enable-kerberos needs krcmd
-%define myoptions --with-binmode=6755 --with-manowner=root --with-mangrp=root --with-manmode=0644 --with-dumpdates="%{_sysconfdir}/dumpdates" --enable-readline
+%define myoptions --with-binmode=6755 --with-manowner=root --with-mangrp=root --with-manmode=0644 --with-dumpdates="%{_sysconfdir}/dumpdates" --enable-readline --enable-largefile
Summary: Programs for backing up and restoring filesystems.
Name: dump
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.47 2001/04/27 12:23:23 stelian Exp $";
+ "$Id: main.c,v 1.48 2001/04/27 15:22:47 stelian Exp $";
#endif /* not lint */
#include <config.h>
+#include <compatlfs.h>
#include <ctype.h>
#include <compaterr.h>
#include <fcntl.h>
register int ch;
int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1;
dump_ino_t maxino;
- struct stat statbuf;
+ struct STAT statbuf;
dev_t filedev = 0;
#ifdef __linux__
errcode_t retval;
msg("The ENTIRE dump is aborted.\n");
exit(X_STARTUP);
}
- if ((diskfd = open(disk, O_RDONLY)) < 0) {
+ if ((diskfd = OPEN(disk, O_RDONLY)) < 0) {
msg("Cannot open %s\n", disk);
msg("The ENTIRE dump is aborted.\n");
exit(X_STARTUP);
nonodump = spcl.c_level < honorlevel;
- if (!sizeest) {
+ if (!sizest) {
msg("Label: %s\n", spcl.c_label);
if (compressed)
if (directory[0] == 0)
anydirskipped = mapfiles(maxino, &tapesize);
else {
- if (stat(pathname, &statbuf) == -1) {
+ if (STAT(pathname, &statbuf) == -1) {
msg("File cannot be accessed (%s).\n", pathname);
msg("The ENTIRE dump is aborted.\n");
exit(X_STARTUP);
int anydirskipped2;
char *p = *argv;
/* check if file is available */
- if (stat(p, &statbuf) == -1) {
+ if (STAT(p, &statbuf) == -1) {
msg("File cannot be accessed (%s).\n", p);
msg("The ENTIRE dump is aborted.\n");
exit(X_STARTUP);
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.44 2001/04/24 10:59:12 stelian Exp $";
+ "$Id: tape.c,v 1.45 2001/04/27 15:22:47 stelian Exp $";
#endif /* not lint */
#include <config.h>
+#include <compatlfs.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.h>
#endif
{
(void) close(tapefd);
- while ((f = open(tape, 0)) < 0)
+ while ((f = OPEN(tape, 0)) < 0)
sleep (10);
(void) close(f);
}
#ifdef RDUMP
while ((tapefd = (host ? rmtopen(tape, 2) : pipeout ?
fileno(stdout) :
- open(tape, O_WRONLY|O_CREAT, 0666))) < 0)
+ OPEN(tape, O_WRONLY|O_CREAT, 0666))) < 0)
#else
while ((tapefd = (pipeout ? fileno(stdout) :
- open(tape, O_RDWR|O_CREAT, 0666))) < 0)
+ OPEN(tape, O_RDWR|O_CREAT, 0666))) < 0)
#endif
{
msg("Cannot open output \"%s\".\n", tape);
* Need our own seek pointer.
*/
(void) close(diskfd);
- if ((diskfd = open(disk, O_RDONLY)) < 0)
+ if ((diskfd = OPEN(disk, O_RDONLY)) < 0)
quit("slave couldn't reopen disk: %s\n", strerror(errno));
#ifdef __linux__
ext2fs_close(fs);
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.23 2001/04/26 08:59:32 stelian Exp $";
+ "$Id: main.c,v 1.24 2001/04/27 15:22:47 stelian Exp $";
#endif /* not lint */
#include <config.h>
+#include <compatlfs.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <errno.h>
* Compare contents of tape.
*/
case 'C': {
- struct stat stbuf;
+ struct STAT stbuf;
Vprintf(stdout, "Begin compare restore\n");
compare_ignore_not_found = 0;
compare_errors = 0;
setup();
printf("filesys = %s\n", filesys);
- if (stat(filesys, &stbuf) < 0)
+ if (STAT(filesys, &stbuf) < 0)
err(1, "cannot stat directory %s", filesys);
if (chdir(filesys) < 0)
err(1, "cannot cd to %s", filesys);
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.36 2001/04/27 12:23:23 stelian Exp $";
+ "$Id: tape.c,v 1.37 2001/04/27 15:22:47 stelian Exp $";
#endif /* not lint */
#include <config.h>
+#include <compatlfs.h>
#include <errno.h>
#include <compaterr.h>
#include <setjmp.h>
setup(void)
{
int i, j, *ip;
- struct stat stbuf;
+ struct STAT stbuf;
struct mtget mt_stat;
Vprintf(stdout, "Verify tape and initialize maps\n");
if (pipein)
mt = 0;
else
- mt = open(magtape, O_RDONLY, 0);
+ mt = OPEN(magtape, O_RDONLY, 0);
if (mt < 0)
err(1, "%s", magtape);
volno = 1;
}
dumptime = spcl.c_ddate;
dumpdate = spcl.c_date;
- if (stat(".", &stbuf) < 0)
+ if (STAT(".", &stbuf) < 0)
err(1, "cannot stat .");
if (stbuf.st_blksize > 0 && stbuf.st_blksize < TP_BSIZE )
fssize = TP_BSIZE;
mt = rmtopen(magtape, 0);
else
#endif
- mt = open(magtape, O_RDONLY, 0);
+ mt = OPEN(magtape, O_RDONLY, 0);
if (mt == -1) {
fprintf(stderr, "Cannot open %s\n", magtape);
}
if (uflag)
(void)unlink(name);
- if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC,
+ if ((ofile = OPEN(name, O_WRONLY | O_CREAT | O_TRUNC,
0666)) < 0) {
warn("%s: cannot create file", name);
skipfile();
}
if (size > 0) {
fprintf(stderr, "Missing blocks at the end of %s, assuming hole\n", curfile.name);
- (*skip)(clearedbuf, size);
+ while (size > 0) {
+ size_t skp = size > TP_BSIZE ? TP_BSIZE : size;
+ (*skip)(clearedbuf, skp);
+ size -= skp;
+ }
last_write_was_hole = 1;
}
if (last_write_was_hole) {
- ftruncate(ofile, origsize);
+ FTRUNCATE(ofile, origsize);
}
findinode(&spcl);
gettingfile = 0;
xtrskip(char *buf, size_t size)
{
- if (lseek(ofile, (off_t)size, SEEK_CUR) == -1)
+ if (LSEEK(ofile, (off_t)size, SEEK_CUR) == -1)
err(1, "seek error extracting inode %lu, name %s\nlseek",
(unsigned long)curfile.ino, curfile.name);
}
#else
void
#endif
-cmpfiles(char *tapefile, char *diskfile, struct stat *sbuf_disk)
+cmpfiles(char *tapefile, char *diskfile, struct STAT *sbuf_disk)
{
- struct stat sbuf_tape;
+ struct STAT sbuf_tape;
int fd_tape, fd_disk;
- if (stat(tapefile, &sbuf_tape) != 0) {
+ if (STAT(tapefile, &sbuf_tape) != 0) {
panic("Can't lstat tmp file %s: %s\n", tapefile,
strerror(errno));
compare_errors = 1;
#endif
}
- if ((fd_tape = open(tapefile, O_RDONLY)) < 0) {
+ if ((fd_tape = OPEN(tapefile, O_RDONLY)) < 0) {
panic("Can't open %s: %s\n", tapefile, strerror(errno));
compare_errors = 1;
}
- if ((fd_disk = open(diskfile, O_RDONLY)) < 0) {
+ if ((fd_disk = OPEN(diskfile, O_RDONLY)) < 0) {
close(fd_tape);
panic("Can't open %s: %s\n", diskfile, strerror(errno));
compare_errors = 1;
comparefile(char *name)
{
int mode;
- struct stat sb;
+ struct STAT sb;
int r;
#if !COMPARE_ONTHEFLY
static char *tmpfile = NULL;
- struct stat stemp;
+ struct STAT stemp;
#endif
- if ((r = lstat(name, &sb)) != 0) {
+ if ((r = LSTAT(name, &sb)) != 0) {
warn("%s: does not exist (%d)", name, r);
compare_errors = 1;
skipfile();
case IFREG:
#if COMPARE_ONTHEFLY
- if ((ifile = open(name, O_RDONLY)) < 0) {
+ if ((ifile = OPEN(name, O_RDONLY)) < 0) {
panic("Can't open %s: %s\n", name, strerror(errno));
skipfile();
compare_errors = 1;
snprintf(tmpfilename, sizeof(tmpfilename), "%s/restoreCXXXXXX", tmpdir);
tmpfile = mktemp(&tmpfilename[0]);
}
- if ((stat(tmpfile, &stemp) == 0) && (unlink(tmpfile) != 0)) {
+ if ((STAT(tmpfile, &stemp) == 0) && (unlink(tmpfile) != 0)) {
panic("cannot delete tmp file %s: %s\n",
tmpfile, strerror(errno));
}
- if ((ofile = open(tmpfile, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0) {
+ if ((ofile = OPEN(tmpfile, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0) {
panic("cannot create file temp file %s: %s\n",
name, strerror(errno));
}
seek_failed = (rmtseek(i, 1) < 0);
else
#endif
- seek_failed = (lseek(mt, i, SEEK_CUR) == (off_t)-1);
+ seek_failed = (LSEEK(mt, i, SEEK_CUR) == (off_t)-1);
if (seek_failed) {
warn("continuation failed");
#ifndef lint
static const char rcsid[] =
- "$Id: rmt.c,v 1.13 2001/03/28 12:59:49 stelian Exp $";
+ "$Id: rmt.c,v 1.14 2001/04/27 15:22:47 stelian Exp $";
#endif /* not linux */
/*
* rmt
*/
#include <config.h>
+#include <compatlfs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/mtio.h>
* specify the permission bits; allow rw for everyone,
* as modified by the users umask
*/
- tape = open(device, atoi(filemode), 0666);
+ tape = OPEN(device, atoi(filemode), 0666);
if (tape < 0)
goto ioerror;
block = 0;
getstring(count);
getstring(pos);
DEBUG2("rmtd: L %s %s\n", count, pos);
- rval = lseek(tape, (off_t)atol(count), atoi(pos));
+ rval = LSEEK(tape, (off_t)atol(count), atoi(pos));
if (rval < 0)
goto ioerror;
goto respond;