If "property set ... compression no" is called, it sets FS_NOCOMP_FL flag (which is equivalent to BTRFS_INODE_NO_COMPRESS in btrfs). This means compression will not be done and is different from default status.
However, current "property get" won't check the status of FS_NOCOMP_FL and the output (no output message) cannot be distinguished from the default status when the flag is set. Fix this to call FS_IOC_GETFLAGS to check FS_NOCOMP_FL flag and print "compression=no" if the flag is set. Signed-off-by: Tomohiro Misono <[email protected]> --- props.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/props.c b/props.c index cddbd927..3af349af 100644 --- a/props.c +++ b/props.c @@ -14,6 +14,7 @@ * Boston, MA 021110-1307, USA. */ +#include <linux/fs.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/types.h> @@ -151,11 +152,19 @@ static int prop_compression(enum prop_object_type type, } if (sret < 0) { ret = -errno; - if (ret != -ENOATTR) + if (ret != -ENOATTR) { error("failed to %s compression for %s: %s", value ? "set" : "get", object, strerror(-ret)); - else - ret = 0; + } else { + unsigned int flags = 0; + + ret = ioctl(fd, FS_IOC_GETFLAGS, &flags); + if (ret) + error("failed to get FS_FLAGS for %s: %s", + object, strerror(ret)); + else if (flags & FS_NOCOMP_FL) + fprintf(stdout, "compression=no\n"); + } goto out; } if (!value) { -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
