super.c (ea9b395fe20ac74be788f415af2622ac8f0c35c7) super.c (634725a92938b0f282b17cec0b007dca77adebd2)
1/*
2 * linux/fs/hfsplus/super.c
3 *
4 * Copyright (C) 2001
5 * Brad Boyer (flar@allandria.com)
6 * (C) 2003 Ardis Technologies <roman@ardistech.com>
7 *
8 */

--- 155 unchanged lines hidden (view full) ---

164 if (HFSPLUS_SB(sb).flags & HFSPLUS_SB_WRITEBACKUP) {
165 if (HFSPLUS_SB(sb).sect_count) {
166 struct buffer_head *bh;
167 u32 block, offset;
168
169 block = HFSPLUS_SB(sb).blockoffset;
170 block += (HFSPLUS_SB(sb).sect_count - 2) >> (sb->s_blocksize_bits - 9);
171 offset = ((HFSPLUS_SB(sb).sect_count - 2) << 9) & (sb->s_blocksize - 1);
1/*
2 * linux/fs/hfsplus/super.c
3 *
4 * Copyright (C) 2001
5 * Brad Boyer (flar@allandria.com)
6 * (C) 2003 Ardis Technologies <roman@ardistech.com>
7 *
8 */

--- 155 unchanged lines hidden (view full) ---

164 if (HFSPLUS_SB(sb).flags & HFSPLUS_SB_WRITEBACKUP) {
165 if (HFSPLUS_SB(sb).sect_count) {
166 struct buffer_head *bh;
167 u32 block, offset;
168
169 block = HFSPLUS_SB(sb).blockoffset;
170 block += (HFSPLUS_SB(sb).sect_count - 2) >> (sb->s_blocksize_bits - 9);
171 offset = ((HFSPLUS_SB(sb).sect_count - 2) << 9) & (sb->s_blocksize - 1);
172 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,
173 HFSPLUS_SB(sb).sect_count, block, offset);
174 bh = sb_bread(sb, block);
175 if (bh) {
176 vhdr = (struct hfsplus_vh *)(bh->b_data + offset);
177 if (be16_to_cpu(vhdr->signature) == HFSPLUS_VOLHEAD_SIG) {
178 memcpy(vhdr, HFSPLUS_SB(sb).s_vhdr, sizeof(*vhdr));
179 mark_buffer_dirty(bh);
180 brelse(bh);
181 } else
173 HFSPLUS_SB(sb).sect_count, block, offset);
174 bh = sb_bread(sb, block);
175 if (bh) {
176 vhdr = (struct hfsplus_vh *)(bh->b_data + offset);
177 if (be16_to_cpu(vhdr->signature) == HFSPLUS_VOLHEAD_SIG) {
178 memcpy(vhdr, HFSPLUS_SB(sb).s_vhdr, sizeof(*vhdr));
179 mark_buffer_dirty(bh);
180 brelse(bh);
181 } else
182 printk("backup not found!\n");
182 printk(KERN_WARNING "hfs: backup not found!\n");
183 }
184 }
185 HFSPLUS_SB(sb).flags &= ~HFSPLUS_SB_WRITEBACKUP;
186 }
187}
188
189static void hfsplus_put_super(struct super_block *sb)
190{

--- 44 unchanged lines hidden (view full) ---

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;
241
242 if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
183 }
184 }
185 HFSPLUS_SB(sb).flags &= ~HFSPLUS_SB_WRITEBACKUP;
186 }
187}
188
189static void hfsplus_put_super(struct super_block *sb)
190{

--- 44 unchanged lines hidden (view full) ---

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;
241
242 if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
243 printk("HFS+-fs warning: Filesystem was not cleanly unmounted, "
243 printk(KERN_WARNING "hfs: filesystem was not cleanly unmounted, "
244 "running fsck.hfsplus is recommended. leaving read-only.\n");
245 sb->s_flags |= MS_RDONLY;
246 *flags |= MS_RDONLY;
247 } else if (sbi.flags & HFSPLUS_SB_FORCE) {
248 /* nothing */
249 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
244 "running fsck.hfsplus is recommended. leaving read-only.\n");
245 sb->s_flags |= MS_RDONLY;
246 *flags |= MS_RDONLY;
247 } else if (sbi.flags & HFSPLUS_SB_FORCE) {
248 /* nothing */
249 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
250 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)) {
251 sb->s_flags |= MS_RDONLY;
252 *flags |= MS_RDONLY;
253 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) {
254 printk("HFS+-fs: Filesystem is marked journaled, leaving read-only.\n");
254 printk(KERN_WARNING "hfs: filesystem is marked journaled, leaving read-only.\n");
255 sb->s_flags |= MS_RDONLY;
256 *flags |= MS_RDONLY;
257 }
258 }
259 return 0;
260}
261
262static struct super_operations hfsplus_sops = {

--- 24 unchanged lines hidden (view full) ---

287 if (!sbi)
288 return -ENOMEM;
289
290 memset(sbi, 0, sizeof(HFSPLUS_SB(sb)));
291 sb->s_fs_info = sbi;
292 INIT_HLIST_HEAD(&sbi->rsrc_inodes);
293 hfsplus_fill_defaults(sbi);
294 if (!hfsplus_parse_options(data, sbi)) {
255 sb->s_flags |= MS_RDONLY;
256 *flags |= MS_RDONLY;
257 }
258 }
259 return 0;
260}
261
262static struct super_operations hfsplus_sops = {

--- 24 unchanged lines hidden (view full) ---

287 if (!sbi)
288 return -ENOMEM;
289
290 memset(sbi, 0, sizeof(HFSPLUS_SB(sb)));
291 sb->s_fs_info = sbi;
292 INIT_HLIST_HEAD(&sbi->rsrc_inodes);
293 hfsplus_fill_defaults(sbi);
294 if (!hfsplus_parse_options(data, sbi)) {
295 if (!silent)
296 printk("HFS+-fs: unable to parse mount options\n");
295 printk(KERN_ERR "hfs: unable to parse mount options\n");
297 err = -EINVAL;
298 goto cleanup;
299 }
300
301 /* temporarily use utf8 to correctly find the hidden dir below */
302 nls = sbi->nls;
303 sbi->nls = load_nls("utf8");
304 if (!sbi->nls) {
296 err = -EINVAL;
297 goto cleanup;
298 }
299
300 /* temporarily use utf8 to correctly find the hidden dir below */
301 nls = sbi->nls;
302 sbi->nls = load_nls("utf8");
303 if (!sbi->nls) {
305 printk("HFS+: unable to load nls for utf8\n");
304 printk(KERN_ERR "hfs: unable to load nls for utf8\n");
306 err = -EINVAL;
307 goto cleanup;
308 }
309
310 /* Grab the volume header */
311 if (hfsplus_read_wrapper(sb)) {
312 if (!silent)
305 err = -EINVAL;
306 goto cleanup;
307 }
308
309 /* Grab the volume header */
310 if (hfsplus_read_wrapper(sb)) {
311 if (!silent)
313 printk("HFS+-fs: unable to find HFS+ superblock\n");
312 printk(KERN_WARNING "hfs: unable to find HFS+ superblock\n");
314 err = -EINVAL;
315 goto cleanup;
316 }
317 vhdr = HFSPLUS_SB(sb).s_vhdr;
318
319 /* Copy parts of the volume header into the superblock */
320 sb->s_magic = be16_to_cpu(vhdr->signature);
321 if (be16_to_cpu(vhdr->version) != HFSPLUS_CURRENT_VERSION) {
313 err = -EINVAL;
314 goto cleanup;
315 }
316 vhdr = HFSPLUS_SB(sb).s_vhdr;
317
318 /* Copy parts of the volume header into the superblock */
319 sb->s_magic = be16_to_cpu(vhdr->signature);
320 if (be16_to_cpu(vhdr->version) != HFSPLUS_CURRENT_VERSION) {
322 if (!silent)
323 printk("HFS+-fs: wrong filesystem version\n");
321 printk(KERN_ERR "hfs: wrong filesystem version\n");
324 goto cleanup;
325 }
326 HFSPLUS_SB(sb).total_blocks = be32_to_cpu(vhdr->total_blocks);
327 HFSPLUS_SB(sb).free_blocks = be32_to_cpu(vhdr->free_blocks);
328 HFSPLUS_SB(sb).next_alloc = be32_to_cpu(vhdr->next_alloc);
329 HFSPLUS_SB(sb).next_cnid = be32_to_cpu(vhdr->next_cnid);
330 HFSPLUS_SB(sb).file_count = be32_to_cpu(vhdr->file_count);
331 HFSPLUS_SB(sb).folder_count = be32_to_cpu(vhdr->folder_count);

--- 4 unchanged lines hidden (view full) ---

336 if (!HFSPLUS_SB(sb).rsrc_clump_blocks)
337 HFSPLUS_SB(sb).rsrc_clump_blocks = 1;
338
339 /* Set up operations so we can load metadata */
340 sb->s_op = &hfsplus_sops;
341 sb->s_maxbytes = MAX_LFS_FILESIZE;
342
343 if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
322 goto cleanup;
323 }
324 HFSPLUS_SB(sb).total_blocks = be32_to_cpu(vhdr->total_blocks);
325 HFSPLUS_SB(sb).free_blocks = be32_to_cpu(vhdr->free_blocks);
326 HFSPLUS_SB(sb).next_alloc = be32_to_cpu(vhdr->next_alloc);
327 HFSPLUS_SB(sb).next_cnid = be32_to_cpu(vhdr->next_cnid);
328 HFSPLUS_SB(sb).file_count = be32_to_cpu(vhdr->file_count);
329 HFSPLUS_SB(sb).folder_count = be32_to_cpu(vhdr->folder_count);

