diff options
author | robert <robert@FreeBSD.org> | 2005-05-06 00:06:06 +0000 |
---|---|---|
committer | robert <robert@FreeBSD.org> | 2005-05-06 00:06:06 +0000 |
commit | 46abb4815c0ae6b1f17a40fd0166b4da700d8d8f (patch) | |
tree | 7f3176a97e8883f955e0baa30ec738831e4e12a4 /sys/fs | |
parent | 8ff6ea60ca4dfffaaff332e3162ecddd3a14e98b (diff) | |
download | FreeBSD-src-46abb4815c0ae6b1f17a40fd0166b4da700d8d8f.zip FreeBSD-src-46abb4815c0ae6b1f17a40fd0166b4da700d8d8f.tar.gz |
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 *'.
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/ntfs/ntfs_subr.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/fs/ntfs/ntfs_subr.c b/sys/fs/ntfs/ntfs_subr.c index fb46539..de6ac60 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++; } |