Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.24 /fs/ext2/ioctl.c

Filename:/fs/ext2/ioctl.c
Lines Added:50
Lines Deleted:0
Also changed in: (Previous) 2.6.24-rc8  2.6.24-rc7  2.6.24-rc6  2.6.24-rc5  2.6.24-rc4  2.6.24-rc3 
(Following) 2.6.24-git16  2.6.24-git17  2.6.24-git18  2.6.24-git19  2.6.24-git20  2.6.24-git21 

Location
[  2.6.24
  [  fs
    [  ext2
       o  ioctl.c

Patch

diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 3bcd254..320b2cb 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -22,6 +22,7 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 {
    struct ext2_inode_info *ei = EXT2_I(inode);
    unsigned int flags;
+   unsigned short rsv_window_size;
 
    ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg);
 
@@ -46,6 +47,11 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
          flags &= ~EXT2_DIRSYNC_FL;
 
       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);
+         return -EPERM;
+      }
       oldflags = ei->i_flags;
 
       /*
@@ -83,6 +89,50 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
       inode->i_ctime = CURRENT_TIME_SEC;
       mark_inode_dirty(inode);
       return 0;
+   case EXT2_IOC_GETRSVSZ:
+      if (test_opt(inode->i_sb, RESERVATION)
+         && S_ISREG(inode->i_mode)
+         && ei->i_block_alloc_info) {
+         rsv_window_size = ei->i_block_alloc_info->rsv_window_node.rsv_goal_size;
+         return put_user(rsv_window_size, (int __user *)arg);
+      }
+      return -ENOTTY;
+   case EXT2_IOC_SETRSVSZ: {
+
+      if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
+         return -ENOTTY;
+
+      if (IS_RDONLY(inode))
+         return -EROFS;
+
+      if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
+         return -EACCES;
+
+      if (get_user(rsv_window_size, (int __user *)arg))
+         return -EFAULT;
+
+      if (rsv_window_size > EXT2_MAX_RESERVE_BLOCKS)
+         rsv_window_size = EXT2_MAX_RESERVE_BLOCKS;
+
+      /*
+       * need to allocate reservation structure for this inode
+       * before set the window size
+       */
+      /*
+       * XXX What lock should protect the rsv_goal_size?
+       * Accessed in ext2_get_block only.  ext3 uses i_truncate.
+       */
+      mutex_lock(&ei->truncate_mutex);
+      if (!ei->i_block_alloc_info)
+         ext2_init_block_alloc_info(inode);
+
+      if (ei->i_block_alloc_info){
+         struct ext2_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node;
+         rsv->rsv_goal_size = rsv_window_size;
+      }
+      mutex_unlock(&ei->truncate_mutex);
+      return 0;
+   }
    default:
       return -ENOTTY;
    }


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.