1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _BCACHEFS_DIRENT_FORMAT_H 3 #define _BCACHEFS_DIRENT_FORMAT_H 4 5 /* 6 * Dirents (and xattrs) have to implement string lookups; since our b-tree 7 * doesn't support arbitrary length strings for the key, we instead index by a 8 * 64 bit hash (currently truncated sha1) of the string, stored in the offset 9 * field of the key - using linear probing to resolve hash collisions. This also 10 * provides us with the readdir cookie posix requires. 11 * 12 * Linear probing requires us to use whiteouts for deletions, in the event of a 13 * collision: 14 */ 15 16 struct bch_dirent { 17 struct bch_val v; 18 19 /* Target inode number: */ 20 union { 21 __le64 d_inum; 22 struct { /* DT_SUBVOL */ 23 __le32 d_child_subvol; 24 __le32 d_parent_subvol; 25 }; 26 }; 27 28 /* 29 * Copy of mode bits 12-15 from the target inode - so userspace can get 30 * the filetype without having to do a stat() 31 */ 32 #if defined(__LITTLE_ENDIAN_BITFIELD) 33 __u8 d_type:5, 34 d_unused:2, 35 d_casefold:1; 36 #elif defined(__BIG_ENDIAN_BITFIELD) 37 __u8 d_casefold:1, 38 d_unused:2, 39 d_type:5; 40 #endif 41 42 union { 43 struct { 44 __u8 d_pad; 45 __le16 d_name_len; 46 __le16 d_cf_name_len; 47 __u8 d_names[]; 48 } d_cf_name_block __packed; 49 __DECLARE_FLEX_ARRAY(__u8, d_name); 50 } __packed; 51 } __packed __aligned(8); 52 53 #define DT_SUBVOL 16 54 #define BCH_DT_MAX 17 55 56 #define BCH_NAME_MAX 512 57 58 #endif /* _BCACHEFS_DIRENT_FORMAT_H */ 59