summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-09-19 06:55:25 +0000
committerJeremy Allison <jra@samba.org>2001-09-19 06:55:25 +0000
commit0ef1acbabb13006429d06cb1d90bf887bf987ddc (patch)
treed1291a3b71ba74f1455008e79f127c6f40e79b27
parent8c8b9c69e5c92c6e18710af33c7851c2fb8913d3 (diff)
downloadsamba-0ef1acbabb13006429d06cb1d90bf887bf987ddc.tar.gz
samba-0ef1acbabb13006429d06cb1d90bf887bf987ddc.tar.bz2
samba-0ef1acbabb13006429d06cb1d90bf887bf987ddc.zip
Put pwrite code back in expand_file.
Jeremy. (This used to be commit a3267551d88dffb226e4a1c3852fe9c817517d02)
-rw-r--r--source3/tdb/tdb.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index 3a5b66bbc7..b90c307ec6 100644
--- a/source3/tdb/tdb.c
+++ b/source3/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)));