path: root/props.c
diff options
authorFilipe David Borba Manana <>2014-04-15 20:47:27 +0100
committerDavid Sterba <>2014-05-02 17:03:21 +0200
commit1e6195885baa1d3aea7b75c6fb752ce293e1b936 (patch)
treefc936a10d7df2fcd93c69abf20ec525cccb0bcfe /props.c
parent726bc372b9529a11c79dea75f2bcc8ef8a34d67a (diff)
Btrfs-progs: allow compression property gets for read-only subvolumes
Because the function open_file_or_dir() always opened the input file in read/write mode (O_RDWR), we were not able to due a compression property get against a file living in a read-only subvolume/snapshot. Fix this by opening the file with O_RDONLY mode if we're doing a property get. Signed-off-by: Filipe David Borba Manana <> Reviewed-by: Liu Bo <> Signed-off-by: David Sterba <>
Diffstat (limited to 'props.c')
1 files changed, 2 insertions, 1 deletions
diff --git a/props.c b/props.c
index c09865b3..04b9e5f1 100644
--- a/props.c
+++ b/props.c
@@ -119,8 +119,9 @@ static int prop_compression(enum prop_object_type type,
DIR *dirstream = NULL;
char *buf = NULL;
char *xattr_name = NULL;
+ int open_flags = value ? O_RDWR : O_RDONLY;
- fd = open_file_or_dir(object, &dirstream);
+ fd = open_file_or_dir3(object, &dirstream, open_flags);
if (fd == -1) {
ret = -errno;
fprintf(stderr, "ERROR: open %s failed. %s\n",