Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 26208
b: refs/heads/master
c: a090d91
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro authored and Linus Torvalds committed Apr 26, 2006
1 parent bcbc8fb commit 9de75aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 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: 6ad0013b316367671ef316cff91ab2d912e309c9
refs/heads/master: a090d9132c1e53e3517111123680c15afb25c0a4
18 changes: 14 additions & 4 deletions trunk/fs/ext3/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
if (!S_ISDIR(inode->i_mode))
flags &= ~EXT3_DIRSYNC_FL;

mutex_lock(&inode->i_mutex);
oldflags = ei->i_flags;

/* The JOURNAL_DATA flag is modifiable only by root */
Expand All @@ -60,23 +61,29 @@ 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))
if (!capable(CAP_LINUX_IMMUTABLE)) {
mutex_unlock(&inode->i_mutex);
return -EPERM;
}
}

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


handle = ext3_journal_start(inode, 1);
if (IS_ERR(handle))
if (IS_ERR(handle)) {
mutex_unlock(&inode->i_mutex);
return PTR_ERR(handle);
}
if (IS_SYNC(inode))
handle->h_sync = 1;
err = ext3_reserve_inode_write(handle, inode, &iloc);
Expand All @@ -93,11 +100,14 @@ 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)
if (err) {
mutex_unlock(&inode->i_mutex);
return err;
}

if ((jflag ^ oldflags) & (EXT3_JOURNAL_DATA_FL))
err = ext3_change_inode_journal_flag(inode, jflag);
mutex_unlock(&inode->i_mutex);
return err;
}
case EXT3_IOC_GETVERSION:
Expand Down

0 comments on commit 9de75aa

Please sign in to comment.