diff options
Diffstat (limited to 'fs/udf/super.c')
-rw-r--r-- | fs/udf/super.c | 1256 |
1 files changed, 567 insertions, 689 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c index 6658afb41cc7..7b30964665db 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -38,7 +38,7 @@ | |||
38 | * 12/20/98 find the free space bitmap (if it exists) | 38 | * 12/20/98 find the free space bitmap (if it exists) |
39 | */ | 39 | */ |
40 | 40 | ||
41 | #include "udfdecl.h" | 41 | #include "udfdecl.h" |
42 | 42 | ||
43 | #include <linux/blkdev.h> | 43 | #include <linux/blkdev.h> |
44 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
@@ -80,12 +80,15 @@ static int udf_remount_fs(struct super_block *, int *, char *); | |||
80 | static int udf_check_valid(struct super_block *, int, int); | 80 | static int udf_check_valid(struct super_block *, int, int); |
81 | static int udf_vrs(struct super_block *sb, int silent); | 81 | static int udf_vrs(struct super_block *sb, int silent); |
82 | static int udf_load_partition(struct super_block *, kernel_lb_addr *); | 82 | static int udf_load_partition(struct super_block *, kernel_lb_addr *); |
83 | static int udf_load_logicalvol(struct super_block *, struct buffer_head *, kernel_lb_addr *); | 83 | static int udf_load_logicalvol(struct super_block *, struct buffer_head *, |
84 | kernel_lb_addr *); | ||
84 | static void udf_load_logicalvolint(struct super_block *, kernel_extent_ad); | 85 | static void udf_load_logicalvolint(struct super_block *, kernel_extent_ad); |
85 | static void udf_find_anchor(struct super_block *); | 86 | static void udf_find_anchor(struct super_block *); |
86 | static int udf_find_fileset(struct super_block *, kernel_lb_addr *, kernel_lb_addr *); | 87 | static int udf_find_fileset(struct super_block *, kernel_lb_addr *, |
88 | kernel_lb_addr *); | ||
87 | static void udf_load_pvoldesc(struct super_block *, struct buffer_head *); | 89 | static void udf_load_pvoldesc(struct super_block *, struct buffer_head *); |
88 | static void udf_load_fileset(struct super_block *, struct buffer_head *, kernel_lb_addr *); | 90 | static void udf_load_fileset(struct super_block *, struct buffer_head *, |
91 | kernel_lb_addr *); | ||
89 | static void udf_load_partdesc(struct super_block *, struct buffer_head *); | 92 | static void udf_load_partdesc(struct super_block *, struct buffer_head *); |
90 | static void udf_open_lvid(struct super_block *); | 93 | static void udf_open_lvid(struct super_block *); |
91 | static void udf_close_lvid(struct super_block *); | 94 | static void udf_close_lvid(struct super_block *); |
@@ -94,7 +97,8 @@ static int udf_statfs(struct dentry *, struct kstatfs *); | |||
94 | 97 | ||
95 | /* UDF filesystem type */ | 98 | /* UDF filesystem type */ |
96 | static int udf_get_sb(struct file_system_type *fs_type, | 99 | static int udf_get_sb(struct file_system_type *fs_type, |
97 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) | 100 | int flags, const char *dev_name, void *data, |
101 | struct vfsmount *mnt) | ||
98 | { | 102 | { |
99 | return get_sb_bdev(fs_type, flags, dev_name, data, udf_fill_super, mnt); | 103 | return get_sb_bdev(fs_type, flags, dev_name, data, udf_fill_super, mnt); |
100 | } | 104 | } |
@@ -107,7 +111,7 @@ static struct file_system_type udf_fstype = { | |||
107 | .fs_flags = FS_REQUIRES_DEV, | 111 | .fs_flags = FS_REQUIRES_DEV, |
108 | }; | 112 | }; |
109 | 113 | ||
110 | static struct kmem_cache * udf_inode_cachep; | 114 | static struct kmem_cache *udf_inode_cachep; |
111 | 115 | ||
112 | static struct inode *udf_alloc_inode(struct super_block *sb) | 116 | static struct inode *udf_alloc_inode(struct super_block *sb) |
113 | { | 117 | { |
@@ -130,9 +134,9 @@ static void udf_destroy_inode(struct inode *inode) | |||
130 | kmem_cache_free(udf_inode_cachep, UDF_I(inode)); | 134 | kmem_cache_free(udf_inode_cachep, UDF_I(inode)); |
131 | } | 135 | } |
132 | 136 | ||
133 | static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags) | 137 | static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags) |
134 | { | 138 | { |
135 | struct udf_inode_info *ei = (struct udf_inode_info *) foo; | 139 | struct udf_inode_info *ei = (struct udf_inode_info *)foo; |
136 | 140 | ||
137 | ei->i_ext.i_data = NULL; | 141 | ei->i_ext.i_data = NULL; |
138 | inode_init_once(&ei->vfs_inode); | 142 | inode_init_once(&ei->vfs_inode); |
@@ -142,10 +146,10 @@ static int init_inodecache(void) | |||
142 | { | 146 | { |
143 | udf_inode_cachep = kmem_cache_create("udf_inode_cache", | 147 | udf_inode_cachep = kmem_cache_create("udf_inode_cache", |
144 | sizeof(struct udf_inode_info), | 148 | sizeof(struct udf_inode_info), |
145 | 0, (SLAB_RECLAIM_ACCOUNT| | 149 | 0, (SLAB_RECLAIM_ACCOUNT | |
146 | SLAB_MEM_SPREAD), | 150 | SLAB_MEM_SPREAD), |
147 | init_once, NULL); | 151 | init_once); |
148 | if (udf_inode_cachep == NULL) | 152 | if (!udf_inode_cachep) |
149 | return -ENOMEM; | 153 | return -ENOMEM; |
150 | return 0; | 154 | return 0; |
151 | } | 155 | } |
@@ -157,19 +161,18 @@ static void destroy_inodecache(void) | |||
157 | 161 | ||
158 | /* Superblock operations */ | 162 | /* Superblock operations */ |
159 | static const struct super_operations udf_sb_ops = { | 163 | static const struct super_operations udf_sb_ops = { |
160 | .alloc_inode = udf_alloc_inode, | 164 | .alloc_inode = udf_alloc_inode, |
161 | .destroy_inode = udf_destroy_inode, | 165 | .destroy_inode = udf_destroy_inode, |
162 | .write_inode = udf_write_inode, | 166 | .write_inode = udf_write_inode, |
163 | .delete_inode = udf_delete_inode, | 167 | .delete_inode = udf_delete_inode, |
164 | .clear_inode = udf_clear_inode, | 168 | .clear_inode = udf_clear_inode, |
165 | .put_super = udf_put_super, | 169 | .put_super = udf_put_super, |
166 | .write_super = udf_write_super, | 170 | .write_super = udf_write_super, |
167 | .statfs = udf_statfs, | 171 | .statfs = udf_statfs, |
168 | .remount_fs = udf_remount_fs, | 172 | .remount_fs = udf_remount_fs, |
169 | }; | 173 | }; |
170 | 174 | ||
171 | struct udf_options | 175 | struct udf_options { |
172 | { | ||
173 | unsigned char novrs; | 176 | unsigned char novrs; |
174 | unsigned int blocksize; | 177 | unsigned int blocksize; |
175 | unsigned int session; | 178 | unsigned int session; |
@@ -189,15 +192,19 @@ struct udf_options | |||
189 | static int __init init_udf_fs(void) | 192 | static int __init init_udf_fs(void) |
190 | { | 193 | { |
191 | int err; | 194 | int err; |
195 | |||
192 | err = init_inodecache(); | 196 | err = init_inodecache(); |
193 | if (err) | 197 | if (err) |
194 | goto out1; | 198 | goto out1; |
195 | err = register_filesystem(&udf_fstype); | 199 | err = register_filesystem(&udf_fstype); |
196 | if (err) | 200 | if (err) |
197 | goto out; | 201 | goto out; |
202 | |||
198 | return 0; | 203 | return 0; |
204 | |||
199 | out: | 205 | out: |
200 | destroy_inodecache(); | 206 | destroy_inodecache(); |
207 | |||
201 | out1: | 208 | out1: |
202 | return err; | 209 | return err; |
203 | } | 210 | } |
@@ -235,7 +242,7 @@ module_exit(exit_udf_fs) | |||
235 | * | 242 | * |
236 | * The remaining are for debugging and disaster recovery: | 243 | * The remaining are for debugging and disaster recovery: |
237 | * | 244 | * |
238 | * novrs Skip volume sequence recognition | 245 | * novrs Skip volume sequence recognition |
239 | * | 246 | * |
240 | * The following expect a offset from 0. | 247 | * The following expect a offset from 0. |
241 | * | 248 | * |
@@ -275,36 +282,35 @@ enum { | |||
275 | }; | 282 | }; |
276 | 283 | ||
277 | static match_table_t tokens = { | 284 | static match_table_t tokens = { |
278 | {Opt_novrs, "novrs"}, | 285 | {Opt_novrs, "novrs"}, |
279 | {Opt_nostrict, "nostrict"}, | 286 | {Opt_nostrict, "nostrict"}, |
280 | {Opt_bs, "bs=%u"}, | 287 | {Opt_bs, "bs=%u"}, |
281 | {Opt_unhide, "unhide"}, | 288 | {Opt_unhide, "unhide"}, |
282 | {Opt_undelete, "undelete"}, | 289 | {Opt_undelete, "undelete"}, |
283 | {Opt_noadinicb, "noadinicb"}, | 290 | {Opt_noadinicb, "noadinicb"}, |
284 | {Opt_adinicb, "adinicb"}, | 291 | {Opt_adinicb, "adinicb"}, |
285 | {Opt_shortad, "shortad"}, | 292 | {Opt_shortad, "shortad"}, |
286 | {Opt_longad, "longad"}, | 293 | {Opt_longad, "longad"}, |
287 | {Opt_uforget, "uid=forget"}, | 294 | {Opt_uforget, "uid=forget"}, |
288 | {Opt_uignore, "uid=ignore"}, | 295 | {Opt_uignore, "uid=ignore"}, |
289 | {Opt_gforget, "gid=forget"}, | 296 | {Opt_gforget, "gid=forget"}, |
290 | {Opt_gignore, "gid=ignore"}, | 297 | {Opt_gignore, "gid=ignore"}, |
291 | {Opt_gid, "gid=%u"}, | 298 | {Opt_gid, "gid=%u"}, |
292 | {Opt_uid, "uid=%u"}, | 299 | {Opt_uid, "uid=%u"}, |
293 | {Opt_umask, "umask=%o"}, | 300 | {Opt_umask, "umask=%o"}, |
294 | {Opt_session, "session=%u"}, | 301 | {Opt_session, "session=%u"}, |
295 | {Opt_lastblock, "lastblock=%u"}, | 302 | {Opt_lastblock, "lastblock=%u"}, |
296 | {Opt_anchor, "anchor=%u"}, | 303 | {Opt_anchor, "anchor=%u"}, |
297 | {Opt_volume, "volume=%u"}, | 304 | {Opt_volume, "volume=%u"}, |
298 | {Opt_partition, "partition=%u"}, | 305 | {Opt_partition, "partition=%u"}, |
299 | {Opt_fileset, "fileset=%u"}, | 306 | {Opt_fileset, "fileset=%u"}, |
300 | {Opt_rootdir, "rootdir=%u"}, | 307 | {Opt_rootdir, "rootdir=%u"}, |
301 | {Opt_utf8, "utf8"}, | 308 | {Opt_utf8, "utf8"}, |
302 | {Opt_iocharset, "iocharset=%s"}, | 309 | {Opt_iocharset, "iocharset=%s"}, |
303 | {Opt_err, NULL} | 310 | {Opt_err, NULL} |
304 | }; | 311 | }; |
305 | 312 | ||
306 | static int | 313 | static int udf_parse_options(char *options, struct udf_options *uopt) |
307 | udf_parse_options(char *options, struct udf_options *uopt) | ||
308 | { | 314 | { |
309 | char *p; | 315 | char *p; |
310 | int option; | 316 | int option; |
@@ -323,145 +329,143 @@ udf_parse_options(char *options, struct udf_options *uopt) | |||
323 | if (!options) | 329 | if (!options) |
324 | return 1; | 330 | return 1; |
325 | 331 | ||
326 | while ((p = strsep(&options, ",")) != NULL) | 332 | while ((p = strsep(&options, ",")) != NULL) { |
327 | { | ||
328 | substring_t args[MAX_OPT_ARGS]; | 333 | substring_t args[MAX_OPT_ARGS]; |
329 | int token; | 334 | int token; |
330 | if (!*p) | 335 | if (!*p) |
331 | continue; | 336 | continue; |
332 | 337 | ||
333 | token = match_token(p, tokens, args); | 338 | token = match_token(p, tokens, args); |
334 | switch (token) | 339 | switch (token) { |
335 | { | 340 | case Opt_novrs: |
336 | case Opt_novrs: | 341 | uopt->novrs = 1; |
337 | uopt->novrs = 1; | 342 | case Opt_bs: |
338 | case Opt_bs: | 343 | if (match_int(&args[0], &option)) |
339 | if (match_int(&args[0], &option)) | 344 | return 0; |
340 | return 0; | 345 | uopt->blocksize = option; |
341 | uopt->blocksize = option; | 346 | break; |
342 | break; | 347 | case Opt_unhide: |
343 | case Opt_unhide: | 348 | uopt->flags |= (1 << UDF_FLAG_UNHIDE); |
344 | uopt->flags |= (1 << UDF_FLAG_UNHIDE); | 349 | break; |
345 | break; | 350 | case Opt_undelete: |
346 | case Opt_undelete: | 351 | uopt->flags |= (1 << UDF_FLAG_UNDELETE); |
347 | uopt->flags |= (1 << UDF_FLAG_UNDELETE); | 352 | break; |
348 | break; | 353 | case Opt_noadinicb: |
349 | case Opt_noadinicb: | 354 | uopt->flags &= ~(1 << UDF_FLAG_USE_AD_IN_ICB); |
350 | uopt->flags &= ~(1 << UDF_FLAG_USE_AD_IN_ICB); | 355 | break; |
351 | break; | 356 | case Opt_adinicb: |
352 | case Opt_adinicb: | 357 | uopt->flags |= (1 << UDF_FLAG_USE_AD_IN_ICB); |
353 | uopt->flags |= (1 << UDF_FLAG_USE_AD_IN_ICB); | 358 | break; |
354 | break; | 359 | case Opt_shortad: |
355 | case Opt_shortad: | 360 | uopt->flags |= (1 << UDF_FLAG_USE_SHORT_AD); |
356 | uopt->flags |= (1 << UDF_FLAG_USE_SHORT_AD); | 361 | break; |
357 | break; | 362 | case Opt_longad: |
358 | case Opt_longad: | 363 | uopt->flags &= ~(1 << UDF_FLAG_USE_SHORT_AD); |
359 | uopt->flags &= ~(1 << UDF_FLAG_USE_SHORT_AD); | 364 | break; |
360 | break; | 365 | case Opt_gid: |
361 | case Opt_gid: | 366 | if (match_int(args, &option)) |
362 | if (match_int(args, &option)) | 367 | return 0; |
363 | return 0; | 368 | uopt->gid = option; |
364 | uopt->gid = option; | 369 | break; |
365 | break; | 370 | case Opt_uid: |
366 | case Opt_uid: | 371 | if (match_int(args, &option)) |
367 | if (match_int(args, &option)) | 372 | return 0; |
368 | return 0; | 373 | uopt->uid = option; |
369 | uopt->uid = option; | 374 | break; |
370 | break; | 375 | case Opt_umask: |
371 | case Opt_umask: | 376 | if (match_octal(args, &option)) |
372 | if (match_octal(args, &option)) | 377 | return 0; |
373 | return 0; | 378 | uopt->umask = option; |
374 | uopt->umask = option; | 379 | break; |
375 | break; | 380 | case Opt_nostrict: |
376 | case Opt_nostrict: | 381 | uopt->flags &= ~(1 << UDF_FLAG_STRICT); |
377 | uopt->flags &= ~(1 << UDF_FLAG_STRICT); | 382 | break; |
378 | break; | 383 | case Opt_session: |
379 | case Opt_session: | 384 | if (match_int(args, &option)) |
380 | if (match_int(args, &option)) | 385 | return 0; |
381 | return 0; | 386 | uopt->session = option; |
382 | uopt->session = option; | 387 | break; |
383 | break; | 388 | case Opt_lastblock: |
384 | case Opt_lastblock: | 389 | if (match_int(args, &option)) |
385 | if (match_int(args, &option)) | 390 | return 0; |
386 | return 0; | 391 | uopt->lastblock = option; |
387 | uopt->lastblock = option; | 392 | break; |
388 | break; | 393 | case Opt_anchor: |
389 | case Opt_anchor: | 394 | if (match_int(args, &option)) |
390 | if (match_int(args, &option)) | 395 | return 0; |
391 | return 0; | 396 | uopt->anchor = option; |
392 | uopt->anchor = option; | 397 | break; |
393 | break; | 398 | case Opt_volume: |
394 | case Opt_volume: | 399 | if (match_int(args, &option)) |
395 | if (match_int(args, &option)) | 400 | return 0; |
396 | return 0; | 401 | uopt->volume = option; |
397 | uopt->volume = option; | 402 | break; |
398 | break; | 403 | case Opt_partition: |
399 | case Opt_partition: | 404 | if (match_int(args, &option)) |
400 | if (match_int(args, &option)) | 405 | return 0; |
401 | return 0; | 406 | uopt->partition = option; |
402 | uopt->partition = option; | 407 | break; |
403 | break; | 408 | case Opt_fileset: |
404 | case Opt_fileset: | 409 | if (match_int(args, &option)) |
405 | if (match_int(args, &option)) | 410 | return 0; |
406 | return 0; | 411 | uopt->fileset = option; |
407 | uopt->fileset = option; | 412 | break; |
408 | break; | 413 | case Opt_rootdir: |
409 | case Opt_rootdir: | 414 | if (match_int(args, &option)) |
410 | if (match_int(args, &option)) | 415 | return 0; |
411 | return 0; | 416 | uopt->rootdir = option; |
412 | uopt->rootdir = option; | 417 | break; |
413 | break; | 418 | case Opt_utf8: |
414 | case Opt_utf8: | 419 | uopt->flags |= (1 << UDF_FLAG_UTF8); |
415 | uopt->flags |= (1 << UDF_FLAG_UTF8); | 420 | break; |
416 | break; | ||
417 | #ifdef CONFIG_UDF_NLS | 421 | #ifdef CONFIG_UDF_NLS |
418 | case Opt_iocharset: | 422 | case Opt_iocharset: |
419 | uopt->nls_map = load_nls(args[0].from); | 423 | uopt->nls_map = load_nls(args[0].from); |
420 | uopt->flags |= (1 << UDF_FLAG_NLS_MAP); | 424 | uopt->flags |= (1 << UDF_FLAG_NLS_MAP); |
421 | break; | 425 | break; |
422 | #endif | 426 | #endif |
423 | case Opt_uignore: | 427 | case Opt_uignore: |
424 | uopt->flags |= (1 << UDF_FLAG_UID_IGNORE); | 428 | uopt->flags |= (1 << UDF_FLAG_UID_IGNORE); |
425 | break; | 429 | break; |
426 | case Opt_uforget: | 430 | case Opt_uforget: |
427 | uopt->flags |= (1 << UDF_FLAG_UID_FORGET); | 431 | uopt->flags |= (1 << UDF_FLAG_UID_FORGET); |
428 | break; | 432 | break; |
429 | case Opt_gignore: | 433 | case Opt_gignore: |
430 | uopt->flags |= (1 << UDF_FLAG_GID_IGNORE); | 434 | uopt->flags |= (1 << UDF_FLAG_GID_IGNORE); |
431 | break; | 435 | break; |
432 | case Opt_gforget: | 436 | case Opt_gforget: |
433 | uopt->flags |= (1 << UDF_FLAG_GID_FORGET); | 437 | uopt->flags |= (1 << UDF_FLAG_GID_FORGET); |
434 | break; | 438 | break; |
435 | default: | 439 | default: |
436 | printk(KERN_ERR "udf: bad mount option \"%s\" " | 440 | printk(KERN_ERR "udf: bad mount option \"%s\" " |
437 | "or missing value\n", p); | 441 | "or missing value\n", p); |
438 | return 0; | 442 | return 0; |
439 | } | 443 | } |
440 | } | 444 | } |
441 | return 1; | 445 | return 1; |
442 | } | 446 | } |
443 | 447 | ||
444 | void | 448 | void udf_write_super(struct super_block *sb) |
445 | udf_write_super(struct super_block *sb) | ||
446 | { | 449 | { |
447 | lock_kernel(); | 450 | lock_kernel(); |
451 | |||
448 | if (!(sb->s_flags & MS_RDONLY)) | 452 | if (!(sb->s_flags & MS_RDONLY)) |
449 | udf_open_lvid(sb); | 453 | udf_open_lvid(sb); |
450 | sb->s_dirt = 0; | 454 | sb->s_dirt = 0; |
455 | |||
451 | unlock_kernel(); | 456 | unlock_kernel(); |
452 | } | 457 | } |
453 | 458 | ||
454 | static int | 459 | static int udf_remount_fs(struct super_block *sb, int *flags, char *options) |
455 | udf_remount_fs(struct super_block *sb, int *flags, char *options) | ||
456 | { | 460 | { |
457 | struct udf_options uopt; | 461 | struct udf_options uopt; |
458 | 462 | ||
459 | uopt.flags = UDF_SB(sb)->s_flags ; | 463 | uopt.flags = UDF_SB(sb)->s_flags; |
460 | uopt.uid = UDF_SB(sb)->s_uid ; | 464 | uopt.uid = UDF_SB(sb)->s_uid; |
461 | uopt.gid = UDF_SB(sb)->s_gid ; | 465 | uopt.gid = UDF_SB(sb)->s_gid; |
462 | uopt.umask = UDF_SB(sb)->s_umask ; | 466 | uopt.umask = UDF_SB(sb)->s_umask; |
463 | 467 | ||
464 | if ( !udf_parse_options(options, &uopt) ) | 468 | if (!udf_parse_options(options, &uopt)) |
465 | return -EINVAL; | 469 | return -EINVAL; |
466 | 470 | ||
467 | UDF_SB(sb)->s_flags = uopt.flags; | 471 | UDF_SB(sb)->s_flags = uopt.flags; |
@@ -512,27 +516,26 @@ udf_remount_fs(struct super_block *sb, int *flags, char *options) | |||
512 | * July 1, 1997 - Andrew E. Mileski | 516 | * July 1, 1997 - Andrew E. Mileski |
513 | * Written, tested, and released. | 517 | * Written, tested, and released. |
514 | */ | 518 | */ |
515 | static int | 519 | static int udf_set_blocksize(struct super_block *sb, int bsize) |
516 | udf_set_blocksize(struct super_block *sb, int bsize) | ||
517 | { | 520 | { |
518 | if (!sb_min_blocksize(sb, bsize)) { | 521 | if (!sb_min_blocksize(sb, bsize)) { |
519 | udf_debug("Bad block size (%d)\n", bsize); | 522 | udf_debug("Bad block size (%d)\n", bsize); |
520 | printk(KERN_ERR "udf: bad block size (%d)\n", bsize); | 523 | printk(KERN_ERR "udf: bad block size (%d)\n", bsize); |
521 | return 0; | 524 | return 0; |
522 | } | 525 | } |
526 | |||
523 | return sb->s_blocksize; | 527 | return sb->s_blocksize; |
524 | } | 528 | } |
525 | 529 | ||
526 | static int | 530 | static int udf_vrs(struct super_block *sb, int silent) |
527 | udf_vrs(struct super_block *sb, int silent) | ||
528 | { | 531 | { |
529 | struct volStructDesc *vsd = NULL; | 532 | struct volStructDesc *vsd = NULL; |
530 | int sector = 32768; | 533 | int sector = 32768; |
531 | int sectorsize; | 534 | int sectorsize; |
532 | struct buffer_head *bh = NULL; | 535 | struct buffer_head *bh = NULL; |
533 | int iso9660=0; | 536 | int iso9660 = 0; |
534 | int nsr02=0; | 537 | int nsr02 = 0; |
535 | int nsr03=0; | 538 | int nsr03 = 0; |
536 | 539 | ||
537 | /* Block size must be a multiple of 512 */ | 540 | /* Block size must be a multiple of 512 */ |
538 | if (sb->s_blocksize & 511) | 541 | if (sb->s_blocksize & 511) |
@@ -546,10 +549,9 @@ udf_vrs(struct super_block *sb, int silent) | |||
546 | sector += (UDF_SB_SESSION(sb) << sb->s_blocksize_bits); | 549 | sector += (UDF_SB_SESSION(sb) << sb->s_blocksize_bits); |
547 | 550 | ||
548 | udf_debug("Starting at sector %u (%ld byte sectors)\n", | 551 | udf_debug("Starting at sector %u (%ld byte sectors)\n", |
549 | (sector >> sb->s_blocksize_bits), sb->s_blocksize); | 552 | (sector >> sb->s_blocksize_bits), sb->s_blocksize); |
550 | /* Process the sequence (if applicable) */ | 553 | /* Process the sequence (if applicable) */ |
551 | for (;!nsr02 && !nsr03; sector += sectorsize) | 554 | for (; !nsr02 && !nsr03; sector += sectorsize) { |
552 | { | ||
553 | /* Read a block */ | 555 | /* Read a block */ |
554 | bh = udf_tread(sb, sector >> sb->s_blocksize_bits); | 556 | bh = udf_tread(sb, sector >> sb->s_blocksize_bits); |
555 | if (!bh) | 557 | if (!bh) |
@@ -557,52 +559,45 @@ udf_vrs(struct super_block *sb, int silent) | |||
557 | 559 | ||
558 | /* Look for ISO descriptors */ | 560 | /* Look for ISO descriptors */ |
559 | vsd = (struct volStructDesc *)(bh->b_data + | 561 | vsd = (struct volStructDesc *)(bh->b_data + |
560 | (sector & (sb->s_blocksize - 1))); | 562 | (sector & (sb->s_blocksize - 1))); |
561 | 563 | ||
562 | if (vsd->stdIdent[0] == 0) | 564 | if (vsd->stdIdent[0] == 0) { |
563 | { | ||
564 | brelse(bh); | 565 | brelse(bh); |
565 | break; | 566 | break; |
566 | } | 567 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) { |
567 | else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) | ||
568 | { | ||
569 | iso9660 = sector; | 568 | iso9660 = sector; |
570 | switch (vsd->structType) | 569 | switch (vsd->structType) { |
571 | { | 570 | case 0: |
572 | case 0: | 571 | udf_debug("ISO9660 Boot Record found\n"); |
573 | udf_debug("ISO9660 Boot Record found\n"); | 572 | break; |
574 | break; | 573 | case 1: |
575 | case 1: | 574 | udf_debug |
576 | udf_debug("ISO9660 Primary Volume Descriptor found\n"); | 575 | ("ISO9660 Primary Volume Descriptor found\n"); |
577 | break; | 576 | break; |
578 | case 2: | 577 | case 2: |
579 | udf_debug("ISO9660 Supplementary Volume Descriptor found\n"); | 578 | udf_debug |
580 | break; | 579 | ("ISO9660 Supplementary Volume Descriptor found\n"); |
581 | case 3: | 580 | break; |
582 | udf_debug("ISO9660 Volume Partition Descriptor found\n"); | 581 | case 3: |
583 | break; | 582 | udf_debug |
584 | case 255: | 583 | ("ISO9660 Volume Partition Descriptor found\n"); |
585 | udf_debug("ISO9660 Volume Descriptor Set Terminator found\n"); | 584 | break; |
586 | break; | 585 | case 255: |
587 | default: | 586 | udf_debug |
588 | udf_debug("ISO9660 VRS (%u) found\n", vsd->structType); | 587 | ("ISO9660 Volume Descriptor Set Terminator found\n"); |
589 | break; | 588 | break; |
589 | default: | ||
590 | udf_debug("ISO9660 VRS (%u) found\n", | ||
591 | vsd->structType); | ||
592 | break; | ||
590 | } | 593 | } |
591 | } | 594 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) { |
592 | else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) | 595 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN)) { |
593 | { | ||
594 | } | ||
595 | else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN)) | ||
596 | { | ||
597 | brelse(bh); | 596 | brelse(bh); |
598 | break; | 597 | break; |
599 | } | 598 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) { |
600 | else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) | ||
601 | { | ||
602 | nsr02 = sector; | 599 | nsr02 = sector; |
603 | } | 600 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) { |
604 | else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) | ||
605 | { | ||
606 | nsr03 = sector; | 601 | nsr03 = sector; |
607 | } | 602 | } |
608 | brelse(bh); | 603 | brelse(bh); |
@@ -635,8 +630,7 @@ udf_vrs(struct super_block *sb, int silent) | |||
635 | * July 1, 1997 - Andrew E. Mileski | 630 | * July 1, 1997 - Andrew E. Mileski |
636 | * Written, tested, and released. | 631 | * Written, tested, and released. |
637 | */ | 632 | */ |
638 | static void | 633 | static void udf_find_anchor(struct super_block *sb) |
639 | udf_find_anchor(struct super_block *sb) | ||
640 | { | 634 | { |
641 | int lastblock = UDF_SB_LASTBLOCK(sb); | 635 | int lastblock = UDF_SB_LASTBLOCK(sb); |
642 | struct buffer_head *bh = NULL; | 636 | struct buffer_head *bh = NULL; |
@@ -644,8 +638,7 @@ udf_find_anchor(struct super_block *sb) | |||
644 | uint32_t location; | 638 | uint32_t location; |
645 | int i; | 639 | int i; |
646 | 640 | ||
647 | if (lastblock) | 641 | if (lastblock) { |
648 | { | ||
649 | int varlastblock = udf_variable_to_fixed(lastblock); | 642 | int varlastblock = udf_variable_to_fixed(lastblock); |
650 | int last[] = { lastblock, lastblock - 2, | 643 | int last[] = { lastblock, lastblock - 2, |
651 | lastblock - 150, lastblock - 152, | 644 | lastblock - 150, lastblock - 152, |
@@ -663,74 +656,54 @@ udf_find_anchor(struct super_block *sb) | |||
663 | * however, if the disc isn't closed, it could be 512 */ | 656 | * however, if the disc isn't closed, it could be 512 */ |
664 | 657 | ||
665 | for (i = 0; !lastblock && i < ARRAY_SIZE(last); i++) { | 658 | for (i = 0; !lastblock && i < ARRAY_SIZE(last); i++) { |
666 | if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) | 659 | if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) { |
667 | { | ||
668 | ident = location = 0; | 660 | ident = location = 0; |
669 | } | 661 | } else { |
670 | else | ||
671 | { | ||
672 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); | 662 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); |
673 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); | 663 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); |
674 | brelse(bh); | 664 | brelse(bh); |
675 | } | 665 | } |
676 | 666 | ||
677 | if (ident == TAG_IDENT_AVDP) | 667 | if (ident == TAG_IDENT_AVDP) { |
678 | { | 668 | if (location == last[i] - UDF_SB_SESSION(sb)) { |
679 | if (location == last[i] - UDF_SB_SESSION(sb)) | ||
680 | { | ||
681 | lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] - UDF_SB_SESSION(sb); | 669 | lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] - UDF_SB_SESSION(sb); |
682 | UDF_SB_ANCHOR(sb)[1] = last[i] - 256 - UDF_SB_SESSION(sb); | 670 | UDF_SB_ANCHOR(sb)[1] = last[i] - 256 - UDF_SB_SESSION(sb); |
683 | } | 671 | } else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb)) { |
684 | else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb)) | ||
685 | { | ||
686 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); | 672 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); |
687 | lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb); | 673 | lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb); |
688 | UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb); | 674 | UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb); |
689 | } | 675 | } else { |
690 | else | ||
691 | udf_debug("Anchor found at block %d, location mismatch %d.\n", | 676 | udf_debug("Anchor found at block %d, location mismatch %d.\n", |
692 | last[i], location); | 677 | last[i], location); |
693 | } | 678 | } |
694 | else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE) | 679 | } else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE) { |
695 | { | ||
696 | lastblock = last[i]; | 680 | lastblock = last[i]; |
697 | UDF_SB_ANCHOR(sb)[3] = 512; | 681 | UDF_SB_ANCHOR(sb)[3] = 512; |
698 | } | 682 | } else { |
699 | else | 683 | if (last[i] < 256 || !(bh = sb_bread(sb, last[i] - 256))) { |
700 | { | ||
701 | if (last[i] < 256 || !(bh = sb_bread(sb, last[i] - 256))) | ||
702 | { | ||
703 | ident = location = 0; | 684 | ident = location = 0; |
704 | } | 685 | } else { |
705 | else | ||
706 | { | ||
707 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); | 686 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); |
708 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); | 687 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); |
709 | brelse(bh); | 688 | brelse(bh); |
710 | } | 689 | } |
711 | 690 | ||
712 | if (ident == TAG_IDENT_AVDP && | 691 | if (ident == TAG_IDENT_AVDP && |
713 | location == last[i] - 256 - UDF_SB_SESSION(sb)) | 692 | location == last[i] - 256 - UDF_SB_SESSION(sb)) { |
714 | { | ||
715 | lastblock = last[i]; | 693 | lastblock = last[i]; |
716 | UDF_SB_ANCHOR(sb)[1] = last[i] - 256; | 694 | UDF_SB_ANCHOR(sb)[1] = last[i] - 256; |
717 | } | 695 | } else { |
718 | else | 696 | if (last[i] < 312 + UDF_SB_SESSION(sb) || |
719 | { | 697 | !(bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb)))) { |
720 | if (last[i] < 312 + UDF_SB_SESSION(sb) || !(bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb)))) | ||
721 | { | ||
722 | ident = location = 0; | 698 | ident = location = 0; |
723 | } | 699 | } else { |
724 | else | ||
725 | { | ||
726 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); | 700 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); |
727 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); | 701 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); |
728 | brelse(bh); | 702 | brelse(bh); |
729 | } | 703 | } |
730 | 704 | ||
731 | if (ident == TAG_IDENT_AVDP && | 705 | if (ident == TAG_IDENT_AVDP && |
732 | location == udf_variable_to_fixed(last[i]) - 256) | 706 | location == udf_variable_to_fixed(last[i]) - 256) { |
733 | { | ||
734 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); | 707 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); |
735 | lastblock = udf_variable_to_fixed(last[i]); | 708 | lastblock = udf_variable_to_fixed(last[i]); |
736 | UDF_SB_ANCHOR(sb)[1] = lastblock - 256; | 709 | UDF_SB_ANCHOR(sb)[1] = lastblock - 256; |
@@ -740,11 +713,9 @@ udf_find_anchor(struct super_block *sb) | |||
740 | } | 713 | } |
741 | } | 714 | } |
742 | 715 | ||
743 | if (!lastblock) | 716 | if (!lastblock) { |
744 | { | ||
745 | /* We havn't found the lastblock. check 312 */ | 717 | /* We havn't found the lastblock. check 312 */ |
746 | if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) | 718 | if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) { |
747 | { | ||
748 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); | 719 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); |
749 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); | 720 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); |
750 | brelse(bh); | 721 | brelse(bh); |
@@ -755,19 +726,14 @@ udf_find_anchor(struct super_block *sb) | |||
755 | } | 726 | } |
756 | 727 | ||
757 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { | 728 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { |
758 | if (UDF_SB_ANCHOR(sb)[i]) | 729 | if (UDF_SB_ANCHOR(sb)[i]) { |
759 | { | 730 | if (!(bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i], |
760 | if (!(bh = udf_read_tagged(sb, | 731 | UDF_SB_ANCHOR(sb)[i], &ident))) { |
761 | UDF_SB_ANCHOR(sb)[i], UDF_SB_ANCHOR(sb)[i], &ident))) | ||
762 | { | ||
763 | UDF_SB_ANCHOR(sb)[i] = 0; | 732 | UDF_SB_ANCHOR(sb)[i] = 0; |
764 | } | 733 | } else { |
765 | else | ||
766 | { | ||
767 | brelse(bh); | 734 | brelse(bh); |
768 | if ((ident != TAG_IDENT_AVDP) && (i || | 735 | if ((ident != TAG_IDENT_AVDP) && |
769 | (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE))) | 736 | (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE))) { |
770 | { | ||
771 | UDF_SB_ANCHOR(sb)[i] = 0; | 737 | UDF_SB_ANCHOR(sb)[i] = 0; |
772 | } | 738 | } |
773 | } | 739 | } |
@@ -777,89 +743,78 @@ udf_find_anchor(struct super_block *sb) | |||
777 | UDF_SB_LASTBLOCK(sb) = lastblock; | 743 | UDF_SB_LASTBLOCK(sb) = lastblock; |
778 | } | 744 | } |
779 | 745 | ||
780 | static int | 746 | static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr *root) |
781 | udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr *root) | ||
782 | { | 747 | { |
783 | struct buffer_head *bh = NULL; | 748 | struct buffer_head *bh = NULL; |
784 | long lastblock; | 749 | long lastblock; |
785 | uint16_t ident; | 750 | uint16_t ident; |
786 | 751 | ||
787 | if (fileset->logicalBlockNum != 0xFFFFFFFF || | 752 | if (fileset->logicalBlockNum != 0xFFFFFFFF || |
788 | fileset->partitionReferenceNum != 0xFFFF) | 753 | fileset->partitionReferenceNum != 0xFFFF) { |
789 | { | ||
790 | bh = udf_read_ptagged(sb, *fileset, 0, &ident); | 754 | bh = udf_read_ptagged(sb, *fileset, 0, &ident); |
791 | 755 | ||
792 | if (!bh) | 756 | if (!bh) { |
793 | return 1; | 757 | return 1; |
794 | else if (ident != TAG_IDENT_FSD) | 758 | } else if (ident != TAG_IDENT_FSD) { |
795 | { | ||
796 | brelse(bh); | 759 | brelse(bh); |
797 | return 1; | 760 | return 1; |
798 | } | 761 | } |
799 | 762 | ||
800 | } | 763 | } |
801 | 764 | ||
802 | if (!bh) /* Search backwards through the partitions */ | 765 | if (!bh) { /* Search backwards through the partitions */ |
803 | { | ||
804 | kernel_lb_addr newfileset; | 766 | kernel_lb_addr newfileset; |
805 | 767 | ||
768 | /* --> cvg: FIXME - is it reasonable? */ | ||
806 | return 1; | 769 | return 1; |
807 | 770 | ||
808 | for (newfileset.partitionReferenceNum=UDF_SB_NUMPARTS(sb)-1; | 771 | for (newfileset.partitionReferenceNum = UDF_SB_NUMPARTS(sb) - 1; |
809 | (newfileset.partitionReferenceNum != 0xFFFF && | 772 | (newfileset.partitionReferenceNum != 0xFFFF && |
810 | fileset->logicalBlockNum == 0xFFFFFFFF && | 773 | fileset->logicalBlockNum == 0xFFFFFFFF && |
811 | fileset->partitionReferenceNum == 0xFFFF); | 774 | fileset->partitionReferenceNum == 0xFFFF); |
812 | newfileset.partitionReferenceNum--) | 775 | newfileset.partitionReferenceNum--) { |
813 | { | ||
814 | lastblock = UDF_SB_PARTLEN(sb, newfileset.partitionReferenceNum); | 776 | lastblock = UDF_SB_PARTLEN(sb, newfileset.partitionReferenceNum); |
815 | newfileset.logicalBlockNum = 0; | 777 | newfileset.logicalBlockNum = 0; |
816 | 778 | ||
817 | do | 779 | do { |
818 | { | ||
819 | bh = udf_read_ptagged(sb, newfileset, 0, &ident); | 780 | bh = udf_read_ptagged(sb, newfileset, 0, &ident); |
820 | if (!bh) | 781 | if (!bh) { |
821 | { | 782 | newfileset.logicalBlockNum++; |
822 | newfileset.logicalBlockNum ++; | ||
823 | continue; | 783 | continue; |
824 | } | 784 | } |
825 | 785 | ||
826 | switch (ident) | 786 | switch (ident) { |
787 | case TAG_IDENT_SBD: | ||
827 | { | 788 | { |
828 | case TAG_IDENT_SBD: | 789 | struct spaceBitmapDesc *sp; |
829 | { | 790 | sp = (struct spaceBitmapDesc *)bh->b_data; |
830 | struct spaceBitmapDesc *sp; | 791 | newfileset.logicalBlockNum += 1 + |
831 | sp = (struct spaceBitmapDesc *)bh->b_data; | 792 | ((le32_to_cpu(sp->numOfBytes) + |
832 | newfileset.logicalBlockNum += 1 + | 793 | sizeof(struct spaceBitmapDesc) - 1) |
833 | ((le32_to_cpu(sp->numOfBytes) + sizeof(struct spaceBitmapDesc) - 1) | 794 | >> sb->s_blocksize_bits); |
834 | >> sb->s_blocksize_bits); | 795 | brelse(bh); |
835 | brelse(bh); | 796 | break; |
836 | break; | ||
837 | } | ||
838 | case TAG_IDENT_FSD: | ||
839 | { | ||
840 | *fileset = newfileset; | ||
841 | break; | ||
842 | } | ||
843 | default: | ||
844 | { | ||
845 | newfileset.logicalBlockNum ++; | ||
846 | brelse(bh); | ||
847 | bh = NULL; | ||
848 | break; | ||
849 | } | ||
850 | } | 797 | } |
851 | } | 798 | case TAG_IDENT_FSD: |
852 | while (newfileset.logicalBlockNum < lastblock && | 799 | *fileset = newfileset; |
853 | fileset->logicalBlockNum == 0xFFFFFFFF && | 800 | break; |
854 | fileset->partitionReferenceNum == 0xFFFF); | 801 | default: |
802 | newfileset.logicalBlockNum++; | ||
803 | brelse(bh); | ||
804 | bh = NULL; | ||
805 | break; | ||
806 | } | ||
807 | } while (newfileset.logicalBlockNum < lastblock && | ||
808 | fileset->logicalBlockNum == 0xFFFFFFFF && | ||
809 | fileset->partitionReferenceNum == 0xFFFF); | ||
855 | } | 810 | } |
856 | } | 811 | } |
857 | 812 | ||
858 | if ((fileset->logicalBlockNum != 0xFFFFFFFF || | 813 | if ((fileset->logicalBlockNum != 0xFFFFFFFF || |
859 | fileset->partitionReferenceNum != 0xFFFF) && bh) | 814 | fileset->partitionReferenceNum != 0xFFFF) && bh) { |
860 | { | ||
861 | udf_debug("Fileset at block=%d, partition=%d\n", | 815 | udf_debug("Fileset at block=%d, partition=%d\n", |
862 | fileset->logicalBlockNum, fileset->partitionReferenceNum); | 816 | fileset->logicalBlockNum, |
817 | fileset->partitionReferenceNum); | ||
863 | 818 | ||
864 | UDF_SB_PARTITION(sb) = fileset->partitionReferenceNum; | 819 | UDF_SB_PARTITION(sb) = fileset->partitionReferenceNum; |
865 | udf_load_fileset(sb, bh, root); | 820 | udf_load_fileset(sb, bh, root); |
@@ -869,8 +824,7 @@ udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr | |||
869 | return 1; | 824 | return 1; |
870 | } | 825 | } |
871 | 826 | ||
872 | static void | 827 | static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh) |
873 | udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh) | ||
874 | { | 828 | { |
875 | struct primaryVolDesc *pvoldesc; | 829 | struct primaryVolDesc *pvoldesc; |
876 | time_t recording; | 830 | time_t recording; |
@@ -880,37 +834,34 @@ udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh) | |||
880 | 834 | ||
881 | pvoldesc = (struct primaryVolDesc *)bh->b_data; | 835 | pvoldesc = (struct primaryVolDesc *)bh->b_data; |
882 | 836 | ||
883 | if ( udf_stamp_to_time(&recording, &recording_usec, | 837 | if (udf_stamp_to_time(&recording, &recording_usec, |
884 | lets_to_cpu(pvoldesc->recordingDateAndTime)) ) | 838 | lets_to_cpu(pvoldesc->recordingDateAndTime))) { |
885 | { | ||
886 | kernel_timestamp ts; | 839 | kernel_timestamp ts; |
887 | ts = lets_to_cpu(pvoldesc->recordingDateAndTime); | 840 | ts = lets_to_cpu(pvoldesc->recordingDateAndTime); |
888 | udf_debug("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n", | 841 | udf_debug("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n", |
889 | recording, recording_usec, | 842 | recording, recording_usec, |
890 | ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.typeAndTimezone); | 843 | ts.year, ts.month, ts.day, ts.hour, |
844 | ts.minute, ts.typeAndTimezone); | ||
891 | UDF_SB_RECORDTIME(sb).tv_sec = recording; | 845 | UDF_SB_RECORDTIME(sb).tv_sec = recording; |
892 | UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000; | 846 | UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000; |
893 | } | 847 | } |
894 | 848 | ||
895 | if ( !udf_build_ustr(&instr, pvoldesc->volIdent, 32) ) | 849 | if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32)) { |
896 | { | 850 | if (udf_CS0toUTF8(&outstr, &instr)) { |
897 | if (udf_CS0toUTF8(&outstr, &instr)) | 851 | strncpy(UDF_SB_VOLIDENT(sb), outstr.u_name, |
898 | { | ||
899 | strncpy( UDF_SB_VOLIDENT(sb), outstr.u_name, | ||
900 | outstr.u_len > 31 ? 31 : outstr.u_len); | 852 | outstr.u_len > 31 ? 31 : outstr.u_len); |
901 | udf_debug("volIdent[] = '%s'\n", UDF_SB_VOLIDENT(sb)); | 853 | udf_debug("volIdent[] = '%s'\n", UDF_SB_VOLIDENT(sb)); |
902 | } | 854 | } |
903 | } | 855 | } |
904 | 856 | ||
905 | if ( !udf_build_ustr(&instr, pvoldesc->volSetIdent, 128) ) | 857 | if (!udf_build_ustr(&instr, pvoldesc->volSetIdent, 128)) { |
906 | { | ||
907 | if (udf_CS0toUTF8(&outstr, &instr)) | 858 | if (udf_CS0toUTF8(&outstr, &instr)) |
908 | udf_debug("volSetIdent[] = '%s'\n", outstr.u_name); | 859 | udf_debug("volSetIdent[] = '%s'\n", outstr.u_name); |
909 | } | 860 | } |
910 | } | 861 | } |
911 | 862 | ||
912 | static void | 863 | static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, |
913 | udf_load_fileset(struct super_block *sb, struct buffer_head *bh, kernel_lb_addr *root) | 864 | kernel_lb_addr *root) |
914 | { | 865 | { |
915 | struct fileSetDesc *fset; | 866 | struct fileSetDesc *fset; |
916 | 867 | ||
@@ -920,24 +871,21 @@ udf_load_fileset(struct super_block *sb, struct buffer_head *bh, kernel_lb_addr | |||
920 | 871 | ||
921 | UDF_SB_SERIALNUM(sb) = le16_to_cpu(fset->descTag.tagSerialNum); | 872 | UDF_SB_SERIALNUM(sb) = le16_to_cpu(fset->descTag.tagSerialNum); |
922 | 873 | ||
923 | udf_debug("Rootdir at block=%d, partition=%d\n", | 874 | udf_debug("Rootdir at block=%d, partition=%d\n", |
924 | root->logicalBlockNum, root->partitionReferenceNum); | 875 | root->logicalBlockNum, root->partitionReferenceNum); |
925 | } | 876 | } |
926 | 877 | ||
927 | static void | 878 | static void udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) |
928 | udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) | ||
929 | { | 879 | { |
930 | struct partitionDesc *p; | 880 | struct partitionDesc *p; |
931 | int i; | 881 | int i; |
932 | 882 | ||
933 | p = (struct partitionDesc *)bh->b_data; | 883 | p = (struct partitionDesc *)bh->b_data; |
934 | 884 | ||
935 | for (i=0; i<UDF_SB_NUMPARTS(sb); i++) | 885 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { |
936 | { | 886 | udf_debug("Searching map: (%d == %d)\n", |
937 | udf_debug("Searching map: (%d == %d)\n", | 887 | UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber)); |
938 | UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber)); | 888 | if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) { |
939 | if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) | ||
940 | { | ||
941 | UDF_SB_PARTLEN(sb,i) = le32_to_cpu(p->partitionLength); /* blocks */ | 889 | UDF_SB_PARTLEN(sb,i) = le32_to_cpu(p->partitionLength); /* blocks */ |
942 | UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation); | 890 | UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation); |
943 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY) | 891 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY) |
@@ -950,79 +898,76 @@ udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) | |||
950 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_OVERWRITABLE; | 898 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_OVERWRITABLE; |
951 | 899 | ||
952 | if (!strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) || | 900 | if (!strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) || |
953 | !strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) | 901 | !strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) { |
954 | { | ||
955 | struct partitionHeaderDesc *phd; | 902 | struct partitionHeaderDesc *phd; |
956 | 903 | ||
957 | phd = (struct partitionHeaderDesc *)(p->partitionContentsUse); | 904 | phd = (struct partitionHeaderDesc *)(p->partitionContentsUse); |
958 | if (phd->unallocSpaceTable.extLength) | 905 | if (phd->unallocSpaceTable.extLength) { |
959 | { | 906 | kernel_lb_addr loc = { |
960 | kernel_lb_addr loc = { le32_to_cpu(phd->unallocSpaceTable.extPosition), i }; | 907 | .logicalBlockNum = le32_to_cpu(phd->unallocSpaceTable.extPosition), |
908 | .partitionReferenceNum = i, | ||
909 | }; | ||
961 | 910 | ||
962 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table = | 911 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table = |
963 | udf_iget(sb, loc); | 912 | udf_iget(sb, loc); |
964 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_TABLE; | 913 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_TABLE; |
965 | udf_debug("unallocSpaceTable (part %d) @ %ld\n", | 914 | udf_debug("unallocSpaceTable (part %d) @ %ld\n", |
966 | i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino); | 915 | i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino); |
967 | } | 916 | } |
968 | if (phd->unallocSpaceBitmap.extLength) | 917 | if (phd->unallocSpaceBitmap.extLength) { |
969 | { | ||
970 | UDF_SB_ALLOC_BITMAP(sb, i, s_uspace); | 918 | UDF_SB_ALLOC_BITMAP(sb, i, s_uspace); |
971 | if (UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap != NULL) | 919 | if (UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap != NULL) { |
972 | { | ||
973 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extLength = | 920 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extLength = |
974 | le32_to_cpu(phd->unallocSpaceBitmap.extLength); | 921 | le32_to_cpu(phd->unallocSpaceBitmap.extLength); |
975 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition = | 922 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition = |
976 | le32_to_cpu(phd->unallocSpaceBitmap.extPosition); | 923 | le32_to_cpu(phd->unallocSpaceBitmap.extPosition); |
977 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_BITMAP; | 924 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_BITMAP; |
978 | udf_debug("unallocSpaceBitmap (part %d) @ %d\n", | 925 | udf_debug("unallocSpaceBitmap (part %d) @ %d\n", |
979 | i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition); | 926 | i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition); |
980 | } | 927 | } |
981 | } | 928 | } |
982 | if (phd->partitionIntegrityTable.extLength) | 929 | if (phd->partitionIntegrityTable.extLength) |
983 | udf_debug("partitionIntegrityTable (part %d)\n", i); | 930 | udf_debug("partitionIntegrityTable (part %d)\n", i); |
984 | if (phd->freedSpaceTable.extLength) | 931 | if (phd->freedSpaceTable.extLength) { |
985 | { | 932 | kernel_lb_addr loc = { |
986 | kernel_lb_addr loc = { le32_to_cpu(phd->freedSpaceTable.extPosition), i }; | 933 | .logicalBlockNum = le32_to_cpu(phd->freedSpaceTable.extPosition), |
934 | .partitionReferenceNum = i, | ||
935 | }; | ||
987 | 936 | ||
988 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table = | 937 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table = |
989 | udf_iget(sb, loc); | 938 | udf_iget(sb, loc); |
990 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_TABLE; | 939 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_TABLE; |
991 | udf_debug("freedSpaceTable (part %d) @ %ld\n", | 940 | udf_debug("freedSpaceTable (part %d) @ %ld\n", |
992 | i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino); | 941 | i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino); |
993 | } | 942 | } |
994 | if (phd->freedSpaceBitmap.extLength) | 943 | if (phd->freedSpaceBitmap.extLength) { |
995 | { | ||
996 | UDF_SB_ALLOC_BITMAP(sb, i, s_fspace); | 944 | UDF_SB_ALLOC_BITMAP(sb, i, s_fspace); |
997 | if (UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap != NULL) | 945 | if (UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap != NULL) { |
998 | { | ||
999 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extLength = | 946 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extLength = |
1000 | le32_to_cpu(phd->freedSpaceBitmap.extLength); | 947 | le32_to_cpu(phd->freedSpaceBitmap.extLength); |
1001 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition = | 948 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition = |
1002 | le32_to_cpu(phd->freedSpaceBitmap.extPosition); | 949 | le32_to_cpu(phd->freedSpaceBitmap.extPosition); |
1003 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_BITMAP; | 950 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_BITMAP; |
1004 | udf_debug("freedSpaceBitmap (part %d) @ %d\n", | 951 | udf_debug("freedSpaceBitmap (part %d) @ %d\n", |
1005 | i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition); | 952 | i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition); |
1006 | } | 953 | } |
1007 | } | 954 | } |
1008 | } | 955 | } |
1009 | break; | 956 | break; |
1010 | } | 957 | } |
1011 | } | 958 | } |
1012 | if (i == UDF_SB_NUMPARTS(sb)) | 959 | if (i == UDF_SB_NUMPARTS(sb)) { |
1013 | { | 960 | udf_debug("Partition (%d) not found in partition map\n", |
1014 | udf_debug("Partition (%d) not found in partition map\n", le16_to_cpu(p->partitionNumber)); | 961 | le16_to_cpu(p->partitionNumber)); |
1015 | } | 962 | } else { |
1016 | else | ||
1017 | { | ||
1018 | udf_debug("Partition (%d:%d type %x) starts at physical %d, block length %d\n", | 963 | udf_debug("Partition (%d:%d type %x) starts at physical %d, block length %d\n", |
1019 | le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb,i), | 964 | le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb,i), |
1020 | UDF_SB_PARTROOT(sb,i), UDF_SB_PARTLEN(sb,i)); | 965 | UDF_SB_PARTROOT(sb,i), UDF_SB_PARTLEN(sb,i)); |
1021 | } | 966 | } |
1022 | } | 967 | } |
1023 | 968 | ||
1024 | static int | 969 | static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh, |
1025 | udf_load_logicalvol(struct super_block *sb, struct buffer_head * bh, kernel_lb_addr *fileset) | 970 | kernel_lb_addr *fileset) |
1026 | { | 971 | { |
1027 | struct logicalVolDesc *lvd; | 972 | struct logicalVolDesc *lvd; |
1028 | int i, j, offset; | 973 | int i, j, offset; |
@@ -1032,37 +977,27 @@ udf_load_logicalvol(struct super_block *sb, struct buffer_head * bh, kernel_lb_a | |||
1032 | 977 | ||
1033 | UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps)); | 978 | UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps)); |
1034 | 979 | ||
1035 | for (i=0,offset=0; | 980 | for (i = 0, offset = 0; |
1036 | i<UDF_SB_NUMPARTS(sb) && offset<le32_to_cpu(lvd->mapTableLength); | 981 | i < UDF_SB_NUMPARTS(sb) && offset < le32_to_cpu(lvd->mapTableLength); |
1037 | i++,offset+=((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength) | 982 | i++, offset += ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength) { |
1038 | { | ||
1039 | type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType; | 983 | type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType; |
1040 | if (type == 1) | 984 | if (type == 1) { |
1041 | { | ||
1042 | struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]); | 985 | struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]); |
1043 | UDF_SB_PARTTYPE(sb,i) = UDF_TYPE1_MAP15; | 986 | UDF_SB_PARTTYPE(sb,i) = UDF_TYPE1_MAP15; |
1044 | UDF_SB_PARTVSN(sb,i) = le16_to_cpu(gpm1->volSeqNum); | 987 | UDF_SB_PARTVSN(sb,i) = le16_to_cpu(gpm1->volSeqNum); |
1045 | UDF_SB_PARTNUM(sb,i) = le16_to_cpu(gpm1->partitionNum); | 988 | UDF_SB_PARTNUM(sb,i) = le16_to_cpu(gpm1->partitionNum); |
1046 | UDF_SB_PARTFUNC(sb,i) = NULL; | 989 | UDF_SB_PARTFUNC(sb,i) = NULL; |
1047 | } | 990 | } else if (type == 2) { |
1048 | else if (type == 2) | ||
1049 | { | ||
1050 | struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]); | 991 | struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]); |
1051 | if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) | 992 | if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) { |
1052 | { | 993 | if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) { |
1053 | if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) | ||
1054 | { | ||
1055 | UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP15; | 994 | UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP15; |
1056 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt15; | 995 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt15; |
1057 | } | 996 | } else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) { |
1058 | else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) | ||
1059 | { | ||
1060 | UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP20; | 997 | UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP20; |
1061 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt20; | 998 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt20; |
1062 | } | 999 | } |
1063 | } | 1000 | } else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) { |
1064 | else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) | ||
1065 | { | ||
1066 | uint32_t loc; | 1001 | uint32_t loc; |
1067 | uint16_t ident; | 1002 | uint16_t ident; |
1068 | struct sparingTable *st; | 1003 | struct sparingTable *st; |
@@ -1070,26 +1005,21 @@ udf_load_logicalvol(struct super_block *sb, struct buffer_head * bh, kernel_lb_a | |||
1070 | 1005 | ||
1071 | UDF_SB_PARTTYPE(sb,i) = UDF_SPARABLE_MAP15; | 1006 | UDF_SB_PARTTYPE(sb,i) = UDF_SPARABLE_MAP15; |
1072 | UDF_SB_TYPESPAR(sb,i).s_packet_len = le16_to_cpu(spm->packetLength); | 1007 | UDF_SB_TYPESPAR(sb,i).s_packet_len = le16_to_cpu(spm->packetLength); |
1073 | for (j=0; j<spm->numSparingTables; j++) | 1008 | for (j = 0; j < spm->numSparingTables; j++) { |
1074 | { | ||
1075 | loc = le32_to_cpu(spm->locSparingTable[j]); | 1009 | loc = le32_to_cpu(spm->locSparingTable[j]); |
1076 | UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = | 1010 | UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = |
1077 | udf_read_tagged(sb, loc, loc, &ident); | 1011 | udf_read_tagged(sb, loc, loc, &ident); |
1078 | if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) | 1012 | if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) { |
1079 | { | ||
1080 | st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,i).s_spar_map[j]->b_data; | 1013 | st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,i).s_spar_map[j]->b_data; |
1081 | if (ident != 0 || | 1014 | if (ident != 0 || |
1082 | strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) | 1015 | strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) { |
1083 | { | ||
1084 | brelse(UDF_SB_TYPESPAR(sb,i).s_spar_map[j]); | 1016 | brelse(UDF_SB_TYPESPAR(sb,i).s_spar_map[j]); |
1085 | UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = NULL; | 1017 | UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = NULL; |
1086 | } | 1018 | } |
1087 | } | 1019 | } |
1088 | } | 1020 | } |
1089 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_spar15; | 1021 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_spar15; |
1090 | } | 1022 | } else { |
1091 | else | ||
1092 | { | ||
1093 | udf_debug("Unknown ident: %s\n", upm2->partIdent.ident); | 1023 | udf_debug("Unknown ident: %s\n", upm2->partIdent.ident); |
1094 | continue; | 1024 | continue; |
1095 | } | 1025 | } |
@@ -1097,20 +1027,20 @@ udf_load_logicalvol(struct super_block *sb, struct buffer_head * bh, kernel_lb_a | |||
1097 | UDF_SB_PARTNUM(sb,i) = le16_to_cpu(upm2->partitionNum); | 1027 | UDF_SB_PARTNUM(sb,i) = le16_to_cpu(upm2->partitionNum); |
1098 | } | 1028 | } |
1099 | udf_debug("Partition (%d:%d) type %d on volume %d\n", | 1029 | udf_debug("Partition (%d:%d) type %d on volume %d\n", |
1100 | i, UDF_SB_PARTNUM(sb,i), type, UDF_SB_PARTVSN(sb,i)); | 1030 | i, UDF_SB_PARTNUM(sb,i), type, UDF_SB_PARTVSN(sb,i)); |
1101 | } | 1031 | } |
1102 | 1032 | ||
1103 | if (fileset) | 1033 | if (fileset) { |
1104 | { | ||
1105 | long_ad *la = (long_ad *)&(lvd->logicalVolContentsUse[0]); | 1034 | long_ad *la = (long_ad *)&(lvd->logicalVolContentsUse[0]); |
1106 | 1035 | ||
1107 | *fileset = lelb_to_cpu(la->extLocation); | 1036 | *fileset = lelb_to_cpu(la->extLocation); |
1108 | udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n", | 1037 | udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n", |
1109 | fileset->logicalBlockNum, | 1038 | fileset->logicalBlockNum, |
1110 | fileset->partitionReferenceNum); | 1039 | fileset->partitionReferenceNum); |
1111 | } | 1040 | } |
1112 | if (lvd->integritySeqExt.extLength) | 1041 | if (lvd->integritySeqExt.extLength) |
1113 | udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt)); | 1042 | udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt)); |
1043 | |||
1114 | return 0; | 1044 | return 0; |
1115 | } | 1045 | } |
1116 | 1046 | ||
@@ -1118,26 +1048,24 @@ udf_load_logicalvol(struct super_block *sb, struct buffer_head * bh, kernel_lb_a | |||
1118 | * udf_load_logicalvolint | 1048 | * udf_load_logicalvolint |
1119 | * | 1049 | * |
1120 | */ | 1050 | */ |
1121 | static void | 1051 | static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc) |
1122 | udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc) | ||
1123 | { | 1052 | { |
1124 | struct buffer_head *bh = NULL; | 1053 | struct buffer_head *bh = NULL; |
1125 | uint16_t ident; | 1054 | uint16_t ident; |
1126 | 1055 | ||
1127 | while (loc.extLength > 0 && | 1056 | while (loc.extLength > 0 && |
1128 | (bh = udf_read_tagged(sb, loc.extLocation, | 1057 | (bh = udf_read_tagged(sb, loc.extLocation, |
1129 | loc.extLocation, &ident)) && | 1058 | loc.extLocation, &ident)) && |
1130 | ident == TAG_IDENT_LVID) | 1059 | ident == TAG_IDENT_LVID) { |
1131 | { | ||
1132 | UDF_SB_LVIDBH(sb) = bh; | 1060 | UDF_SB_LVIDBH(sb) = bh; |
1133 | 1061 | ||
1134 | if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength) | 1062 | if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength) |
1135 | udf_load_logicalvolint(sb, leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt)); | 1063 | udf_load_logicalvolint(sb, leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt)); |
1136 | 1064 | ||
1137 | if (UDF_SB_LVIDBH(sb) != bh) | 1065 | if (UDF_SB_LVIDBH(sb) != bh) |
1138 | brelse(bh); | 1066 | brelse(bh); |
1139 | loc.extLength -= sb->s_blocksize; | 1067 | loc.extLength -= sb->s_blocksize; |
1140 | loc.extLocation ++; | 1068 | loc.extLocation++; |
1141 | } | 1069 | } |
1142 | if (UDF_SB_LVIDBH(sb) != bh) | 1070 | if (UDF_SB_LVIDBH(sb) != bh) |
1143 | brelse(bh); | 1071 | brelse(bh); |
@@ -1158,15 +1086,15 @@ udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc) | |||
1158 | * July 1, 1997 - Andrew E. Mileski | 1086 | * July 1, 1997 - Andrew E. Mileski |
1159 | * Written, tested, and released. | 1087 | * Written, tested, and released. |
1160 | */ | 1088 | */ |
1161 | static int | 1089 | static int udf_process_sequence(struct super_block *sb, long block, long lastblock, |
1162 | udf_process_sequence(struct super_block *sb, long block, long lastblock, kernel_lb_addr *fileset) | 1090 | kernel_lb_addr *fileset) |
1163 | { | 1091 | { |
1164 | struct buffer_head *bh = NULL; | 1092 | struct buffer_head *bh = NULL; |
1165 | struct udf_vds_record vds[VDS_POS_LENGTH]; | 1093 | struct udf_vds_record vds[VDS_POS_LENGTH]; |
1166 | struct generic_desc *gd; | 1094 | struct generic_desc *gd; |
1167 | struct volDescPtr *vdp; | 1095 | struct volDescPtr *vdp; |
1168 | int done=0; | 1096 | int done = 0; |
1169 | int i,j; | 1097 | int i, j; |
1170 | uint32_t vdsn; | 1098 | uint32_t vdsn; |
1171 | uint16_t ident; | 1099 | uint16_t ident; |
1172 | long next_s = 0, next_e = 0; | 1100 | long next_s = 0, next_e = 0; |
@@ -1174,93 +1102,81 @@ udf_process_sequence(struct super_block *sb, long block, long lastblock, kernel_ | |||
1174 | memset(vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH); | 1102 | memset(vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH); |
1175 | 1103 | ||
1176 | /* Read the main descriptor sequence */ | 1104 | /* Read the main descriptor sequence */ |
1177 | for (;(!done && block <= lastblock); block++) | 1105 | for (; (!done && block <= lastblock); block++) { |
1178 | { | ||
1179 | 1106 | ||
1180 | bh = udf_read_tagged(sb, block, block, &ident); | 1107 | bh = udf_read_tagged(sb, block, block, &ident); |
1181 | if (!bh) | 1108 | if (!bh) |
1182 | break; | 1109 | break; |
1183 | 1110 | ||
1184 | /* Process each descriptor (ISO 13346 3/8.3-8.4) */ | 1111 | /* Process each descriptor (ISO 13346 3/8.3-8.4) */ |
1185 | gd = (struct generic_desc *)bh->b_data; | 1112 | gd = (struct generic_desc *)bh->b_data; |
1186 | vdsn = le32_to_cpu(gd->volDescSeqNum); | 1113 | vdsn = le32_to_cpu(gd->volDescSeqNum); |
1187 | switch (ident) | 1114 | switch (ident) { |
1188 | { | 1115 | case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */ |
1189 | case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */ | 1116 | if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum) { |
1190 | if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum) | 1117 | vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = vdsn; |
1191 | { | 1118 | vds[VDS_POS_PRIMARY_VOL_DESC].block = block; |
1192 | vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = vdsn; | 1119 | } |
1193 | vds[VDS_POS_PRIMARY_VOL_DESC].block = block; | 1120 | break; |
1194 | } | 1121 | case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */ |
1195 | break; | 1122 | if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum) { |
1196 | case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */ | 1123 | vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn; |
1197 | if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum) | 1124 | vds[VDS_POS_VOL_DESC_PTR].block = block; |
1198 | { | 1125 | |
1199 | vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn; | 1126 | vdp = (struct volDescPtr *)bh->b_data; |
1200 | vds[VDS_POS_VOL_DESC_PTR].block = block; | 1127 | next_s = le32_to_cpu(vdp->nextVolDescSeqExt.extLocation); |
1201 | 1128 | next_e = le32_to_cpu(vdp->nextVolDescSeqExt.extLength); | |
1202 | vdp = (struct volDescPtr *)bh->b_data; | 1129 | next_e = next_e >> sb->s_blocksize_bits; |
1203 | next_s = le32_to_cpu(vdp->nextVolDescSeqExt.extLocation); | 1130 | next_e += next_s; |
1204 | next_e = le32_to_cpu(vdp->nextVolDescSeqExt.extLength); | 1131 | } |
1205 | next_e = next_e >> sb->s_blocksize_bits; | 1132 | break; |
1206 | next_e += next_s; | 1133 | case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */ |
1207 | } | 1134 | if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum) { |
1208 | break; | 1135 | vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = vdsn; |
1209 | case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */ | 1136 | vds[VDS_POS_IMP_USE_VOL_DESC].block = block; |
1210 | if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum) | 1137 | } |
1211 | { | 1138 | break; |
1212 | vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = vdsn; | 1139 | case TAG_IDENT_PD: /* ISO 13346 3/10.5 */ |
1213 | vds[VDS_POS_IMP_USE_VOL_DESC].block = block; | 1140 | if (!vds[VDS_POS_PARTITION_DESC].block) |
1214 | } | 1141 | vds[VDS_POS_PARTITION_DESC].block = block; |
1215 | break; | 1142 | break; |
1216 | case TAG_IDENT_PD: /* ISO 13346 3/10.5 */ | 1143 | case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ |
1217 | if (!vds[VDS_POS_PARTITION_DESC].block) | 1144 | if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum) { |
1218 | vds[VDS_POS_PARTITION_DESC].block = block; | 1145 | vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = vdsn; |
1219 | break; | 1146 | vds[VDS_POS_LOGICAL_VOL_DESC].block = block; |
1220 | case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ | 1147 | } |
1221 | if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum) | 1148 | break; |
1222 | { | 1149 | case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ |
1223 | vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = vdsn; | 1150 | if (vdsn >= vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum) { |
1224 | vds[VDS_POS_LOGICAL_VOL_DESC].block = block; | 1151 | vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum = vdsn; |
1225 | } | 1152 | vds[VDS_POS_UNALLOC_SPACE_DESC].block = block; |
1226 | break; | 1153 | } |
1227 | case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ | 1154 | break; |
1228 | if (vdsn >= vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum) | 1155 | case TAG_IDENT_TD: /* ISO 13346 3/10.9 */ |
1229 | { | 1156 | vds[VDS_POS_TERMINATING_DESC].block = block; |
1230 | vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum = vdsn; | 1157 | if (next_e) { |
1231 | vds[VDS_POS_UNALLOC_SPACE_DESC].block = block; | 1158 | block = next_s; |
1232 | } | 1159 | lastblock = next_e; |
1233 | break; | 1160 | next_s = next_e = 0; |
1234 | case TAG_IDENT_TD: /* ISO 13346 3/10.9 */ | 1161 | } else { |
1235 | vds[VDS_POS_TERMINATING_DESC].block = block; | 1162 | done = 1; |
1236 | if (next_e) | 1163 | } |
1237 | { | 1164 | break; |
1238 | block = next_s; | ||
1239 | lastblock = next_e; | ||
1240 | next_s = next_e = 0; | ||
1241 | } | ||
1242 | else | ||
1243 | done = 1; | ||
1244 | break; | ||
1245 | } | 1165 | } |
1246 | brelse(bh); | 1166 | brelse(bh); |
1247 | } | 1167 | } |
1248 | for (i=0; i<VDS_POS_LENGTH; i++) | 1168 | for (i = 0; i < VDS_POS_LENGTH; i++) { |
1249 | { | 1169 | if (vds[i].block) { |
1250 | if (vds[i].block) | ||
1251 | { | ||
1252 | bh = udf_read_tagged(sb, vds[i].block, vds[i].block, &ident); | 1170 | bh = udf_read_tagged(sb, vds[i].block, vds[i].block, &ident); |
1253 | 1171 | ||
1254 | if (i == VDS_POS_PRIMARY_VOL_DESC) | 1172 | if (i == VDS_POS_PRIMARY_VOL_DESC) { |
1255 | udf_load_pvoldesc(sb, bh); | 1173 | udf_load_pvoldesc(sb, bh); |
1256 | else if (i == VDS_POS_LOGICAL_VOL_DESC) | 1174 | } else if (i == VDS_POS_LOGICAL_VOL_DESC) { |
1257 | udf_load_logicalvol(sb, bh, fileset); | 1175 | udf_load_logicalvol(sb, bh, fileset); |
1258 | else if (i == VDS_POS_PARTITION_DESC) | 1176 | } else if (i == VDS_POS_PARTITION_DESC) { |
1259 | { | ||
1260 | struct buffer_head *bh2 = NULL; | 1177 | struct buffer_head *bh2 = NULL; |
1261 | udf_load_partdesc(sb, bh); | 1178 | udf_load_partdesc(sb, bh); |
1262 | for (j=vds[i].block+1; j<vds[VDS_POS_TERMINATING_DESC].block; j++) | 1179 | for (j = vds[i].block + 1; j < vds[VDS_POS_TERMINATING_DESC].block; j++) { |
1263 | { | ||
1264 | bh2 = udf_read_tagged(sb, j, j, &ident); | 1180 | bh2 = udf_read_tagged(sb, j, j, &ident); |
1265 | gd = (struct generic_desc *)bh2->b_data; | 1181 | gd = (struct generic_desc *)bh2->b_data; |
1266 | if (ident == TAG_IDENT_PD) | 1182 | if (ident == TAG_IDENT_PD) |
@@ -1278,31 +1194,28 @@ udf_process_sequence(struct super_block *sb, long block, long lastblock, kernel_ | |||
1278 | /* | 1194 | /* |
1279 | * udf_check_valid() | 1195 | * udf_check_valid() |
1280 | */ | 1196 | */ |
1281 | static int | 1197 | static int udf_check_valid(struct super_block *sb, int novrs, int silent) |
1282 | udf_check_valid(struct super_block *sb, int novrs, int silent) | ||
1283 | { | 1198 | { |
1284 | long block; | 1199 | long block; |
1285 | 1200 | ||
1286 | if (novrs) | 1201 | if (novrs) { |
1287 | { | ||
1288 | udf_debug("Validity check skipped because of novrs option\n"); | 1202 | udf_debug("Validity check skipped because of novrs option\n"); |
1289 | return 0; | 1203 | return 0; |
1290 | } | 1204 | } |
1291 | /* Check that it is NSR02 compliant */ | 1205 | /* Check that it is NSR02 compliant */ |
1292 | /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ | 1206 | /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ |
1293 | else if ((block = udf_vrs(sb, silent)) == -1) | 1207 | else if ((block = udf_vrs(sb, silent)) == -1) { |
1294 | { | 1208 | udf_debug("Failed to read byte 32768. Assuming open disc. " |
1295 | udf_debug("Failed to read byte 32768. Assuming open disc. Skipping validity check\n"); | 1209 | "Skipping validity check\n"); |
1296 | if (!UDF_SB_LASTBLOCK(sb)) | 1210 | if (!UDF_SB_LASTBLOCK(sb)) |
1297 | UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); | 1211 | UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); |
1298 | return 0; | 1212 | return 0; |
1299 | } | 1213 | } else { |
1300 | else | ||
1301 | return !block; | 1214 | return !block; |
1215 | } | ||
1302 | } | 1216 | } |
1303 | 1217 | ||
1304 | static int | 1218 | static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) |
1305 | udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | ||
1306 | { | 1219 | { |
1307 | struct anchorVolDescPtr *anchor; | 1220 | struct anchorVolDescPtr *anchor; |
1308 | uint16_t ident; | 1221 | uint16_t ident; |
@@ -1314,14 +1227,14 @@ udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | |||
1314 | return 1; | 1227 | return 1; |
1315 | 1228 | ||
1316 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { | 1229 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { |
1317 | if (UDF_SB_ANCHOR(sb)[i] && (bh = udf_read_tagged(sb, | 1230 | if (UDF_SB_ANCHOR(sb)[i] && |
1318 | UDF_SB_ANCHOR(sb)[i], UDF_SB_ANCHOR(sb)[i], &ident))) | 1231 | (bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i], |
1319 | { | 1232 | UDF_SB_ANCHOR(sb)[i], &ident))) { |
1320 | anchor = (struct anchorVolDescPtr *)bh->b_data; | 1233 | anchor = (struct anchorVolDescPtr *)bh->b_data; |
1321 | 1234 | ||
1322 | /* Locate the main sequence */ | 1235 | /* Locate the main sequence */ |
1323 | main_s = le32_to_cpu( anchor->mainVolDescSeqExt.extLocation ); | 1236 | main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation); |
1324 | main_e = le32_to_cpu( anchor->mainVolDescSeqExt.extLength ); | 1237 | main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength ); |
1325 | main_e = main_e >> sb->s_blocksize_bits; | 1238 | main_e = main_e >> sb->s_blocksize_bits; |
1326 | main_e += main_s; | 1239 | main_e += main_s; |
1327 | 1240 | ||
@@ -1336,8 +1249,7 @@ udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | |||
1336 | /* Process the main & reserve sequences */ | 1249 | /* Process the main & reserve sequences */ |
1337 | /* responsible for finding the PartitionDesc(s) */ | 1250 | /* responsible for finding the PartitionDesc(s) */ |
1338 | if (!(udf_process_sequence(sb, main_s, main_e, fileset) && | 1251 | if (!(udf_process_sequence(sb, main_s, main_e, fileset) && |
1339 | udf_process_sequence(sb, reserve_s, reserve_e, fileset))) | 1252 | udf_process_sequence(sb, reserve_s, reserve_e, fileset))) { |
1340 | { | ||
1341 | break; | 1253 | break; |
1342 | } | 1254 | } |
1343 | } | 1255 | } |
@@ -1349,70 +1261,68 @@ udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | |||
1349 | } else | 1261 | } else |
1350 | udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]); | 1262 | udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]); |
1351 | 1263 | ||
1352 | for (i=0; i<UDF_SB_NUMPARTS(sb); i++) | 1264 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { |
1353 | { | 1265 | kernel_lb_addr uninitialized_var(ino); |
1354 | switch (UDF_SB_PARTTYPE(sb, i)) | 1266 | switch (UDF_SB_PARTTYPE(sb, i)) { |
1355 | { | 1267 | case UDF_VIRTUAL_MAP15: |
1356 | case UDF_VIRTUAL_MAP15: | 1268 | case UDF_VIRTUAL_MAP20: |
1357 | case UDF_VIRTUAL_MAP20: | 1269 | if (!UDF_SB_LASTBLOCK(sb)) { |
1358 | { | 1270 | UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); |
1359 | kernel_lb_addr ino; | 1271 | udf_find_anchor(sb); |
1272 | } | ||
1360 | 1273 | ||
1361 | if (!UDF_SB_LASTBLOCK(sb)) | 1274 | if (!UDF_SB_LASTBLOCK(sb)) { |
1362 | { | 1275 | udf_debug("Unable to determine Lastblock (For " |
1363 | UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); | 1276 | "Virtual Partition)\n"); |
1364 | udf_find_anchor(sb); | 1277 | return 1; |
1365 | } | 1278 | } |
1366 | 1279 | ||
1367 | if (!UDF_SB_LASTBLOCK(sb)) | 1280 | for (j = 0; j < UDF_SB_NUMPARTS(sb); j++) { |
1368 | { | 1281 | if (j != i && UDF_SB_PARTVSN(sb, i) == |
1369 | udf_debug("Unable to determine Lastblock (For Virtual Partition)\n"); | 1282 | UDF_SB_PARTVSN(sb, j) && |
1370 | return 1; | 1283 | UDF_SB_PARTNUM(sb, i) == |
1284 | UDF_SB_PARTNUM(sb, j)) { | ||
1285 | ino.partitionReferenceNum = j; | ||
1286 | ino.logicalBlockNum = | ||
1287 | UDF_SB_LASTBLOCK(sb) - | ||
1288 | UDF_SB_PARTROOT(sb, j); | ||
1289 | break; | ||
1371 | } | 1290 | } |
1291 | } | ||
1372 | 1292 | ||
1373 | for (j=0; j<UDF_SB_NUMPARTS(sb); j++) | 1293 | if (j == UDF_SB_NUMPARTS(sb)) |
1374 | { | 1294 | return 1; |
1375 | if (j != i && | ||
1376 | UDF_SB_PARTVSN(sb,i) == UDF_SB_PARTVSN(sb,j) && | ||
1377 | UDF_SB_PARTNUM(sb,i) == UDF_SB_PARTNUM(sb,j)) | ||
1378 | { | ||
1379 | ino.partitionReferenceNum = j; | ||
1380 | ino.logicalBlockNum = UDF_SB_LASTBLOCK(sb) - | ||
1381 | UDF_SB_PARTROOT(sb,j); | ||
1382 | break; | ||
1383 | } | ||
1384 | } | ||
1385 | 1295 | ||
1386 | if (j == UDF_SB_NUMPARTS(sb)) | 1296 | if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino))) |
1387 | return 1; | 1297 | return 1; |
1388 | 1298 | ||
1389 | if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino))) | 1299 | if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) { |
1390 | return 1; | 1300 | UDF_SB_TYPEVIRT(sb, i).s_start_offset = |
1301 | udf_ext0_offset(UDF_SB_VAT(sb)); | ||
1302 | UDF_SB_TYPEVIRT(sb, i).s_num_entries = | ||
1303 | (UDF_SB_VAT(sb)->i_size - 36) >> 2; | ||
1304 | } else if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP20) { | ||
1305 | struct buffer_head *bh = NULL; | ||
1306 | uint32_t pos; | ||
1391 | 1307 | ||
1392 | if (UDF_SB_PARTTYPE(sb,i) == UDF_VIRTUAL_MAP15) | 1308 | pos = udf_block_map(UDF_SB_VAT(sb), 0); |
1393 | { | 1309 | bh = sb_bread(sb, pos); |
1394 | UDF_SB_TYPEVIRT(sb,i).s_start_offset = udf_ext0_offset(UDF_SB_VAT(sb)); | 1310 | if (!bh) |
1395 | UDF_SB_TYPEVIRT(sb,i).s_num_entries = (UDF_SB_VAT(sb)->i_size - 36) >> 2; | 1311 | return 1; |
1396 | } | 1312 | UDF_SB_TYPEVIRT(sb, i).s_start_offset = |
1397 | else if (UDF_SB_PARTTYPE(sb,i) == UDF_VIRTUAL_MAP20) | 1313 | le16_to_cpu(((struct |
1398 | { | 1314 | virtualAllocationTable20 *)bh->b_data + |
1399 | struct buffer_head *bh = NULL; | 1315 | udf_ext0_offset(UDF_SB_VAT(sb)))-> |
1400 | uint32_t pos; | 1316 | lengthHeader) + |
1401 | 1317 | udf_ext0_offset(UDF_SB_VAT(sb)); | |
1402 | pos = udf_block_map(UDF_SB_VAT(sb), 0); | 1318 | UDF_SB_TYPEVIRT(sb, i).s_num_entries = |
1403 | bh = sb_bread(sb, pos); | 1319 | (UDF_SB_VAT(sb)->i_size - |
1404 | if (!bh) | 1320 | UDF_SB_TYPEVIRT(sb, i).s_start_offset) >> 2; |
1405 | return 1; | 1321 | brelse(bh); |
1406 | UDF_SB_TYPEVIRT(sb,i).s_start_offset = | ||
1407 | le16_to_cpu(((struct virtualAllocationTable20 *)bh->b_data + udf_ext0_offset(UDF_SB_VAT(sb)))->lengthHeader) + | ||
1408 | udf_ext0_offset(UDF_SB_VAT(sb)); | ||
1409 | UDF_SB_TYPEVIRT(sb,i).s_num_entries = (UDF_SB_VAT(sb)->i_size - | ||
1410 | UDF_SB_TYPEVIRT(sb,i).s_start_offset) >> 2; | ||
1411 | brelse(bh); | ||
1412 | } | ||
1413 | UDF_SB_PARTROOT(sb,i) = udf_get_pblock(sb, 0, i, 0); | ||
1414 | UDF_SB_PARTLEN(sb,i) = UDF_SB_PARTLEN(sb,ino.partitionReferenceNum); | ||
1415 | } | 1322 | } |
1323 | UDF_SB_PARTROOT(sb, i) = udf_get_pblock(sb, 0, i, 0); | ||
1324 | UDF_SB_PARTLEN(sb, i) = UDF_SB_PARTLEN(sb, | ||
1325 | ino.partitionReferenceNum); | ||
1416 | } | 1326 | } |
1417 | } | 1327 | } |
1418 | return 0; | 1328 | return 0; |
@@ -1420,26 +1330,28 @@ udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | |||
1420 | 1330 | ||
1421 | static void udf_open_lvid(struct super_block *sb) | 1331 | static void udf_open_lvid(struct super_block *sb) |
1422 | { | 1332 | { |
1423 | if (UDF_SB_LVIDBH(sb)) | 1333 | if (UDF_SB_LVIDBH(sb)) { |
1424 | { | ||
1425 | int i; | 1334 | int i; |
1426 | kernel_timestamp cpu_time; | 1335 | kernel_timestamp cpu_time; |
1427 | 1336 | ||
1428 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1337 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1429 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1338 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1430 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) | 1339 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) |
1431 | UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time); | 1340 | UDF_SB_LVID(sb)->recordingDateAndTime = |
1341 | cpu_to_lets(cpu_time); | ||
1432 | UDF_SB_LVID(sb)->integrityType = LVID_INTEGRITY_TYPE_OPEN; | 1342 | UDF_SB_LVID(sb)->integrityType = LVID_INTEGRITY_TYPE_OPEN; |
1433 | 1343 | ||
1434 | UDF_SB_LVID(sb)->descTag.descCRC = | 1344 | UDF_SB_LVID(sb)->descTag.descCRC = |
1435 | cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), | 1345 | cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), |
1436 | le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0)); | 1346 | le16_to_cpu(UDF_SB_LVID(sb)->descTag. |
1347 | descCRCLength), 0)); | ||
1437 | 1348 | ||
1438 | UDF_SB_LVID(sb)->descTag.tagChecksum = 0; | 1349 | UDF_SB_LVID(sb)->descTag.tagChecksum = 0; |
1439 | for (i=0; i<16; i++) | 1350 | for (i = 0; i < 16; i++) |
1440 | if (i != 4) | 1351 | if (i != 4) |
1441 | UDF_SB_LVID(sb)->descTag.tagChecksum += | 1352 | UDF_SB_LVID(sb)->descTag.tagChecksum += |
1442 | ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i]; | 1353 | ((uint8_t *) & |
1354 | (UDF_SB_LVID(sb)->descTag))[i]; | ||
1443 | 1355 | ||
1444 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 1356 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); |
1445 | } | 1357 | } |
@@ -1447,12 +1359,11 @@ static void udf_open_lvid(struct super_block *sb) | |||
1447 | 1359 | ||
1448 | static void udf_close_lvid(struct super_block *sb) | 1360 | static void udf_close_lvid(struct super_block *sb) |
1449 | { | 1361 | { |
1450 | if (UDF_SB_LVIDBH(sb) && | 1362 | kernel_timestamp cpu_time; |
1451 | UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) | 1363 | int i; |
1452 | { | ||
1453 | int i; | ||
1454 | kernel_timestamp cpu_time; | ||
1455 | 1364 | ||
1365 | if (UDF_SB_LVIDBH(sb) && | ||
1366 | UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) { | ||
1456 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1367 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1457 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1368 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1458 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) | 1369 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) |
@@ -1467,10 +1378,10 @@ static void udf_close_lvid(struct super_block *sb) | |||
1467 | 1378 | ||
1468 | UDF_SB_LVID(sb)->descTag.descCRC = | 1379 | UDF_SB_LVID(sb)->descTag.descCRC = |
1469 | cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), | 1380 | cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), |
1470 | le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0)); | 1381 | le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0)); |
1471 | 1382 | ||
1472 | UDF_SB_LVID(sb)->descTag.tagChecksum = 0; | 1383 | UDF_SB_LVID(sb)->descTag.tagChecksum = 0; |
1473 | for (i=0; i<16; i++) | 1384 | for (i = 0; i < 16; i++) |
1474 | if (i != 4) | 1385 | if (i != 4) |
1475 | UDF_SB_LVID(sb)->descTag.tagChecksum += | 1386 | UDF_SB_LVID(sb)->descTag.tagChecksum += |
1476 | ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i]; | 1387 | ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i]; |
@@ -1498,7 +1409,7 @@ static void udf_close_lvid(struct super_block *sb) | |||
1498 | static int udf_fill_super(struct super_block *sb, void *options, int silent) | 1409 | static int udf_fill_super(struct super_block *sb, void *options, int silent) |
1499 | { | 1410 | { |
1500 | int i; | 1411 | int i; |
1501 | struct inode *inode=NULL; | 1412 | struct inode *inode = NULL; |
1502 | struct udf_options uopt; | 1413 | struct udf_options uopt; |
1503 | kernel_lb_addr rootdir, fileset; | 1414 | kernel_lb_addr rootdir, fileset; |
1504 | struct udf_sb_info *sbi; | 1415 | struct udf_sb_info *sbi; |
@@ -1511,6 +1422,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1511 | sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL); | 1422 | sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL); |
1512 | if (!sbi) | 1423 | if (!sbi) |
1513 | return -ENOMEM; | 1424 | return -ENOMEM; |
1425 | |||
1514 | sb->s_fs_info = sbi; | 1426 | sb->s_fs_info = sbi; |
1515 | memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); | 1427 | memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); |
1516 | 1428 | ||
@@ -1520,15 +1432,13 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1520 | goto error_out; | 1432 | goto error_out; |
1521 | 1433 | ||
1522 | if (uopt.flags & (1 << UDF_FLAG_UTF8) && | 1434 | if (uopt.flags & (1 << UDF_FLAG_UTF8) && |
1523 | uopt.flags & (1 << UDF_FLAG_NLS_MAP)) | 1435 | uopt.flags & (1 << UDF_FLAG_NLS_MAP)) { |
1524 | { | ||
1525 | udf_error(sb, "udf_read_super", | 1436 | udf_error(sb, "udf_read_super", |
1526 | "utf8 cannot be combined with iocharset\n"); | 1437 | "utf8 cannot be combined with iocharset\n"); |
1527 | goto error_out; | 1438 | goto error_out; |
1528 | } | 1439 | } |
1529 | #ifdef CONFIG_UDF_NLS | 1440 | #ifdef CONFIG_UDF_NLS |
1530 | if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map) | 1441 | if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map) { |
1531 | { | ||
1532 | uopt.nls_map = load_nls_default(); | 1442 | uopt.nls_map = load_nls_default(); |
1533 | if (!uopt.nls_map) | 1443 | if (!uopt.nls_map) |
1534 | uopt.flags &= ~(1 << UDF_FLAG_NLS_MAP); | 1444 | uopt.flags &= ~(1 << UDF_FLAG_NLS_MAP); |
@@ -1552,7 +1462,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1552 | if (!udf_set_blocksize(sb, uopt.blocksize)) | 1462 | if (!udf_set_blocksize(sb, uopt.blocksize)) |
1553 | goto error_out; | 1463 | goto error_out; |
1554 | 1464 | ||
1555 | if ( uopt.session == 0xFFFFFFFF ) | 1465 | if (uopt.session == 0xFFFFFFFF) |
1556 | UDF_SB_SESSION(sb) = udf_get_last_session(sb); | 1466 | UDF_SB_SESSION(sb) = udf_get_last_session(sb); |
1557 | else | 1467 | else |
1558 | UDF_SB_SESSION(sb) = uopt.session; | 1468 | UDF_SB_SESSION(sb) = uopt.session; |
@@ -1564,10 +1474,9 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1564 | UDF_SB_ANCHOR(sb)[2] = uopt.anchor; | 1474 | UDF_SB_ANCHOR(sb)[2] = uopt.anchor; |
1565 | UDF_SB_ANCHOR(sb)[3] = 256; | 1475 | UDF_SB_ANCHOR(sb)[3] = 256; |
1566 | 1476 | ||
1567 | if (udf_check_valid(sb, uopt.novrs, silent)) /* read volume recognition sequences */ | 1477 | if (udf_check_valid(sb, uopt.novrs, silent)) { /* read volume recognition sequences */ |
1568 | { | ||
1569 | printk("UDF-fs: No VRS found\n"); | 1478 | printk("UDF-fs: No VRS found\n"); |
1570 | goto error_out; | 1479 | goto error_out; |
1571 | } | 1480 | } |
1572 | 1481 | ||
1573 | udf_find_anchor(sb); | 1482 | udf_find_anchor(sb); |
@@ -1579,29 +1488,24 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1579 | sb->s_magic = UDF_SUPER_MAGIC; | 1488 | sb->s_magic = UDF_SUPER_MAGIC; |
1580 | sb->s_time_gran = 1000; | 1489 | sb->s_time_gran = 1000; |
1581 | 1490 | ||
1582 | if (udf_load_partition(sb, &fileset)) | 1491 | if (udf_load_partition(sb, &fileset)) { |
1583 | { | ||
1584 | printk("UDF-fs: No partition found (1)\n"); | 1492 | printk("UDF-fs: No partition found (1)\n"); |
1585 | goto error_out; | 1493 | goto error_out; |
1586 | } | 1494 | } |
1587 | 1495 | ||
1588 | udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb)); | 1496 | udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb)); |
1589 | 1497 | ||
1590 | if ( UDF_SB_LVIDBH(sb) ) | 1498 | if (UDF_SB_LVIDBH(sb)) { |
1591 | { | ||
1592 | uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev); | 1499 | uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev); |
1593 | uint16_t minUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev); | 1500 | uint16_t minUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev); |
1594 | /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */ | 1501 | /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */ |
1595 | 1502 | ||
1596 | if (minUDFReadRev > UDF_MAX_READ_VERSION) | 1503 | if (minUDFReadRev > UDF_MAX_READ_VERSION) { |
1597 | { | ||
1598 | printk("UDF-fs: minUDFReadRev=%x (max is %x)\n", | 1504 | printk("UDF-fs: minUDFReadRev=%x (max is %x)\n", |
1599 | le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev), | 1505 | le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev), |
1600 | UDF_MAX_READ_VERSION); | 1506 | UDF_MAX_READ_VERSION); |
1601 | goto error_out; | 1507 | goto error_out; |
1602 | } | 1508 | } else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION) { |
1603 | else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION) | ||
1604 | { | ||
1605 | sb->s_flags |= MS_RDONLY; | 1509 | sb->s_flags |= MS_RDONLY; |
1606 | } | 1510 | } |
1607 | 1511 | ||
@@ -1613,8 +1517,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1613 | UDF_SET_FLAG(sb, UDF_FLAG_USE_STREAMS); | 1517 | UDF_SET_FLAG(sb, UDF_FLAG_USE_STREAMS); |
1614 | } | 1518 | } |
1615 | 1519 | ||
1616 | if ( !UDF_SB_NUMPARTS(sb) ) | 1520 | if (!UDF_SB_NUMPARTS(sb)) { |
1617 | { | ||
1618 | printk("UDF-fs: No partition found (2)\n"); | 1521 | printk("UDF-fs: No partition found (2)\n"); |
1619 | goto error_out; | 1522 | goto error_out; |
1620 | } | 1523 | } |
@@ -1624,20 +1527,19 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1624 | sb->s_flags |= MS_RDONLY; | 1527 | sb->s_flags |= MS_RDONLY; |
1625 | } | 1528 | } |
1626 | 1529 | ||
1627 | if ( udf_find_fileset(sb, &fileset, &rootdir) ) | 1530 | if (udf_find_fileset(sb, &fileset, &rootdir)) { |
1628 | { | ||
1629 | printk("UDF-fs: No fileset found\n"); | 1531 | printk("UDF-fs: No fileset found\n"); |
1630 | goto error_out; | 1532 | goto error_out; |
1631 | } | 1533 | } |
1632 | 1534 | ||
1633 | if (!silent) | 1535 | if (!silent) { |
1634 | { | ||
1635 | kernel_timestamp ts; | 1536 | kernel_timestamp ts; |
1636 | udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb)); | 1537 | udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb)); |
1637 | udf_info("UDF %s (%s) Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n", | 1538 | udf_info("UDF %s (%s) Mounting volume '%s', " |
1638 | UDFFS_VERSION, UDFFS_DATE, | 1539 | "timestamp %04u/%02u/%02u %02u:%02u (%x)\n", |
1639 | UDF_SB_VOLIDENT(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute, | 1540 | UDFFS_VERSION, UDFFS_DATE, |
1640 | ts.typeAndTimezone); | 1541 | UDF_SB_VOLIDENT(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute, |
1542 | ts.typeAndTimezone); | ||
1641 | } | 1543 | } |
1642 | if (!(sb->s_flags & MS_RDONLY)) | 1544 | if (!(sb->s_flags & MS_RDONLY)) |
1643 | udf_open_lvid(sb); | 1545 | udf_open_lvid(sb); |
@@ -1645,18 +1547,16 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1645 | /* Assign the root inode */ | 1547 | /* Assign the root inode */ |
1646 | /* assign inodes by physical block number */ | 1548 | /* assign inodes by physical block number */ |
1647 | /* perhaps it's not extensible enough, but for now ... */ | 1549 | /* perhaps it's not extensible enough, but for now ... */ |
1648 | inode = udf_iget(sb, rootdir); | 1550 | inode = udf_iget(sb, rootdir); |
1649 | if (!inode) | 1551 | if (!inode) { |
1650 | { | ||
1651 | printk("UDF-fs: Error in udf_iget, block=%d, partition=%d\n", | 1552 | printk("UDF-fs: Error in udf_iget, block=%d, partition=%d\n", |
1652 | rootdir.logicalBlockNum, rootdir.partitionReferenceNum); | 1553 | rootdir.logicalBlockNum, rootdir.partitionReferenceNum); |
1653 | goto error_out; | 1554 | goto error_out; |
1654 | } | 1555 | } |
1655 | 1556 | ||
1656 | /* Allocate a dentry for the root inode */ | 1557 | /* Allocate a dentry for the root inode */ |
1657 | sb->s_root = d_alloc_root(inode); | 1558 | sb->s_root = d_alloc_root(inode); |
1658 | if (!sb->s_root) | 1559 | if (!sb->s_root) { |
1659 | { | ||
1660 | printk("UDF-fs: Couldn't allocate root dentry\n"); | 1560 | printk("UDF-fs: Couldn't allocate root dentry\n"); |
1661 | iput(inode); | 1561 | iput(inode); |
1662 | goto error_out; | 1562 | goto error_out; |
@@ -1667,19 +1567,17 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1667 | error_out: | 1567 | error_out: |
1668 | if (UDF_SB_VAT(sb)) | 1568 | if (UDF_SB_VAT(sb)) |
1669 | iput(UDF_SB_VAT(sb)); | 1569 | iput(UDF_SB_VAT(sb)); |
1670 | if (UDF_SB_NUMPARTS(sb)) | 1570 | if (UDF_SB_NUMPARTS(sb)) { |
1671 | { | ||
1672 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) | 1571 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) |
1673 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); | 1572 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); |
1674 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) | 1573 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) |
1675 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); | 1574 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); |
1676 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) | 1575 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) |
1677 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_uspace); | 1576 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace); |
1678 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) | 1577 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) |
1679 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_fspace); | 1578 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace); |
1680 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) | 1579 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) { |
1681 | { | 1580 | for (i = 0; i < 4; i++) |
1682 | for (i=0; i<4; i++) | ||
1683 | brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]); | 1581 | brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]); |
1684 | } | 1582 | } |
1685 | } | 1583 | } |
@@ -1693,16 +1591,16 @@ error_out: | |||
1693 | UDF_SB_FREE(sb); | 1591 | UDF_SB_FREE(sb); |
1694 | kfree(sbi); | 1592 | kfree(sbi); |
1695 | sb->s_fs_info = NULL; | 1593 | sb->s_fs_info = NULL; |
1594 | |||
1696 | return -EINVAL; | 1595 | return -EINVAL; |
1697 | } | 1596 | } |
1698 | 1597 | ||
1699 | void udf_error(struct super_block *sb, const char *function, | 1598 | void udf_error(struct super_block *sb, const char *function, |
1700 | const char *fmt, ...) | 1599 | const char *fmt, ...) |
1701 | { | 1600 | { |
1702 | va_list args; | 1601 | va_list args; |
1703 | 1602 | ||
1704 | if (!(sb->s_flags & MS_RDONLY)) | 1603 | if (!(sb->s_flags & MS_RDONLY)) { |
1705 | { | ||
1706 | /* mark sb error */ | 1604 | /* mark sb error */ |
1707 | sb->s_dirt = 1; | 1605 | sb->s_dirt = 1; |
1708 | } | 1606 | } |
@@ -1714,15 +1612,15 @@ void udf_error(struct super_block *sb, const char *function, | |||
1714 | } | 1612 | } |
1715 | 1613 | ||
1716 | void udf_warning(struct super_block *sb, const char *function, | 1614 | void udf_warning(struct super_block *sb, const char *function, |
1717 | const char *fmt, ...) | 1615 | const char *fmt, ...) |
1718 | { | 1616 | { |
1719 | va_list args; | 1617 | va_list args; |
1720 | 1618 | ||
1721 | va_start (args, fmt); | 1619 | va_start(args, fmt); |
1722 | vsnprintf(error_buf, sizeof(error_buf), fmt, args); | 1620 | vsnprintf(error_buf, sizeof(error_buf), fmt, args); |
1723 | va_end(args); | 1621 | va_end(args); |
1724 | printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n", | 1622 | printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n", |
1725 | sb->s_id, function, error_buf); | 1623 | sb->s_id, function, error_buf); |
1726 | } | 1624 | } |
1727 | 1625 | ||
1728 | /* | 1626 | /* |
@@ -1738,26 +1636,23 @@ void udf_warning(struct super_block *sb, const char *function, | |||
1738 | * July 1, 1997 - Andrew E. Mileski | 1636 | * July 1, 1997 - Andrew E. Mileski |
1739 | * Written, tested, and released. | 1637 | * Written, tested, and released. |
1740 | */ | 1638 | */ |
1741 | static void | 1639 | static void udf_put_super(struct super_block *sb) |
1742 | udf_put_super(struct super_block *sb) | ||
1743 | { | 1640 | { |
1744 | int i; | 1641 | int i; |
1745 | 1642 | ||
1746 | if (UDF_SB_VAT(sb)) | 1643 | if (UDF_SB_VAT(sb)) |
1747 | iput(UDF_SB_VAT(sb)); | 1644 | iput(UDF_SB_VAT(sb)); |
1748 | if (UDF_SB_NUMPARTS(sb)) | 1645 | if (UDF_SB_NUMPARTS(sb)) { |
1749 | { | ||
1750 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) | 1646 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) |
1751 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); | 1647 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); |
1752 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) | 1648 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) |
1753 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); | 1649 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); |
1754 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) | 1650 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) |
1755 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_uspace); | 1651 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace); |
1756 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) | 1652 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) |
1757 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_fspace); | 1653 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace); |
1758 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) | 1654 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) { |
1759 | { | 1655 | for (i = 0; i < 4; i++) |
1760 | for (i=0; i<4; i++) | ||
1761 | brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]); | 1656 | brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]); |
1762 | } | 1657 | } |
1763 | } | 1658 | } |
@@ -1786,8 +1681,7 @@ udf_put_super(struct super_block *sb) | |||
1786 | * July 1, 1997 - Andrew E. Mileski | 1681 | * July 1, 1997 - Andrew E. Mileski |
1787 | * Written, tested, and released. | 1682 | * Written, tested, and released. |
1788 | */ | 1683 | */ |
1789 | static int | 1684 | static int udf_statfs(struct dentry *dentry, struct kstatfs *buf) |
1790 | udf_statfs(struct dentry *dentry, struct kstatfs *buf) | ||
1791 | { | 1685 | { |
1792 | struct super_block *sb = dentry->d_sb; | 1686 | struct super_block *sb = dentry->d_sb; |
1793 | 1687 | ||
@@ -1797,11 +1691,11 @@ udf_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
1797 | buf->f_bfree = udf_count_free(sb); | 1691 | buf->f_bfree = udf_count_free(sb); |
1798 | buf->f_bavail = buf->f_bfree; | 1692 | buf->f_bavail = buf->f_bfree; |
1799 | buf->f_files = (UDF_SB_LVIDBH(sb) ? | 1693 | buf->f_files = (UDF_SB_LVIDBH(sb) ? |
1800 | (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + | 1694 | (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + |
1801 | le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + buf->f_bfree; | 1695 | le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + buf->f_bfree; |
1802 | buf->f_ffree = buf->f_bfree; | 1696 | buf->f_ffree = buf->f_bfree; |
1803 | /* __kernel_fsid_t f_fsid */ | 1697 | /* __kernel_fsid_t f_fsid */ |
1804 | buf->f_namelen = UDF_NAME_LEN-2; | 1698 | buf->f_namelen = UDF_NAME_LEN - 2; |
1805 | 1699 | ||
1806 | return 0; | 1700 | return 0; |
1807 | } | 1701 | } |
@@ -1810,8 +1704,7 @@ static unsigned char udf_bitmap_lookup[16] = { | |||
1810 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 | 1704 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 |
1811 | }; | 1705 | }; |
1812 | 1706 | ||
1813 | static unsigned int | 1707 | static unsigned int udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap) |
1814 | udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap) | ||
1815 | { | 1708 | { |
1816 | struct buffer_head *bh = NULL; | 1709 | struct buffer_head *bh = NULL; |
1817 | unsigned int accum = 0; | 1710 | unsigned int accum = 0; |
@@ -1830,13 +1723,10 @@ udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap) | |||
1830 | loc.partitionReferenceNum = UDF_SB_PARTITION(sb); | 1723 | loc.partitionReferenceNum = UDF_SB_PARTITION(sb); |
1831 | bh = udf_read_ptagged(sb, loc, 0, &ident); | 1724 | bh = udf_read_ptagged(sb, loc, 0, &ident); |
1832 | 1725 | ||
1833 | if (!bh) | 1726 | if (!bh) { |
1834 | { | ||
1835 | printk(KERN_ERR "udf: udf_count_free failed\n"); | 1727 | printk(KERN_ERR "udf: udf_count_free failed\n"); |
1836 | goto out; | 1728 | goto out; |
1837 | } | 1729 | } else if (ident != TAG_IDENT_SBD) { |
1838 | else if (ident != TAG_IDENT_SBD) | ||
1839 | { | ||
1840 | brelse(bh); | 1730 | brelse(bh); |
1841 | printk(KERN_ERR "udf: udf_count_free failed\n"); | 1731 | printk(KERN_ERR "udf: udf_count_free failed\n"); |
1842 | goto out; | 1732 | goto out; |
@@ -1847,23 +1737,19 @@ udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap) | |||
1847 | index = sizeof(struct spaceBitmapDesc); /* offset in first block only */ | 1737 | index = sizeof(struct spaceBitmapDesc); /* offset in first block only */ |
1848 | ptr = (uint8_t *)bh->b_data; | 1738 | ptr = (uint8_t *)bh->b_data; |
1849 | 1739 | ||
1850 | while ( bytes > 0 ) | 1740 | while (bytes > 0) { |
1851 | { | 1741 | while ((bytes > 0) && (index < sb->s_blocksize)) { |
1852 | while ((bytes > 0) && (index < sb->s_blocksize)) | ||
1853 | { | ||
1854 | value = ptr[index]; | 1742 | value = ptr[index]; |
1855 | accum += udf_bitmap_lookup[ value & 0x0f ]; | 1743 | accum += udf_bitmap_lookup[value & 0x0f]; |
1856 | accum += udf_bitmap_lookup[ value >> 4 ]; | 1744 | accum += udf_bitmap_lookup[value >> 4]; |
1857 | index++; | 1745 | index++; |
1858 | bytes--; | 1746 | bytes--; |
1859 | } | 1747 | } |
1860 | if ( bytes ) | 1748 | if (bytes) { |
1861 | { | ||
1862 | brelse(bh); | 1749 | brelse(bh); |
1863 | newblock = udf_get_lb_pblock(sb, loc, ++block); | 1750 | newblock = udf_get_lb_pblock(sb, loc, ++block); |
1864 | bh = udf_tread(sb, newblock); | 1751 | bh = udf_tread(sb, newblock); |
1865 | if (!bh) | 1752 | if (!bh) { |
1866 | { | ||
1867 | udf_debug("read failed\n"); | 1753 | udf_debug("read failed\n"); |
1868 | goto out; | 1754 | goto out; |
1869 | } | 1755 | } |
@@ -1879,8 +1765,7 @@ out: | |||
1879 | return accum; | 1765 | return accum; |
1880 | } | 1766 | } |
1881 | 1767 | ||
1882 | static unsigned int | 1768 | static unsigned int udf_count_free_table(struct super_block *sb, struct inode *table) |
1883 | udf_count_free_table(struct super_block *sb, struct inode * table) | ||
1884 | { | 1769 | { |
1885 | unsigned int accum = 0; | 1770 | unsigned int accum = 0; |
1886 | uint32_t elen; | 1771 | uint32_t elen; |
@@ -1894,26 +1779,23 @@ udf_count_free_table(struct super_block *sb, struct inode * table) | |||
1894 | epos.offset = sizeof(struct unallocSpaceEntry); | 1779 | epos.offset = sizeof(struct unallocSpaceEntry); |
1895 | epos.bh = NULL; | 1780 | epos.bh = NULL; |
1896 | 1781 | ||
1897 | while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) | 1782 | while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { |
1898 | accum += (elen >> table->i_sb->s_blocksize_bits); | 1783 | accum += (elen >> table->i_sb->s_blocksize_bits); |
1784 | } | ||
1899 | brelse(epos.bh); | 1785 | brelse(epos.bh); |
1900 | 1786 | ||
1901 | unlock_kernel(); | 1787 | unlock_kernel(); |
1902 | 1788 | ||
1903 | return accum; | 1789 | return accum; |
1904 | } | 1790 | } |
1905 | 1791 | ||
1906 | static unsigned int | 1792 | static unsigned int udf_count_free(struct super_block *sb) |
1907 | udf_count_free(struct super_block *sb) | ||
1908 | { | 1793 | { |
1909 | unsigned int accum = 0; | 1794 | unsigned int accum = 0; |
1910 | 1795 | ||
1911 | if (UDF_SB_LVIDBH(sb)) | 1796 | if (UDF_SB_LVIDBH(sb)) { |
1912 | { | 1797 | if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > UDF_SB_PARTITION(sb)) { |
1913 | if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > UDF_SB_PARTITION(sb)) | ||
1914 | { | ||
1915 | accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]); | 1798 | accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]); |
1916 | |||
1917 | if (accum == 0xFFFFFFFF) | 1799 | if (accum == 0xFFFFFFFF) |
1918 | accum = 0; | 1800 | accum = 0; |
1919 | } | 1801 | } |
@@ -1922,28 +1804,24 @@ udf_count_free(struct super_block *sb) | |||
1922 | if (accum) | 1804 | if (accum) |
1923 | return accum; | 1805 | return accum; |
1924 | 1806 | ||
1925 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) | 1807 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) { |
1926 | { | ||
1927 | accum += udf_count_free_bitmap(sb, | 1808 | accum += udf_count_free_bitmap(sb, |
1928 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap); | 1809 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap); |
1929 | } | 1810 | } |
1930 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) | 1811 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) { |
1931 | { | ||
1932 | accum += udf_count_free_bitmap(sb, | 1812 | accum += udf_count_free_bitmap(sb, |
1933 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap); | 1813 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap); |
1934 | } | 1814 | } |
1935 | if (accum) | 1815 | if (accum) |
1936 | return accum; | 1816 | return accum; |
1937 | 1817 | ||
1938 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) | 1818 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) { |
1939 | { | ||
1940 | accum += udf_count_free_table(sb, | 1819 | accum += udf_count_free_table(sb, |
1941 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); | 1820 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); |
1942 | } | 1821 | } |
1943 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) | 1822 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) { |
1944 | { | ||
1945 | accum += udf_count_free_table(sb, | 1823 | accum += udf_count_free_table(sb, |
1946 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); | 1824 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); |
1947 | } | 1825 | } |
1948 | 1826 | ||
1949 | return accum; | 1827 | return accum; |