diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-06-13 16:29:25 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-06-13 16:29:25 +0000 |
commit | db7d4daea91e105e3859cf461d7e53b9b77454b2 (patch) | |
tree | 9bb65b95440af09e8aca63abe56970dd3360cc57 /fs/ext2 | |
parent | 9c1c01ead627bdda9211c9abd5b758d6c687d8ac (diff) |
Merge with Linux 2.2.8.
Diffstat (limited to 'fs/ext2')
-rw-r--r-- | fs/ext2/dir.c | 2 | ||||
-rw-r--r-- | fs/ext2/inode.c | 22 | ||||
-rw-r--r-- | fs/ext2/namei.c | 103 | ||||
-rw-r--r-- | fs/ext2/super.c | 20 |
4 files changed, 36 insertions, 111 deletions
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index 22af55334..a6753d276 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c @@ -115,8 +115,6 @@ static int ext2_readdir(struct file * filp, int err; struct inode *inode = filp->f_dentry->d_inode; - if (!inode || !S_ISDIR(inode->i_mode)) - return -EBADF; sb = inode->i_sb; stored = 0; diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index f0f2ca98f..8bd5c9684 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -286,7 +286,8 @@ static struct buffer_head * block_getblk (struct inode * inode, u32 * p; struct buffer_head * result; int blocks = inode->i_sb->s_blocksize / 512; - + unsigned long limit; + if (!bh) return NULL; if (!buffer_uptodate(bh)) { @@ -309,13 +310,22 @@ repeat: brelse (result); goto repeat; } - if (!create || new_block >= - (current->rlim[RLIMIT_FSIZE].rlim_cur >> - EXT2_BLOCK_SIZE_BITS(inode->i_sb))) { + *err = -EFBIG; + if (!create) { brelse (bh); - *err = -EFBIG; return NULL; } + + limit = current->rlim[RLIMIT_FSIZE].rlim_cur; + if (limit < RLIM_INFINITY) { + limit >>= EXT2_BLOCK_SIZE_BITS(inode->i_sb); + if (new_block >= limit) { + brelse (bh); + send_sig(SIGXFSZ, current, 0); + return NULL; + } + } + if (inode->u.ext2_i.i_next_alloc_block == new_block) goal = inode->u.ext2_i.i_next_alloc_goal; if (!goal) { @@ -697,7 +707,7 @@ static int ext2_update_inode(struct inode * inode, int do_sync) if (buffer_req(bh) && !buffer_uptodate(bh)) { printk ("IO error syncing ext2 inode [" "%s:%08lx]\n", - kdevname(inode->i_dev), inode->i_ino); + bdevname(inode->i_dev), inode->i_ino); err = -EIO; } } diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 5f66f5dab..7a309fa77 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c @@ -74,8 +74,6 @@ static struct buffer_head * ext2_find_entry (struct inode * dir, int block, toread, i, err; *res_dir = NULL; - if (!dir) - return NULL; sb = dir->i_sb; if (namelen > EXT2_NAME_LEN) @@ -168,14 +166,14 @@ failure: return NULL; } -int ext2_lookup(struct inode * dir, struct dentry *dentry) +struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry) { struct inode * inode; struct ext2_dir_entry_2 * de; struct buffer_head * bh; if (dentry->d_name.len > EXT2_NAME_LEN) - return -ENAMETOOLONG; + return ERR_PTR(-ENAMETOOLONG); bh = ext2_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &de); inode = NULL; @@ -185,10 +183,10 @@ int ext2_lookup(struct inode * dir, struct dentry *dentry) inode = iget(dir->i_sb, ino); if (!inode) - return -EACCES; + return ERR_PTR(-EACCES); } d_add(dentry, inode); - return 0; + return NULL; } /* @@ -218,12 +216,6 @@ static struct buffer_head * ext2_add_entry (struct inode * dir, return NULL; sb = dir->i_sb; - if (namelen > EXT2_NAME_LEN) - { - *err = -ENAMETOOLONG; - return NULL; - } - if (!namelen) return NULL; /* @@ -409,10 +401,6 @@ int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, int rdev) struct ext2_dir_entry_2 * de; int err = -EIO; - err = -ENAMETOOLONG; - if (dentry->d_name.len > EXT2_NAME_LEN) - goto out; - inode = ext2_new_inode (dir, mode, &err); if (!inode) goto out; @@ -474,10 +462,6 @@ int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode) struct ext2_dir_entry_2 * de; int err; - err = -ENAMETOOLONG; - if (dentry->d_name.len > EXT2_NAME_LEN) - goto out; - err = -EMLINK; if (dir->i_nlink >= EXT2_LINK_MAX) goto out; @@ -618,10 +602,6 @@ int ext2_rmdir (struct inode * dir, struct dentry *dentry) struct buffer_head * bh; struct ext2_dir_entry_2 * de; - retval = -ENAMETOOLONG; - if (dentry->d_name.len > EXT2_NAME_LEN) - goto out; - retval = -ENOENT; bh = ext2_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &de); if (!bh) @@ -634,14 +614,12 @@ int ext2_rmdir (struct inode * dir, struct dentry *dentry) if (le32_to_cpu(de->inode) != inode->i_ino) goto end_rmdir; + retval = -ENOTEMPTY; if (!empty_dir (inode)) - retval = -ENOTEMPTY; - else if (le32_to_cpu(de->inode) != inode->i_ino) - retval = -ENOENT; - else { - retval = ext2_delete_entry (de, bh); - dir->i_version = ++event; - } + goto end_rmdir; + + retval = ext2_delete_entry (de, bh); + dir->i_version = ++event; if (retval) goto end_rmdir; mark_buffer_dirty(bh, 1); @@ -665,7 +643,6 @@ int ext2_rmdir (struct inode * dir, struct dentry *dentry) end_rmdir: brelse (bh); -out: return retval; } @@ -676,10 +653,6 @@ int ext2_unlink(struct inode * dir, struct dentry *dentry) struct buffer_head * bh; struct ext2_dir_entry_2 * de; - retval = -ENAMETOOLONG; - if (dentry->d_name.len > EXT2_NAME_LEN) - goto out; - retval = -ENOENT; bh = ext2_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &de); if (!bh) @@ -718,7 +691,6 @@ int ext2_unlink(struct inode * dir, struct dentry *dentry) end_unlink: brelse (bh); -out: return retval; } @@ -805,9 +777,6 @@ int ext2_link (struct dentry * old_dentry, if (S_ISDIR(inode->i_mode)) return -EPERM; - if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) - return -EPERM; - if (inode->i_nlink >= EXT2_LINK_MAX) return -EMLINK; @@ -851,17 +820,10 @@ int ext2_link (struct dentry * old_dentry, le16_to_cpu(((struct ext2_dir_entry_2 *) buffer)->rec_len)))->inode /* - * rename uses retrying to avoid race-conditions: at least they should be - * minimal. - * it tries to allocate all the blocks, then sanity-checks, and if the sanity- - * checks fail, it tries to restart itself again. Very practical - no changes - * are done until we know everything works ok.. and then all the changes can be - * done in one fell swoop when we have claimed all the buffers needed. - * * Anybody can rename anything with this: the permission checks are left to the * higher-level routines. */ -static int do_ext2_rename (struct inode * old_dir, struct dentry *old_dentry, +int ext2_rename (struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry) { struct inode * old_inode, * new_inode; @@ -870,9 +832,6 @@ static int do_ext2_rename (struct inode * old_dir, struct dentry *old_dentry, int retval; old_bh = new_bh = dir_bh = NULL; - retval = -ENAMETOOLONG; - if (old_dentry->d_name.len > EXT2_NAME_LEN) - goto end_rename; old_bh = ext2_find_entry (old_dir, old_dentry->d_name.name, old_dentry->d_name.len, &old_de); /* @@ -897,24 +856,13 @@ static int do_ext2_rename (struct inode * old_dir, struct dentry *old_dentry, DQUOT_INIT(new_inode); } } - retval = 0; - if (new_inode == old_inode) - goto end_rename; if (S_ISDIR(old_inode->i_mode)) { - retval = -EINVAL; - if (is_subdir(new_dentry, old_dentry)) - goto end_rename; if (new_inode) { - /* Prune any children before testing for busy */ - if (new_dentry->d_count > 1) - shrink_dcache_parent(new_dentry); - retval = -EBUSY; - if (new_dentry->d_count > 1) - goto end_rename; retval = -ENOTEMPTY; if (!empty_dir (new_inode)) goto end_rename; } + retval = -EIO; dir_bh = ext2_bread (old_inode, 0, 0, &retval); if (!dir_bh) goto end_rename; @@ -977,8 +925,6 @@ static int do_ext2_rename (struct inode * old_dir, struct dentry *old_dentry, wait_on_buffer (new_bh); } - /* Update the dcache */ - d_move(old_dentry, new_dentry); retval = 0; end_rename: @@ -987,30 +933,3 @@ end_rename: brelse (new_bh); return retval; } - -/* - * Ok, rename also locks out other renames, as they can change the parent of - * a directory, and we don't want any races. Other races are checked for by - * "do_rename()", which restarts if there are inconsistencies. - * - * Note that there is no race between different filesystems: it's only within - * the same device that races occur: many renames can happen at once, as long - * as they are on different partitions. - * - * In the second extended file system, we use a lock flag stored in the memory - * super-block. This way, we really lock other renames only if they occur - * on the same file system - */ -int ext2_rename (struct inode * old_dir, struct dentry *old_dentry, - struct inode * new_dir, struct dentry *new_dentry) -{ - int result; - - while (old_dir->i_sb->u.ext2_sb.s_rename_lock) - sleep_on (&old_dir->i_sb->u.ext2_sb.s_rename_wait); - old_dir->i_sb->u.ext2_sb.s_rename_lock = 1; - result = do_ext2_rename (old_dir, old_dentry, new_dir, new_dentry); - old_dir->i_sb->u.ext2_sb.s_rename_lock = 0; - wake_up (&old_dir->i_sb->u.ext2_sb.s_rename_wait); - return result; -} diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 674a5043c..b7c08a009 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -56,9 +56,9 @@ void ext2_error (struct super_block * sb, const char * function, (le16_to_cpu(sb->u.ext2_sb.s_es->s_errors) == EXT2_ERRORS_PANIC && !test_opt (sb, ERRORS_CONT) && !test_opt (sb, ERRORS_RO))) panic ("EXT2-fs panic (device %s): %s: %s\n", - kdevname(sb->s_dev), function, error_buf); + bdevname(sb->s_dev), function, error_buf); printk (KERN_CRIT "EXT2-fs error (device %s): %s: %s\n", - kdevname(sb->s_dev), function, error_buf); + bdevname(sb->s_dev), function, error_buf); if (test_opt (sb, ERRORS_RO) || (le16_to_cpu(sb->u.ext2_sb.s_es->s_errors) == EXT2_ERRORS_RO && !test_opt (sb, ERRORS_CONT) && !test_opt (sb, ERRORS_PANIC))) { @@ -87,7 +87,7 @@ NORET_TYPE void ext2_panic (struct super_block * sb, const char * function, sb->s_lock=0; sb->s_flags |= MS_RDONLY; panic ("EXT2-fs panic (device %s): %s: %s\n", - kdevname(sb->s_dev), function, error_buf); + bdevname(sb->s_dev), function, error_buf); } void ext2_warning (struct super_block * sb, const char * function, @@ -99,7 +99,7 @@ void ext2_warning (struct super_block * sb, const char * function, vsprintf (error_buf, fmt, args); va_end (args); printk (KERN_WARNING "EXT2-fs warning (device %s): %s: %s\n", - kdevname(sb->s_dev), function, error_buf); + bdevname(sb->s_dev), function, error_buf); } void ext2_put_super (struct super_block * sb) @@ -444,7 +444,7 @@ struct super_block * ext2_read_super (struct super_block * sb, void * data, if (sb->s_magic != EXT2_SUPER_MAGIC) { if (!silent) printk ("VFS: Can't find an ext2 filesystem on dev " - "%s.\n", kdevname(dev)); + "%s.\n", bdevname(dev)); failed_mount: sb->s_dev = 0; unlock_super (sb); @@ -457,14 +457,14 @@ struct super_block * ext2_read_super (struct super_block * sb, void * data, if (le32_to_cpu(es->s_feature_incompat) & ~EXT2_FEATURE_INCOMPAT_SUPP) { printk("EXT2-fs: %s: couldn't mount because of " "unsupported optional features.\n", - kdevname(dev)); + bdevname(dev)); goto failed_mount; } if (!(sb->s_flags & MS_RDONLY) && (le32_to_cpu(es->s_feature_ro_compat) & ~EXT2_FEATURE_RO_COMPAT_SUPP)) { printk("EXT2-fs: %s: couldn't mount RDWR because of " "unsupported optional features.\n", - kdevname(dev)); + bdevname(dev)); goto failed_mount; } } @@ -543,8 +543,6 @@ struct super_block * ext2_read_super (struct super_block * sb, void * data, else sb->u.ext2_sb.s_resgid = le16_to_cpu(es->s_def_resgid); sb->u.ext2_sb.s_mount_state = le16_to_cpu(es->s_state); - sb->u.ext2_sb.s_rename_lock = 0; - sb->u.ext2_sb.s_rename_wait = NULL; sb->u.ext2_sb.s_addr_per_block_bits = log2 (EXT2_ADDR_PER_BLOCK(sb)); sb->u.ext2_sb.s_desc_per_block_bits = @@ -553,13 +551,13 @@ struct super_block * ext2_read_super (struct super_block * sb, void * data, if (!silent) printk ("VFS: Can't find an ext2 filesystem on dev " "%s.\n", - kdevname(dev)); + bdevname(dev)); goto failed_mount; } if (sb->s_blocksize != bh->b_size) { if (!silent) printk ("VFS: Unsupported blocksize on dev " - "%s.\n", kdevname(dev)); + "%s.\n", bdevname(dev)); goto failed_mount; } |