diff options
author | Jeremy Allison <jra@samba.org> | 2001-09-19 06:55:25 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-09-19 06:55:25 +0000 |
commit | a3267551d88dffb226e4a1c3852fe9c817517d02 (patch) | |
tree | c3033e02a2b4af7046308bf12bbf049ed9e6a0a6 /source/tdb | |
parent | fc91ecc236e0d27f5836e9820332ababd762f1a7 (diff) | |
download | samba-a3267551d88dffb226e4a1c3852fe9c817517d02.tar.gz samba-a3267551d88dffb226e4a1c3852fe9c817517d02.tar.xz samba-a3267551d88dffb226e4a1c3852fe9c817517d02.zip |
Put pwrite code back in expand_file.
Jeremy.
Diffstat (limited to 'source/tdb')
-rw-r--r-- | source/tdb/tdb.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source/tdb/tdb.c b/source/tdb/tdb.c index 3a5b66bbc78..b90c307ec6b 100644 --- a/source/tdb/tdb.c +++ b/source/tdb/tdb.c @@ -611,24 +611,31 @@ static int expand_file(TDB_CONTEXT *tdb, tdb_off size, tdb_off addition) #else char b = 0; +#ifdef HAVE_PWRITE + if (pwrite(tdb->fd, &b, 1, (size+addition) - 1) != 1) { +#else if (lseek(tdb->fd, (size+addition) - 1, SEEK_SET) != (size+addition) - 1 || write(tdb->fd, &b, 1) != 1) { +#endif TDB_LOG((tdb, 0, "expand_file to %d failed (%s)\n", size+addition, strerror(errno))); return -1; } #endif - /* now fill the file with something. This ensures that the - file isn't sparse, which would be very bad if we ran out of - disk. This must be done with write, not via mmap */ + /* now fill the file with something. This ensures that the file isn't sparse, which would be + very bad if we ran out of disk. This must be done with write, not via mmap */ memset(buf, 0x42, sizeof(buf)); while (addition) { int n = addition>sizeof(buf)?sizeof(buf):addition; +#ifdef HAVE_PWRITE + int ret = pwrite(tdb->fd, buf, n, size); +#else int ret; if (lseek(tdb->fd, size, SEEK_SET) != size) return -1; ret = write(tdb->fd, buf, n); +#endif if (ret != n) { TDB_LOG((tdb, 0, "expand_file write of %d failed (%s)\n", n, strerror(errno))); |