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>
This commit is contained in:
@ -371,7 +371,7 @@ xfs_dir2_sf_addname(
|
|||||||
/*
|
/*
|
||||||
* Compute entry (and change in) size.
|
* Compute entry (and change in) size.
|
||||||
*/
|
*/
|
||||||
add_entsize = xfs_dir2_sf_entsize_byname(sfp, args->namelen);
|
add_entsize = xfs_dir2_sf_entsize(sfp, args->namelen);
|
||||||
incr_isize = add_entsize;
|
incr_isize = add_entsize;
|
||||||
objchange = 0;
|
objchange = 0;
|
||||||
#if XFS_BIG_INUMS
|
#if XFS_BIG_INUMS
|
||||||
@ -465,7 +465,7 @@ xfs_dir2_sf_addname_easy(
|
|||||||
/*
|
/*
|
||||||
* Grow the in-inode space.
|
* Grow the in-inode space.
|
||||||
*/
|
*/
|
||||||
xfs_idata_realloc(dp, xfs_dir2_sf_entsize_byname(sfp, args->namelen),
|
xfs_idata_realloc(dp, xfs_dir2_sf_entsize(sfp, args->namelen),
|
||||||
XFS_DATA_FORK);
|
XFS_DATA_FORK);
|
||||||
/*
|
/*
|
||||||
* Need to set up again due to realloc of the inode data.
|
* Need to set up again due to realloc of the inode data.
|
||||||
@ -1001,7 +1001,7 @@ xfs_dir2_sf_removename(
|
|||||||
* Calculate sizes.
|
* Calculate sizes.
|
||||||
*/
|
*/
|
||||||
byteoff = (int)((char *)sfep - (char *)sfp);
|
byteoff = (int)((char *)sfep - (char *)sfp);
|
||||||
entsize = xfs_dir2_sf_entsize_byname(sfp, args->namelen);
|
entsize = xfs_dir2_sf_entsize(sfp, args->namelen);
|
||||||
newsize = oldsize - entsize;
|
newsize = oldsize - entsize;
|
||||||
/*
|
/*
|
||||||
* Copy the part if any after the removed entry, sliding it down.
|
* Copy the part if any after the removed entry, sliding it down.
|
||||||
|
@ -76,10 +76,13 @@ typedef struct xfs_dir2_sf_hdr {
|
|||||||
} __arch_pack xfs_dir2_sf_hdr_t;
|
} __arch_pack xfs_dir2_sf_hdr_t;
|
||||||
|
|
||||||
typedef struct xfs_dir2_sf_entry {
|
typedef struct xfs_dir2_sf_entry {
|
||||||
__uint8_t namelen; /* actual name length */
|
__u8 namelen; /* actual name length */
|
||||||
xfs_dir2_sf_off_t offset; /* saved offset */
|
xfs_dir2_sf_off_t offset; /* saved offset */
|
||||||
__uint8_t name[1]; /* name, variable size */
|
__u8 name[]; /* name, variable size */
|
||||||
xfs_dir2_inou_t inumber; /* inode number, var. offset */
|
/*
|
||||||
|
* A xfs_dir2_ino8_t or xfs_dir2_ino4_t follows here, at a
|
||||||
|
* variable offset after the name.
|
||||||
|
*/
|
||||||
} __arch_pack xfs_dir2_sf_entry_t;
|
} __arch_pack xfs_dir2_sf_entry_t;
|
||||||
|
|
||||||
static inline int xfs_dir2_sf_hdr_size(int i8count)
|
static 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)
|
|||||||
INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off);
|
INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_hdr_t *sfp, int len)
|
|
||||||
{
|
|
||||||
return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \
|
|
||||||
((sfp)->i8count == 0) * \
|
|
||||||
((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_hdr_t *sfp, xfs_dir2_sf_entry_t *sfep)
|
xfs_dir2_sf_entsize(struct xfs_dir2_sf_hdr *hdr, int len)
|
||||||
{
|
{
|
||||||
return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (sfep)->namelen - \
|
return sizeof(struct xfs_dir2_sf_entry) + /* namelen + offset */
|
||||||
((sfp)->i8count == 0) * \
|
len + /* name */
|
||||||
((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
|
(hdr->i8count ? /* ino */
|
||||||
|
sizeof(xfs_dir2_ino8_t) :
|
||||||
|
sizeof(xfs_dir2_ino4_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct xfs_dir2_sf_entry *
|
static inline struct xfs_dir2_sf_entry *
|
||||||
@ -128,7 +126,7 @@ xfs_dir2_sf_nextentry(struct xfs_dir2_sf_hdr *hdr,
|
|||||||
struct xfs_dir2_sf_entry *sfep)
|
struct xfs_dir2_sf_entry *sfep)
|
||||||
{
|
{
|
||||||
return (struct xfs_dir2_sf_entry *)
|
return (struct xfs_dir2_sf_entry *)
|
||||||
((char *)sfep + xfs_dir2_sf_entsize_byentry(hdr, sfep));
|
((char *)sfep + xfs_dir2_sf_entsize(hdr, sfep->namelen));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user