Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139641
b: refs/heads/master
c: 039fd8c
h: refs/heads/master
i:
  139639: 1ed4a47
v: v3
  • Loading branch information
Cyrus Massoumi authored and Linus Torvalds committed Apr 3, 2009
1 parent 1b055d6 commit 15f5475
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 45 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b277c884f7856ce0791b1e72079023a86767981b
refs/heads/master: 039fd8ce6258e01ec29f1637f9bf1868dd877c55
2 changes: 1 addition & 1 deletion trunk/fs/ext3/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const struct file_operations ext3_dir_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir,
.readdir = ext3_readdir, /* we take BKL. needed?*/
.ioctl = ext3_ioctl, /* BKL held */
.unlocked_ioctl = ext3_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = ext3_compat_ioctl,
#endif
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/ext3/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const struct file_operations ext3_file_operations = {
.write = do_sync_write,
.aio_read = generic_file_aio_read,
.aio_write = ext3_file_write,
.ioctl = ext3_ioctl,
.unlocked_ioctl = ext3_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = ext3_compat_ioctl,
#endif
Expand Down
59 changes: 20 additions & 39 deletions trunk/fs/ext3/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
#include <linux/mount.h>
#include <linux/time.h>
#include <linux/compat.h>
#include <linux/smp_lock.h>
#include <asm/uaccess.h>

int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
unsigned long arg)
long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
struct inode *inode = filp->f_dentry->d_inode;
struct ext3_inode_info *ei = EXT3_I(inode);
unsigned int flags;
unsigned short rsv_window_size;
Expand All @@ -39,29 +38,25 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
unsigned int oldflags;
unsigned int jflag;

if (!is_owner_or_cap(inode))
return -EACCES;

if (get_user(flags, (int __user *) arg))
return -EFAULT;

err = mnt_want_write(filp->f_path.mnt);
if (err)
return err;

if (!is_owner_or_cap(inode)) {
err = -EACCES;
goto flags_out;
}

if (get_user(flags, (int __user *) arg)) {
err = -EFAULT;
goto flags_out;
}

flags = ext3_mask_flags(inode->i_mode, flags);

mutex_lock(&inode->i_mutex);

/* Is it quota file? Do not allow user to mess with it */
if (IS_NOQUOTA(inode)) {
mutex_unlock(&inode->i_mutex);
err = -EPERM;
err = -EPERM;
if (IS_NOQUOTA(inode))
goto flags_out;
}

oldflags = ei->i_flags;

/* The JOURNAL_DATA flag is modifiable only by root */
Expand All @@ -74,29 +69,21 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
* This test looks nicer. Thanks to Pauline Middelink
*/
if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
if (!capable(CAP_LINUX_IMMUTABLE)) {
mutex_unlock(&inode->i_mutex);
err = -EPERM;
if (!capable(CAP_LINUX_IMMUTABLE))
goto flags_out;
}
}

/*
* The JOURNAL_DATA flag can only be changed by
* the relevant capability.
*/
if ((jflag ^ oldflags) & (EXT3_JOURNAL_DATA_FL)) {
if (!capable(CAP_SYS_RESOURCE)) {
mutex_unlock(&inode->i_mutex);
err = -EPERM;
if (!capable(CAP_SYS_RESOURCE))
goto flags_out;
}
}


handle = ext3_journal_start(inode, 1);
if (IS_ERR(handle)) {
mutex_unlock(&inode->i_mutex);
err = PTR_ERR(handle);
goto flags_out;
}
Expand All @@ -116,15 +103,13 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
err = ext3_mark_iloc_dirty(handle, inode, &iloc);
flags_err:
ext3_journal_stop(handle);
if (err) {
mutex_unlock(&inode->i_mutex);
return err;
}
if (err)
goto flags_out;

if ((jflag ^ oldflags) & (EXT3_JOURNAL_DATA_FL))
err = ext3_change_inode_journal_flag(inode, jflag);
mutex_unlock(&inode->i_mutex);
flags_out:
mutex_unlock(&inode->i_mutex);
mnt_drop_write(filp->f_path.mnt);
return err;
}
Expand All @@ -140,13 +125,15 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,

if (!is_owner_or_cap(inode))
return -EPERM;

err = mnt_want_write(filp->f_path.mnt);
if (err)
return err;
if (get_user(generation, (int __user *) arg)) {
err = -EFAULT;
goto setversion_out;
}

handle = ext3_journal_start(inode, 1);
if (IS_ERR(handle)) {
err = PTR_ERR(handle);
Expand Down Expand Up @@ -299,9 +286,6 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
#ifdef CONFIG_COMPAT
long ext3_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct inode *inode = file->f_path.dentry->d_inode;
int ret;

/* These are just misnamed, they actually get/put from/to user an int */
switch (cmd) {
case EXT3_IOC32_GETFLAGS:
Expand Down Expand Up @@ -341,9 +325,6 @@ long ext3_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
default:
return -ENOIOCTLCMD;
}
lock_kernel();
ret = ext3_ioctl(inode, file, cmd, (unsigned long) compat_ptr(arg));
unlock_kernel();
return ret;
return ext3_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
}
#endif
5 changes: 2 additions & 3 deletions trunk/include/linux/ext3_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -893,9 +893,8 @@ extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
u64 start, u64 len);

/* ioctl.c */
extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
unsigned long);
extern long ext3_compat_ioctl (struct file *, unsigned int, unsigned long);
extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
extern long ext3_compat_ioctl(struct file *, unsigned int, unsigned long);

/* namei.c */
extern int ext3_orphan_add(handle_t *, struct inode *);
Expand Down

0 comments on commit 15f5475

Please sign in to comment.