Fix a bug in put_inode that causes corruption to the file system and another

bug that causes problems when files grow bigger than a certain threshold. Also
fix a few type and code inconsistencies.
This commit is contained in:
Thomas Veerman 2010-06-09 09:56:43 +00:00
parent 1207fcc6f0
commit a0eaaa5c9f
4 changed files with 9 additions and 6 deletions

View File

@ -150,7 +150,7 @@
/* Some limits. */
#define MAX_INODE_NR ((ino_t) 037777777777) /* largest inode number */
#define MAX_FILE_POS ((off_t) 0x7FFFFFFF) /* largest legal file offset */
#define UMAX_FILE_POS ((unsigned) 0x7FFFFFF) /* largest legal file offset */
#define UMAX_FILE_POS ((unsigned) 0x7FFFFFFF) /* largest legal file offset */
#define MAX_SYM_LOOPS 8 /* how many symbolic links are recursed */

View File

@ -226,7 +226,10 @@ register struct inode *rip; /* pointer to inode to be released */
if (rip->i_nlinks == NO_LINK) {
/* i_nlinks == NO_LINK means free the inode. */
/* return all the disk blocks */
if (truncate_inode(rip, (off_t) 0) != OK) return;
if (truncate_inode(rip, (off_t) 0) != OK) {
printf("MFS: truncate of inode %u on dev %d failed\n",
rip->i_num, rip->i_dev);
}
rip->i_mode = I_NOT_ALLOC; /* clear I_TYPE field */
rip->i_dirt = DIRTY;
free_inode(rip->i_dev, rip->i_num);
@ -339,7 +342,7 @@ PRIVATE void free_inode(
/* Locate the appropriate super_block. */
sp = get_super(dev);
if (inumb > sp->s_ninodes) return;
if (inumb == NO_ENTRY || inumb > sp->s_ninodes) return;
b = (bit_t) inumb;
free_bit(sp, IMAP, b);
if (b < sp->s_isearch) sp->s_isearch = b;

View File

@ -217,7 +217,7 @@ char dir_name[NAME_MAX]; /* name of directory to be removed */
int r;
/* search_dir checks that rip is a directory too. */
if ((r = search_dir(rip, "", (ino_t *) 0, IS_EMPTY, IGN_PERM)) != OK)
if ((r = search_dir(rip, "", NULL, IS_EMPTY, IGN_PERM)) != OK)
return(r);
if (strcmp(dir_name, ".") == 0 || strcmp(dir_name, "..") == 0)return(EINVAL);
@ -258,7 +258,7 @@ char file_name[NAME_MAX]; /* name of file to be removed */
dup_inode(rip); /* inode will be returned with put_inode */
}
r = search_dir(dirp, file_name, (ino_t *) 0, DELETE, IGN_PERM);
r = search_dir(dirp, file_name, NULL, DELETE, IGN_PERM);
if (r == OK) {
rip->i_nlinks--; /* entry deleted from parent's dir */

View File

@ -155,7 +155,7 @@ PUBLIC int fs_mkdir()
} else {
/* It was not possible to enter . or .. probably disk was full -
* links counts haven't been touched. */
if(search_dir(ldirp, lastc, (ino_t *) 0, DELETE, IGN_PERM) != OK)
if(search_dir(ldirp, lastc, NULL, DELETE, IGN_PERM) != OK)
panic("Dir disappeared: %ul", rip->i_num);
rip->i_nlinks--; /* undo the increment done in new_node() */
}