btrfs-progs: fix fi du so it works in more cases
authorAustin S. Hemmelgarn <ahferroin7@gmail.com>
Mon, 21 Mar 2016 12:23:11 +0000 (08:23 -0400)
committerDavid Sterba <dsterba@suse.com>
Wed, 30 Mar 2016 14:22:53 +0000 (16:22 +0200)
commit1c36022fe71b6602787316cd68b6a808bfca0184
tree94b517aeaed12d0ca80b41c9de39c591915348db
parent74a5d7478a5c0035df53823ba0c9167fce59f5e2
btrfs-progs: fix fi du so it works in more cases

Currently, btrfs fi du uses open_file_or_dir(), which tries to open
it's argument with O_RDWR.  Because of POSIX semantics, this fails for
non-root users when the file is read-only or is an executable that
is being run currently, or for all users (including root) when the
filesystem is read-only.  This results in a somewhat confusing 'Unknown
error -1' message when trying to check such files.  Switch to using
open_file_or_dir3() with O_RDONLY passed in the flags, as this avoids
the limitations listed above, and we have no need to write to the files
anyway (and thus shouldn't be opening them writable).

Signed-off-by: Austin S. Hemmelgarn <ahferroin7@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-fi-du.c