|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Hauke Mehrtens < [email protected]> |
| 3 | +Date: Sat, 25 Oct 2025 19:59:58 +0200 |
| 4 | +Subject: create_inode: Fix compilation again kernel < 5.12 |
| 5 | + |
| 6 | +Copy the header definition from Linux kernel v5.12 to allow compilation |
| 7 | +against kernel headers from an kernel older than v5.12. |
| 8 | + |
| 9 | +struct fsverity_descriptor was already added in kernel 5.11, compiling |
| 10 | +against kernel 5.11 kernel headers could cause problems. |
| 11 | + |
| 12 | +Signed-off-by: Hauke Mehrtens < [email protected]> |
| 13 | +--- |
| 14 | + misc/create_inode.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ |
| 15 | + 1 file changed, 47 insertions(+) |
| 16 | + |
| 17 | +--- a/misc/create_inode.c |
| 18 | ++++ b/misc/create_inode.c |
| 19 | +@@ -575,6 +575,53 @@ static inline off_t round_up(off_t n, of |
| 20 | + return ((n - bias + (blksz - 1)) & ~(blksz - 1)) + bias; |
| 21 | + } |
| 22 | + |
| 23 | ++#ifndef FS_IOC_READ_VERITY_METADATA |
| 24 | ++ |
| 25 | ++/* |
| 26 | ++ * Struct containing a file's Merkle tree properties. The fs-verity file digest |
| 27 | ++ * is the hash of this struct. A userspace program needs this struct only if it |
| 28 | ++ * needs to compute fs-verity file digests itself, e.g. in order to sign files. |
| 29 | ++ * It isn't needed just to enable fs-verity on a file. |
| 30 | ++ * |
| 31 | ++ * Note: when computing the file digest, 'sig_size' and 'signature' must be left |
| 32 | ++ * zero and empty, respectively. These fields are present only because some |
| 33 | ++ * filesystems reuse this struct as part of their on-disk format. |
| 34 | ++ */ |
| 35 | ++struct fsverity_descriptor { |
| 36 | ++ __u8 version; /* must be 1 */ |
| 37 | ++ __u8 hash_algorithm; /* Merkle tree hash algorithm */ |
| 38 | ++ __u8 log_blocksize; /* log2 of size of data and tree blocks */ |
| 39 | ++ __u8 salt_size; /* size of salt in bytes; 0 if none */ |
| 40 | ++#ifdef __KERNEL__ |
| 41 | ++ __le32 sig_size; |
| 42 | ++#else |
| 43 | ++ __le32 __reserved_0x04; /* must be 0 */ |
| 44 | ++#endif |
| 45 | ++ __le64 data_size; /* size of file the Merkle tree is built over */ |
| 46 | ++ __u8 root_hash[64]; /* Merkle tree root hash */ |
| 47 | ++ __u8 salt[32]; /* salt prepended to each hashed block */ |
| 48 | ++ __u8 __reserved[144]; /* must be 0's */ |
| 49 | ++#ifdef __KERNEL__ |
| 50 | ++ __u8 signature[]; |
| 51 | ++#endif |
| 52 | ++}; |
| 53 | ++ |
| 54 | ++#define FS_VERITY_METADATA_TYPE_MERKLE_TREE 1 |
| 55 | ++#define FS_VERITY_METADATA_TYPE_DESCRIPTOR 2 |
| 56 | ++#define FS_VERITY_METADATA_TYPE_SIGNATURE 3 |
| 57 | ++ |
| 58 | ++struct fsverity_read_metadata_arg { |
| 59 | ++ __u64 metadata_type; |
| 60 | ++ __u64 offset; |
| 61 | ++ __u64 length; |
| 62 | ++ __u64 buf_ptr; |
| 63 | ++ __u64 __reserved; |
| 64 | ++}; |
| 65 | ++ |
| 66 | ++#define FS_IOC_READ_VERITY_METADATA \ |
| 67 | ++ _IOWR('f', 135, struct fsverity_read_metadata_arg) |
| 68 | ++#endif |
| 69 | ++ |
| 70 | + static errcode_t copy_fs_verity_data(ext2_file_t e2_file, ext2_off_t e2_offset, |
| 71 | + int fd, uint64_t metadata_type, |
| 72 | + __u32 *written) |
0 commit comments