mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-08-17 14:56:02 +00:00
Use full-read instead of safe-read
This helps handle archiving on certain filesystems where read() returns less bytes than requested when reading from a regular file. References: https://savannah.gnu.org/bugs/index.php?64426 https://lists.gnu.org/archive/html/bug-tar/2021-07/msg00001.html * gnulib.modules: Add full-read. * src/common.h: Include full-read.h * src/misc.c: Use full_read. * src/sparse.c: Likewise. * src/update.c: Likewise.
This commit is contained in:
+4
-2
@@ -821,7 +821,7 @@ deref_stat (char const *name, struct stat *buf)
|
||||
size_t
|
||||
blocking_read (int fd, void *buf, size_t count)
|
||||
{
|
||||
size_t bytes = safe_read (fd, buf, count);
|
||||
size_t bytes = full_read (fd, buf, count);
|
||||
|
||||
#if defined F_SETFL && O_NONBLOCK
|
||||
if (bytes == SAFE_READ_ERROR && errno == EAGAIN)
|
||||
@@ -829,10 +829,12 @@ blocking_read (int fd, void *buf, size_t count)
|
||||
int flags = fcntl (fd, F_GETFL);
|
||||
if (0 <= flags && flags & O_NONBLOCK
|
||||
&& fcntl (fd, F_SETFL, flags & ~O_NONBLOCK) != -1)
|
||||
bytes = safe_read (fd, buf, count);
|
||||
bytes = full_read (fd, buf, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bytes == 0 && errno != 0)
|
||||
bytes = SAFE_READ_ERROR;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user