aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2011-07-08 08:35:19 -0400
committerChristoph Hellwig <hch@lst.de>2011-07-08 08:35:19 -0400
commit78f70cd7b7e8fd44dc89af4f72fb110d865338a1 (patch)
treea0faa6e46c6d6504de239a1b34e90938a5763bca /fs
parentac8ba50f6be4a3ab49a2ad2cb676422af4ebaf8a (diff)
xfs: cleanup the definition of struct xfs_dir2_sf_entry
Remove the inumber member which is at a variable offset after the actual name, and make name a real variable sized C99 array instead of the incorrect one-sized array which confuses (not only) gcc. Based on this clean up the helpers to calculate the entry size. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Alex Elder <aelder@sgi.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_dir2_sf.c6
-rw-r--r--fs/xfs/xfs_dir2_sf.h28
2 files changed, 16 insertions, 18 deletions
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index 806b348f496f..3a1e3f4e3fa3 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -371,7 +371,7 @@ xfs_dir2_sf_addname(
371 /* 371 /*
372 * Compute entry (and change in) size. 372 * Compute entry (and change in) size.
373 */ 373 */
374 add_entsize = xfs_dir2_sf_entsize_byname(sfp, args->namelen); 374 add_entsize = xfs_dir2_sf_entsize(sfp, args->namelen);
375 incr_isize = add_entsize; 375 incr_isize = add_entsize;
376 objchange = 0; 376 objchange = 0;
377#if XFS_BIG_INUMS 377#if XFS_BIG_INUMS
@@ -465,7 +465,7 @@ xfs_dir2_sf_addname_easy(
465 /* 465 /*
466 * Grow the in-inode space. 466 * Grow the in-inode space.
467 */ 467 */
468 xfs_idata_realloc(dp, xfs_dir2_sf_entsize_byname(sfp, args->namelen), 468 xfs_idata_realloc(dp, xfs_dir2_sf_entsize(sfp, args->namelen),
469 XFS_DATA_FORK); 469 XFS_DATA_FORK);
470 /* 470 /*
471 * Need to set up again due to realloc of the inode data. 471 * Need to set up again due to realloc of the inode data.
@@ -1001,7 +1001,7 @@ xfs_dir2_sf_removename(
1001 * Calculate sizes. 1001 * Calculate sizes.
1002 */ 1002 */
1003 byteoff = (int)((char *)sfep - (char *)sfp); 1003 byteoff = (int)((char *)sfep - (char *)sfp);
1004 entsize = xfs_dir2_sf_entsize_byname(sfp, args->namelen); 1004 entsize = xfs_dir2_sf_entsize(sfp, args->namelen);
1005 newsize = oldsize - entsize; 1005 newsize = oldsize - entsize;
1006 /* 1006 /*
1007 * Copy the part if any after the removed entry, sliding it down. 1007 * Copy the part if any after the removed entry, sliding it down.
diff --git a/fs/xfs/xfs_dir2_sf.h b/fs/xfs/xfs_dir2_sf.h
index c1ab2e7c66ae..55560bc80ec0 100644
--- a/fs/xfs/xfs_dir2_sf.h
+++ b/fs/xfs/xfs_dir2_sf.h
@@ -76,10 +76,13 @@ typedef struct xfs_dir2_sf_hdr {
76} __arch_pack xfs_dir2_sf_hdr_t; 76} __arch_pack xfs_dir2_sf_hdr_t;
77 77
78typedef struct xfs_dir2_sf_entry { 78typedef struct xfs_dir2_sf_entry {
79 __uint8_t namelen; /* actual name length */ 79 __u8 namelen; /* actual name length */
80 xfs_dir2_sf_off_t offset; /* saved offset */ 80 xfs_dir2_sf_off_t offset; /* saved offset */
81 __uint8_t name[1]; /* name, variable size */ 81 __u8 name[]; /* name, variable size */
82 xfs_dir2_inou_t inumber; /* inode number, var. offset */ 82 /*
83 * A xfs_dir2_ino8_t or xfs_dir2_ino4_t follows here, at a
84 * variable offset after the name.
85 */
83} __arch_pack xfs_dir2_sf_entry_t; 86} __arch_pack xfs_dir2_sf_entry_t;
84 87
85static inline int xfs_dir2_sf_hdr_size(int i8count) 88static inline int xfs_dir2_sf_hdr_size(int i8count)
@@ -101,19 +104,14 @@ xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off)
101 INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off); 104 INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off);
102} 105}
103 106
104static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_hdr_t *sfp, int len)
105{
106 return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \
107 ((sfp)->i8count == 0) * \
108 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
109}
110
111static inline int 107static inline int
112xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_hdr_t *sfp, xfs_dir2_sf_entry_t *sfep) 108xfs_dir2_sf_entsize(struct xfs_dir2_sf_hdr *hdr, int len)
113{ 109{
114 return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (sfep)->namelen - \ 110 return sizeof(struct xfs_dir2_sf_entry) + /* namelen + offset */
115 ((sfp)->i8count == 0) * \ 111 len + /* name */
116 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))); 112 (hdr->i8count ? /* ino */
113 sizeof(xfs_dir2_ino8_t) :
114 sizeof(xfs_dir2_ino4_t));
117} 115}
118 116
119static inline struct xfs_dir2_sf_entry * 117static inline struct xfs_dir2_sf_entry *
@@ -128,7 +126,7 @@ xfs_dir2_sf_nextentry(struct xfs_dir2_sf_hdr *hdr,
128 struct xfs_dir2_sf_entry *sfep) 126 struct xfs_dir2_sf_entry *sfep)
129{ 127{
130 return (struct xfs_dir2_sf_entry *) 128 return (struct xfs_dir2_sf_entry *)
131 ((char *)sfep + xfs_dir2_sf_entsize_byentry(hdr, sfep)); 129 ((char *)sfep + xfs_dir2_sf_entsize(hdr, sfep->namelen));
132} 130}
133 131
134/* 132/*