aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_sf.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_dir2_sf.h')
-rw-r--r--fs/xfs/xfs_dir2_sf.h194
1 files changed, 80 insertions, 114 deletions
diff --git a/fs/xfs/xfs_dir2_sf.h b/fs/xfs/xfs_dir2_sf.h
index bac6f5a2a312..133464935ef1 100644
--- a/fs/xfs/xfs_dir2_sf.h
+++ b/fs/xfs/xfs_dir2_sf.h
@@ -104,140 +104,106 @@ typedef struct xfs_dir2_sf {
104 xfs_dir2_sf_entry_t list[1]; /* shortform entries */ 104 xfs_dir2_sf_entry_t list[1]; /* shortform entries */
105} xfs_dir2_sf_t; 105} xfs_dir2_sf_t;
106 106
107#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_HDR_SIZE)
108int xfs_dir2_sf_hdr_size(int i8count);
109#define XFS_DIR2_SF_HDR_SIZE(i8count) xfs_dir2_sf_hdr_size(i8count) 107#define XFS_DIR2_SF_HDR_SIZE(i8count) xfs_dir2_sf_hdr_size(i8count)
110#else 108static inline int xfs_dir2_sf_hdr_size(int i8count)
111#define XFS_DIR2_SF_HDR_SIZE(i8count) \ 109{
112 ((uint)sizeof(xfs_dir2_sf_hdr_t) - \ 110 return ((uint)sizeof(xfs_dir2_sf_hdr_t) - \
113 ((i8count) == 0) * \ 111 ((i8count) == 0) * \
114 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))) 112 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
115#endif 113}
116 114
117#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_INUMBERP)
118xfs_dir2_inou_t *xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep);
119#define XFS_DIR2_SF_INUMBERP(sfep) xfs_dir2_sf_inumberp(sfep) 115#define XFS_DIR2_SF_INUMBERP(sfep) xfs_dir2_sf_inumberp(sfep)
120#else 116static inline xfs_dir2_inou_t *xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep)
121#define XFS_DIR2_SF_INUMBERP(sfep) \ 117{
122 ((xfs_dir2_inou_t *)&(sfep)->name[(sfep)->namelen]) 118 return (xfs_dir2_inou_t *)&(sfep)->name[(sfep)->namelen];
123#endif 119}
124
125#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_GET_INUMBER)
126xfs_intino_t xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from);
127#define XFS_DIR2_SF_GET_INUMBER(sfp, from) \
128 xfs_dir2_sf_get_inumber(sfp, from)
129 120
130#else 121#define XFS_DIR2_SF_GET_INUMBER(sfp, from) \
131#define XFS_DIR2_SF_GET_INUMBER(sfp, from) \ 122 xfs_dir2_sf_get_inumber(sfp, from)
132 ((sfp)->hdr.i8count == 0 ? \ 123static inline xfs_intino_t
124xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from)
125{
126 return ((sfp)->hdr.i8count == 0 ? \
133 (xfs_intino_t)XFS_GET_DIR_INO4((from)->i4) : \ 127 (xfs_intino_t)XFS_GET_DIR_INO4((from)->i4) : \
134 (xfs_intino_t)XFS_GET_DIR_INO8((from)->i8)) 128 (xfs_intino_t)XFS_GET_DIR_INO8((from)->i8));
135#endif 129}
136 130
137#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_PUT_INUMBER) 131#define XFS_DIR2_SF_PUT_INUMBER(sfp,from,to) \
138void xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from,
139 xfs_dir2_inou_t *to);
140#define XFS_DIR2_SF_PUT_INUMBER(sfp,from,to) \
141 xfs_dir2_sf_put_inumber(sfp,from,to) 132 xfs_dir2_sf_put_inumber(sfp,from,to)
142#else 133static inline void xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from,
143#define XFS_DIR2_SF_PUT_INUMBER(sfp,from,to) \ 134 xfs_dir2_inou_t *to)
144 if ((sfp)->hdr.i8count == 0) { \ 135{
145 XFS_PUT_DIR_INO4(*(from), (to)->i4); \ 136 if ((sfp)->hdr.i8count == 0)
146 } else { \ 137 XFS_PUT_DIR_INO4(*(from), (to)->i4);
147 XFS_PUT_DIR_INO8(*(from), (to)->i8); \ 138 else
148 } 139 XFS_PUT_DIR_INO8(*(from), (to)->i8);
149#endif 140}
150 141
151#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_GET_OFFSET)
152xfs_dir2_data_aoff_t xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep);
153#define XFS_DIR2_SF_GET_OFFSET(sfep) \ 142#define XFS_DIR2_SF_GET_OFFSET(sfep) \
154 xfs_dir2_sf_get_offset(sfep) 143 xfs_dir2_sf_get_offset(sfep)
155#else 144static inline xfs_dir2_data_aoff_t
156#define XFS_DIR2_SF_GET_OFFSET(sfep) \ 145xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep)
157 INT_GET_UNALIGNED_16_BE(&(sfep)->offset.i) 146{
158#endif 147 return INT_GET_UNALIGNED_16_BE(&(sfep)->offset.i);
148}
159 149
160#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_PUT_OFFSET)
161void xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep,
162 xfs_dir2_data_aoff_t off);
163#define XFS_DIR2_SF_PUT_OFFSET(sfep,off) \ 150#define XFS_DIR2_SF_PUT_OFFSET(sfep,off) \
164 xfs_dir2_sf_put_offset(sfep,off) 151 xfs_dir2_sf_put_offset(sfep,off)
165#else 152static inline void
166#define XFS_DIR2_SF_PUT_OFFSET(sfep,off) \ 153xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off)
167 INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i,off) 154{
168#endif 155 INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off);
156}
169 157
170#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_ENTSIZE_BYNAME)
171int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len);
172#define XFS_DIR2_SF_ENTSIZE_BYNAME(sfp,len) \ 158#define XFS_DIR2_SF_ENTSIZE_BYNAME(sfp,len) \
173 xfs_dir2_sf_entsize_byname(sfp,len) 159 xfs_dir2_sf_entsize_byname(sfp,len)
174#else 160static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len)
175#define XFS_DIR2_SF_ENTSIZE_BYNAME(sfp,len) /* space a name uses */ \ 161{
176 ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \ 162 return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \
177 ((sfp)->hdr.i8count == 0) * \ 163 ((sfp)->hdr.i8count == 0) * \
178 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))) 164 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
179#endif 165}
180 166
181#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_ENTSIZE_BYENTRY)
182int xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep);
183#define XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep) \ 167#define XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep) \
184 xfs_dir2_sf_entsize_byentry(sfp,sfep) 168 xfs_dir2_sf_entsize_byentry(sfp,sfep)
185#else 169static inline int
186#define XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep) /* space an entry uses */ \ 170xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep)
187 ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (sfep)->namelen - \ 171{
188 ((sfp)->hdr.i8count == 0) * \ 172 return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (sfep)->namelen - \
189 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))) 173 ((sfp)->hdr.i8count == 0) * \
190#endif 174 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
191 175}
192#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_FIRSTENTRY) 176
193xfs_dir2_sf_entry_t *xfs_dir2_sf_firstentry(xfs_dir2_sf_t *sfp);
194#define XFS_DIR2_SF_FIRSTENTRY(sfp) xfs_dir2_sf_firstentry(sfp) 177#define XFS_DIR2_SF_FIRSTENTRY(sfp) xfs_dir2_sf_firstentry(sfp)
195#else 178static inline xfs_dir2_sf_entry_t *xfs_dir2_sf_firstentry(xfs_dir2_sf_t *sfp)
196#define XFS_DIR2_SF_FIRSTENTRY(sfp) /* first entry in struct */ \ 179{
197 ((xfs_dir2_sf_entry_t *) \ 180 return ((xfs_dir2_sf_entry_t *) \
198 ((char *)(sfp) + XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count))) 181 ((char *)(sfp) + XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count)));
199#endif 182}
200 183
201#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_NEXTENTRY) 184#define XFS_DIR2_SF_NEXTENTRY(sfp,sfep) xfs_dir2_sf_nextentry(sfp,sfep)
202xfs_dir2_sf_entry_t *xfs_dir2_sf_nextentry(xfs_dir2_sf_t *sfp, 185static inline xfs_dir2_sf_entry_t *
203 xfs_dir2_sf_entry_t *sfep); 186xfs_dir2_sf_nextentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep)
204#define XFS_DIR2_SF_NEXTENTRY(sfp,sfep) xfs_dir2_sf_nextentry(sfp,sfep) 187{
205#else 188 return ((xfs_dir2_sf_entry_t *) \
206#define XFS_DIR2_SF_NEXTENTRY(sfp,sfep) /* next entry in struct */ \ 189 ((char *)(sfep) + XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep)));
207 ((xfs_dir2_sf_entry_t *) \ 190}
208 ((char *)(sfep) + XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep)))
209#endif
210 191
211/* 192/*
212 * Functions. 193 * Functions.
213 */ 194 */
214 195extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
215extern int 196 struct xfs_dir2_block *block,
216 xfs_dir2_block_sfsize(struct xfs_inode *dp, 197 xfs_dir2_sf_hdr_t *sfhp);
217 struct xfs_dir2_block *block, 198extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp,
218 xfs_dir2_sf_hdr_t *sfhp); 199 int size, xfs_dir2_sf_hdr_t *sfhp);
219 200extern int xfs_dir2_sf_addname(struct xfs_da_args *args);
220extern int 201extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
221 xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp, 202extern int xfs_dir2_sf_getdents(struct xfs_inode *dp, struct uio *uio,
222 int size, xfs_dir2_sf_hdr_t *sfhp); 203 int *eofp, struct xfs_dirent *dbp,
223 204 xfs_dir2_put_t put);
224extern int 205extern int xfs_dir2_sf_lookup(struct xfs_da_args *args);
225 xfs_dir2_sf_addname(struct xfs_da_args *args); 206extern int xfs_dir2_sf_removename(struct xfs_da_args *args);
226 207extern int xfs_dir2_sf_replace(struct xfs_da_args *args);
227extern int
228 xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
229
230extern int
231 xfs_dir2_sf_getdents(struct xfs_inode *dp, struct uio *uio, int *eofp,
232 struct xfs_dirent *dbp, xfs_dir2_put_t put);
233
234extern int
235 xfs_dir2_sf_lookup(struct xfs_da_args *args);
236
237extern int
238 xfs_dir2_sf_removename(struct xfs_da_args *args);
239
240extern int
241 xfs_dir2_sf_replace(struct xfs_da_args *args);
242 208
243#endif /* __XFS_DIR2_SF_H__ */ 209#endif /* __XFS_DIR2_SF_H__ */