patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / fs / bfs / dir.c
index 09db6f3..4656ecc 100644 (file)
@@ -274,7 +274,7 @@ static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int
 {
        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);
@@ -286,12 +286,17 @@ static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int
 
        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;