From 14cbd02b8a1a4f1d3c30dd4fb2864d35f39a95eb Mon Sep 17 00:00:00 2001 From: Tim Creech Date: Thu, 29 Aug 2019 21:35:36 -0400 Subject: [PATCH] FBSD: Accommodate 12.0's 64-bit inodes In FreeBSD 12 (see: https://reviews.freebsd.org/rS318736), the layout of struct dirent changed to allow for 64-bit inodes and a few other changes. Update our struct min_direct to accommodate, to allow our readdir() results to be accurate. Without this, readdir() can yield garbage entries, due to the mismatch in the structure definitions. Change-Id: I36c2bf1f35b4d1ab61a2b4d51da7514827b3551b Reviewed-on: https://gerrit.openafs.org/13854 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/afs/VNOPS/afs_vnop_readdir.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/afs/VNOPS/afs_vnop_readdir.c b/src/afs/VNOPS/afs_vnop_readdir.c index 7bfc629f8a..8d41c3ef26 100644 --- a/src/afs/VNOPS/afs_vnop_readdir.c +++ b/src/afs/VNOPS/afs_vnop_readdir.c @@ -158,6 +158,15 @@ struct min_direct { /* miniature direct structure */ uint16_t d_reclen; /* length of this record */ uint16_t d_namlen; /* length of string in d_name */ uint8_t d_type; /* file type, see below */ +#elif defined(AFS_FBSD120_ENV) + /* FreeBSD 12.0 moved to 64-bit inodes and bumped d_namlen to 16 bits. */ + ino_t d_fileno; + off_t d_off; + u_short d_reclen; + u_char d_type; + u_char d_pad0; + u_short d_namlen; + u_short d_pad1; #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) afs_uint32 d_fileno; u_short d_reclen; @@ -317,6 +326,7 @@ afs_readdir_move(struct DirEntry *de, struct vcache *vc, struct uio *auio, #endif /* AFS_SUN5_ENV */ #ifndef AFS_SGI53_ENV struct min_direct sdirEntry; + memset(&sdirEntry, 0, sizeof(sdirEntry)); #endif /* AFS_SGI53_ENV */ AFS_STATCNT(afs_readdir_move);