From: Thomas Veerman Date: Wed, 9 Jun 2010 09:56:43 +0000 (+0000) Subject: Fix a bug in put_inode that causes corruption to the file system and another X-Git-Tag: v3.1.8~484 X-Git-Url: http://zhaoyanbai.com/repos/man.dnssec-settime.html?a=commitdiff_plain;h=a0eaaa5c9f269fb9c6f41fe4646ad39d77650036;p=minix.git 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. --- diff --git a/include/minix/const.h b/include/minix/const.h index f4722189e..4d881fb84 100644 --- a/include/minix/const.h +++ b/include/minix/const.h @@ -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 */ diff --git a/servers/mfs/inode.c b/servers/mfs/inode.c index febd5bea4..81f3441a2 100644 --- a/servers/mfs/inode.c +++ b/servers/mfs/inode.c @@ -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; diff --git a/servers/mfs/link.c b/servers/mfs/link.c index 07ac263fe..2848345fa 100644 --- a/servers/mfs/link.c +++ b/servers/mfs/link.c @@ -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 */ diff --git a/servers/mfs/open.c b/servers/mfs/open.c index b45ec6f74..0e1d62525 100644 --- a/servers/mfs/open.c +++ b/servers/mfs/open.c @@ -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() */ }