aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hfsplus/inode.c')
-rw-r--r--fs/hfsplus/inode.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index c5a979d62c65..050eee6c81bd 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -62,13 +62,13 @@ static int hfsplus_releasepage(struct page *page, gfp_t mask)
62 62
63 switch (inode->i_ino) { 63 switch (inode->i_ino) {
64 case HFSPLUS_EXT_CNID: 64 case HFSPLUS_EXT_CNID:
65 tree = HFSPLUS_SB(sb).ext_tree; 65 tree = HFSPLUS_SB(sb)->ext_tree;
66 break; 66 break;
67 case HFSPLUS_CAT_CNID: 67 case HFSPLUS_CAT_CNID:
68 tree = HFSPLUS_SB(sb).cat_tree; 68 tree = HFSPLUS_SB(sb)->cat_tree;
69 break; 69 break;
70 case HFSPLUS_ATTR_CNID: 70 case HFSPLUS_ATTR_CNID:
71 tree = HFSPLUS_SB(sb).attr_tree; 71 tree = HFSPLUS_SB(sb)->attr_tree;
72 break; 72 break;
73 default: 73 default:
74 BUG(); 74 BUG();
@@ -190,7 +190,7 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
190 mutex_init(&HFSPLUS_I(inode).extents_lock); 190 mutex_init(&HFSPLUS_I(inode).extents_lock);
191 HFSPLUS_I(inode).flags = HFSPLUS_FLG_RSRC; 191 HFSPLUS_I(inode).flags = HFSPLUS_FLG_RSRC;
192 192
193 hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd); 193 hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
194 err = hfsplus_find_cat(sb, dir->i_ino, &fd); 194 err = hfsplus_find_cat(sb, dir->i_ino, &fd);
195 if (!err) 195 if (!err)
196 err = hfsplus_cat_read_inode(inode, &fd); 196 err = hfsplus_cat_read_inode(inode, &fd);
@@ -202,7 +202,7 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
202 HFSPLUS_I(inode).rsrc_inode = dir; 202 HFSPLUS_I(inode).rsrc_inode = dir;
203 HFSPLUS_I(dir).rsrc_inode = inode; 203 HFSPLUS_I(dir).rsrc_inode = inode;
204 igrab(dir); 204 igrab(dir);
205 hlist_add_head(&inode->i_hash, &HFSPLUS_SB(sb).rsrc_inodes); 205 hlist_add_head(&inode->i_hash, &HFSPLUS_SB(sb)->rsrc_inodes);
206 mark_inode_dirty(inode); 206 mark_inode_dirty(inode);
207out: 207out:
208 d_add(dentry, inode); 208 d_add(dentry, inode);
@@ -211,26 +211,24 @@ out:
211 211
212static void hfsplus_get_perms(struct inode *inode, struct hfsplus_perm *perms, int dir) 212static void hfsplus_get_perms(struct inode *inode, struct hfsplus_perm *perms, int dir)
213{ 213{
214 struct super_block *sb = inode->i_sb; 214 struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
215 u16 mode; 215 u16 mode;
216 216
217 mode = be16_to_cpu(perms->mode); 217 mode = be16_to_cpu(perms->mode);
218 218
219 inode->i_uid = be32_to_cpu(perms->owner); 219 inode->i_uid = be32_to_cpu(perms->owner);
220 if (!inode->i_uid && !mode) 220 if (!inode->i_uid && !mode)
221 inode->i_uid = HFSPLUS_SB(sb).uid; 221 inode->i_uid = sbi->uid;
222 222
223 inode->i_gid = be32_to_cpu(perms->group); 223 inode->i_gid = be32_to_cpu(perms->group);
224 if (!inode->i_gid && !mode) 224 if (!inode->i_gid && !mode)
225 inode->i_gid = HFSPLUS_SB(sb).gid; 225 inode->i_gid = sbi->gid;
226 226
227 if (dir) { 227 if (dir) {
228 mode = mode ? (mode & S_IALLUGO) : 228 mode = mode ? (mode & S_IALLUGO) : (S_IRWXUGO & ~(sbi->umask));
229 (S_IRWXUGO & ~(HFSPLUS_SB(sb).umask));
230 mode |= S_IFDIR; 229 mode |= S_IFDIR;
231 } else if (!mode) 230 } else if (!mode)
232 mode = S_IFREG | ((S_IRUGO|S_IWUGO) & 231 mode = S_IFREG | ((S_IRUGO|S_IWUGO) & ~(sbi->umask));
233 ~(HFSPLUS_SB(sb).umask));
234 inode->i_mode = mode; 232 inode->i_mode = mode;
235 233
236 HFSPLUS_I(inode).rootflags = perms->rootflags; 234 HFSPLUS_I(inode).rootflags = perms->rootflags;
@@ -282,7 +280,8 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)
282 mutex_lock(&inode->i_mutex); 280 mutex_lock(&inode->i_mutex);
283 hfsplus_file_truncate(inode); 281 hfsplus_file_truncate(inode);
284 if (inode->i_flags & S_DEAD) { 282 if (inode->i_flags & S_DEAD) {
285 hfsplus_delete_cat(inode->i_ino, HFSPLUS_SB(sb).hidden_dir, NULL); 283 hfsplus_delete_cat(inode->i_ino,
284 HFSPLUS_SB(sb)->hidden_dir, NULL);
286 hfsplus_delete_inode(inode); 285 hfsplus_delete_inode(inode);
287 } 286 }
288 mutex_unlock(&inode->i_mutex); 287 mutex_unlock(&inode->i_mutex);
@@ -361,11 +360,13 @@ static const struct file_operations hfsplus_file_operations = {
361 360
362struct inode *hfsplus_new_inode(struct super_block *sb, int mode) 361struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
363{ 362{
363 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
364 struct inode *inode = new_inode(sb); 364 struct inode *inode = new_inode(sb);
365
365 if (!inode) 366 if (!inode)
366 return NULL; 367 return NULL;
367 368
368 inode->i_ino = HFSPLUS_SB(sb).next_cnid++; 369 inode->i_ino = sbi->next_cnid++;
369 inode->i_mode = mode; 370 inode->i_mode = mode;
370 inode->i_uid = current_fsuid(); 371 inode->i_uid = current_fsuid();
371 inode->i_gid = current_fsgid(); 372 inode->i_gid = current_fsgid();
@@ -386,22 +387,22 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
386 HFSPLUS_I(inode).rsrc_inode = NULL; 387 HFSPLUS_I(inode).rsrc_inode = NULL;
387 if (S_ISDIR(inode->i_mode)) { 388 if (S_ISDIR(inode->i_mode)) {
388 inode->i_size = 2; 389 inode->i_size = 2;
389 HFSPLUS_SB(sb).folder_count++; 390 sbi->folder_count++;
390 inode->i_op = &hfsplus_dir_inode_operations; 391 inode->i_op = &hfsplus_dir_inode_operations;
391 inode->i_fop = &hfsplus_dir_operations; 392 inode->i_fop = &hfsplus_dir_operations;
392 } else if (S_ISREG(inode->i_mode)) { 393 } else if (S_ISREG(inode->i_mode)) {
393 HFSPLUS_SB(sb).file_count++; 394 sbi->file_count++;
394 inode->i_op = &hfsplus_file_inode_operations; 395 inode->i_op = &hfsplus_file_inode_operations;
395 inode->i_fop = &hfsplus_file_operations; 396 inode->i_fop = &hfsplus_file_operations;
396 inode->i_mapping->a_ops = &hfsplus_aops; 397 inode->i_mapping->a_ops = &hfsplus_aops;
397 HFSPLUS_I(inode).clump_blocks = HFSPLUS_SB(sb).data_clump_blocks; 398 HFSPLUS_I(inode).clump_blocks = sbi->data_clump_blocks;
398 } else if (S_ISLNK(inode->i_mode)) { 399 } else if (S_ISLNK(inode->i_mode)) {
399 HFSPLUS_SB(sb).file_count++; 400 sbi->file_count++;
400 inode->i_op = &page_symlink_inode_operations; 401 inode->i_op = &page_symlink_inode_operations;
401 inode->i_mapping->a_ops = &hfsplus_aops; 402 inode->i_mapping->a_ops = &hfsplus_aops;
402 HFSPLUS_I(inode).clump_blocks = 1; 403 HFSPLUS_I(inode).clump_blocks = 1;
403 } else 404 } else
404 HFSPLUS_SB(sb).file_count++; 405 sbi->file_count++;
405 insert_inode_hash(inode); 406 insert_inode_hash(inode);
406 mark_inode_dirty(inode); 407 mark_inode_dirty(inode);
407 sb->s_dirt = 1; 408 sb->s_dirt = 1;
@@ -414,11 +415,11 @@ void hfsplus_delete_inode(struct inode *inode)
414 struct super_block *sb = inode->i_sb; 415 struct super_block *sb = inode->i_sb;
415 416
416 if (S_ISDIR(inode->i_mode)) { 417 if (S_ISDIR(inode->i_mode)) {
417 HFSPLUS_SB(sb).folder_count--; 418 HFSPLUS_SB(sb)->folder_count--;
418 sb->s_dirt = 1; 419 sb->s_dirt = 1;
419 return; 420 return;
420 } 421 }
421 HFSPLUS_SB(sb).file_count--; 422 HFSPLUS_SB(sb)->file_count--;
422 if (S_ISREG(inode->i_mode)) { 423 if (S_ISREG(inode->i_mode)) {
423 if (!inode->i_nlink) { 424 if (!inode->i_nlink) {
424 inode->i_size = 0; 425 inode->i_size = 0;
@@ -434,6 +435,7 @@ void hfsplus_delete_inode(struct inode *inode)
434void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork) 435void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
435{ 436{
436 struct super_block *sb = inode->i_sb; 437 struct super_block *sb = inode->i_sb;
438 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
437 u32 count; 439 u32 count;
438 int i; 440 int i;
439 441
@@ -450,10 +452,13 @@ void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
450 inode->i_size = HFSPLUS_I(inode).phys_size = be64_to_cpu(fork->total_size); 452 inode->i_size = HFSPLUS_I(inode).phys_size = be64_to_cpu(fork->total_size);
451 HFSPLUS_I(inode).fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits; 453 HFSPLUS_I(inode).fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
452 inode_set_bytes(inode, HFSPLUS_I(inode).fs_blocks << sb->s_blocksize_bits); 454 inode_set_bytes(inode, HFSPLUS_I(inode).fs_blocks << sb->s_blocksize_bits);
453 HFSPLUS_I(inode).clump_blocks = be32_to_cpu(fork->clump_size) >> HFSPLUS_SB(sb).alloc_blksz_shift; 455 HFSPLUS_I(inode).clump_blocks =
454 if (!HFSPLUS_I(inode).clump_blocks) 456 be32_to_cpu(fork->clump_size) >> sbi->alloc_blksz_shift;
455 HFSPLUS_I(inode).clump_blocks = HFSPLUS_IS_RSRC(inode) ? HFSPLUS_SB(sb).rsrc_clump_blocks : 457 if (!HFSPLUS_I(inode).clump_blocks) {
456 HFSPLUS_SB(sb).data_clump_blocks; 458 HFSPLUS_I(inode).clump_blocks = HFSPLUS_IS_RSRC(inode) ?
459 sbi->rsrc_clump_blocks :
460 sbi->data_clump_blocks;
461 }
457} 462}
458 463
459void hfsplus_inode_write_fork(struct inode *inode, struct hfsplus_fork_raw *fork) 464void hfsplus_inode_write_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
@@ -538,7 +543,7 @@ int hfsplus_cat_write_inode(struct inode *inode)
538 if (!main_inode->i_nlink) 543 if (!main_inode->i_nlink)
539 return 0; 544 return 0;
540 545
541 if (hfs_find_init(HFSPLUS_SB(main_inode->i_sb).cat_tree, &fd)) 546 if (hfs_find_init(HFSPLUS_SB(main_inode->i_sb)->cat_tree, &fd))
542 /* panic? */ 547 /* panic? */
543 return -EIO; 548 return -EIO;
544 549