aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus/inode.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@tuxera.com>2010-09-30 23:43:31 -0400
committerChristoph Hellwig <hch@lst.de>2010-09-30 23:43:31 -0400
commit6af502de224c3742936d54eee7e3690c09822934 (patch)
tree9988331693952348503d64764ff81dc3b5d801ab /fs/hfsplus/inode.c
parentdd73a01a30d729e8fa6f829c4582650e258e36f9 (diff)
hfsplus: fix HFSPLUS_I calling convention
HFSPLUS_I doesn't return a pointer to the hfsplus-specific inode information like all other FOO_I macros, but dereference the pointer in a way that made it look like a direct struct derefence. This only works as long as the HFSPLUS_I macro is used directly and prevents us from keepig a local hfsplus_inode_info pointer. Fix the calling convention and introduce a local hip variable in all functions that use it constantly. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
Diffstat (limited to 'fs/hfsplus/inode.c')
-rw-r--r--fs/hfsplus/inode.c112
1 files changed, 59 insertions, 53 deletions
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 050eee6c81bd..309defb4f41f 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -36,7 +36,7 @@ static int hfsplus_write_begin(struct file *file, struct address_space *mapping,
36 *pagep = NULL; 36 *pagep = NULL;
37 ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata, 37 ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
38 hfsplus_get_block, 38 hfsplus_get_block,
39 &HFSPLUS_I(mapping->host).phys_size); 39 &HFSPLUS_I(mapping->host)->phys_size);
40 if (unlikely(ret)) { 40 if (unlikely(ret)) {
41 loff_t isize = mapping->host->i_size; 41 loff_t isize = mapping->host->i_size;
42 if (pos + len > isize) 42 if (pos + len > isize)
@@ -172,12 +172,13 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
172 struct hfs_find_data fd; 172 struct hfs_find_data fd;
173 struct super_block *sb = dir->i_sb; 173 struct super_block *sb = dir->i_sb;
174 struct inode *inode = NULL; 174 struct inode *inode = NULL;
175 struct hfsplus_inode_info *hip;
175 int err; 176 int err;
176 177
177 if (HFSPLUS_IS_RSRC(dir) || strcmp(dentry->d_name.name, "rsrc")) 178 if (HFSPLUS_IS_RSRC(dir) || strcmp(dentry->d_name.name, "rsrc"))
178 goto out; 179 goto out;
179 180
180 inode = HFSPLUS_I(dir).rsrc_inode; 181 inode = HFSPLUS_I(dir)->rsrc_inode;
181 if (inode) 182 if (inode)
182 goto out; 183 goto out;
183 184
@@ -185,10 +186,11 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
185 if (!inode) 186 if (!inode)
186 return ERR_PTR(-ENOMEM); 187 return ERR_PTR(-ENOMEM);
187 188
189 hip = HFSPLUS_I(inode);
188 inode->i_ino = dir->i_ino; 190 inode->i_ino = dir->i_ino;
189 INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); 191 INIT_LIST_HEAD(&hip->open_dir_list);
190 mutex_init(&HFSPLUS_I(inode).extents_lock); 192 mutex_init(&hip->extents_lock);
191 HFSPLUS_I(inode).flags = HFSPLUS_FLG_RSRC; 193 hip->flags = HFSPLUS_FLG_RSRC;
192 194
193 hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); 195 hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
194 err = hfsplus_find_cat(sb, dir->i_ino, &fd); 196 err = hfsplus_find_cat(sb, dir->i_ino, &fd);
@@ -199,8 +201,8 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
199 iput(inode); 201 iput(inode);
200 return ERR_PTR(err); 202 return ERR_PTR(err);
201 } 203 }
202 HFSPLUS_I(inode).rsrc_inode = dir; 204 hip->rsrc_inode = dir;
203 HFSPLUS_I(dir).rsrc_inode = inode; 205 HFSPLUS_I(dir)->rsrc_inode = inode;
204 igrab(dir); 206 igrab(dir);
205 hlist_add_head(&inode->i_hash, &HFSPLUS_SB(sb)->rsrc_inodes); 207 hlist_add_head(&inode->i_hash, &HFSPLUS_SB(sb)->rsrc_inodes);
206 mark_inode_dirty(inode); 208 mark_inode_dirty(inode);
@@ -231,8 +233,8 @@ static void hfsplus_get_perms(struct inode *inode, struct hfsplus_perm *perms, i
231 mode = S_IFREG | ((S_IRUGO|S_IWUGO) & ~(sbi->umask)); 233 mode = S_IFREG | ((S_IRUGO|S_IWUGO) & ~(sbi->umask));
232 inode->i_mode = mode; 234 inode->i_mode = mode;
233 235
234 HFSPLUS_I(inode).rootflags = perms->rootflags; 236 HFSPLUS_I(inode)->rootflags = perms->rootflags;
235 HFSPLUS_I(inode).userflags = perms->userflags; 237 HFSPLUS_I(inode)->userflags = perms->userflags;
236 if (perms->rootflags & HFSPLUS_FLG_IMMUTABLE) 238 if (perms->rootflags & HFSPLUS_FLG_IMMUTABLE)
237 inode->i_flags |= S_IMMUTABLE; 239 inode->i_flags |= S_IMMUTABLE;
238 else 240 else
@@ -253,20 +255,20 @@ static void hfsplus_set_perms(struct inode *inode, struct hfsplus_perm *perms)
253 perms->rootflags |= HFSPLUS_FLG_APPEND; 255 perms->rootflags |= HFSPLUS_FLG_APPEND;
254 else 256 else
255 perms->rootflags &= ~HFSPLUS_FLG_APPEND; 257 perms->rootflags &= ~HFSPLUS_FLG_APPEND;
256 perms->userflags = HFSPLUS_I(inode).userflags; 258 perms->userflags = HFSPLUS_I(inode)->userflags;
257 perms->mode = cpu_to_be16(inode->i_mode); 259 perms->mode = cpu_to_be16(inode->i_mode);
258 perms->owner = cpu_to_be32(inode->i_uid); 260 perms->owner = cpu_to_be32(inode->i_uid);
259 perms->group = cpu_to_be32(inode->i_gid); 261 perms->group = cpu_to_be32(inode->i_gid);
260 perms->dev = cpu_to_be32(HFSPLUS_I(inode).dev); 262 perms->dev = cpu_to_be32(HFSPLUS_I(inode)->dev);
261} 263}
262 264
263static int hfsplus_file_open(struct inode *inode, struct file *file) 265static int hfsplus_file_open(struct inode *inode, struct file *file)
264{ 266{
265 if (HFSPLUS_IS_RSRC(inode)) 267 if (HFSPLUS_IS_RSRC(inode))
266 inode = HFSPLUS_I(inode).rsrc_inode; 268 inode = HFSPLUS_I(inode)->rsrc_inode;
267 if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS) 269 if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
268 return -EOVERFLOW; 270 return -EOVERFLOW;
269 atomic_inc(&HFSPLUS_I(inode).opencnt); 271 atomic_inc(&HFSPLUS_I(inode)->opencnt);
270 return 0; 272 return 0;
271} 273}
272 274
@@ -275,8 +277,8 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)
275 struct super_block *sb = inode->i_sb; 277 struct super_block *sb = inode->i_sb;
276 278
277 if (HFSPLUS_IS_RSRC(inode)) 279 if (HFSPLUS_IS_RSRC(inode))
278 inode = HFSPLUS_I(inode).rsrc_inode; 280 inode = HFSPLUS_I(inode)->rsrc_inode;
279 if (atomic_dec_and_test(&HFSPLUS_I(inode).opencnt)) { 281 if (atomic_dec_and_test(&HFSPLUS_I(inode)->opencnt)) {
280 mutex_lock(&inode->i_mutex); 282 mutex_lock(&inode->i_mutex);
281 hfsplus_file_truncate(inode); 283 hfsplus_file_truncate(inode);
282 if (inode->i_flags & S_DEAD) { 284 if (inode->i_flags & S_DEAD) {
@@ -362,6 +364,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
362{ 364{
363 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); 365 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
364 struct inode *inode = new_inode(sb); 366 struct inode *inode = new_inode(sb);
367 struct hfsplus_inode_info *hip;
365 368
366 if (!inode) 369 if (!inode)
367 return NULL; 370 return NULL;
@@ -372,19 +375,21 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
372 inode->i_gid = current_fsgid(); 375 inode->i_gid = current_fsgid();
373 inode->i_nlink = 1; 376 inode->i_nlink = 1;
374 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 377 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
375 INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); 378
376 mutex_init(&HFSPLUS_I(inode).extents_lock); 379 hip = HFSPLUS_I(inode);
377 atomic_set(&HFSPLUS_I(inode).opencnt, 0); 380 INIT_LIST_HEAD(&hip->open_dir_list);
378 HFSPLUS_I(inode).flags = 0; 381 mutex_init(&hip->extents_lock);
379 memset(HFSPLUS_I(inode).first_extents, 0, sizeof(hfsplus_extent_rec)); 382 atomic_set(&hip->opencnt, 0);
380 memset(HFSPLUS_I(inode).cached_extents, 0, sizeof(hfsplus_extent_rec)); 383 hip->flags = 0;
381 HFSPLUS_I(inode).alloc_blocks = 0; 384 memset(hip->first_extents, 0, sizeof(hfsplus_extent_rec));
382 HFSPLUS_I(inode).first_blocks = 0; 385 memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
383 HFSPLUS_I(inode).cached_start = 0; 386 hip->alloc_blocks = 0;
384 HFSPLUS_I(inode).cached_blocks = 0; 387 hip->first_blocks = 0;
385 HFSPLUS_I(inode).phys_size = 0; 388 hip->cached_start = 0;
386 HFSPLUS_I(inode).fs_blocks = 0; 389 hip->cached_blocks = 0;
387 HFSPLUS_I(inode).rsrc_inode = NULL; 390 hip->phys_size = 0;
391 hip->fs_blocks = 0;
392 hip->rsrc_inode = NULL;
388 if (S_ISDIR(inode->i_mode)) { 393 if (S_ISDIR(inode->i_mode)) {
389 inode->i_size = 2; 394 inode->i_size = 2;
390 sbi->folder_count++; 395 sbi->folder_count++;
@@ -395,12 +400,12 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
395 inode->i_op = &hfsplus_file_inode_operations; 400 inode->i_op = &hfsplus_file_inode_operations;
396 inode->i_fop = &hfsplus_file_operations; 401 inode->i_fop = &hfsplus_file_operations;
397 inode->i_mapping->a_ops = &hfsplus_aops; 402 inode->i_mapping->a_ops = &hfsplus_aops;
398 HFSPLUS_I(inode).clump_blocks = sbi->data_clump_blocks; 403 hip->clump_blocks = sbi->data_clump_blocks;
399 } else if (S_ISLNK(inode->i_mode)) { 404 } else if (S_ISLNK(inode->i_mode)) {
400 sbi->file_count++; 405 sbi->file_count++;
401 inode->i_op = &page_symlink_inode_operations; 406 inode->i_op = &page_symlink_inode_operations;
402 inode->i_mapping->a_ops = &hfsplus_aops; 407 inode->i_mapping->a_ops = &hfsplus_aops;
403 HFSPLUS_I(inode).clump_blocks = 1; 408 hip->clump_blocks = 1;
404 } else 409 } else
405 sbi->file_count++; 410 sbi->file_count++;
406 insert_inode_hash(inode); 411 insert_inode_hash(inode);
@@ -436,26 +441,27 @@ void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
436{ 441{
437 struct super_block *sb = inode->i_sb; 442 struct super_block *sb = inode->i_sb;
438 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); 443 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
444 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
439 u32 count; 445 u32 count;
440 int i; 446 int i;
441 447
442 memcpy(&HFSPLUS_I(inode).first_extents, &fork->extents, 448 memcpy(&hip->first_extents, &fork->extents, sizeof(hfsplus_extent_rec));
443 sizeof(hfsplus_extent_rec));
444 for (count = 0, i = 0; i < 8; i++) 449 for (count = 0, i = 0; i < 8; i++)
445 count += be32_to_cpu(fork->extents[i].block_count); 450 count += be32_to_cpu(fork->extents[i].block_count);
446 HFSPLUS_I(inode).first_blocks = count; 451 hip->first_blocks = count;
447 memset(HFSPLUS_I(inode).cached_extents, 0, sizeof(hfsplus_extent_rec)); 452 memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
448 HFSPLUS_I(inode).cached_start = 0; 453 hip->cached_start = 0;
449 HFSPLUS_I(inode).cached_blocks = 0; 454 hip->cached_blocks = 0;
450 455
451 HFSPLUS_I(inode).alloc_blocks = be32_to_cpu(fork->total_blocks); 456 hip->alloc_blocks = be32_to_cpu(fork->total_blocks);
452 inode->i_size = HFSPLUS_I(inode).phys_size = be64_to_cpu(fork->total_size); 457 hip->phys_size = inode->i_size = be64_to_cpu(fork->total_size);
453 HFSPLUS_I(inode).fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits; 458 hip->fs_blocks =
454 inode_set_bytes(inode, HFSPLUS_I(inode).fs_blocks << sb->s_blocksize_bits); 459 (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
455 HFSPLUS_I(inode).clump_blocks = 460 inode_set_bytes(inode, hip->fs_blocks << sb->s_blocksize_bits);
461 hip->clump_blocks =
456 be32_to_cpu(fork->clump_size) >> sbi->alloc_blksz_shift; 462 be32_to_cpu(fork->clump_size) >> sbi->alloc_blksz_shift;
457 if (!HFSPLUS_I(inode).clump_blocks) { 463 if (!hip->clump_blocks) {
458 HFSPLUS_I(inode).clump_blocks = HFSPLUS_IS_RSRC(inode) ? 464 hip->clump_blocks = HFSPLUS_IS_RSRC(inode) ?
459 sbi->rsrc_clump_blocks : 465 sbi->rsrc_clump_blocks :
460 sbi->data_clump_blocks; 466 sbi->data_clump_blocks;
461 } 467 }
@@ -463,10 +469,10 @@ void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
463 469
464void hfsplus_inode_write_fork(struct inode *inode, struct hfsplus_fork_raw *fork) 470void hfsplus_inode_write_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
465{ 471{
466 memcpy(&fork->extents, &HFSPLUS_I(inode).first_extents, 472 memcpy(&fork->extents, &HFSPLUS_I(inode)->first_extents,
467 sizeof(hfsplus_extent_rec)); 473 sizeof(hfsplus_extent_rec));
468 fork->total_size = cpu_to_be64(inode->i_size); 474 fork->total_size = cpu_to_be64(inode->i_size);
469 fork->total_blocks = cpu_to_be32(HFSPLUS_I(inode).alloc_blocks); 475 fork->total_blocks = cpu_to_be32(HFSPLUS_I(inode)->alloc_blocks);
470} 476}
471 477
472int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd) 478int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
@@ -477,7 +483,7 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
477 483
478 type = hfs_bnode_read_u16(fd->bnode, fd->entryoffset); 484 type = hfs_bnode_read_u16(fd->bnode, fd->entryoffset);
479 485
480 HFSPLUS_I(inode).dev = 0; 486 HFSPLUS_I(inode)->dev = 0;
481 if (type == HFSPLUS_FOLDER) { 487 if (type == HFSPLUS_FOLDER) {
482 struct hfsplus_cat_folder *folder = &entry.folder; 488 struct hfsplus_cat_folder *folder = &entry.folder;
483 489
@@ -491,8 +497,8 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
491 inode->i_atime = hfsp_mt2ut(folder->access_date); 497 inode->i_atime = hfsp_mt2ut(folder->access_date);
492 inode->i_mtime = hfsp_mt2ut(folder->content_mod_date); 498 inode->i_mtime = hfsp_mt2ut(folder->content_mod_date);
493 inode->i_ctime = hfsp_mt2ut(folder->attribute_mod_date); 499 inode->i_ctime = hfsp_mt2ut(folder->attribute_mod_date);
494 HFSPLUS_I(inode).create_date = folder->create_date; 500 HFSPLUS_I(inode)->create_date = folder->create_date;
495 HFSPLUS_I(inode).fs_blocks = 0; 501 HFSPLUS_I(inode)->fs_blocks = 0;
496 inode->i_op = &hfsplus_dir_inode_operations; 502 inode->i_op = &hfsplus_dir_inode_operations;
497 inode->i_fop = &hfsplus_dir_operations; 503 inode->i_fop = &hfsplus_dir_operations;
498 } else if (type == HFSPLUS_FILE) { 504 } else if (type == HFSPLUS_FILE) {
@@ -523,7 +529,7 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
523 inode->i_atime = hfsp_mt2ut(file->access_date); 529 inode->i_atime = hfsp_mt2ut(file->access_date);
524 inode->i_mtime = hfsp_mt2ut(file->content_mod_date); 530 inode->i_mtime = hfsp_mt2ut(file->content_mod_date);
525 inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date); 531 inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date);
526 HFSPLUS_I(inode).create_date = file->create_date; 532 HFSPLUS_I(inode)->create_date = file->create_date;
527 } else { 533 } else {
528 printk(KERN_ERR "hfs: bad catalog entry used to create inode\n"); 534 printk(KERN_ERR "hfs: bad catalog entry used to create inode\n");
529 res = -EIO; 535 res = -EIO;
@@ -538,7 +544,7 @@ int hfsplus_cat_write_inode(struct inode *inode)
538 hfsplus_cat_entry entry; 544 hfsplus_cat_entry entry;
539 545
540 if (HFSPLUS_IS_RSRC(inode)) 546 if (HFSPLUS_IS_RSRC(inode))
541 main_inode = HFSPLUS_I(inode).rsrc_inode; 547 main_inode = HFSPLUS_I(inode)->rsrc_inode;
542 548
543 if (!main_inode->i_nlink) 549 if (!main_inode->i_nlink)
544 return 0; 550 return 0;
@@ -582,9 +588,9 @@ int hfsplus_cat_write_inode(struct inode *inode)
582 sizeof(struct hfsplus_cat_file)); 588 sizeof(struct hfsplus_cat_file));
583 hfsplus_inode_write_fork(inode, &file->data_fork); 589 hfsplus_inode_write_fork(inode, &file->data_fork);
584 if (S_ISREG(inode->i_mode)) 590 if (S_ISREG(inode->i_mode))
585 HFSPLUS_I(inode).dev = inode->i_nlink; 591 HFSPLUS_I(inode)->dev = inode->i_nlink;
586 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) 592 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
587 HFSPLUS_I(inode).dev = kdev_t_to_nr(inode->i_rdev); 593 HFSPLUS_I(inode)->dev = kdev_t_to_nr(inode->i_rdev);
588 hfsplus_set_perms(inode, &file->permissions); 594 hfsplus_set_perms(inode, &file->permissions);
589 if ((file->permissions.rootflags | file->permissions.userflags) & HFSPLUS_FLG_IMMUTABLE) 595 if ((file->permissions.rootflags | file->permissions.userflags) & HFSPLUS_FLG_IMMUTABLE)
590 file->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED); 596 file->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED);