summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2005-05-24 05:43:32 +0000
committerBrad Smith <brad@cvs.openbsd.org>2005-05-24 05:43:32 +0000
commit7a6e90a24ababc01e84a168be0d99e0c06d2dea2 (patch)
tree21dec0bed41c51cade59d04416b84271d2e63867 /sys
parent757d44844da85b55fbad10cfaa740dcfa9b26579 (diff)
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 *'. From FreeBSD ok pedro
Diffstat (limited to 'sys')
-rw-r--r--sys/ntfs/ntfs_subr.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/ntfs/ntfs_subr.c b/sys/ntfs/ntfs_subr.c
index cbb0d441243..2e0689df8d1 100644
--- a/sys/ntfs/ntfs_subr.c
+++ b/sys/ntfs/ntfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntfs_subr.c,v 1.6 2005/05/22 04:38:54 brad Exp $ */
+/* $OpenBSD: ntfs_subr.c,v 1.7 2005/05/24 05:43:31 brad Exp $ */
/* $NetBSD: ntfs_subr.c,v 1.4 2003/04/10 21:37:32 jdolecek Exp $ */
/*-
@@ -1244,7 +1244,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 */
@@ -1285,7 +1285,7 @@ ntfs_ntreaddir(
error = ENOTDIR;
goto fail;
}
- bmp = (u_char *) malloc(bmvap->va_datalen, M_TEMP, M_WAITOK);
+ bmp = (u_int8_t *) malloc(bmvap->va_datalen, M_TEMP, M_WAITOK);
error = ntfs_readattr(ntmp, ip, NTFS_A_INDXBITMAP, "$I30", 0,
bmvap->va_datalen, bmp, NULL);
if (error)
@@ -1367,7 +1367,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++;
}