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/dquot.c | |
parent | 9c1c01ead627bdda9211c9abd5b758d6c687d8ac (diff) |
Merge with Linux 2.2.8.
Diffstat (limited to 'fs/dquot.c')
-rw-r--r-- | fs/dquot.c | 98 |
1 files changed, 40 insertions, 58 deletions
diff --git a/fs/dquot.c b/fs/dquot.c index 8b7d07295..76630352f 100644 --- a/fs/dquot.c +++ b/fs/dquot.c @@ -483,7 +483,10 @@ got_it: if (dquot->dq_flags & (DQ_LOCKED | DQ_MOD)) { wait_on_dquot(dquot); if (dquot->dq_flags & DQ_MOD) - write_dquot(dquot); + { + if(dquot->dq_mnt != (struct vfsmount *)NULL) + write_dquot(dquot); + } /* * The dquot may be back in use now, so we * must recheck the free list. @@ -1265,11 +1268,11 @@ out: int quota_on(kdev_t dev, short type, char *path) { - struct file *filp = NULL; - struct dentry *dentry; + struct file *f; struct vfsmount *vfsmnt; struct inode *inode; struct dquot *dquot; + struct quota_mount_options *mnt_dquot; char *tmp; int error; @@ -1278,69 +1281,48 @@ int quota_on(kdev_t dev, short type, char *path) return -ENODEV; if (is_enabled(vfsmnt, type)) - return(-EBUSY); + return -EBUSY; + mnt_dquot = &vfsmnt->mnt_dquot; tmp = getname(path); error = PTR_ERR(tmp); if (IS_ERR(tmp)) return error; - dentry = open_namei(tmp, O_RDWR, 0600); + f = filp_open(tmp, O_RDWR, 0600); putname(tmp); + if (IS_ERR(f)) + return PTR_ERR(f); + + /* sanity checks */ + error = -EIO; + if (!f->f_op->read && !f->f_op->write) + goto cleanup; + inode = f->f_dentry->d_inode; + error = -EACCES; + if (!S_ISREG(inode->i_mode)) + goto cleanup; + error = -EINVAL; + if (inode->i_size == 0 || (inode->i_size % sizeof(struct dqblk)) != 0) + goto cleanup; + + /* OK, there we go */ + set_enable_flags(vfsmnt, type); + mnt_dquot->files[type] = f; + + dquot = dqget(dev, 0, type); + mnt_dquot->inode_expire[type] = (dquot) ? dquot->dq_itime : MAX_IQ_TIME; + mnt_dquot->block_expire[type] = (dquot) ? dquot->dq_btime : MAX_DQ_TIME; + dqput(dquot); - error = PTR_ERR(dentry); - if (IS_ERR(dentry)) - return error; - inode = dentry->d_inode; - - if (!S_ISREG(inode->i_mode)) { - dput(dentry); - return -EACCES; - } - - if (inode->i_size == 0 || (inode->i_size % sizeof(struct dqblk)) != 0) { - dput(dentry); - return(-EINVAL); - } - - filp = get_empty_filp(); - if (filp != (struct file *)NULL) { - filp->f_mode = (O_RDWR + 1) & O_ACCMODE; - filp->f_flags = O_RDWR; - filp->f_dentry = dentry; - filp->f_pos = 0; - filp->f_reada = 0; - filp->f_op = inode->i_op->default_file_ops; - if (filp->f_op->read || filp->f_op->write) { - error = get_write_access(inode); - if (!error) { - if (filp->f_op && filp->f_op->open) - error = filp->f_op->open(inode, filp); - if (!error) { - set_enable_flags(vfsmnt, type); - vfsmnt->mnt_dquot.files[type] = filp; - - dquot = dqget(dev, 0, type); - vfsmnt->mnt_dquot.inode_expire[type] = (dquot) ? dquot->dq_itime : MAX_IQ_TIME; - vfsmnt->mnt_dquot.block_expire[type] = (dquot) ? dquot->dq_btime : MAX_DQ_TIME; - dqput(dquot); - - vfsmnt->mnt_sb->dq_op = &dquot_operations; - add_dquot_ref(dev, type); - - return(0); - } - put_write_access(inode); - } - } else - error = -EIO; - put_filp(filp); - } else - error = -EMFILE; + vfsmnt->mnt_sb->dq_op = &dquot_operations; + add_dquot_ref(dev, type); - dput(dentry); + return(0); - return(error); +cleanup: + fput(f); + return error; } /* @@ -1367,8 +1349,8 @@ asmlinkage int sys_quotactl(int cmd, const char *special, int id, caddr_t addr) case Q_GETSTATS: break; case Q_GETQUOTA: - if (((type == USRQUOTA && current->uid != id) || - (type == GRPQUOTA && current->gid != id)) && + if (((type == USRQUOTA && current->euid != id) || + (type == GRPQUOTA && current->egid != id)) && !capable(CAP_SYS_RESOURCE)) goto out; break; |