--- 4 unchanged lines hidden (view full) ---

334 if (!HFSPLUS_SB(sb).rsrc_clump_blocks)
335 HFSPLUS_SB(sb).rsrc_clump_blocks = 1;
336
337 /* Set up operations so we can load metadata */
338 sb->s_op = &hfsplus_sops;
339 sb->s_maxbytes = MAX_LFS_FILESIZE;
340
341 if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
344 if (!silent)
345 printk("HFS+-fs warning: Filesystem was not cleanly unmounted, "
346 "running fsck.hfsplus is recommended. mounting read-only.\n");
342 printk(KERN_WARNING "hfs: Filesystem was not cleanly unmounted, "
343 "running fsck.hfsplus is recommended. mounting read-only.\n");
347 sb->s_flags |= MS_RDONLY;
348 } else if (sbi->flags & HFSPLUS_SB_FORCE) {
349 /* nothing */
350 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
344 sb->s_flags |= MS_RDONLY;
345 } else if (sbi->flags & HFSPLUS_SB_FORCE) {
346 /* nothing */
347 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
351 if (!silent)
352 printk("HFS+-fs: Filesystem is marked locked, mounting read-only.\n");
348 printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n");
353 sb->s_flags |= MS_RDONLY;
354 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) {
349 sb->s_flags |= MS_RDONLY;
350 } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) {
355 if (!silent)
356 printk("HFS+-fs: write access to a jounaled filesystem is not supported, "
357 "use the force option at your own risk, mounting read-only.\n");
351 printk(KERN_WARNING "hfs: write access to a jounaled filesystem is not supported, "
352 "use the force option at your own risk, mounting read-only.\n");
358 sb->s_flags |= MS_RDONLY;
359 }
360 sbi->flags &= ~HFSPLUS_SB_FORCE;
361
362 /* Load metadata objects (B*Trees) */
363 HFSPLUS_SB(sb).ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID);
364 if (!HFSPLUS_SB(sb).ext_tree) {
353 sb->s_flags |= MS_RDONLY;
354 }
355 sbi->flags &= ~HFSPLUS_SB_FORCE;
356
357 /* Load metadata objects (B*Trees) */
358 HFSPLUS_SB(sb).ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID);
359 if (!HFSPLUS_SB(sb).ext_tree) {
365 if (!silent)
366 printk("HFS+-fs: failed to load extents file\n");
360 printk(KERN_ERR "hfs: failed to load extents file\n");
367 goto cleanup;
368 }
369 HFSPLUS_SB(sb).cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID);
370 if (!HFSPLUS_SB(sb).cat_tree) {
361 goto cleanup;
362 }
363 HFSPLUS_SB(sb).cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID);
364 if (!HFSPLUS_SB(sb).cat_tree) {
371 if (!silent)
372 printk("HFS+-fs: failed to load catalog file\n");
365 printk(KERN_ERR "hfs: failed to load catalog file\n");
373 goto cleanup;
374 }
375
376 HFSPLUS_SB(sb).alloc_file = iget(sb, HFSPLUS_ALLOC_CNID);
377 if (!HFSPLUS_SB(sb).alloc_file) {
366 goto cleanup;
367 }
368
369 HFSPLUS_SB(sb).alloc_file = iget(sb, HFSPLUS_ALLOC_CNID);
370 if (!HFSPLUS_SB(sb).alloc_file) {
378 if (!silent)
379 printk("HFS+-fs: failed to load allocation file\n");
371 printk(KERN_ERR "hfs: failed to load allocation file\n");
380 goto cleanup;
381 }
382
383 /* Load the root directory */
384 root = iget(sb, HFSPLUS_ROOT_CNID);
385 sb->s_root = d_alloc_root(root);
386 if (!sb->s_root) {
372 goto cleanup;
373 }
374
375 /* Load the root directory */
376 root = iget(sb, HFSPLUS_ROOT_CNID);
377 sb->s_root = d_alloc_root(root);
378 if (!sb->s_root) {
387 if (!silent)
388 printk("HFS+-fs: failed to load root directory\n");
379 printk(KERN_ERR "hfs: failed to load root directory\n");
389 iput(root);
390 goto cleanup;
391 }
392
393 str.len = sizeof(HFSP_HIDDENDIR_NAME) - 1;
394 str.name = HFSP_HIDDENDIR_NAME;
395 hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
396 hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str);

