diff options
author | Michael Adam <obnox@samba.org> | 2007-07-20 16:31:32 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:28:52 -0500 |
commit | 84f352caa58a5a903087ff93e56113a07a7840aa (patch) | |
tree | 3dee6f3405ba4939f48ab9de437c8e35aa62169a | |
parent | 207a213c061b2c3a4dab42e9af1c19edaa39a2a0 (diff) | |
download | samba-84f352caa58a5a903087ff93e56113a07a7840aa.tar.gz samba-84f352caa58a5a903087ff93e56113a07a7840aa.tar.bz2 samba-84f352caa58a5a903087ff93e56113a07a7840aa.zip |
r23980: Fix one more use of pwrite in expand_file.
Michael
(This used to be commit de0ef9134650e3e7cc5b5cfec9e8dd8510bd6677)
-rw-r--r-- | source3/lib/tdb/common/io.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source3/lib/tdb/common/io.c b/source3/lib/tdb/common/io.c index a24b5e24a2..df924a9dcd 100644 --- a/source3/lib/tdb/common/io.c +++ b/source3/lib/tdb/common/io.c @@ -220,7 +220,16 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad if (ftruncate(tdb->fd, size+addition) == -1) { char b = 0; - if (pwrite(tdb->fd, &b, 1, (size+addition) - 1) != 1) { + ssize_t written = pwrite(tdb->fd, &b, 1, (size+addition) - 1); + if (written == 0) { + /* try once more, potentially revealing errno */ + written = pwrite(tdb->fd, &b, 1, (size+addition) - 1); + } + if (written == 0) { + /* again - give up, guessing errno */ + errno = ENOSPC; + } + if (written != 1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file to %d failed (%s)\n", size+addition, strerror(errno))); return -1; |