mirror of
https://github.com/samba-team/samba.git
synced 2025-11-25 00:23:52 +03:00
r23980: Fix one more use of pwrite in expand_file.
Michael
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
eb524df0a5
commit
b97acdc67b
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user