We need to enforce that the opened file is a block device, as
opening a file with the O_EXCL flag on and the O_CREATE flag off has
undefined behavior unless the file is a block device.
Signed-off-by: Ari Sundholm
---
util-linux/blkdiscard.c | 14 +-
1 file changed,
We need to enforce that the opened file is a block device, as
opening a file with the O_EXCL flag on and the O_CREAT flag off has
undefined behavior unless the file is a block device.
v2: Fix typo: O_CREAT, not O_CREATE.
Signed-off-by: Ari Sundholm
---
util-linux/blkdiscard.c
This patch just trades one undefined behaviour for another.
I'd open first and then do fstat.
Otherwise change your comment, because it isn't really enforcing anything
with a race condition between the stat and the open.
Sam
On Tue, Jan 5, 2016 at 11:50 AM, Ari Sundholm wrote:
Opening a file with the O_EXCL flag on and the O_CREAT flag off has
undefined behavior unless the file is a block device. Let's try and
avoid this case on a best-effort basis. The undefined behavior can
still be hit if the block device is replaced with something else
inbetween.
v2: Fix typo:
Hi!
Thanks for your comments.
On Tue, 2016-01-05 at 11:54 +, Sam Liddicott wrote:
> This patch just trades one undefined behaviour for another.
I'd rather think of it as reducing the number of cases where we would
get undefined behavior, while not completely eliminating them.
>
> I'd open