aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hpfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hpfs/inode.c')
-rw-r--r--fs/hpfs/inode.c58
1 files changed, 26 insertions, 32 deletions
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 56f0da1cfd10..338cd8368451 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -6,7 +6,6 @@
6 * inode VFS functions 6 * inode VFS functions
7 */ 7 */
8 8
9#include <linux/smp_lock.h>
10#include <linux/slab.h> 9#include <linux/slab.h>
11#include "hpfs_fn.h" 10#include "hpfs_fn.h"
12 11
@@ -18,7 +17,6 @@ void hpfs_init_inode(struct inode *i)
18 i->i_uid = hpfs_sb(sb)->sb_uid; 17 i->i_uid = hpfs_sb(sb)->sb_uid;
19 i->i_gid = hpfs_sb(sb)->sb_gid; 18 i->i_gid = hpfs_sb(sb)->sb_gid;
20 i->i_mode = hpfs_sb(sb)->sb_mode; 19 i->i_mode = hpfs_sb(sb)->sb_mode;
21 hpfs_inode->i_conv = hpfs_sb(sb)->sb_conv;
22 i->i_size = -1; 20 i->i_size = -1;
23 i->i_blocks = -1; 21 i->i_blocks = -1;
24 22
@@ -117,8 +115,8 @@ void hpfs_read_inode(struct inode *i)
117 i->i_mode |= S_IFDIR; 115 i->i_mode |= S_IFDIR;
118 i->i_op = &hpfs_dir_iops; 116 i->i_op = &hpfs_dir_iops;
119 i->i_fop = &hpfs_dir_ops; 117 i->i_fop = &hpfs_dir_ops;
120 hpfs_inode->i_parent_dir = fnode->up; 118 hpfs_inode->i_parent_dir = le32_to_cpu(fnode->up);
121 hpfs_inode->i_dno = fnode->u.external[0].disk_secno; 119 hpfs_inode->i_dno = le32_to_cpu(fnode->u.external[0].disk_secno);
122 if (hpfs_sb(sb)->sb_chk >= 2) { 120 if (hpfs_sb(sb)->sb_chk >= 2) {
123 struct buffer_head *bh0; 121 struct buffer_head *bh0;
124 if (hpfs_map_fnode(sb, hpfs_inode->i_parent_dir, &bh0)) brelse(bh0); 122 if (hpfs_map_fnode(sb, hpfs_inode->i_parent_dir, &bh0)) brelse(bh0);
@@ -134,7 +132,7 @@ void hpfs_read_inode(struct inode *i)
134 i->i_op = &hpfs_file_iops; 132 i->i_op = &hpfs_file_iops;
135 i->i_fop = &hpfs_file_ops; 133 i->i_fop = &hpfs_file_ops;
136 i->i_nlink = 1; 134 i->i_nlink = 1;
137 i->i_size = fnode->file_size; 135 i->i_size = le32_to_cpu(fnode->file_size);
138 i->i_blocks = ((i->i_size + 511) >> 9) + 1; 136 i->i_blocks = ((i->i_size + 511) >> 9) + 1;
139 i->i_data.a_ops = &hpfs_aops; 137 i->i_data.a_ops = &hpfs_aops;
140 hpfs_i(i)->mmu_private = i->i_size; 138 hpfs_i(i)->mmu_private = i->i_size;
@@ -145,7 +143,7 @@ void hpfs_read_inode(struct inode *i)
145static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode) 143static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode)
146{ 144{
147 struct hpfs_inode_info *hpfs_inode = hpfs_i(i); 145 struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
148 /*if (fnode->acl_size_l || fnode->acl_size_s) { 146 /*if (le32_to_cpu(fnode->acl_size_l) || le16_to_cpu(fnode->acl_size_s)) {
149 Some unknown structures like ACL may be in fnode, 147 Some unknown structures like ACL may be in fnode,
150 we'd better not overwrite them 148 we'd better not overwrite them
151 hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino); 149 hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino);
@@ -188,9 +186,7 @@ void hpfs_write_inode(struct inode *i)
188 kfree(hpfs_inode->i_rddir_off); 186 kfree(hpfs_inode->i_rddir_off);
189 hpfs_inode->i_rddir_off = NULL; 187 hpfs_inode->i_rddir_off = NULL;
190 } 188 }
191 mutex_lock(&hpfs_inode->i_parent_mutex);
192 if (!i->i_nlink) { 189 if (!i->i_nlink) {
193 mutex_unlock(&hpfs_inode->i_parent_mutex);
194 return; 190 return;
195 } 191 }
196 parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir); 192 parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir);
@@ -201,14 +197,9 @@ void hpfs_write_inode(struct inode *i)
201 hpfs_read_inode(parent); 197 hpfs_read_inode(parent);
202 unlock_new_inode(parent); 198 unlock_new_inode(parent);
203 } 199 }
204 mutex_lock(&hpfs_inode->i_mutex);
205 hpfs_write_inode_nolock(i); 200 hpfs_write_inode_nolock(i);
206 mutex_unlock(&hpfs_inode->i_mutex);
207 iput(parent); 201 iput(parent);
208 } else {
209 mark_inode_dirty(i);
210 } 202 }
211 mutex_unlock(&hpfs_inode->i_parent_mutex);
212} 203}
213 204
214void hpfs_write_inode_nolock(struct inode *i) 205void hpfs_write_inode_nolock(struct inode *i)
@@ -227,30 +218,30 @@ void hpfs_write_inode_nolock(struct inode *i)
227 } 218 }
228 } else de = NULL; 219 } else de = NULL;
229 if (S_ISREG(i->i_mode)) { 220 if (S_ISREG(i->i_mode)) {
230 fnode->file_size = i->i_size; 221 fnode->file_size = cpu_to_le32(i->i_size);
231 if (de) de->file_size = i->i_size; 222 if (de) de->file_size = cpu_to_le32(i->i_size);
232 } else if (S_ISDIR(i->i_mode)) { 223 } else if (S_ISDIR(i->i_mode)) {
233 fnode->file_size = 0; 224 fnode->file_size = cpu_to_le32(0);
234 if (de) de->file_size = 0; 225 if (de) de->file_size = cpu_to_le32(0);
235 } 226 }
236 hpfs_write_inode_ea(i, fnode); 227 hpfs_write_inode_ea(i, fnode);
237 if (de) { 228 if (de) {
238 de->write_date = gmt_to_local(i->i_sb, i->i_mtime.tv_sec); 229 de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec));
239 de->read_date = gmt_to_local(i->i_sb, i->i_atime.tv_sec); 230 de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec));
240 de->creation_date = gmt_to_local(i->i_sb, i->i_ctime.tv_sec); 231 de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec));
241 de->read_only = !(i->i_mode & 0222); 232 de->read_only = !(i->i_mode & 0222);
242 de->ea_size = hpfs_inode->i_ea_size; 233 de->ea_size = cpu_to_le32(hpfs_inode->i_ea_size);
243 hpfs_mark_4buffers_dirty(&qbh); 234 hpfs_mark_4buffers_dirty(&qbh);
244 hpfs_brelse4(&qbh); 235 hpfs_brelse4(&qbh);
245 } 236 }
246 if (S_ISDIR(i->i_mode)) { 237 if (S_ISDIR(i->i_mode)) {
247 if ((de = map_dirent(i, hpfs_inode->i_dno, "\001\001", 2, NULL, &qbh))) { 238 if ((de = map_dirent(i, hpfs_inode->i_dno, "\001\001", 2, NULL, &qbh))) {
248 de->write_date = gmt_to_local(i->i_sb, i->i_mtime.tv_sec); 239 de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec));
249 de->read_date = gmt_to_local(i->i_sb, i->i_atime.tv_sec); 240 de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec));
250 de->creation_date = gmt_to_local(i->i_sb, i->i_ctime.tv_sec); 241 de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec));
251 de->read_only = !(i->i_mode & 0222); 242 de->read_only = !(i->i_mode & 0222);
252 de->ea_size = /*hpfs_inode->i_ea_size*/0; 243 de->ea_size = cpu_to_le32(/*hpfs_inode->i_ea_size*/0);
253 de->file_size = 0; 244 de->file_size = cpu_to_le32(0);
254 hpfs_mark_4buffers_dirty(&qbh); 245 hpfs_mark_4buffers_dirty(&qbh);
255 hpfs_brelse4(&qbh); 246 hpfs_brelse4(&qbh);
256 } else 247 } else
@@ -267,9 +258,13 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
267 struct inode *inode = dentry->d_inode; 258 struct inode *inode = dentry->d_inode;
268 int error = -EINVAL; 259 int error = -EINVAL;
269 260
270 lock_kernel(); 261 hpfs_lock(inode->i_sb);
271 if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root) 262 if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root)
272 goto out_unlock; 263 goto out_unlock;
264 if ((attr->ia_valid & ATTR_UID) && attr->ia_uid >= 0x10000)
265 goto out_unlock;
266 if ((attr->ia_valid & ATTR_GID) && attr->ia_gid >= 0x10000)
267 goto out_unlock;
273 if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) 268 if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
274 goto out_unlock; 269 goto out_unlock;
275 270
@@ -281,16 +276,15 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
281 attr->ia_size != i_size_read(inode)) { 276 attr->ia_size != i_size_read(inode)) {
282 error = vmtruncate(inode, attr->ia_size); 277 error = vmtruncate(inode, attr->ia_size);
283 if (error) 278 if (error)
284 return error; 279 goto out_unlock;
285 } 280 }
286 281
287 setattr_copy(inode, attr); 282 setattr_copy(inode, attr);
288 mark_inode_dirty(inode);
289 283
290 hpfs_write_inode(inode); 284 hpfs_write_inode(inode);
291 285
292 out_unlock: 286 out_unlock:
293 unlock_kernel(); 287 hpfs_unlock(inode->i_sb);
294 return error; 288 return error;
295} 289}
296 290
@@ -307,8 +301,8 @@ void hpfs_evict_inode(struct inode *inode)
307 truncate_inode_pages(&inode->i_data, 0); 301 truncate_inode_pages(&inode->i_data, 0);
308 end_writeback(inode); 302 end_writeback(inode);
309 if (!inode->i_nlink) { 303 if (!inode->i_nlink) {
310 lock_kernel(); 304 hpfs_lock(inode->i_sb);
311 hpfs_remove_fnode(inode->i_sb, inode->i_ino); 305 hpfs_remove_fnode(inode->i_sb, inode->i_ino);
312 unlock_kernel(); 306 hpfs_unlock(inode->i_sb);
313 } 307 }
314} 308}