|
From: | Paul Eggert |
Subject: | Re: Tar doesn't handle short reads |
Date: | Mon, 27 Jul 2020 11:38:34 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 7/27/20 6:33 AM, Dominique Martinet wrote:
It's interesting to see an application actually does open regular files with O_NONBLOCK; when this was discussed in the pull request[2] basically the agreement was that apps should either just not be setting nonblock (which ought to be no-op on regular files),
O_NONBLOCK is needed there because the file might be a FIFO or a special file, and 'tar' doesn't want to hang forever trying to open the file. And 'tar' shouldn't stat the file first to see whether the file is a FIFO or a special file, as that (a) would be slower and (b) would introduce a race condition.
or would handle short reads so it would probably be fineā¢ (But I guess life always proves us wrong, sorry for the trouble)
Yes, POSIX requires that you don't get a short read when you're reading a regular file (unless it's at EOF or you're interrupted by a signal), and I assume 'tar' and other programs use this to avoid an unnecessary read of 0 bytes at end of file.
[Prev in Thread] | Current Thread | [Next in Thread] |