From 1c36022fe71b6602787316cd68b6a808bfca0184 Mon Sep 17 00:00:00 2001 From: "Austin S. Hemmelgarn" Date: Mon, 21 Mar 2016 08:23:11 -0400 Subject: 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 Signed-off-by: David Sterba --- cmds-fi-du.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmds-fi-du.c') diff --git a/cmds-fi-du.c b/cmds-fi-du.c index 2ffd917d..168fc722 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; -- cgit v1.2.3