[PATCH 1/2] btrfs-progs: prop: check FS_NOCOMP_FL flag in property get

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux