@@ -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) {
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 <misono.tomohiro@jp.fujitsu.com> --- props.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)