From 1f4a5aba59f39a33a84152b5ae3ec0a5657b12a1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 25 Feb 2021 12:33:35 -0500 Subject: [PATCH] chattr/lsattr: expose FS_NOCOMP_FL (aka EXT2_NOCOMPR_FL) This adds support for setting/querying the FS_NOCOMP_FL/EXT2_NOCOMPR_FL file flag to chattr/lsattr. I picked the character "m" because it was so far unused and all other characters that were more obvious candidates were already taken. The flag is available on btrfs, and with this patch it is possible to manage it correctly. Signed-off-by: Lennart Poettering Signed-off-by: Theodore Ts'o --- lib/e2p/pf.c | 2 +- misc/chattr.1.in | 9 +++++++-- misc/chattr.c | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/e2p/pf.c b/lib/e2p/pf.c index 61fd4ab..81e3bb2 100644 --- a/lib/e2p/pf.c +++ b/lib/e2p/pf.c @@ -49,6 +49,7 @@ static struct flags_name flags_array[] = { { EXT4_INLINE_DATA_FL, "N", "Inline_Data" }, { EXT4_PROJINHERIT_FL, "P", "Project_Hierarchy" }, { EXT4_VERITY_FL, "V", "Verity" }, + { EXT2_NOCOMPR_FL, "m", "Dont_Compress" }, { 0, NULL, NULL } }; @@ -76,4 +77,3 @@ void print_flags (FILE * f, unsigned long flags, unsigned options) if (long_opt && first) fputs("---", f); } - diff --git a/misc/chattr.1.in b/misc/chattr.1.in index 5bc76a9..5e1eeb7 100644 --- a/misc/chattr.1.in +++ b/misc/chattr.1.in @@ -23,13 +23,13 @@ chattr \- change file attributes on a Linux file system .B chattr changes the file attributes on a Linux file system. .PP -The format of a symbolic mode is +-=[aAcCdDeFijPsStTux]. +The format of a symbolic mode is +-=[aAcCdDeFijmPsStTux]. .PP The operator '+' causes the selected attributes to be added to the existing attributes of the files; '-' causes them to be removed; and '=' causes them to be the only attributes that the files have. .PP -The letters 'aAcCdDeFijPsStTux' select the new attributes for the files: +The letters 'aAcCdDeFijmPsStTux' select the new attributes for the files: append only (a), no atime updates (A), compressed (c), @@ -40,6 +40,7 @@ extent format (e), case-insensitive directory lookups (F), immutable (i), data journalling (j), +don't compress (m), project hierarchy (P), secure deletion (s), synchronous updates (S), @@ -161,6 +162,10 @@ file system has a journal. When the filesystem is mounted with the attribute has no effect. Only the superuser or a process possessing the CAP_SYS_RESOURCE capability can set or clear this attribute. .TP +.B m +A file with the 'm' attribute is excluded from compression on file +systems that support per-file compression. +.TP .B N A file with the 'N' attribute set indicates that the file has data stored inline, within the inode itself. It may not be set or cleared diff --git a/misc/chattr.c b/misc/chattr.c index c0337f8..14b5734 100644 --- a/misc/chattr.c +++ b/misc/chattr.c @@ -102,6 +102,7 @@ static const struct flags_char flags_array[] = { { EXT2_DIRSYNC_FL, 'D' }, { EXT2_APPEND_FL, 'a' }, { EXT2_COMPR_FL, 'c' }, + { EXT2_NOCOMPR_FL, 'm' }, { EXT2_NODUMP_FL, 'd' }, { EXT4_EXTENTS_FL, 'e'}, { EXT2_IMMUTABLE_FL, 'i' }, -- 1.8.3.1