1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* AFS fileserver XDR types
4 * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
11 struct afs_xdr_AFSFetchStatus {
13 #define AFS_FSTATUS_VERSION 1
17 __be32 data_version_lo;
30 __be32 data_version_hi;
36 #define AFS_DIR_HASHTBL_SIZE 128
37 #define AFS_DIR_DIRENT_SIZE 32
38 #define AFS_DIR_SLOTS_PER_BLOCK 64
39 #define AFS_DIR_BLOCK_SIZE 2048
40 #define AFS_DIR_BLOCKS_PER_PAGE (PAGE_SIZE / AFS_DIR_BLOCK_SIZE)
41 #define AFS_DIR_MAX_SLOTS 65536
42 #define AFS_DIR_BLOCKS_WITH_CTR 128
43 #define AFS_DIR_MAX_BLOCKS 1023
44 #define AFS_DIR_RESV_BLOCKS 1
45 #define AFS_DIR_RESV_BLOCKS0 13
48 * Directory entry structure.
50 union afs_xdr_dirent {
58 /* When determining the number of dirent slots needed to
59 * represent a directory entry, name should be assumed to be 16
60 * bytes, due to a now-standardised (mis)calculation, but it is
61 * in fact 20 bytes in size. afs_dir_calc_slots() should be
64 * For names longer than (16 or) 20 bytes, extra slots should
65 * be annexed to this one using the extended_name format.
72 * Directory block header (one at the beginning of every 2048-byte block).
74 struct afs_xdr_dir_hdr {
77 #define AFS_DIR_MAGIC htons(1234)
84 * Directory block layout
86 union afs_xdr_dir_block {
87 struct afs_xdr_dir_hdr hdr;
90 struct afs_xdr_dir_hdr hdr;
91 u8 alloc_ctrs[AFS_DIR_MAX_BLOCKS];
92 __be16 hashtable[AFS_DIR_HASHTBL_SIZE];
95 union afs_xdr_dirent dirents[AFS_DIR_SLOTS_PER_BLOCK];
99 * Directory layout on a linux VM page.
101 struct afs_xdr_dir_page {
102 union afs_xdr_dir_block blocks[AFS_DIR_BLOCKS_PER_PAGE];
106 * Calculate the number of dirent slots required for any given name length.
107 * The calculation is made assuming the part of the name in the first slot is
108 * 16 bytes, rather than 20, but this miscalculation is now standardised.
110 static inline unsigned int afs_dir_calc_slots(size_t name_len)
112 name_len++; /* NUL-terminated */
113 return 1 + ((name_len + 15) / AFS_DIR_DIRENT_SIZE);
116 #endif /* XDR_FS_H */