--- 17 unchanged lines hidden (view full) ---

414 vhdr->modify_date = hfsp_now2mt();
415 vhdr->write_count = cpu_to_be32(be32_to_cpu(vhdr->write_count) + 1);
416 vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_UNMNT);
417 vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_INCNSTNT);
418 mark_buffer_dirty(HFSPLUS_SB(sb).s_vhbh);
419 sync_dirty_buffer(HFSPLUS_SB(sb).s_vhbh);
420
421 if (!HFSPLUS_SB(sb).hidden_dir) {
380 iput(root);
381 goto cleanup;
382 }
383
384 str.len = sizeof(HFSP_HIDDENDIR_NAME) - 1;
385 str.name = HFSP_HIDDENDIR_NAME;
386 hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
387 hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str);

--- 17 unchanged lines hidden (view full) ---

405 vhdr->modify_date = hfsp_now2mt();
406 vhdr->write_count = cpu_to_be32(be32_to_cpu(vhdr->write_count) + 1);
407 vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_UNMNT);
408 vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_INCNSTNT);
409 mark_buffer_dirty(HFSPLUS_SB(sb).s_vhbh);
410 sync_dirty_buffer(HFSPLUS_SB(sb).s_vhbh);
411
412 if (!HFSPLUS_SB(sb).hidden_dir) {
422 printk("HFS+: create hidden dir...\n");
413 printk(KERN_DEBUG "hfs: create hidden dir...\n");
423 HFSPLUS_SB(sb).hidden_dir = hfsplus_new_inode(sb, S_IFDIR);
424 hfsplus_create_cat(HFSPLUS_SB(sb).hidden_dir->i_ino, sb->s_root->d_inode,
425 &str, HFSPLUS_SB(sb).hidden_dir);
426 mark_inode_dirty(HFSPLUS_SB(sb).hidden_dir);
427 }
428out:
429 unload_nls(sbi->nls);
430 sbi->nls = nls;

