Whamcloud - gitweb
libext2fs: ext2fs_new_block2() should call alloc_block hook
[tools/e2fsprogs.git] / lib / ext2fs / ext2_fs.h
index 2b24080..9f069e2 100644 (file)
@@ -307,7 +307,8 @@ struct ext2_dx_tail {
 #define EXT2_DIRTY_FL                  0x00000100
 #define EXT2_COMPRBLK_FL               0x00000200 /* One or more compressed clusters */
 #define EXT2_NOCOMPR_FL                        0x00000400 /* Access raw compressed data */
-#define EXT2_ECOMPR_FL                 0x00000800 /* Compression error */
+       /* nb: was previously EXT2_ECOMPR_FL */
+#define EXT4_ENCRYPT_FL                        0x00000800 /* encrypted inode */
 /* End compression flags --- maybe not all used */
 #define EXT2_BTREE_FL                  0x00001000 /* btree format dir */
 #define EXT2_INDEX_FL                  0x00001000 /* hash-indexed directory */
@@ -564,6 +565,41 @@ struct ext2_inode_large {
 /* Metadata checksum algorithms */
 #define EXT2_CRC32C_CHKSUM             1
 
+/* Encryption algorithms, key size and key reference len */
+#define EXT4_ENCRYPTION_MODE_INVALID           0
+#define EXT4_ENCRYPTION_MODE_AES_256_XTS       1
+#define EXT4_ENCRYPTION_MODE_AES_256_GCM       2
+#define EXT4_ENCRYPTION_MODE_AES_256_CBC       3
+
+#define EXT4_AES_256_XTS_KEY_SIZE              64
+#define EXT4_AES_256_GCM_KEY_SIZE              32
+#define EXT4_AES_256_CBC_KEY_SIZE              32
+#define EXT4_MAX_KEY_SIZE                      64
+
+#define EXT4_KEY_DESCRIPTOR_SIZE               8
+
+/* Password derivation constants */
+#define EXT4_MAX_PASSPHRASE_SIZE               1024
+#define EXT4_MAX_SALT_SIZE                     256
+#define EXT4_PBKDF2_ITERATIONS                 0xFFFF
+
+/*
+ * Policy provided via an ioctl on the topmost directory. This
+ * structure is also in the kernel.
+ */
+struct ext4_encryption_policy {
+  char version;
+  char contents_encryption_mode;
+  char filenames_encryption_mode;
+  char master_key_descriptor[EXT4_KEY_DESCRIPTOR_SIZE];
+} __attribute__((__packed__));
+
+struct ext4_encryption_key {
+        __u32 mode;
+        char raw[EXT4_MAX_KEY_SIZE];
+        __u32 size;
+} __attribute__((__packed__));
+
 /*
  * Structure of the super block
  */
@@ -675,7 +711,9 @@ struct ext2_super_block {
        __u32   s_grp_quota_inum;       /* inode number of group quota file */
        __u32   s_overhead_blocks;      /* overhead blocks/clusters in fs */
        __u32   s_backup_bgs[2];        /* If sparse_super2 enabled */
-       __u32   s_reserved[106];        /* Padding to the end of the block */
+       __u8    s_encrypt_algos[4];     /* Encryption algorithms in use  */
+       __u8    s_encrypt_pw_salt[16];  /* Salt used for string2key algorithm */
+       __u32   s_reserved[101];        /* Padding to the end of the block */
        __u32   s_checksum;             /* crc32c(superblock) */
 };
 
@@ -746,6 +784,8 @@ struct ext2_super_block {
  */
 #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM   0x0400
 #define EXT4_FEATURE_RO_COMPAT_REPLICA         0x0800
+#define EXT4_FEATURE_RO_COMPAT_READONLY                0x1000
+
 
 #define EXT2_FEATURE_INCOMPAT_COMPRESSION      0x0001
 #define EXT2_FEATURE_INCOMPAT_FILETYPE         0x0002
@@ -761,6 +801,7 @@ struct ext2_super_block {
 /* 0x2000 was EXT4_FEATURE_INCOMPAT_BG_USE_META_CSUM but this was never used */
 #define EXT4_FEATURE_INCOMPAT_LARGEDIR         0x4000 /* >2GB or 3-lvl htree */
 #define EXT4_FEATURE_INCOMPAT_INLINE_DATA      0x8000 /* data in inode */
+#define EXT4_FEATURE_INCOMPAT_ENCRYPT          0x10000
 
 #define EXT2_FEATURE_COMPAT_SUPP       0
 #define EXT2_FEATURE_INCOMPAT_SUPP    (EXT2_FEATURE_INCOMPAT_FILETYPE| \
@@ -866,9 +907,12 @@ struct ext2_dir_entry_tail {
  *
  * NOTE: It must be a multiple of 4
  */
+#define EXT2_DIR_ENTRY_HEADER_LEN      8
 #define EXT2_DIR_PAD                   4
 #define EXT2_DIR_ROUND                 (EXT2_DIR_PAD - 1)
-#define EXT2_DIR_REC_LEN(name_len)     (((name_len) + 8 + EXT2_DIR_ROUND) & \
+#define EXT2_DIR_REC_LEN(name_len)     (((name_len) + \
+                                         EXT2_DIR_ENTRY_HEADER_LEN + \
+                                         EXT2_DIR_ROUND) & \
                                         ~EXT2_DIR_ROUND)
 
 /*