diff options
Diffstat (limited to 'fs/ext2/ioctl.c')
-rw-r--r-- | fs/ext2/ioctl.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c index 3bcd25422ee4..c2324d5fe4ac 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, | |||
22 | { | 22 | { |
23 | struct ext2_inode_info *ei = EXT2_I(inode); | 23 | struct ext2_inode_info *ei = EXT2_I(inode); |
24 | unsigned int flags; | 24 | unsigned int flags; |
25 | unsigned short rsv_window_size; | ||
25 | 26 | ||
26 | ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg); | 27 | ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg); |
27 | 28 | ||
@@ -83,6 +84,50 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, | |||
83 | inode->i_ctime = CURRENT_TIME_SEC; | 84 | inode->i_ctime = CURRENT_TIME_SEC; |
84 | mark_inode_dirty(inode); | 85 | mark_inode_dirty(inode); |
85 | return 0; | 86 | return 0; |
87 | case EXT2_IOC_GETRSVSZ: | ||
88 | if (test_opt(inode->i_sb, RESERVATION) | ||
89 | && S_ISREG(inode->i_mode) | ||
90 | && ei->i_block_alloc_info) { | ||
91 | rsv_window_size = ei->i_block_alloc_info->rsv_window_node.rsv_goal_size; | ||
92 | return put_user(rsv_window_size, (int __user *)arg); | ||
93 | } | ||
94 | return -ENOTTY; | ||
95 | case EXT2_IOC_SETRSVSZ: { | ||
96 | |||
97 | if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode)) | ||
98 | return -ENOTTY; | ||
99 | |||
100 | if (IS_RDONLY(inode)) | ||
101 | return -EROFS; | ||
102 | |||
103 | if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) | ||
104 | return -EACCES; | ||
105 | |||
106 | if (get_user(rsv_window_size, (int __user *)arg)) | ||
107 | return -EFAULT; | ||
108 | |||
109 | if (rsv_window_size > EXT2_MAX_RESERVE_BLOCKS) | ||
110 | rsv_window_size = EXT2_MAX_RESERVE_BLOCKS; | ||
111 | |||
112 | /* | ||
113 | * need to allocate reservation structure for this inode | ||
114 | * before set the window size | ||
115 | */ | ||
116 | /* | ||
117 | * XXX What lock should protect the rsv_goal_size? | ||
118 | * Accessed in ext2_get_block only. ext3 uses i_truncate. | ||
119 | */ | ||
120 | mutex_lock(&ei->truncate_mutex); | ||
121 | if (!ei->i_block_alloc_info) | ||
122 | ext2_init_block_alloc_info(inode); | ||
123 | |||
124 | if (ei->i_block_alloc_info){ | ||
125 | struct ext2_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node; | ||
126 | rsv->rsv_goal_size = rsv_window_size; | ||
127 | } | ||
128 | mutex_unlock(&ei->truncate_mutex); | ||
129 | return 0; | ||
130 | } | ||
86 | default: | 131 | default: |
87 | return -ENOTTY; | 132 | return -ENOTTY; |
88 | } | 133 | } |