From df11e2787b5b57ecdb313f2725dc5c9a5e549576 Mon Sep 17 00:00:00 2001 From: Satoru Takeuchi Date: Sat, 14 Oct 2017 21:54:54 +0900 Subject: btrfs-progs: allow "no" to disable compression for convenience It's messy to use "" to disable compression. Introduce the new value "no" which can also be used for this purpose. Signed-off-by: Satoru Takeuchi [ coding style fixes ] Signed-off-by: David Sterba --- Documentation/btrfs-property.asciidoc | 2 +- props.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Documentation/btrfs-property.asciidoc b/Documentation/btrfs-property.asciidoc index 7ed6a7df..97b90d65 100644 --- a/Documentation/btrfs-property.asciidoc +++ b/Documentation/btrfs-property.asciidoc @@ -43,7 +43,7 @@ read-only flag of subvolume: true or false label:::: label of device compression:::: -compression setting for an inode: lzo, zlib, zstd, or "" (empty string) +compression setting for an inode: lzo, zlib, zstd, no, or "" (empty string). Both no and "" are for disabling compression. *list* [-t ] :: Lists available properties with their descriptions for the given object. diff --git a/props.c b/props.c index a7e3e96b..94b43b40 100644 --- a/props.c +++ b/props.c @@ -142,10 +142,13 @@ static int prop_compression(enum prop_object_type type, memcpy(xattr_name + XATTR_BTRFS_PREFIX_LEN, name, strlen(name)); xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0'; - if (value) + if (value) { + if (strcmp(value, "no") == 0) + value = ""; sret = fsetxattr(fd, xattr_name, value, strlen(value), 0); - else + } else { sret = fgetxattr(fd, xattr_name, NULL, 0); + } if (sret < 0) { ret = -errno; if (ret != -ENOATTR) -- cgit v1.2.3