diff options
author | Dave Kleikamp <shaggy@austin.ibm.com> | 2006-01-24 15:34:47 -0500 |
---|---|---|
committer | Dave Kleikamp <shaggy@austin.ibm.com> | 2006-01-24 15:34:47 -0500 |
commit | 0a0fc0ddbe732779366ab6b1b879f62195e65967 (patch) | |
tree | 7b42490a676cf39ae0691b6859ecf7fd410f229b /fs/hfsplus/super.c | |
parent | 4d5dbd0945d9e0833dd7964a3d6ee33157f7cc7a (diff) | |
parent | 3ee68c4af3fd7228c1be63254b9f884614f9ebb2 (diff) |
Merge with /home/shaggy/git/linus-clean/
Diffstat (limited to 'fs/hfsplus/super.c')
-rw-r--r-- | fs/hfsplus/super.c | 87 |
1 files changed, 40 insertions, 47 deletions
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index 0ce1c455ae55..7843f792a4b7 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
@@ -22,29 +22,12 @@ static void hfsplus_destroy_inode(struct inode *inode); | |||
22 | 22 | ||
23 | #include "hfsplus_fs.h" | 23 | #include "hfsplus_fs.h" |
24 | 24 | ||
25 | void hfsplus_inode_check(struct super_block *sb) | ||
26 | { | ||
27 | #if 0 | ||
28 | u32 cnt = atomic_read(&HFSPLUS_SB(sb).inode_cnt); | ||
29 | u32 last_cnt = HFSPLUS_SB(sb).last_inode_cnt; | ||
30 | |||
31 | if (cnt <= (last_cnt / 2) || | ||
32 | cnt >= (last_cnt * 2)) { | ||
33 | HFSPLUS_SB(sb).last_inode_cnt = cnt; | ||
34 | printk("inode_check: %u,%u,%u\n", cnt, last_cnt, | ||
35 | HFSPLUS_SB(sb).cat_tree ? HFSPLUS_SB(sb).cat_tree->node_hash_cnt : 0); | ||
36 | } | ||
37 | #endif | ||
38 | } | ||
39 | |||
40 | static void hfsplus_read_inode(struct inode *inode) | 25 | static void hfsplus_read_inode(struct inode *inode) |
41 | { | 26 | { |
42 | struct hfs_find_data fd; | 27 | struct hfs_find_data fd; |
43 | struct hfsplus_vh *vhdr; | 28 | struct hfsplus_vh *vhdr; |
44 | int err; | 29 | int err; |
45 | 30 | ||
46 | atomic_inc(&HFSPLUS_SB(inode->i_sb).inode_cnt); | ||
47 | hfsplus_inode_check(inode->i_sb); | ||
48 | INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); | 31 | INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); |
49 | init_MUTEX(&HFSPLUS_I(inode).extents_lock); | 32 | init_MUTEX(&HFSPLUS_I(inode).extents_lock); |
50 | HFSPLUS_I(inode).flags = 0; | 33 | HFSPLUS_I(inode).flags = 0; |
@@ -155,12 +138,10 @@ static int hfsplus_write_inode(struct inode *inode, int unused) | |||
155 | static void hfsplus_clear_inode(struct inode *inode) | 138 | static void hfsplus_clear_inode(struct inode *inode) |
156 | { | 139 | { |
157 | dprint(DBG_INODE, "hfsplus_clear_inode: %lu\n", inode->i_ino); | 140 | dprint(DBG_INODE, "hfsplus_clear_inode: %lu\n", inode->i_ino); |
158 | atomic_dec(&HFSPLUS_SB(inode->i_sb).inode_cnt); | ||
159 | if (HFSPLUS_IS_RSRC(inode)) { | 141 | if (HFSPLUS_IS_RSRC(inode)) { |
160 | HFSPLUS_I(HFSPLUS_I(inode).rsrc_inode).rsrc_inode = NULL; | 142 | HFSPLUS_I(HFSPLUS_I(inode).rsrc_inode).rsrc_inode = NULL; |
161 | iput(HFSPLUS_I(inode).rsrc_inode); | 143 | iput(HFSPLUS_I(inode).rsrc_inode); |
162 | } | 144 | } |
163 | hfsplus_inode_check(inode->i_sb); | ||
164 | } | 145 | } |
165 | 146 | ||
166 | static void hfsplus_write_super(struct super_block *sb) | 147 | static void hfsplus_write_super(struct super_block *sb) |
@@ -188,7 +169,7 @@ static void hfsplus_write_super(struct super_block *sb) | |||
188 | block = HFSPLUS_SB(sb).blockoffset; | 169 | block = HFSPLUS_SB(sb).blockoffset; |
189 | block += (HFSPLUS_SB(sb).sect_count - 2) >> (sb->s_blocksize_bits - 9); | 170 | block += (HFSPLUS_SB(sb).sect_count - 2) >> (sb->s_blocksize_bits - 9); |
190 | offset = ((HFSPLUS_SB(sb).sect_count - 2) << 9) & (sb->s_blocksize - 1); | 171 | offset = ((HFSPLUS_SB(sb).sect_count - 2) << 9) & (sb->s_blocksize - 1); |
191 | printk("backup: %u,%u,%u,%u\n", HFSPLUS_SB(sb).blockoffset, | 172 | printk(KERN_DEBUG "hfs: backup: %u,%u,%u,%u\n", HFSPLUS_SB(sb).blockoffset, |
192 | HFSPLUS_SB(sb).sect_count, block, offset); | 173 | HFSPLUS_SB(sb).sect_count, block, offset); |
193 | bh = sb_bread(sb, block); | 174 | bh = sb_bread(sb, block); |
194 | if (bh) { | 175 | if (bh) { |
@@ -198,7 +179,7 @@ static void hfsplus_write_super(struct super_block *sb) | |||
198 | mark_buffer_dirty(bh); | 179 | mark_buffer_dirty(bh); |
199 | brelse(bh); | 180 | brelse(bh); |
200 | } else | 181 | } else |
201 | printk("backup not found!\n"); | 182 | printk(KERN_WARNING "hfs: backup not found!\n"); |
202 | } | 183 | } |
203 | } | 184 | } |
204 | HFSPLUS_SB(sb).flags &= ~HFSPLUS_SB_WRITEBACKUP; | 185 | HFSPLUS_SB(sb).flags &= ~HFSPLUS_SB_WRITEBACKUP; |
@@ -251,14 +232,26 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data) | |||
251 | return 0; | 232 | return 0; |
252 | if (!(*flags & MS_RDONLY)) { | 233 | if (!(*flags & MS_RDONLY)) { |
253 | struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr; | 234 | struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr; |
235 | struct hfsplus_sb_info sbi; | ||
236 | |||
237 | memset(&sbi, 0, sizeof(struct hfsplus_sb_info)); | ||
238 | sbi.nls = HFSPLUS_SB(sb).nls; | ||
239 | if (!hfsplus_parse_options(data, &sbi)) | ||
240 | return -EINVAL; | ||
254 | 241 | ||
255 | if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { | 242 | if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { |
256 | printk("HFS+-fs warning: Filesystem was not cleanly unmounted, " | 243 | printk(KERN_WARNING "hfs: filesystem was not cleanly unmounted, " |
257 | "running fsck.hfsplus is recommended. leaving read-only.\n"); | 244 | "running fsck.hfsplus is recommended. leaving read-only.\n"); |
258 | sb->s_flags |= MS_RDONLY; | 245 | sb->s_flags |= MS_RDONLY; |
259 | *flags |= MS_RDONLY; | 246 | *flags |= MS_RDONLY; |
247 | } else if (sbi.flags & HFSPLUS_SB_FORCE) { | ||
248 | /* nothing */ | ||
260 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { | 249 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { |
261 | printk("HFS+-fs: Filesystem is marked locked, leaving read-only.\n"); | 250 | printk(KERN_WARNING "hfs: filesystem is marked locked, leaving read-only.\n"); |
251 | sb->s_flags |= MS_RDONLY; | ||
252 | *flags |= MS_RDONLY; | ||
253 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) { | ||
254 | printk(KERN_WARNING "hfs: filesystem is marked journaled, leaving read-only.\n"); | ||
262 | sb->s_flags |= MS_RDONLY; | 255 | sb->s_flags |= MS_RDONLY; |
263 | *flags |= MS_RDONLY; | 256 | *flags |= MS_RDONLY; |
264 | } | 257 | } |
@@ -299,8 +292,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
299 | INIT_HLIST_HEAD(&sbi->rsrc_inodes); | 292 | INIT_HLIST_HEAD(&sbi->rsrc_inodes); |
300 | hfsplus_fill_defaults(sbi); | 293 | hfsplus_fill_defaults(sbi); |
301 | if (!hfsplus_parse_options(data, sbi)) { | 294 | if (!hfsplus_parse_options(data, sbi)) { |
302 | if (!silent) | 295 | printk(KERN_ERR "hfs: unable to parse mount options\n"); |
303 | printk("HFS+-fs: unable to parse mount options\n"); | ||
304 | err = -EINVAL; | 296 | err = -EINVAL; |
305 | goto cleanup; | 297 | goto cleanup; |
306 | } | 298 | } |
@@ -308,8 +300,8 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
308 | /* temporarily use utf8 to correctly find the hidden dir below */ | 300 | /* temporarily use utf8 to correctly find the hidden dir below */ |
309 | nls = sbi->nls; | 301 | nls = sbi->nls; |
310 | sbi->nls = load_nls("utf8"); | 302 | sbi->nls = load_nls("utf8"); |
311 | if (!nls) { | 303 | if (!sbi->nls) { |
312 | printk("HFS+: unable to load nls for utf8\n"); | 304 | printk(KERN_ERR "hfs: unable to load nls for utf8\n"); |
313 | err = -EINVAL; | 305 | err = -EINVAL; |
314 | goto cleanup; | 306 | goto cleanup; |
315 | } | 307 | } |
@@ -317,17 +309,17 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
317 | /* Grab the volume header */ | 309 | /* Grab the volume header */ |
318 | if (hfsplus_read_wrapper(sb)) { | 310 | if (hfsplus_read_wrapper(sb)) { |
319 | if (!silent) | 311 | if (!silent) |
320 | printk("HFS+-fs: unable to find HFS+ superblock\n"); | 312 | printk(KERN_WARNING "hfs: unable to find HFS+ superblock\n"); |
321 | err = -EINVAL; | 313 | err = -EINVAL; |
322 | goto cleanup; | 314 | goto cleanup; |
323 | } | 315 | } |
324 | vhdr = HFSPLUS_SB(sb).s_vhdr; | 316 | vhdr = HFSPLUS_SB(sb).s_vhdr; |
325 | 317 | ||
326 | /* Copy parts of the volume header into the superblock */ | 318 | /* Copy parts of the volume header into the superblock */ |
327 | sb->s_magic = be16_to_cpu(vhdr->signature); | 319 | sb->s_magic = HFSPLUS_VOLHEAD_SIG; |
328 | if (be16_to_cpu(vhdr->version) != HFSPLUS_CURRENT_VERSION) { | 320 | if (be16_to_cpu(vhdr->version) < HFSPLUS_MIN_VERSION || |
329 | if (!silent) | 321 | be16_to_cpu(vhdr->version) > HFSPLUS_CURRENT_VERSION) { |
330 | printk("HFS+-fs: wrong filesystem version\n"); | 322 | printk(KERN_ERR "hfs: wrong filesystem version\n"); |
331 | goto cleanup; | 323 | goto cleanup; |
332 | } | 324 | } |
333 | HFSPLUS_SB(sb).total_blocks = be32_to_cpu(vhdr->total_blocks); | 325 | HFSPLUS_SB(sb).total_blocks = be32_to_cpu(vhdr->total_blocks); |
@@ -348,34 +340,36 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
348 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 340 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
349 | 341 | ||
350 | if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { | 342 | if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { |
351 | if (!silent) | 343 | printk(KERN_WARNING "hfs: Filesystem was not cleanly unmounted, " |
352 | printk("HFS+-fs warning: Filesystem was not cleanly unmounted, " | 344 | "running fsck.hfsplus is recommended. mounting read-only.\n"); |
353 | "running fsck.hfsplus is recommended. mounting read-only.\n"); | ||
354 | sb->s_flags |= MS_RDONLY; | 345 | sb->s_flags |= MS_RDONLY; |
346 | } else if (sbi->flags & HFSPLUS_SB_FORCE) { | ||
347 | /* nothing */ | ||
355 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { | 348 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { |
356 | if (!silent) | 349 | printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n"); |
357 | printk("HFS+-fs: Filesystem is marked locked, mounting read-only.\n"); | 350 | sb->s_flags |= MS_RDONLY; |
351 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) { | ||
352 | printk(KERN_WARNING "hfs: write access to a jounaled filesystem is not supported, " | ||
353 | "use the force option at your own risk, mounting read-only.\n"); | ||
358 | sb->s_flags |= MS_RDONLY; | 354 | sb->s_flags |= MS_RDONLY; |
359 | } | 355 | } |
356 | sbi->flags &= ~HFSPLUS_SB_FORCE; | ||
360 | 357 | ||
361 | /* Load metadata objects (B*Trees) */ | 358 | /* Load metadata objects (B*Trees) */ |
362 | HFSPLUS_SB(sb).ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID); | 359 | HFSPLUS_SB(sb).ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID); |
363 | if (!HFSPLUS_SB(sb).ext_tree) { | 360 | if (!HFSPLUS_SB(sb).ext_tree) { |
364 | if (!silent) | 361 | printk(KERN_ERR "hfs: failed to load extents file\n"); |
365 | printk("HFS+-fs: failed to load extents file\n"); | ||
366 | goto cleanup; | 362 | goto cleanup; |
367 | } | 363 | } |
368 | HFSPLUS_SB(sb).cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID); | 364 | HFSPLUS_SB(sb).cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID); |
369 | if (!HFSPLUS_SB(sb).cat_tree) { | 365 | if (!HFSPLUS_SB(sb).cat_tree) { |
370 | if (!silent) | 366 | printk(KERN_ERR "hfs: failed to load catalog file\n"); |
371 | printk("HFS+-fs: failed to load catalog file\n"); | ||
372 | goto cleanup; | 367 | goto cleanup; |
373 | } | 368 | } |
374 | 369 | ||
375 | HFSPLUS_SB(sb).alloc_file = iget(sb, HFSPLUS_ALLOC_CNID); | 370 | HFSPLUS_SB(sb).alloc_file = iget(sb, HFSPLUS_ALLOC_CNID); |
376 | if (!HFSPLUS_SB(sb).alloc_file) { | 371 | if (!HFSPLUS_SB(sb).alloc_file) { |
377 | if (!silent) | 372 | printk(KERN_ERR "hfs: failed to load allocation file\n"); |
378 | printk("HFS+-fs: failed to load allocation file\n"); | ||
379 | goto cleanup; | 373 | goto cleanup; |
380 | } | 374 | } |
381 | 375 | ||
@@ -383,8 +377,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
383 | root = iget(sb, HFSPLUS_ROOT_CNID); | 377 | root = iget(sb, HFSPLUS_ROOT_CNID); |
384 | sb->s_root = d_alloc_root(root); | 378 | sb->s_root = d_alloc_root(root); |
385 | if (!sb->s_root) { | 379 | if (!sb->s_root) { |
386 | if (!silent) | 380 | printk(KERN_ERR "hfs: failed to load root directory\n"); |
387 | printk("HFS+-fs: failed to load root directory\n"); | ||
388 | iput(root); | 381 | iput(root); |
389 | goto cleanup; | 382 | goto cleanup; |
390 | } | 383 | } |
@@ -418,7 +411,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
418 | sync_dirty_buffer(HFSPLUS_SB(sb).s_vhbh); | 411 | sync_dirty_buffer(HFSPLUS_SB(sb).s_vhbh); |
419 | 412 | ||
420 | if (!HFSPLUS_SB(sb).hidden_dir) { | 413 | if (!HFSPLUS_SB(sb).hidden_dir) { |
421 | printk("HFS+: create hidden dir...\n"); | 414 | printk(KERN_DEBUG "hfs: create hidden dir...\n"); |
422 | HFSPLUS_SB(sb).hidden_dir = hfsplus_new_inode(sb, S_IFDIR); | 415 | HFSPLUS_SB(sb).hidden_dir = hfsplus_new_inode(sb, S_IFDIR); |
423 | hfsplus_create_cat(HFSPLUS_SB(sb).hidden_dir->i_ino, sb->s_root->d_inode, | 416 | hfsplus_create_cat(HFSPLUS_SB(sb).hidden_dir->i_ino, sb->s_root->d_inode, |
424 | &str, HFSPLUS_SB(sb).hidden_dir); | 417 | &str, HFSPLUS_SB(sb).hidden_dir); |
@@ -498,7 +491,7 @@ static void __exit exit_hfsplus_fs(void) | |||
498 | { | 491 | { |
499 | unregister_filesystem(&hfsplus_fs_type); | 492 | unregister_filesystem(&hfsplus_fs_type); |
500 | if (kmem_cache_destroy(hfsplus_inode_cachep)) | 493 | if (kmem_cache_destroy(hfsplus_inode_cachep)) |
501 | printk(KERN_INFO "hfsplus_inode_cache: not all structures were freed\n"); | 494 | printk(KERN_ERR "hfsplus_inode_cache: not all structures were freed\n"); |
502 | } | 495 | } |
503 | 496 | ||
504 | module_init(init_hfsplus_fs) | 497 | module_init(init_hfsplus_fs) |