use result of open(2) to check for presence

5 messages, 2 authors, 2016-06-15 · open the first message on its own page

use result of open(2) to check for presence

From: Alex Riesen <hidden>
Date: 2016-06-15 22:42:15

Not that the stat against open race would matter much in this context,
but that simplifies
the code a bit. Also some diagnostics added (why the open failed)

Signed-off-by: Alex Riesen <redacted>

Re: use result of open(2) to check for presence

From: Morten Welinder <hidden>
Date: 2016-06-15 22:42:15

Neat, but perhaps you should check the fstat return code.
It actually can fail, for example if the filesize cannot be represented in the
structure because it is too big.

Morten

Re: use result of open(2) to check for presence

From: Alex Riesen <hidden>
Date: 2016-06-15 22:42:15

On 1/5/06, Morten Welinder [off-list ref] wrote:
Neat, but perhaps you should check the fstat return code.
It actually can fail, for example if the filesize cannot be represented in the
structure because it is too big.
Yes, of course. It will be added along with the missing test for mmap
returning MAP_FAILED. Sometime.

Sarcasm aside, how do you get such a situation?

Re: use result of open(2) to check for presence

From: Morten Welinder <hidden>
Date: 2016-06-15 22:42:15

Config files always tend to grow, but I do agree that 4GB config files stretches
credibility a bit.

However, empty ones are not unlikely and then mmap will fail.

M.

Re: use result of open(2) to check for presence

From: Alex Riesen <hidden>
Date: 2016-06-15 22:42:15

Morten Welinder, Thu, Jan 05, 2006 17:45:27 +0100:
Config files always tend to grow, but I do agree that 4GB config files stretches
credibility a bit.

However, empty ones are not unlikely and then mmap will fail.
Shouldn't be a problem: the code in question does not seem to do
anything for empty files and wont even touch the result of mmap.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help