aboutsummaryrefslogtreecommitdiffstats
path: root/cmds-fi-du.c
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <ahferroin7@gmail.com>2016-03-21 08:23:11 -0400
committerDavid Sterba <dsterba@suse.com>2016-03-30 16:22:53 +0200
commit1c36022fe71b6602787316cd68b6a808bfca0184 (patch)
tree94b517aeaed12d0ca80b41c9de39c591915348db /cmds-fi-du.c
parent74a5d7478a5c0035df53823ba0c9167fce59f5e2 (diff)
downloadbtrfs-progs-1c36022fe71b6602787316cd68b6a808bfca0184.tar.gz
btrfs-progs-1c36022fe71b6602787316cd68b6a808bfca0184.tar.xz
btrfs-progs-1c36022fe71b6602787316cd68b6a808bfca0184.zip
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>
Diffstat (limited to 'cmds-fi-du.c')
-rw-r--r--cmds-fi-du.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/cmds-fi-du.c b/cmds-fi-du.c
index 2ffd917..168fc72 100644
--- a/cmds-fi-du.c
+++ b/cmds-fi-du.c
@@ -438,7 +438,7 @@ static int du_add_file(const char *filename, int dirfd,
ret = sprintf(pathp, "/%s", filename);
pathp += ret;
- fd = open_file_or_dir(path, &dirstream);
+ fd = open_file_or_dir3(path, &dirstream, O_RDONLY);
if (fd < 0) {
ret = fd;
goto out;