{
struct buffer_head * bh;
struct bfs_dirent * de;
- int block, sblock, eblock, off;
+ int block, sblock, eblock, off, eoff;
int i;
dprintf("name=%s, namelen=%d\n", name, namelen);
sblock = BFS_I(dir)->i_sblock;
eblock = BFS_I(dir)->i_eblock;
+ eoff = dir->i_size % BFS_BSIZE;
for (block=sblock; block<=eblock; block++) {
bh = sb_bread(dir->i_sb, block);
if(!bh)
return -ENOSPC;
for (off=0; off<BFS_BSIZE; off+=BFS_DIRENT_SIZE) {
de = (struct bfs_dirent *)(bh->b_data + off);
+ if (block==eblock && off>=eoff) {
+ /* Do not read/interpret the garbage in the end of eblock. */
+ de->ino = 0;
+ }
if (!de->ino) {
if ((block-sblock)*BFS_BSIZE + off >= dir->i_size) {
dir->i_size += BFS_DIRENT_SIZE;