At about the time of 4/4/2007 3:51 AM, Barry stated the following:
"Daniel Rudy" <sp******@spamthis.netwrote in message
news:lw*****************@newssvr21.news.prodigy.ne t...
>Hello Group,
With all the different threads lately about bit operations, I'm
wondering if you can do this:
typedef unsigned long uint32
uint32 eof;
uint32 bmap;
uint32 blocksect;
uint32 sectsize;
uint32 i;
...
blocksect = 4;
sectsize = 512;
bmap = usbdev.fcb[x].inode.bitmap;
...
for (i = 0; i < blocksect; i++)
eof += (((bmap <<= 1 & 0x80000000) != 0) ? 1 : 0) * sectsize;
...
You can do it, but it probably isn't what you want.
This will & 1 with 0x80000000 and then shift bmap the 0 bits
yielded from that &. I am guessing you want:
eof += ((((bmap <<= 1) & 0x80000000) != 0) ? 1 : 0) * sectsize;
Good eye.
Here's the entire function that has that line in it...
/* computes the file EOF from the inode data */
static uint32 fs_inode_ceof(int fd)
{
uint32 i; /* generic counter */
uint32 eof; /* end of file pointer (file size in bytes) */
uint32 blocksize; /* size of disk block (in bytes) */
bmap_t bmap; /* sector bitmap (eof block fragment map) */
eof = 0;
blocksize = usbdev.sect_block * usbdev.sect_size;
bmap = usbdev.fcb[fd].inode.bitmap;
for (i = 0; i < FS_MAXFRAG; i++)
{
eof += usbdev.fcb[fd].inode.loc[i].length * blocksize;
}
if (bmap != 0)
{
eof -= blocksize;
for (i = 0; i < usbdev.sect_block; i++)
{
eof += ((((bmap <<= 1) & FS_BITMASK) == 0) ? 0 : 1) *
usbdev.sect_size;
}
eof += usbdev.fcb[fd].inode.mod;
}
return(eof);
}
--
Daniel Rudy
Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m
Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep