History

btrfs: extend btrfs_dir_item type to store encryption status

For directories with encrypted files/filenames, we need to store a flag indicating this fact. There's no room in other fields, so we'll need to borrow a bit from dir_type. Since it's now a combination of type and flags, we rename it to dir_flags to reflect its new usage. The new flag, FT_ENCRYPTED, indicates a directory containing encrypted data, which is orthogonal to file type; therefore, add the new flag, and make conversion from directory type to file type strip the flag. As the file types almost never change we can afford to use the bits. Actual usage will be guarded behind an incompat bit, this patch only adds the support for later use by fscrypt.

Omar Sandoval committed 4 years ago

Commit 94a48ae1 parent 6db753110 files · +50 −28Browse files

Showing the changes to include/uapi (1 of 10 files). Show all

Unified · Split

include/uapi/linux/btrfs_tree.h+7−0
@@ -376,6 +376,13 @@ enum btrfs_csum_type { · 375 unmodified lines
376376 #define BTRFS_FT_SYMLINK 7
377377 #define BTRFS_FT_XATTR 8
378378 #define BTRFS_FT_MAX 9
379+/* Directory contains encrypted data */
380+#define BTRFS_FT_ENCRYPTED 0x80
381+
382+static inline __u8 btrfs_dir_flags_to_ftype(__u8 flags)
383+{
384+ return flags & ~BTRFS_FT_ENCRYPTED;
385+}
379386
380387 /*
381388 * Inode flags