mirror of
https://github.com/samba-team/samba.git
synced 2025-02-03 13:47:25 +03:00
tdb: Protect against EINTR
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
ab132ba7e5
commit
3e7efbfb36
@ -52,27 +52,48 @@ static bool tdb_adjust_offset(struct tdb_context *tdb, off_t *off)
|
||||
static ssize_t tdb_pwrite(struct tdb_context *tdb, const void *buf,
|
||||
size_t count, off_t offset)
|
||||
{
|
||||
ssize_t ret;
|
||||
|
||||
if (!tdb_adjust_offset(tdb, &offset)) {
|
||||
return -1;
|
||||
}
|
||||
return pwrite(tdb->fd, buf, count, offset);
|
||||
|
||||
do {
|
||||
ret = pwrite(tdb->fd, buf, count, offset);
|
||||
} while ((ret == -1) && (errno == EINTR));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t tdb_pread(struct tdb_context *tdb, void *buf,
|
||||
size_t count, off_t offset)
|
||||
{
|
||||
ssize_t ret;
|
||||
|
||||
if (!tdb_adjust_offset(tdb, &offset)) {
|
||||
return -1;
|
||||
}
|
||||
return pread(tdb->fd, buf, count, offset);
|
||||
|
||||
do {
|
||||
ret = pread(tdb->fd, buf, count, offset);
|
||||
} while ((ret == -1) && (errno == EINTR));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int tdb_ftruncate(struct tdb_context *tdb, off_t length)
|
||||
{
|
||||
ssize_t ret;
|
||||
|
||||
if (!tdb_adjust_offset(tdb, &length)) {
|
||||
return -1;
|
||||
}
|
||||
return ftruncate(tdb->fd, length);
|
||||
|
||||
do {
|
||||
ret = ftruncate(tdb->fd, length);
|
||||
} while ((ret == -1) && (errno == EINTR));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int tdb_fstat(struct tdb_context *tdb, struct stat *buf)
|
||||
|
Loading…
x
Reference in New Issue
Block a user