| 1 |
void abort(void); |
| 2 |
void exit(int); |
| 3 |
|
| 4 |
struct inode { |
| 5 |
long long i_size; |
| 6 |
struct super_block *i_sb; |
| 7 |
}; |
| 8 |
|
| 9 |
struct file { |
| 10 |
long long f_pos; |
| 11 |
}; |
| 12 |
|
| 13 |
struct super_block { |
| 14 |
int s_blocksize; |
| 15 |
unsigned char s_blocksize_bits; |
| 16 |
int s_hs; |
| 17 |
}; |
| 18 |
|
| 19 |
static char * |
| 20 |
isofs_bread(unsigned int block) |
| 21 |
{ |
| 22 |
if (block) |
| 23 |
abort (); |
| 24 |
exit(0); |
| 25 |
} |
| 26 |
|
| 27 |
static int |
| 28 |
do_isofs_readdir(struct inode *inode, struct file *filp) |
| 29 |
{ |
| 30 |
int bufsize = inode->i_sb->s_blocksize; |
| 31 |
unsigned char bufbits = inode->i_sb->s_blocksize_bits; |
| 32 |
unsigned int block, offset; |
| 33 |
char *bh = 0; |
| 34 |
int hs; |
| 35 |
|
| 36 |
if (filp->f_pos >= inode->i_size) |
| 37 |
return 0; |
| 38 |
|
| 39 |
offset = filp->f_pos & (bufsize - 1); |
| 40 |
block = filp->f_pos >> bufbits; |
| 41 |
hs = inode->i_sb->s_hs; |
| 42 |
|
| 43 |
while (filp->f_pos < inode->i_size) { |
| 44 |
if (!bh) |
| 45 |
bh = isofs_bread(block); |
| 46 |
|
| 47 |
hs += block << bufbits; |
| 48 |
|
| 49 |
if (hs == 0) |
| 50 |
filp->f_pos++; |
| 51 |
|
| 52 |
if (offset >= bufsize) |
| 53 |
offset &= bufsize - 1; |
| 54 |
|
| 55 |
if (*bh) |
| 56 |
filp->f_pos++; |
| 57 |
|
| 58 |
filp->f_pos++; |
| 59 |
} |
| 60 |
return 0; |
| 61 |
} |
| 62 |
|
| 63 |
struct super_block s; |
| 64 |
struct inode i; |
| 65 |
struct file f; |
| 66 |
|
| 67 |
int |
| 68 |
main(int argc, char **argv) |
| 69 |
{ |
| 70 |
s.s_blocksize = 512; |
| 71 |
s.s_blocksize_bits = 9; |
| 72 |
i.i_size = 2048; |
| 73 |
i.i_sb = &s; |
| 74 |
f.f_pos = 0; |
| 75 |
|
| 76 |
do_isofs_readdir(&i,&f); |
| 77 |
abort (); |
| 78 |
} |