--- 63 unchanged lines hidden (view full) ---

494 kmem_cache_destroy(hfsplus_inode_cachep);
495 return err;
496}
497
498static void __exit exit_hfsplus_fs(void)
499{
500 unregister_filesystem(&hfsplus_fs_type);
501 if (kmem_cache_destroy(hfsplus_inode_cachep))
414 HFSPLUS_SB(sb).hidden_dir = hfsplus_new_inode(sb, S_IFDIR);
415 hfsplus_create_cat(HFSPLUS_SB(sb).hidden_dir->i_ino, sb->s_root->d_inode,
416 &str, HFSPLUS_SB(sb).hidden_dir);
417 mark_inode_dirty(HFSPLUS_SB(sb).hidden_dir);
418 }
419out:
420 unload_nls(sbi->nls);
421 sbi->nls = nls;

--- 63 unchanged lines hidden (view full) ---

485 kmem_cache_destroy(hfsplus_inode_cachep);
486 return err;
487}
488
489static void __exit exit_hfsplus_fs(void)
490{
491 unregister_filesystem(&hfsplus_fs_type);
492 if (kmem_cache_destroy(hfsplus_inode_cachep))
502 printk(KERN_INFO "hfsplus_inode_cache: not all structures were freed\n");
493 printk(KERN_ERR "hfsplus_inode_cache: not all structures were freed\n");
503}
504
505module_init(init_hfsplus_fs)
506module_exit(exit_hfsplus_fs)
494}
495
496module_init(init_hfsplus_fs)
497module_exit(exit_hfsplus_fs)