Messages in this thread | | | Date | Tue, 4 May 1999 07:01:08 -0400 (EDT) | From | Alexander Viro <> | Subject | Re: [PATCH] Minor cleanup/fix in quota_on(). |
| |
On Tue, 4 May 1999, Jan Kara wrote:
> > quota_on() contains almost verbatim copy of filp_open(), except > > that it returns EMFILE instead of ENFILE (wrong, since EMFILE is about > > per-process limit and it's not the case here) and calls open_namei() with > > slightly wrong arguments (as the result read permissions are not checked). > > I replaced the cruft with call of filp_open(). Could you apply the > > following patch? > Ooops. Your patch seems to collide with mine fixes in quotas (I also did some > cleanup in quota_on, added locks for serializing quota_on, quota_off...). I'll > probably merge your cleanup with mine and submit it...
I've looked at your patch now. Seems to be trivially mergeable with mine - new version of quota_on in the combined variant would looks so:
int quota_on(kdev_t dev, short type, char *path) { struct file *f; struct vfsmount *vfsmnt; struct inode *inode; struct dquot *dquot; struct quota_mount_options *mnt_dquot; char *tmp; int error;
vfsmnt = lookup_vfsmnt(dev); if (vfsmnt == (struct vfsmount *)NULL) return -ENODEV;
if (is_enabled(vfsmnt, type)) return -EBUSY;
mnt_dquot = &vfsmnt->mnt_dquot; down(&mnt_dquot.dqoff_sem); tmp = getname(path); error = PTR_ERR(tmp); if (IS_ERR(tmp)) goto out_lock;
f = filp_open(tmp, O_RDWR, 0600); putname(tmp);
error = PTR_ERR(f); if (IS_ERR(f)) goto out_lock; error = -EIO; if (!f->f_op->read && !f->f_op->write) goto out_f; inode = f->f_dentry->d_inode; error = -EACCES; if (!S_ISREG(inode->i_mode)) goto out_f; error = -EINVAL; if (inode->i_size == 0 || (inode->i_size % sizeof(struct dqblk)) != 0) goto out_f;
set_enable_flags(vfsmnt, type); mnt_dquot.files[type] = f;
dquot = dqget(dev, 0, type); mnt_dquot.inode_expire[type] = (dquot != NODQUOT) ? dquot->dq_itime : MAX_IQ_TIME; mnt_dquot.block_expire[type] = (dquot != NODQUOT) ? dquot->dq_btime : MAX_DQ_TIME; dqput(dquot);
mnt_sb->dq_op = &dquot_operations; add_dquot_ref(dev, type);
up(&mnt_dquot.dqoff_sem); return 0;
out_f: filp_close(f, NULL); out_lock: up(&mnt_dquot.dqoff_sem);
return error; } Cheers, Al
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |