aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorRobert Drehmel <robert@FreeBSD.org>2005-05-06 00:06:06 +0000
committerRobert Drehmel <robert@FreeBSD.org>2005-05-06 00:06:06 +0000
commite7aabf96a46aa644db9572f41a6244a82fb173ba (patch)
tree7f3176a97e8883f955e0baa30ec738831e4e12a4 /sys
parentc4c9b52b872066b7106453c20c4a2cc7b1de015a (diff)
downloadsrc-e7aabf96a46aa644db9572f41a6244a82fb173ba.tar.gz
src-e7aabf96a46aa644db9572f41a6244a82fb173ba.zip
Fix our NTFS readdir function.
To check a directory's in-use bitmap bit by bit, we use a pointer to an 8 bit wide unsigned value. The index used to dereference this pointer is calculated by shifting the bit index right 3 bits. Then we do a logical AND with the bit# represented by the lower 3 bits of the bit index. This is an idiomatic way of iterating through a bit map with simple bitwise operations. This commit fixes the bug that we only checked bits 3:0 of each 8 bit chunk, because we only used bits 1:0 of the bit index for the bit# in the current 8 bit value. This resulted in files not being returned by getdirentries(2). Change the type of the bit map pointer from `char *' to `u_int8_t *'.
Notes
Notes: svn path=/head/; revision=145938
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/ntfs/ntfs_subr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/fs/ntfs/ntfs_subr.c b/sys/fs/ntfs/ntfs_subr.c
index fb46539e3ef2..de6ac6015cf5 100644
--- a/sys/fs/ntfs/ntfs_subr.c
+++ b/sys/fs/ntfs/ntfs_subr.c
@@ -1125,7 +1125,7 @@ ntfs_ntreaddir(
struct ntvattr *bmvap = NULL; /* BitMap attribute */
struct ntvattr *iavap = NULL; /* IndexAllocation attribute */
caddr_t rdbuf; /* Buffer to read directory's blocks */
- u_char *bmp = NULL; /* Bitmap */
+ u_int8_t *bmp = NULL; /* Bitmap */
u_int32_t blsize; /* Index allocation size (2048) */
u_int32_t rdsize; /* Length of data to read */
u_int32_t attrnum; /* Current attribute type */
@@ -1162,7 +1162,7 @@ ntfs_ntreaddir(
error = ENOTDIR;
goto fail;
}
- MALLOC(bmp, u_char *, bmvap->va_datalen, M_TEMP, M_WAITOK);
+ MALLOC(bmp, u_int8_t *, bmvap->va_datalen, M_TEMP, M_WAITOK);
error = ntfs_readattr(ntmp, ip, NTFS_A_INDXBITMAP, "$I30", 0,
bmvap->va_datalen, bmp, NULL);
if (error)
@@ -1244,7 +1244,7 @@ ntfs_ntreaddir(
blnum++;
while (ntfs_cntob(blnum * cpbl) < iavap->va_datalen) {
- if (bmp[blnum >> 3] & (1 << (blnum & 3)))
+ if (bmp[blnum >> 3] & (1 << (blnum & 7)))
break;
blnum++;
}