diff options
Diffstat (limited to 'fs')
117 files changed, 4274 insertions, 2521 deletions
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 7c3d5f923da1..b5c3b6114add 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt | |||
@@ -61,7 +61,8 @@ config BINFMT_SHARED_FLAT | |||
61 | 61 | ||
62 | config BINFMT_AOUT | 62 | config BINFMT_AOUT |
63 | tristate "Kernel support for a.out and ECOFF binaries" | 63 | tristate "Kernel support for a.out and ECOFF binaries" |
64 | depends on X86_32 || ALPHA || ARM || M68K || SPARC32 | 64 | depends on ARCH_SUPPORTS_AOUT && \ |
65 | (X86_32 || ALPHA || ARM || M68K || SPARC32) | ||
65 | ---help--- | 66 | ---help--- |
66 | A.out (Assembler.OUTput) is a set of formats for libraries and | 67 | A.out (Assembler.OUTput) is a set of formats for libraries and |
67 | executables used in the earliest versions of UNIX. Linux used | 68 | executables used in the earliest versions of UNIX. Linux used |
diff --git a/fs/adfs/super.c b/fs/adfs/super.c index b36695ae5c2e..9e421eeb672b 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c | |||
@@ -20,6 +20,8 @@ | |||
20 | #include <linux/vfs.h> | 20 | #include <linux/vfs.h> |
21 | #include <linux/parser.h> | 21 | #include <linux/parser.h> |
22 | #include <linux/bitops.h> | 22 | #include <linux/bitops.h> |
23 | #include <linux/mount.h> | ||
24 | #include <linux/seq_file.h> | ||
23 | 25 | ||
24 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
25 | #include <asm/system.h> | 27 | #include <asm/system.h> |
@@ -30,6 +32,9 @@ | |||
30 | #include "dir_f.h" | 32 | #include "dir_f.h" |
31 | #include "dir_fplus.h" | 33 | #include "dir_fplus.h" |
32 | 34 | ||
35 | #define ADFS_DEFAULT_OWNER_MASK S_IRWXU | ||
36 | #define ADFS_DEFAULT_OTHER_MASK (S_IRWXG | S_IRWXO) | ||
37 | |||
33 | void __adfs_error(struct super_block *sb, const char *function, const char *fmt, ...) | 38 | void __adfs_error(struct super_block *sb, const char *function, const char *fmt, ...) |
34 | { | 39 | { |
35 | char error_buf[128]; | 40 | char error_buf[128]; |
@@ -134,6 +139,22 @@ static void adfs_put_super(struct super_block *sb) | |||
134 | sb->s_fs_info = NULL; | 139 | sb->s_fs_info = NULL; |
135 | } | 140 | } |
136 | 141 | ||
142 | static int adfs_show_options(struct seq_file *seq, struct vfsmount *mnt) | ||
143 | { | ||
144 | struct adfs_sb_info *asb = ADFS_SB(mnt->mnt_sb); | ||
145 | |||
146 | if (asb->s_uid != 0) | ||
147 | seq_printf(seq, ",uid=%u", asb->s_uid); | ||
148 | if (asb->s_gid != 0) | ||
149 | seq_printf(seq, ",gid=%u", asb->s_gid); | ||
150 | if (asb->s_owner_mask != ADFS_DEFAULT_OWNER_MASK) | ||
151 | seq_printf(seq, ",ownmask=%o", asb->s_owner_mask); | ||
152 | if (asb->s_other_mask != ADFS_DEFAULT_OTHER_MASK) | ||
153 | seq_printf(seq, ",othmask=%o", asb->s_other_mask); | ||
154 | |||
155 | return 0; | ||
156 | } | ||
157 | |||
137 | enum {Opt_uid, Opt_gid, Opt_ownmask, Opt_othmask, Opt_err}; | 158 | enum {Opt_uid, Opt_gid, Opt_ownmask, Opt_othmask, Opt_err}; |
138 | 159 | ||
139 | static match_table_t tokens = { | 160 | static match_table_t tokens = { |
@@ -259,6 +280,7 @@ static const struct super_operations adfs_sops = { | |||
259 | .put_super = adfs_put_super, | 280 | .put_super = adfs_put_super, |
260 | .statfs = adfs_statfs, | 281 | .statfs = adfs_statfs, |
261 | .remount_fs = adfs_remount, | 282 | .remount_fs = adfs_remount, |
283 | .show_options = adfs_show_options, | ||
262 | }; | 284 | }; |
263 | 285 | ||
264 | static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_discrecord *dr) | 286 | static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_discrecord *dr) |
@@ -344,8 +366,8 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) | |||
344 | /* set default options */ | 366 | /* set default options */ |
345 | asb->s_uid = 0; | 367 | asb->s_uid = 0; |
346 | asb->s_gid = 0; | 368 | asb->s_gid = 0; |
347 | asb->s_owner_mask = S_IRWXU; | 369 | asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK; |
348 | asb->s_other_mask = S_IRWXG | S_IRWXO; | 370 | asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK; |
349 | 371 | ||
350 | if (parse_options(sb, data)) | 372 | if (parse_options(sb, data)) |
351 | goto error; | 373 | goto error; |
diff --git a/fs/affs/super.c b/fs/affs/super.c index 3c45d49c0d26..d2dc047cb479 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c | |||
@@ -122,6 +122,7 @@ static const struct super_operations affs_sops = { | |||
122 | .write_super = affs_write_super, | 122 | .write_super = affs_write_super, |
123 | .statfs = affs_statfs, | 123 | .statfs = affs_statfs, |
124 | .remount_fs = affs_remount, | 124 | .remount_fs = affs_remount, |
125 | .show_options = generic_show_options, | ||
125 | }; | 126 | }; |
126 | 127 | ||
127 | enum { | 128 | enum { |
@@ -272,6 +273,8 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
272 | u8 sig[4]; | 273 | u8 sig[4]; |
273 | int ret = -EINVAL; | 274 | int ret = -EINVAL; |
274 | 275 | ||
276 | save_mount_options(sb, data); | ||
277 | |||
275 | pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options"); | 278 | pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options"); |
276 | 279 | ||
277 | sb->s_magic = AFFS_SUPER_MAGIC; | 280 | sb->s_magic = AFFS_SUPER_MAGIC; |
@@ -487,14 +490,21 @@ affs_remount(struct super_block *sb, int *flags, char *data) | |||
487 | int root_block; | 490 | int root_block; |
488 | unsigned long mount_flags; | 491 | unsigned long mount_flags; |
489 | int res = 0; | 492 | int res = 0; |
493 | char *new_opts = kstrdup(data, GFP_KERNEL); | ||
490 | 494 | ||
491 | pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data); | 495 | pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data); |
492 | 496 | ||
493 | *flags |= MS_NODIRATIME; | 497 | *flags |= MS_NODIRATIME; |
494 | 498 | ||
495 | if (!parse_options(data,&uid,&gid,&mode,&reserved,&root_block, | 499 | if (!parse_options(data, &uid, &gid, &mode, &reserved, &root_block, |
496 | &blocksize,&sbi->s_prefix,sbi->s_volume,&mount_flags)) | 500 | &blocksize, &sbi->s_prefix, sbi->s_volume, |
501 | &mount_flags)) { | ||
502 | kfree(new_opts); | ||
497 | return -EINVAL; | 503 | return -EINVAL; |
504 | } | ||
505 | kfree(sb->s_options); | ||
506 | sb->s_options = new_opts; | ||
507 | |||
498 | sbi->s_flags = mount_flags; | 508 | sbi->s_flags = mount_flags; |
499 | sbi->s_mode = mode; | 509 | sbi->s_mode = mode; |
500 | sbi->s_uid = uid; | 510 | sbi->s_uid = uid; |
diff --git a/fs/afs/security.c b/fs/afs/security.c index 9446a1fd108a..3bcbeceba1bb 100644 --- a/fs/afs/security.c +++ b/fs/afs/security.c | |||
@@ -287,7 +287,7 @@ static int afs_check_permit(struct afs_vnode *vnode, struct key *key, | |||
287 | int afs_permission(struct inode *inode, int mask, struct nameidata *nd) | 287 | int afs_permission(struct inode *inode, int mask, struct nameidata *nd) |
288 | { | 288 | { |
289 | struct afs_vnode *vnode = AFS_FS_I(inode); | 289 | struct afs_vnode *vnode = AFS_FS_I(inode); |
290 | afs_access_t access; | 290 | afs_access_t uninitialized_var(access); |
291 | struct key *key; | 291 | struct key *key; |
292 | int ret; | 292 | int ret; |
293 | 293 | ||
diff --git a/fs/afs/super.c b/fs/afs/super.c index 4b2558c42213..36bbce45f44b 100644 --- a/fs/afs/super.c +++ b/fs/afs/super.c | |||
@@ -52,6 +52,7 @@ static const struct super_operations afs_super_ops = { | |||
52 | .clear_inode = afs_clear_inode, | 52 | .clear_inode = afs_clear_inode, |
53 | .umount_begin = afs_umount_begin, | 53 | .umount_begin = afs_umount_begin, |
54 | .put_super = afs_put_super, | 54 | .put_super = afs_put_super, |
55 | .show_options = generic_show_options, | ||
55 | }; | 56 | }; |
56 | 57 | ||
57 | static struct kmem_cache *afs_inode_cachep; | 58 | static struct kmem_cache *afs_inode_cachep; |
@@ -357,6 +358,7 @@ static int afs_get_sb(struct file_system_type *fs_type, | |||
357 | struct super_block *sb; | 358 | struct super_block *sb; |
358 | struct afs_volume *vol; | 359 | struct afs_volume *vol; |
359 | struct key *key; | 360 | struct key *key; |
361 | char *new_opts = kstrdup(options, GFP_KERNEL); | ||
360 | int ret; | 362 | int ret; |
361 | 363 | ||
362 | _enter(",,%s,%p", dev_name, options); | 364 | _enter(",,%s,%p", dev_name, options); |
@@ -408,9 +410,11 @@ static int afs_get_sb(struct file_system_type *fs_type, | |||
408 | deactivate_super(sb); | 410 | deactivate_super(sb); |
409 | goto error; | 411 | goto error; |
410 | } | 412 | } |
413 | sb->s_options = new_opts; | ||
411 | sb->s_flags |= MS_ACTIVE; | 414 | sb->s_flags |= MS_ACTIVE; |
412 | } else { | 415 | } else { |
413 | _debug("reuse"); | 416 | _debug("reuse"); |
417 | kfree(new_opts); | ||
414 | ASSERTCMP(sb->s_flags, &, MS_ACTIVE); | 418 | ASSERTCMP(sb->s_flags, &, MS_ACTIVE); |
415 | } | 419 | } |
416 | 420 | ||
@@ -424,6 +428,7 @@ error: | |||
424 | afs_put_volume(params.volume); | 428 | afs_put_volume(params.volume); |
425 | afs_put_cell(params.cell); | 429 | afs_put_cell(params.cell); |
426 | key_put(params.key); | 430 | key_put(params.key); |
431 | kfree(new_opts); | ||
427 | _leave(" = %d", ret); | 432 | _leave(" = %d", ret); |
428 | return ret; | 433 | return ret; |
429 | } | 434 | } |
@@ -317,7 +317,7 @@ out: | |||
317 | /* wait_on_sync_kiocb: | 317 | /* wait_on_sync_kiocb: |
318 | * Waits on the given sync kiocb to complete. | 318 | * Waits on the given sync kiocb to complete. |
319 | */ | 319 | */ |
320 | ssize_t fastcall wait_on_sync_kiocb(struct kiocb *iocb) | 320 | ssize_t wait_on_sync_kiocb(struct kiocb *iocb) |
321 | { | 321 | { |
322 | while (iocb->ki_users) { | 322 | while (iocb->ki_users) { |
323 | set_current_state(TASK_UNINTERRUPTIBLE); | 323 | set_current_state(TASK_UNINTERRUPTIBLE); |
@@ -336,7 +336,7 @@ ssize_t fastcall wait_on_sync_kiocb(struct kiocb *iocb) | |||
336 | * go away, they will call put_ioctx and release any pinned memory | 336 | * go away, they will call put_ioctx and release any pinned memory |
337 | * associated with the request (held via struct page * references). | 337 | * associated with the request (held via struct page * references). |
338 | */ | 338 | */ |
339 | void fastcall exit_aio(struct mm_struct *mm) | 339 | void exit_aio(struct mm_struct *mm) |
340 | { | 340 | { |
341 | struct kioctx *ctx = mm->ioctx_list; | 341 | struct kioctx *ctx = mm->ioctx_list; |
342 | mm->ioctx_list = NULL; | 342 | mm->ioctx_list = NULL; |
@@ -365,7 +365,7 @@ void fastcall exit_aio(struct mm_struct *mm) | |||
365 | * Called when the last user of an aio context has gone away, | 365 | * Called when the last user of an aio context has gone away, |
366 | * and the struct needs to be freed. | 366 | * and the struct needs to be freed. |
367 | */ | 367 | */ |
368 | void fastcall __put_ioctx(struct kioctx *ctx) | 368 | void __put_ioctx(struct kioctx *ctx) |
369 | { | 369 | { |
370 | unsigned nr_events = ctx->max_reqs; | 370 | unsigned nr_events = ctx->max_reqs; |
371 | 371 | ||
@@ -397,8 +397,7 @@ void fastcall __put_ioctx(struct kioctx *ctx) | |||
397 | * This prevents races between the aio code path referencing the | 397 | * This prevents races between the aio code path referencing the |
398 | * req (after submitting it) and aio_complete() freeing the req. | 398 | * req (after submitting it) and aio_complete() freeing the req. |
399 | */ | 399 | */ |
400 | static struct kiocb *__aio_get_req(struct kioctx *ctx); | 400 | static struct kiocb *__aio_get_req(struct kioctx *ctx) |
401 | static struct kiocb fastcall *__aio_get_req(struct kioctx *ctx) | ||
402 | { | 401 | { |
403 | struct kiocb *req = NULL; | 402 | struct kiocb *req = NULL; |
404 | struct aio_ring *ring; | 403 | struct aio_ring *ring; |
@@ -533,7 +532,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) | |||
533 | * Returns true if this put was the last user of the kiocb, | 532 | * Returns true if this put was the last user of the kiocb, |
534 | * false if the request is still in use. | 533 | * false if the request is still in use. |
535 | */ | 534 | */ |
536 | int fastcall aio_put_req(struct kiocb *req) | 535 | int aio_put_req(struct kiocb *req) |
537 | { | 536 | { |
538 | struct kioctx *ctx = req->ki_ctx; | 537 | struct kioctx *ctx = req->ki_ctx; |
539 | int ret; | 538 | int ret; |
@@ -893,7 +892,7 @@ static void try_queue_kicked_iocb(struct kiocb *iocb) | |||
893 | * The retry is usually executed by aio workqueue | 892 | * The retry is usually executed by aio workqueue |
894 | * threads (See aio_kick_handler). | 893 | * threads (See aio_kick_handler). |
895 | */ | 894 | */ |
896 | void fastcall kick_iocb(struct kiocb *iocb) | 895 | void kick_iocb(struct kiocb *iocb) |
897 | { | 896 | { |
898 | /* sync iocbs are easy: they can only ever be executing from a | 897 | /* sync iocbs are easy: they can only ever be executing from a |
899 | * single context. */ | 898 | * single context. */ |
@@ -912,7 +911,7 @@ EXPORT_SYMBOL(kick_iocb); | |||
912 | * Returns true if this is the last user of the request. The | 911 | * Returns true if this is the last user of the request. The |
913 | * only other user of the request can be the cancellation code. | 912 | * only other user of the request can be the cancellation code. |
914 | */ | 913 | */ |
915 | int fastcall aio_complete(struct kiocb *iocb, long res, long res2) | 914 | int aio_complete(struct kiocb *iocb, long res, long res2) |
916 | { | 915 | { |
917 | struct kioctx *ctx = iocb->ki_ctx; | 916 | struct kioctx *ctx = iocb->ki_ctx; |
918 | struct aio_ring_info *info; | 917 | struct aio_ring_info *info; |
@@ -1330,6 +1329,10 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb) | |||
1330 | opcode = IOCB_CMD_PWRITEV; | 1329 | opcode = IOCB_CMD_PWRITEV; |
1331 | } | 1330 | } |
1332 | 1331 | ||
1332 | /* This matches the pread()/pwrite() logic */ | ||
1333 | if (iocb->ki_pos < 0) | ||
1334 | return -EINVAL; | ||
1335 | |||
1333 | do { | 1336 | do { |
1334 | ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg], | 1337 | ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg], |
1335 | iocb->ki_nr_segs - iocb->ki_cur_seg, | 1338 | iocb->ki_nr_segs - iocb->ki_cur_seg, |
@@ -1348,6 +1351,13 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb) | |||
1348 | if ((ret == 0) || (iocb->ki_left == 0)) | 1351 | if ((ret == 0) || (iocb->ki_left == 0)) |
1349 | ret = iocb->ki_nbytes - iocb->ki_left; | 1352 | ret = iocb->ki_nbytes - iocb->ki_left; |
1350 | 1353 | ||
1354 | /* If we managed to write some out we return that, rather than | ||
1355 | * the eventual error. */ | ||
1356 | if (opcode == IOCB_CMD_PWRITEV | ||
1357 | && ret < 0 && ret != -EIOCBQUEUED && ret != -EIOCBRETRY | ||
1358 | && iocb->ki_nbytes - iocb->ki_left) | ||
1359 | ret = iocb->ki_nbytes - iocb->ki_left; | ||
1360 | |||
1351 | return ret; | 1361 | return ret; |
1352 | } | 1362 | } |
1353 | 1363 | ||
@@ -1523,7 +1533,7 @@ static int aio_wake_function(wait_queue_t *wait, unsigned mode, | |||
1523 | return 1; | 1533 | return 1; |
1524 | } | 1534 | } |
1525 | 1535 | ||
1526 | int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, | 1536 | int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, |
1527 | struct iocb *iocb) | 1537 | struct iocb *iocb) |
1528 | { | 1538 | { |
1529 | struct kiocb *req; | 1539 | struct kiocb *req; |
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 708bdb89fea1..dda510d31f84 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c | |||
@@ -54,6 +54,7 @@ out_kill_sb: | |||
54 | 54 | ||
55 | static const struct super_operations autofs_sops = { | 55 | static const struct super_operations autofs_sops = { |
56 | .statfs = simple_statfs, | 56 | .statfs = simple_statfs, |
57 | .show_options = generic_show_options, | ||
57 | }; | 58 | }; |
58 | 59 | ||
59 | enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto}; | 60 | enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto}; |
@@ -140,6 +141,8 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) | |||
140 | int minproto, maxproto; | 141 | int minproto, maxproto; |
141 | pid_t pgid; | 142 | pid_t pgid; |
142 | 143 | ||
144 | save_mount_options(s, data); | ||
145 | |||
143 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 146 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
144 | if (!sbi) | 147 | if (!sbi) |
145 | goto fail_unlock; | 148 | goto fail_unlock; |
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c index 7f05d6ccdb13..2fdcf5e1d236 100644 --- a/fs/autofs4/inode.c +++ b/fs/autofs4/inode.c | |||
@@ -176,11 +176,16 @@ out_kill_sb: | |||
176 | static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt) | 176 | static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt) |
177 | { | 177 | { |
178 | struct autofs_sb_info *sbi = autofs4_sbi(mnt->mnt_sb); | 178 | struct autofs_sb_info *sbi = autofs4_sbi(mnt->mnt_sb); |
179 | struct inode *root_inode = mnt->mnt_sb->s_root->d_inode; | ||
179 | 180 | ||
180 | if (!sbi) | 181 | if (!sbi) |
181 | return 0; | 182 | return 0; |
182 | 183 | ||
183 | seq_printf(m, ",fd=%d", sbi->pipefd); | 184 | seq_printf(m, ",fd=%d", sbi->pipefd); |
185 | if (root_inode->i_uid != 0) | ||
186 | seq_printf(m, ",uid=%u", root_inode->i_uid); | ||
187 | if (root_inode->i_gid != 0) | ||
188 | seq_printf(m, ",gid=%u", root_inode->i_gid); | ||
184 | seq_printf(m, ",pgrp=%d", sbi->oz_pgrp); | 189 | seq_printf(m, ",pgrp=%d", sbi->oz_pgrp); |
185 | seq_printf(m, ",timeout=%lu", sbi->exp_timeout/HZ); | 190 | seq_printf(m, ",timeout=%lu", sbi->exp_timeout/HZ); |
186 | seq_printf(m, ",minproto=%d", sbi->min_proto); | 191 | seq_printf(m, ",minproto=%d", sbi->min_proto); |
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 403fe661c144..82123ff3e1dd 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
@@ -57,6 +57,7 @@ static const struct super_operations befs_sops = { | |||
57 | .put_super = befs_put_super, /* uninit super */ | 57 | .put_super = befs_put_super, /* uninit super */ |
58 | .statfs = befs_statfs, /* statfs */ | 58 | .statfs = befs_statfs, /* statfs */ |
59 | .remount_fs = befs_remount, | 59 | .remount_fs = befs_remount, |
60 | .show_options = generic_show_options, | ||
60 | }; | 61 | }; |
61 | 62 | ||
62 | /* slab cache for befs_inode_info objects */ | 63 | /* slab cache for befs_inode_info objects */ |
@@ -759,10 +760,11 @@ befs_fill_super(struct super_block *sb, void *data, int silent) | |||
759 | befs_super_block *disk_sb; | 760 | befs_super_block *disk_sb; |
760 | struct inode *root; | 761 | struct inode *root; |
761 | long ret = -EINVAL; | 762 | long ret = -EINVAL; |
762 | |||
763 | const unsigned long sb_block = 0; | 763 | const unsigned long sb_block = 0; |
764 | const off_t x86_sb_off = 512; | 764 | const off_t x86_sb_off = 512; |
765 | 765 | ||
766 | save_mount_options(sb, data); | ||
767 | |||
766 | sb->s_fs_info = kmalloc(sizeof (*befs_sb), GFP_KERNEL); | 768 | sb->s_fs_info = kmalloc(sizeof (*befs_sb), GFP_KERNEL); |
767 | if (sb->s_fs_info == NULL) { | 769 | if (sb->s_fs_info == NULL) { |
768 | printk(KERN_ERR | 770 | printk(KERN_ERR |
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index 7f65e71bf859..a1bb2244cac7 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <asm/system.h> | 28 | #include <asm/system.h> |
29 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
30 | #include <asm/cacheflush.h> | 30 | #include <asm/cacheflush.h> |
31 | #include <asm/a.out-core.h> | ||
31 | 32 | ||
32 | static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); | 33 | static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); |
33 | static int load_aout_library(struct file*); | 34 | static int load_aout_library(struct file*); |
@@ -118,7 +119,7 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, u | |||
118 | dump.u_ar0 = offsetof(struct user, regs); | 119 | dump.u_ar0 = offsetof(struct user, regs); |
119 | #endif | 120 | #endif |
120 | dump.signal = signr; | 121 | dump.signal = signr; |
121 | dump_thread(regs, &dump); | 122 | aout_dump_thread(regs, &dump); |
122 | 123 | ||
123 | /* If the size of the dump file exceeds the rlimit, then see what would happen | 124 | /* If the size of the dump file exceeds the rlimit, then see what would happen |
124 | if we wrote the stack, but not the data area. */ | 125 | if we wrote the stack, but not the data area. */ |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 111771d38e6e..41a958a7585e 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -134,8 +134,7 @@ static int padzero(unsigned long elf_bss) | |||
134 | 134 | ||
135 | static int | 135 | static int |
136 | create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec, | 136 | create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec, |
137 | int interp_aout, unsigned long load_addr, | 137 | unsigned long load_addr, unsigned long interp_load_addr) |
138 | unsigned long interp_load_addr) | ||
139 | { | 138 | { |
140 | unsigned long p = bprm->p; | 139 | unsigned long p = bprm->p; |
141 | int argc = bprm->argc; | 140 | int argc = bprm->argc; |
@@ -223,12 +222,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec, | |||
223 | 222 | ||
224 | sp = STACK_ADD(p, ei_index); | 223 | sp = STACK_ADD(p, ei_index); |
225 | 224 | ||
226 | items = (argc + 1) + (envc + 1); | 225 | items = (argc + 1) + (envc + 1) + 1; |
227 | if (interp_aout) { | ||
228 | items += 3; /* a.out interpreters require argv & envp too */ | ||
229 | } else { | ||
230 | items += 1; /* ELF interpreters only put argc on the stack */ | ||
231 | } | ||
232 | bprm->p = STACK_ROUND(sp, items); | 226 | bprm->p = STACK_ROUND(sp, items); |
233 | 227 | ||
234 | /* Point sp at the lowest address on the stack */ | 228 | /* Point sp at the lowest address on the stack */ |
@@ -251,16 +245,8 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec, | |||
251 | /* Now, let's put argc (and argv, envp if appropriate) on the stack */ | 245 | /* Now, let's put argc (and argv, envp if appropriate) on the stack */ |
252 | if (__put_user(argc, sp++)) | 246 | if (__put_user(argc, sp++)) |
253 | return -EFAULT; | 247 | return -EFAULT; |
254 | if (interp_aout) { | 248 | argv = sp; |
255 | argv = sp + 2; | 249 | envp = argv + argc + 1; |
256 | envp = argv + argc + 1; | ||
257 | if (__put_user((elf_addr_t)(unsigned long)argv, sp++) || | ||
258 | __put_user((elf_addr_t)(unsigned long)envp, sp++)) | ||
259 | return -EFAULT; | ||
260 | } else { | ||
261 | argv = sp; | ||
262 | envp = argv + argc + 1; | ||
263 | } | ||
264 | 250 | ||
265 | /* Populate argv and envp */ | 251 | /* Populate argv and envp */ |
266 | p = current->mm->arg_end = current->mm->arg_start; | 252 | p = current->mm->arg_end = current->mm->arg_start; |
@@ -513,59 +499,12 @@ out: | |||
513 | return error; | 499 | return error; |
514 | } | 500 | } |
515 | 501 | ||
516 | static unsigned long load_aout_interp(struct exec *interp_ex, | ||
517 | struct file *interpreter) | ||
518 | { | ||
519 | unsigned long text_data, elf_entry = ~0UL; | ||
520 | char __user * addr; | ||
521 | loff_t offset; | ||
522 | |||
523 | current->mm->end_code = interp_ex->a_text; | ||
524 | text_data = interp_ex->a_text + interp_ex->a_data; | ||
525 | current->mm->end_data = text_data; | ||
526 | current->mm->brk = interp_ex->a_bss + text_data; | ||
527 | |||
528 | switch (N_MAGIC(*interp_ex)) { | ||
529 | case OMAGIC: | ||
530 | offset = 32; | ||
531 | addr = (char __user *)0; | ||
532 | break; | ||
533 | case ZMAGIC: | ||
534 | case QMAGIC: | ||
535 | offset = N_TXTOFF(*interp_ex); | ||
536 | addr = (char __user *)N_TXTADDR(*interp_ex); | ||
537 | break; | ||
538 | default: | ||
539 | goto out; | ||
540 | } | ||
541 | |||
542 | down_write(¤t->mm->mmap_sem); | ||
543 | do_brk(0, text_data); | ||
544 | up_write(¤t->mm->mmap_sem); | ||
545 | if (!interpreter->f_op || !interpreter->f_op->read) | ||
546 | goto out; | ||
547 | if (interpreter->f_op->read(interpreter, addr, text_data, &offset) < 0) | ||
548 | goto out; | ||
549 | flush_icache_range((unsigned long)addr, | ||
550 | (unsigned long)addr + text_data); | ||
551 | |||
552 | down_write(¤t->mm->mmap_sem); | ||
553 | do_brk(ELF_PAGESTART(text_data + ELF_MIN_ALIGN - 1), | ||
554 | interp_ex->a_bss); | ||
555 | up_write(¤t->mm->mmap_sem); | ||
556 | elf_entry = interp_ex->a_entry; | ||
557 | |||
558 | out: | ||
559 | return elf_entry; | ||
560 | } | ||
561 | |||
562 | /* | 502 | /* |
563 | * These are the functions used to load ELF style executables and shared | 503 | * These are the functions used to load ELF style executables and shared |
564 | * libraries. There is no binary dependent code anywhere else. | 504 | * libraries. There is no binary dependent code anywhere else. |
565 | */ | 505 | */ |
566 | 506 | ||
567 | #define INTERPRETER_NONE 0 | 507 | #define INTERPRETER_NONE 0 |
568 | #define INTERPRETER_AOUT 1 | ||
569 | #define INTERPRETER_ELF 2 | 508 | #define INTERPRETER_ELF 2 |
570 | 509 | ||
571 | #ifndef STACK_RND_MASK | 510 | #ifndef STACK_RND_MASK |
@@ -594,7 +533,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
594 | unsigned long load_addr = 0, load_bias = 0; | 533 | unsigned long load_addr = 0, load_bias = 0; |
595 | int load_addr_set = 0; | 534 | int load_addr_set = 0; |
596 | char * elf_interpreter = NULL; | 535 | char * elf_interpreter = NULL; |
597 | unsigned int interpreter_type = INTERPRETER_NONE; | ||
598 | unsigned long error; | 536 | unsigned long error; |
599 | struct elf_phdr *elf_ppnt, *elf_phdata; | 537 | struct elf_phdr *elf_ppnt, *elf_phdata; |
600 | unsigned long elf_bss, elf_brk; | 538 | unsigned long elf_bss, elf_brk; |
@@ -605,7 +543,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
605 | unsigned long interp_load_addr = 0; | 543 | unsigned long interp_load_addr = 0; |
606 | unsigned long start_code, end_code, start_data, end_data; | 544 | unsigned long start_code, end_code, start_data, end_data; |
607 | unsigned long reloc_func_desc = 0; | 545 | unsigned long reloc_func_desc = 0; |
608 | char passed_fileno[6]; | ||
609 | struct files_struct *files; | 546 | struct files_struct *files; |
610 | int executable_stack = EXSTACK_DEFAULT; | 547 | int executable_stack = EXSTACK_DEFAULT; |
611 | unsigned long def_flags = 0; | 548 | unsigned long def_flags = 0; |
@@ -774,59 +711,18 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
774 | 711 | ||
775 | /* Some simple consistency checks for the interpreter */ | 712 | /* Some simple consistency checks for the interpreter */ |
776 | if (elf_interpreter) { | 713 | if (elf_interpreter) { |
777 | static int warn; | ||
778 | interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT; | ||
779 | |||
780 | /* Now figure out which format our binary is */ | ||
781 | if ((N_MAGIC(loc->interp_ex) != OMAGIC) && | ||
782 | (N_MAGIC(loc->interp_ex) != ZMAGIC) && | ||
783 | (N_MAGIC(loc->interp_ex) != QMAGIC)) | ||
784 | interpreter_type = INTERPRETER_ELF; | ||
785 | |||
786 | if (memcmp(loc->interp_elf_ex.e_ident, ELFMAG, SELFMAG) != 0) | ||
787 | interpreter_type &= ~INTERPRETER_ELF; | ||
788 | |||
789 | if (interpreter_type == INTERPRETER_AOUT && warn < 10) { | ||
790 | printk(KERN_WARNING "a.out ELF interpreter %s is " | ||
791 | "deprecated and will not be supported " | ||
792 | "after Linux 2.6.25\n", elf_interpreter); | ||
793 | warn++; | ||
794 | } | ||
795 | |||
796 | retval = -ELIBBAD; | 714 | retval = -ELIBBAD; |
797 | if (!interpreter_type) | 715 | /* Not an ELF interpreter */ |
716 | if (memcmp(loc->interp_elf_ex.e_ident, ELFMAG, SELFMAG) != 0) | ||
798 | goto out_free_dentry; | 717 | goto out_free_dentry; |
799 | |||
800 | /* Make sure only one type was selected */ | ||
801 | if ((interpreter_type & INTERPRETER_ELF) && | ||
802 | interpreter_type != INTERPRETER_ELF) { | ||
803 | // FIXME - ratelimit this before re-enabling | ||
804 | // printk(KERN_WARNING "ELF: Ambiguous type, using ELF\n"); | ||
805 | interpreter_type = INTERPRETER_ELF; | ||
806 | } | ||
807 | /* Verify the interpreter has a valid arch */ | 718 | /* Verify the interpreter has a valid arch */ |
808 | if ((interpreter_type == INTERPRETER_ELF) && | 719 | if (!elf_check_arch(&loc->interp_elf_ex)) |
809 | !elf_check_arch(&loc->interp_elf_ex)) | ||
810 | goto out_free_dentry; | 720 | goto out_free_dentry; |
811 | } else { | 721 | } else { |
812 | /* Executables without an interpreter also need a personality */ | 722 | /* Executables without an interpreter also need a personality */ |
813 | SET_PERSONALITY(loc->elf_ex, 0); | 723 | SET_PERSONALITY(loc->elf_ex, 0); |
814 | } | 724 | } |
815 | 725 | ||
816 | /* OK, we are done with that, now set up the arg stuff, | ||
817 | and then start this sucker up */ | ||
818 | if ((!bprm->sh_bang) && (interpreter_type == INTERPRETER_AOUT)) { | ||
819 | char *passed_p = passed_fileno; | ||
820 | sprintf(passed_fileno, "%d", elf_exec_fileno); | ||
821 | |||
822 | if (elf_interpreter) { | ||
823 | retval = copy_strings_kernel(1, &passed_p, bprm); | ||
824 | if (retval) | ||
825 | goto out_free_dentry; | ||
826 | bprm->argc++; | ||
827 | } | ||
828 | } | ||
829 | |||
830 | /* Flush all traces of the currently running executable */ | 726 | /* Flush all traces of the currently running executable */ |
831 | retval = flush_old_exec(bprm); | 727 | retval = flush_old_exec(bprm); |
832 | if (retval) | 728 | if (retval) |
@@ -1004,24 +900,19 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
1004 | } | 900 | } |
1005 | 901 | ||
1006 | if (elf_interpreter) { | 902 | if (elf_interpreter) { |
1007 | if (interpreter_type == INTERPRETER_AOUT) { | 903 | unsigned long uninitialized_var(interp_map_addr); |
1008 | elf_entry = load_aout_interp(&loc->interp_ex, | 904 | |
1009 | interpreter); | 905 | elf_entry = load_elf_interp(&loc->interp_elf_ex, |
1010 | } else { | 906 | interpreter, |
1011 | unsigned long uninitialized_var(interp_map_addr); | 907 | &interp_map_addr, |
1012 | 908 | load_bias); | |
1013 | elf_entry = load_elf_interp(&loc->interp_elf_ex, | 909 | if (!IS_ERR((void *)elf_entry)) { |
1014 | interpreter, | 910 | /* |
1015 | &interp_map_addr, | 911 | * load_elf_interp() returns relocation |
1016 | load_bias); | 912 | * adjustment |
1017 | if (!IS_ERR((void *)elf_entry)) { | 913 | */ |
1018 | /* | 914 | interp_load_addr = elf_entry; |
1019 | * load_elf_interp() returns relocation | 915 | elf_entry += loc->interp_elf_ex.e_entry; |
1020 | * adjustment | ||
1021 | */ | ||
1022 | interp_load_addr = elf_entry; | ||
1023 | elf_entry += loc->interp_elf_ex.e_entry; | ||
1024 | } | ||
1025 | } | 916 | } |
1026 | if (BAD_ADDR(elf_entry)) { | 917 | if (BAD_ADDR(elf_entry)) { |
1027 | force_sig(SIGSEGV, current); | 918 | force_sig(SIGSEGV, current); |
@@ -1045,8 +936,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
1045 | 936 | ||
1046 | kfree(elf_phdata); | 937 | kfree(elf_phdata); |
1047 | 938 | ||
1048 | if (interpreter_type != INTERPRETER_AOUT) | 939 | sys_close(elf_exec_fileno); |
1049 | sys_close(elf_exec_fileno); | ||
1050 | 940 | ||
1051 | set_binfmt(&elf_format); | 941 | set_binfmt(&elf_format); |
1052 | 942 | ||
@@ -1061,15 +951,12 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
1061 | compute_creds(bprm); | 951 | compute_creds(bprm); |
1062 | current->flags &= ~PF_FORKNOEXEC; | 952 | current->flags &= ~PF_FORKNOEXEC; |
1063 | retval = create_elf_tables(bprm, &loc->elf_ex, | 953 | retval = create_elf_tables(bprm, &loc->elf_ex, |
1064 | (interpreter_type == INTERPRETER_AOUT), | ||
1065 | load_addr, interp_load_addr); | 954 | load_addr, interp_load_addr); |
1066 | if (retval < 0) { | 955 | if (retval < 0) { |
1067 | send_sig(SIGKILL, current, 0); | 956 | send_sig(SIGKILL, current, 0); |
1068 | goto out; | 957 | goto out; |
1069 | } | 958 | } |
1070 | /* N.B. passed_fileno might not be initialized? */ | 959 | /* N.B. passed_fileno might not be initialized? */ |
1071 | if (interpreter_type == INTERPRETER_AOUT) | ||
1072 | current->mm->arg_start += strlen(passed_fileno) + 1; | ||
1073 | current->mm->end_code = end_code; | 960 | current->mm->end_code = end_code; |
1074 | current->mm->start_code = start_code; | 961 | current->mm->start_code = start_code; |
1075 | current->mm->start_data = start_data; | 962 | current->mm->start_data = start_data; |
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 33764fd6db66..d8a02f1e08cc 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <linux/mman.h> | 22 | #include <linux/mman.h> |
23 | #include <linux/a.out.h> | ||
24 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
25 | #include <linux/signal.h> | 24 | #include <linux/signal.h> |
26 | #include <linux/string.h> | 25 | #include <linux/string.h> |
diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c index 9208c41209f9..14c63527c762 100644 --- a/fs/binfmt_som.c +++ b/fs/binfmt_som.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/personality.h> | 29 | #include <linux/personality.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | 31 | ||
32 | #include <asm/a.out.h> | ||
33 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
34 | #include <asm/pgtable.h> | 33 | #include <asm/pgtable.h> |
35 | 34 | ||
diff --git a/fs/buffer.c b/fs/buffer.c index 826baf4f04bc..3ebccf4aa7e3 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -67,14 +67,14 @@ static int sync_buffer(void *word) | |||
67 | return 0; | 67 | return 0; |
68 | } | 68 | } |
69 | 69 | ||
70 | void fastcall __lock_buffer(struct buffer_head *bh) | 70 | void __lock_buffer(struct buffer_head *bh) |
71 | { | 71 | { |
72 | wait_on_bit_lock(&bh->b_state, BH_Lock, sync_buffer, | 72 | wait_on_bit_lock(&bh->b_state, BH_Lock, sync_buffer, |
73 | TASK_UNINTERRUPTIBLE); | 73 | TASK_UNINTERRUPTIBLE); |
74 | } | 74 | } |
75 | EXPORT_SYMBOL(__lock_buffer); | 75 | EXPORT_SYMBOL(__lock_buffer); |
76 | 76 | ||
77 | void fastcall unlock_buffer(struct buffer_head *bh) | 77 | void unlock_buffer(struct buffer_head *bh) |
78 | { | 78 | { |
79 | smp_mb__before_clear_bit(); | 79 | smp_mb__before_clear_bit(); |
80 | clear_buffer_locked(bh); | 80 | clear_buffer_locked(bh); |
@@ -678,7 +678,7 @@ void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode) | |||
678 | } else { | 678 | } else { |
679 | BUG_ON(mapping->assoc_mapping != buffer_mapping); | 679 | BUG_ON(mapping->assoc_mapping != buffer_mapping); |
680 | } | 680 | } |
681 | if (list_empty(&bh->b_assoc_buffers)) { | 681 | if (!bh->b_assoc_map) { |
682 | spin_lock(&buffer_mapping->private_lock); | 682 | spin_lock(&buffer_mapping->private_lock); |
683 | list_move_tail(&bh->b_assoc_buffers, | 683 | list_move_tail(&bh->b_assoc_buffers, |
684 | &mapping->private_list); | 684 | &mapping->private_list); |
@@ -794,6 +794,7 @@ static int fsync_buffers_list(spinlock_t *lock, struct list_head *list) | |||
794 | { | 794 | { |
795 | struct buffer_head *bh; | 795 | struct buffer_head *bh; |
796 | struct list_head tmp; | 796 | struct list_head tmp; |
797 | struct address_space *mapping; | ||
797 | int err = 0, err2; | 798 | int err = 0, err2; |
798 | 799 | ||
799 | INIT_LIST_HEAD(&tmp); | 800 | INIT_LIST_HEAD(&tmp); |
@@ -801,9 +802,14 @@ static int fsync_buffers_list(spinlock_t *lock, struct list_head *list) | |||
801 | spin_lock(lock); | 802 | spin_lock(lock); |
802 | while (!list_empty(list)) { | 803 | while (!list_empty(list)) { |
803 | bh = BH_ENTRY(list->next); | 804 | bh = BH_ENTRY(list->next); |
805 | mapping = bh->b_assoc_map; | ||
804 | __remove_assoc_queue(bh); | 806 | __remove_assoc_queue(bh); |
807 | /* Avoid race with mark_buffer_dirty_inode() which does | ||
808 | * a lockless check and we rely on seeing the dirty bit */ | ||
809 | smp_mb(); | ||
805 | if (buffer_dirty(bh) || buffer_locked(bh)) { | 810 | if (buffer_dirty(bh) || buffer_locked(bh)) { |
806 | list_add(&bh->b_assoc_buffers, &tmp); | 811 | list_add(&bh->b_assoc_buffers, &tmp); |
812 | bh->b_assoc_map = mapping; | ||
807 | if (buffer_dirty(bh)) { | 813 | if (buffer_dirty(bh)) { |
808 | get_bh(bh); | 814 | get_bh(bh); |
809 | spin_unlock(lock); | 815 | spin_unlock(lock); |
@@ -822,8 +828,17 @@ static int fsync_buffers_list(spinlock_t *lock, struct list_head *list) | |||
822 | 828 | ||
823 | while (!list_empty(&tmp)) { | 829 | while (!list_empty(&tmp)) { |
824 | bh = BH_ENTRY(tmp.prev); | 830 | bh = BH_ENTRY(tmp.prev); |
825 | list_del_init(&bh->b_assoc_buffers); | ||
826 | get_bh(bh); | 831 | get_bh(bh); |
832 | mapping = bh->b_assoc_map; | ||
833 | __remove_assoc_queue(bh); | ||
834 | /* Avoid race with mark_buffer_dirty_inode() which does | ||
835 | * a lockless check and we rely on seeing the dirty bit */ | ||
836 | smp_mb(); | ||
837 | if (buffer_dirty(bh)) { | ||
838 | list_add(&bh->b_assoc_buffers, | ||
839 | &bh->b_assoc_map->private_list); | ||
840 | bh->b_assoc_map = mapping; | ||
841 | } | ||
827 | spin_unlock(lock); | 842 | spin_unlock(lock); |
828 | wait_on_buffer(bh); | 843 | wait_on_buffer(bh); |
829 | if (!buffer_uptodate(bh)) | 844 | if (!buffer_uptodate(bh)) |
@@ -1164,7 +1179,7 @@ __getblk_slow(struct block_device *bdev, sector_t block, int size) | |||
1164 | * mark_buffer_dirty() is atomic. It takes bh->b_page->mapping->private_lock, | 1179 | * mark_buffer_dirty() is atomic. It takes bh->b_page->mapping->private_lock, |
1165 | * mapping->tree_lock and the global inode_lock. | 1180 | * mapping->tree_lock and the global inode_lock. |
1166 | */ | 1181 | */ |
1167 | void fastcall mark_buffer_dirty(struct buffer_head *bh) | 1182 | void mark_buffer_dirty(struct buffer_head *bh) |
1168 | { | 1183 | { |
1169 | WARN_ON_ONCE(!buffer_uptodate(bh)); | 1184 | WARN_ON_ONCE(!buffer_uptodate(bh)); |
1170 | if (!buffer_dirty(bh) && !test_set_buffer_dirty(bh)) | 1185 | if (!buffer_dirty(bh) && !test_set_buffer_dirty(bh)) |
@@ -1195,7 +1210,7 @@ void __brelse(struct buffer_head * buf) | |||
1195 | void __bforget(struct buffer_head *bh) | 1210 | void __bforget(struct buffer_head *bh) |
1196 | { | 1211 | { |
1197 | clear_buffer_dirty(bh); | 1212 | clear_buffer_dirty(bh); |
1198 | if (!list_empty(&bh->b_assoc_buffers)) { | 1213 | if (bh->b_assoc_map) { |
1199 | struct address_space *buffer_mapping = bh->b_page->mapping; | 1214 | struct address_space *buffer_mapping = bh->b_page->mapping; |
1200 | 1215 | ||
1201 | spin_lock(&buffer_mapping->private_lock); | 1216 | spin_lock(&buffer_mapping->private_lock); |
@@ -1436,6 +1451,7 @@ void invalidate_bh_lrus(void) | |||
1436 | { | 1451 | { |
1437 | on_each_cpu(invalidate_bh_lru, NULL, 1, 1); | 1452 | on_each_cpu(invalidate_bh_lru, NULL, 1, 1); |
1438 | } | 1453 | } |
1454 | EXPORT_SYMBOL_GPL(invalidate_bh_lrus); | ||
1439 | 1455 | ||
1440 | void set_bh_page(struct buffer_head *bh, | 1456 | void set_bh_page(struct buffer_head *bh, |
1441 | struct page *page, unsigned long offset) | 1457 | struct page *page, unsigned long offset) |
@@ -3021,7 +3037,7 @@ drop_buffers(struct page *page, struct buffer_head **buffers_to_free) | |||
3021 | do { | 3037 | do { |
3022 | struct buffer_head *next = bh->b_this_page; | 3038 | struct buffer_head *next = bh->b_this_page; |
3023 | 3039 | ||
3024 | if (!list_empty(&bh->b_assoc_buffers)) | 3040 | if (bh->b_assoc_map) |
3025 | __remove_assoc_queue(bh); | 3041 | __remove_assoc_queue(bh); |
3026 | bh = next; | 3042 | bh = next; |
3027 | } while (bh != head); | 3043 | } while (bh != head); |
diff --git a/fs/char_dev.c b/fs/char_dev.c index 2c7a8b5b4598..038674aa88a7 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c | |||
@@ -357,7 +357,7 @@ void cdev_put(struct cdev *p) | |||
357 | /* | 357 | /* |
358 | * Called every time a character special file is opened | 358 | * Called every time a character special file is opened |
359 | */ | 359 | */ |
360 | int chrdev_open(struct inode * inode, struct file * filp) | 360 | static int chrdev_open(struct inode *inode, struct file *filp) |
361 | { | 361 | { |
362 | struct cdev *p; | 362 | struct cdev *p; |
363 | struct cdev *new = NULL; | 363 | struct cdev *new = NULL; |
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index fa6b7f7ff914..fddffe4851f5 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c | |||
@@ -56,13 +56,15 @@ const struct inode_operations debugfs_link_operations = { | |||
56 | .follow_link = debugfs_follow_link, | 56 | .follow_link = debugfs_follow_link, |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static void debugfs_u8_set(void *data, u64 val) | 59 | static int debugfs_u8_set(void *data, u64 val) |
60 | { | 60 | { |
61 | *(u8 *)data = val; | 61 | *(u8 *)data = val; |
62 | return 0; | ||
62 | } | 63 | } |
63 | static u64 debugfs_u8_get(void *data) | 64 | static int debugfs_u8_get(void *data, u64 *val) |
64 | { | 65 | { |
65 | return *(u8 *)data; | 66 | *val = *(u8 *)data; |
67 | return 0; | ||
66 | } | 68 | } |
67 | DEFINE_SIMPLE_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%llu\n"); | 69 | DEFINE_SIMPLE_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%llu\n"); |
68 | 70 | ||
@@ -97,13 +99,15 @@ struct dentry *debugfs_create_u8(const char *name, mode_t mode, | |||
97 | } | 99 | } |
98 | EXPORT_SYMBOL_GPL(debugfs_create_u8); | 100 | EXPORT_SYMBOL_GPL(debugfs_create_u8); |
99 | 101 | ||
100 | static void debugfs_u16_set(void *data, u64 val) | 102 | static int debugfs_u16_set(void *data, u64 val) |
101 | { | 103 | { |
102 | *(u16 *)data = val; | 104 | *(u16 *)data = val; |
105 | return 0; | ||
103 | } | 106 | } |
104 | static u64 debugfs_u16_get(void *data) | 107 | static int debugfs_u16_get(void *data, u64 *val) |
105 | { | 108 | { |
106 | return *(u16 *)data; | 109 | *val = *(u16 *)data; |
110 | return 0; | ||
107 | } | 111 | } |
108 | DEFINE_SIMPLE_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%llu\n"); | 112 | DEFINE_SIMPLE_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%llu\n"); |
109 | 113 | ||
@@ -138,13 +142,15 @@ struct dentry *debugfs_create_u16(const char *name, mode_t mode, | |||
138 | } | 142 | } |
139 | EXPORT_SYMBOL_GPL(debugfs_create_u16); | 143 | EXPORT_SYMBOL_GPL(debugfs_create_u16); |
140 | 144 | ||
141 | static void debugfs_u32_set(void *data, u64 val) | 145 | static int debugfs_u32_set(void *data, u64 val) |
142 | { | 146 | { |
143 | *(u32 *)data = val; | 147 | *(u32 *)data = val; |
148 | return 0; | ||
144 | } | 149 | } |
145 | static u64 debugfs_u32_get(void *data) | 150 | static int debugfs_u32_get(void *data, u64 *val) |
146 | { | 151 | { |
147 | return *(u32 *)data; | 152 | *val = *(u32 *)data; |
153 | return 0; | ||
148 | } | 154 | } |
149 | DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n"); | 155 | DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n"); |
150 | 156 | ||
@@ -179,14 +185,16 @@ struct dentry *debugfs_create_u32(const char *name, mode_t mode, | |||
179 | } | 185 | } |
180 | EXPORT_SYMBOL_GPL(debugfs_create_u32); | 186 | EXPORT_SYMBOL_GPL(debugfs_create_u32); |
181 | 187 | ||
182 | static void debugfs_u64_set(void *data, u64 val) | 188 | static int debugfs_u64_set(void *data, u64 val) |
183 | { | 189 | { |
184 | *(u64 *)data = val; | 190 | *(u64 *)data = val; |
191 | return 0; | ||
185 | } | 192 | } |
186 | 193 | ||
187 | static u64 debugfs_u64_get(void *data) | 194 | static int debugfs_u64_get(void *data, u64 *val) |
188 | { | 195 | { |
189 | return *(u64 *)data; | 196 | *val = *(u64 *)data; |
197 | return 0; | ||
190 | } | 198 | } |
191 | DEFINE_SIMPLE_ATTRIBUTE(fops_u64, debugfs_u64_get, debugfs_u64_set, "%llu\n"); | 199 | DEFINE_SIMPLE_ATTRIBUTE(fops_u64, debugfs_u64_get, debugfs_u64_set, "%llu\n"); |
192 | 200 | ||
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index 06ef9a255c76..f120e1207874 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
@@ -20,9 +20,12 @@ | |||
20 | #include <linux/devpts_fs.h> | 20 | #include <linux/devpts_fs.h> |
21 | #include <linux/parser.h> | 21 | #include <linux/parser.h> |
22 | #include <linux/fsnotify.h> | 22 | #include <linux/fsnotify.h> |
23 | #include <linux/seq_file.h> | ||
23 | 24 | ||
24 | #define DEVPTS_SUPER_MAGIC 0x1cd1 | 25 | #define DEVPTS_SUPER_MAGIC 0x1cd1 |
25 | 26 | ||
27 | #define DEVPTS_DEFAULT_MODE 0600 | ||
28 | |||
26 | static struct vfsmount *devpts_mnt; | 29 | static struct vfsmount *devpts_mnt; |
27 | static struct dentry *devpts_root; | 30 | static struct dentry *devpts_root; |
28 | 31 | ||
@@ -32,7 +35,7 @@ static struct { | |||
32 | uid_t uid; | 35 | uid_t uid; |
33 | gid_t gid; | 36 | gid_t gid; |
34 | umode_t mode; | 37 | umode_t mode; |
35 | } config = {.mode = 0600}; | 38 | } config = {.mode = DEVPTS_DEFAULT_MODE}; |
36 | 39 | ||
37 | enum { | 40 | enum { |
38 | Opt_uid, Opt_gid, Opt_mode, | 41 | Opt_uid, Opt_gid, Opt_mode, |
@@ -54,7 +57,7 @@ static int devpts_remount(struct super_block *sb, int *flags, char *data) | |||
54 | config.setgid = 0; | 57 | config.setgid = 0; |
55 | config.uid = 0; | 58 | config.uid = 0; |
56 | config.gid = 0; | 59 | config.gid = 0; |
57 | config.mode = 0600; | 60 | config.mode = DEVPTS_DEFAULT_MODE; |
58 | 61 | ||
59 | while ((p = strsep(&data, ",")) != NULL) { | 62 | while ((p = strsep(&data, ",")) != NULL) { |
60 | substring_t args[MAX_OPT_ARGS]; | 63 | substring_t args[MAX_OPT_ARGS]; |
@@ -81,7 +84,7 @@ static int devpts_remount(struct super_block *sb, int *flags, char *data) | |||
81 | case Opt_mode: | 84 | case Opt_mode: |
82 | if (match_octal(&args[0], &option)) | 85 | if (match_octal(&args[0], &option)) |
83 | return -EINVAL; | 86 | return -EINVAL; |
84 | config.mode = option & ~S_IFMT; | 87 | config.mode = option & S_IALLUGO; |
85 | break; | 88 | break; |
86 | default: | 89 | default: |
87 | printk(KERN_ERR "devpts: called with bogus options\n"); | 90 | printk(KERN_ERR "devpts: called with bogus options\n"); |
@@ -92,9 +95,21 @@ static int devpts_remount(struct super_block *sb, int *flags, char *data) | |||
92 | return 0; | 95 | return 0; |
93 | } | 96 | } |
94 | 97 | ||
98 | static int devpts_show_options(struct seq_file *seq, struct vfsmount *vfs) | ||
99 | { | ||
100 | if (config.setuid) | ||
101 | seq_printf(seq, ",uid=%u", config.uid); | ||
102 | if (config.setgid) | ||
103 | seq_printf(seq, ",gid=%u", config.gid); | ||
104 | seq_printf(seq, ",mode=%03o", config.mode); | ||
105 | |||
106 | return 0; | ||
107 | } | ||
108 | |||
95 | static const struct super_operations devpts_sops = { | 109 | static const struct super_operations devpts_sops = { |
96 | .statfs = simple_statfs, | 110 | .statfs = simple_statfs, |
97 | .remount_fs = devpts_remount, | 111 | .remount_fs = devpts_remount, |
112 | .show_options = devpts_show_options, | ||
98 | }; | 113 | }; |
99 | 114 | ||
100 | static int | 115 | static int |
diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c index 6308122890ca..8bf31e3fbf01 100644 --- a/fs/dlm/ast.c +++ b/fs/dlm/ast.c | |||
@@ -39,7 +39,6 @@ void dlm_add_ast(struct dlm_lkb *lkb, int type) | |||
39 | dlm_user_add_ast(lkb, type); | 39 | dlm_user_add_ast(lkb, type); |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | DLM_ASSERT(lkb->lkb_astaddr != DLM_FAKE_USER_AST, dlm_print_lkb(lkb);); | ||
43 | 42 | ||
44 | spin_lock(&ast_queue_lock); | 43 | spin_lock(&ast_queue_lock); |
45 | if (!(lkb->lkb_ast_type & (AST_COMP | AST_BAST))) { | 44 | if (!(lkb->lkb_ast_type & (AST_COMP | AST_BAST))) { |
@@ -58,8 +57,8 @@ static void process_asts(void) | |||
58 | struct dlm_ls *ls = NULL; | 57 | struct dlm_ls *ls = NULL; |
59 | struct dlm_rsb *r = NULL; | 58 | struct dlm_rsb *r = NULL; |
60 | struct dlm_lkb *lkb; | 59 | struct dlm_lkb *lkb; |
61 | void (*cast) (long param); | 60 | void (*cast) (void *astparam); |
62 | void (*bast) (long param, int mode); | 61 | void (*bast) (void *astparam, int mode); |
63 | int type = 0, found, bmode; | 62 | int type = 0, found, bmode; |
64 | 63 | ||
65 | for (;;) { | 64 | for (;;) { |
@@ -83,8 +82,8 @@ static void process_asts(void) | |||
83 | if (!found) | 82 | if (!found) |
84 | break; | 83 | break; |
85 | 84 | ||
86 | cast = lkb->lkb_astaddr; | 85 | cast = lkb->lkb_astfn; |
87 | bast = lkb->lkb_bastaddr; | 86 | bast = lkb->lkb_bastfn; |
88 | bmode = lkb->lkb_bastmode; | 87 | bmode = lkb->lkb_bastmode; |
89 | 88 | ||
90 | if ((type & AST_COMP) && cast) | 89 | if ((type & AST_COMP) && cast) |
diff --git a/fs/dlm/config.c b/fs/dlm/config.c index 2f8e3c81bc19..c3ad1dff3b25 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c | |||
@@ -604,7 +604,7 @@ static struct clusters clusters_root = { | |||
604 | }, | 604 | }, |
605 | }; | 605 | }; |
606 | 606 | ||
607 | int dlm_config_init(void) | 607 | int __init dlm_config_init(void) |
608 | { | 608 | { |
609 | config_group_init(&clusters_root.subsys.su_group); | 609 | config_group_init(&clusters_root.subsys.su_group); |
610 | mutex_init(&clusters_root.subsys.su_mutex); | 610 | mutex_init(&clusters_root.subsys.su_mutex); |
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index 12c3bfd5e660..8fc24f4507a3 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c | |||
@@ -162,14 +162,12 @@ static int print_resource(struct dlm_rsb *res, struct seq_file *s) | |||
162 | 162 | ||
163 | static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r) | 163 | static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r) |
164 | { | 164 | { |
165 | struct dlm_user_args *ua; | ||
166 | unsigned int waiting = 0; | 165 | unsigned int waiting = 0; |
167 | uint64_t xid = 0; | 166 | uint64_t xid = 0; |
168 | 167 | ||
169 | if (lkb->lkb_flags & DLM_IFL_USER) { | 168 | if (lkb->lkb_flags & DLM_IFL_USER) { |
170 | ua = (struct dlm_user_args *) lkb->lkb_astparam; | 169 | if (lkb->lkb_ua) |
171 | if (ua) | 170 | xid = lkb->lkb_ua->xid; |
172 | xid = ua->xid; | ||
173 | } | 171 | } |
174 | 172 | ||
175 | if (lkb->lkb_timestamp) | 173 | if (lkb->lkb_timestamp) |
@@ -543,7 +541,7 @@ void dlm_delete_debug_file(struct dlm_ls *ls) | |||
543 | debugfs_remove(ls->ls_debug_locks_dentry); | 541 | debugfs_remove(ls->ls_debug_locks_dentry); |
544 | } | 542 | } |
545 | 543 | ||
546 | int dlm_register_debugfs(void) | 544 | int __init dlm_register_debugfs(void) |
547 | { | 545 | { |
548 | mutex_init(&debug_buf_lock); | 546 | mutex_init(&debug_buf_lock); |
549 | dlm_root = debugfs_create_dir("dlm", NULL); | 547 | dlm_root = debugfs_create_dir("dlm", NULL); |
diff --git a/fs/dlm/dir.c b/fs/dlm/dir.c index ff97ba924333..85defeb64df4 100644 --- a/fs/dlm/dir.c +++ b/fs/dlm/dir.c | |||
@@ -220,6 +220,7 @@ int dlm_recover_directory(struct dlm_ls *ls) | |||
220 | last_len = 0; | 220 | last_len = 0; |
221 | 221 | ||
222 | for (;;) { | 222 | for (;;) { |
223 | int left; | ||
223 | error = dlm_recovery_stopped(ls); | 224 | error = dlm_recovery_stopped(ls); |
224 | if (error) | 225 | if (error) |
225 | goto out_free; | 226 | goto out_free; |
@@ -235,12 +236,21 @@ int dlm_recover_directory(struct dlm_ls *ls) | |||
235 | * pick namelen/name pairs out of received buffer | 236 | * pick namelen/name pairs out of received buffer |
236 | */ | 237 | */ |
237 | 238 | ||
238 | b = ls->ls_recover_buf + sizeof(struct dlm_rcom); | 239 | b = ls->ls_recover_buf->rc_buf; |
240 | left = ls->ls_recover_buf->rc_header.h_length; | ||
241 | left -= sizeof(struct dlm_rcom); | ||
239 | 242 | ||
240 | for (;;) { | 243 | for (;;) { |
241 | memcpy(&namelen, b, sizeof(uint16_t)); | 244 | __be16 v; |
242 | namelen = be16_to_cpu(namelen); | 245 | |
243 | b += sizeof(uint16_t); | 246 | error = -EINVAL; |
247 | if (left < sizeof(__be16)) | ||
248 | goto out_free; | ||
249 | |||
250 | memcpy(&v, b, sizeof(__be16)); | ||
251 | namelen = be16_to_cpu(v); | ||
252 | b += sizeof(__be16); | ||
253 | left -= sizeof(__be16); | ||
244 | 254 | ||
245 | /* namelen of 0xFFFFF marks end of names for | 255 | /* namelen of 0xFFFFF marks end of names for |
246 | this node; namelen of 0 marks end of the | 256 | this node; namelen of 0 marks end of the |
@@ -251,6 +261,12 @@ int dlm_recover_directory(struct dlm_ls *ls) | |||
251 | if (!namelen) | 261 | if (!namelen) |
252 | break; | 262 | break; |
253 | 263 | ||
264 | if (namelen > left) | ||
265 | goto out_free; | ||
266 | |||
267 | if (namelen > DLM_RESNAME_MAXLEN) | ||
268 | goto out_free; | ||
269 | |||
254 | error = -ENOMEM; | 270 | error = -ENOMEM; |
255 | de = get_free_de(ls, namelen); | 271 | de = get_free_de(ls, namelen); |
256 | if (!de) | 272 | if (!de) |
@@ -262,6 +278,7 @@ int dlm_recover_directory(struct dlm_ls *ls) | |||
262 | memcpy(de->name, b, namelen); | 278 | memcpy(de->name, b, namelen); |
263 | memcpy(last_name, b, namelen); | 279 | memcpy(last_name, b, namelen); |
264 | b += namelen; | 280 | b += namelen; |
281 | left -= namelen; | ||
265 | 282 | ||
266 | add_entry_to_hash(ls, de); | 283 | add_entry_to_hash(ls, de); |
267 | count++; | 284 | count++; |
@@ -302,6 +319,9 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name, | |||
302 | 319 | ||
303 | write_unlock(&ls->ls_dirtbl[bucket].lock); | 320 | write_unlock(&ls->ls_dirtbl[bucket].lock); |
304 | 321 | ||
322 | if (namelen > DLM_RESNAME_MAXLEN) | ||
323 | return -EINVAL; | ||
324 | |||
305 | de = kzalloc(sizeof(struct dlm_direntry) + namelen, GFP_KERNEL); | 325 | de = kzalloc(sizeof(struct dlm_direntry) + namelen, GFP_KERNEL); |
306 | if (!de) | 326 | if (!de) |
307 | return -ENOMEM; | 327 | return -ENOMEM; |
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h index ec61bbaf25df..d30ea8b433a2 100644 --- a/fs/dlm/dlm_internal.h +++ b/fs/dlm/dlm_internal.h | |||
@@ -92,8 +92,6 @@ do { \ | |||
92 | } \ | 92 | } \ |
93 | } | 93 | } |
94 | 94 | ||
95 | #define DLM_FAKE_USER_AST ERR_PTR(-EINVAL) | ||
96 | |||
97 | 95 | ||
98 | struct dlm_direntry { | 96 | struct dlm_direntry { |
99 | struct list_head list; | 97 | struct list_head list; |
@@ -146,9 +144,9 @@ struct dlm_recover { | |||
146 | 144 | ||
147 | struct dlm_args { | 145 | struct dlm_args { |
148 | uint32_t flags; | 146 | uint32_t flags; |
149 | void *astaddr; | 147 | void (*astfn) (void *astparam); |
150 | long astparam; | 148 | void *astparam; |
151 | void *bastaddr; | 149 | void (*bastfn) (void *astparam, int mode); |
152 | int mode; | 150 | int mode; |
153 | struct dlm_lksb *lksb; | 151 | struct dlm_lksb *lksb; |
154 | unsigned long timeout; | 152 | unsigned long timeout; |
@@ -253,9 +251,12 @@ struct dlm_lkb { | |||
253 | 251 | ||
254 | char *lkb_lvbptr; | 252 | char *lkb_lvbptr; |
255 | struct dlm_lksb *lkb_lksb; /* caller's status block */ | 253 | struct dlm_lksb *lkb_lksb; /* caller's status block */ |
256 | void *lkb_astaddr; /* caller's ast function */ | 254 | void (*lkb_astfn) (void *astparam); |
257 | void *lkb_bastaddr; /* caller's bast function */ | 255 | void (*lkb_bastfn) (void *astparam, int mode); |
258 | long lkb_astparam; /* caller's ast arg */ | 256 | union { |
257 | void *lkb_astparam; /* caller's ast arg */ | ||
258 | struct dlm_user_args *lkb_ua; | ||
259 | }; | ||
259 | }; | 260 | }; |
260 | 261 | ||
261 | 262 | ||
@@ -403,28 +404,34 @@ struct dlm_rcom { | |||
403 | char rc_buf[0]; | 404 | char rc_buf[0]; |
404 | }; | 405 | }; |
405 | 406 | ||
407 | union dlm_packet { | ||
408 | struct dlm_header header; /* common to other two */ | ||
409 | struct dlm_message message; | ||
410 | struct dlm_rcom rcom; | ||
411 | }; | ||
412 | |||
406 | struct rcom_config { | 413 | struct rcom_config { |
407 | uint32_t rf_lvblen; | 414 | __le32 rf_lvblen; |
408 | uint32_t rf_lsflags; | 415 | __le32 rf_lsflags; |
409 | uint64_t rf_unused; | 416 | __le64 rf_unused; |
410 | }; | 417 | }; |
411 | 418 | ||
412 | struct rcom_lock { | 419 | struct rcom_lock { |
413 | uint32_t rl_ownpid; | 420 | __le32 rl_ownpid; |
414 | uint32_t rl_lkid; | 421 | __le32 rl_lkid; |
415 | uint32_t rl_remid; | 422 | __le32 rl_remid; |
416 | uint32_t rl_parent_lkid; | 423 | __le32 rl_parent_lkid; |
417 | uint32_t rl_parent_remid; | 424 | __le32 rl_parent_remid; |
418 | uint32_t rl_exflags; | 425 | __le32 rl_exflags; |
419 | uint32_t rl_flags; | 426 | __le32 rl_flags; |
420 | uint32_t rl_lvbseq; | 427 | __le32 rl_lvbseq; |
421 | int rl_result; | 428 | __le32 rl_result; |
422 | int8_t rl_rqmode; | 429 | int8_t rl_rqmode; |
423 | int8_t rl_grmode; | 430 | int8_t rl_grmode; |
424 | int8_t rl_status; | 431 | int8_t rl_status; |
425 | int8_t rl_asts; | 432 | int8_t rl_asts; |
426 | uint16_t rl_wait_type; | 433 | __le16 rl_wait_type; |
427 | uint16_t rl_namelen; | 434 | __le16 rl_namelen; |
428 | char rl_name[DLM_RESNAME_MAXLEN]; | 435 | char rl_name[DLM_RESNAME_MAXLEN]; |
429 | char rl_lvb[0]; | 436 | char rl_lvb[0]; |
430 | }; | 437 | }; |
@@ -494,7 +501,7 @@ struct dlm_ls { | |||
494 | struct rw_semaphore ls_recv_active; /* block dlm_recv */ | 501 | struct rw_semaphore ls_recv_active; /* block dlm_recv */ |
495 | struct list_head ls_requestqueue;/* queue remote requests */ | 502 | struct list_head ls_requestqueue;/* queue remote requests */ |
496 | struct mutex ls_requestqueue_mutex; | 503 | struct mutex ls_requestqueue_mutex; |
497 | char *ls_recover_buf; | 504 | struct dlm_rcom *ls_recover_buf; |
498 | int ls_recover_nodeid; /* for debugging */ | 505 | int ls_recover_nodeid; /* for debugging */ |
499 | uint64_t ls_rcom_seq; | 506 | uint64_t ls_rcom_seq; |
500 | spinlock_t ls_rcom_spin; | 507 | spinlock_t ls_rcom_spin; |
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index ff4a198fa677..8f250ac8b928 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
@@ -436,11 +436,15 @@ static int find_rsb(struct dlm_ls *ls, char *name, int namelen, | |||
436 | { | 436 | { |
437 | struct dlm_rsb *r, *tmp; | 437 | struct dlm_rsb *r, *tmp; |
438 | uint32_t hash, bucket; | 438 | uint32_t hash, bucket; |
439 | int error = 0; | 439 | int error = -EINVAL; |
440 | |||
441 | if (namelen > DLM_RESNAME_MAXLEN) | ||
442 | goto out; | ||
440 | 443 | ||
441 | if (dlm_no_directory(ls)) | 444 | if (dlm_no_directory(ls)) |
442 | flags |= R_CREATE; | 445 | flags |= R_CREATE; |
443 | 446 | ||
447 | error = 0; | ||
444 | hash = jhash(name, namelen, 0); | 448 | hash = jhash(name, namelen, 0); |
445 | bucket = hash & (ls->ls_rsbtbl_size - 1); | 449 | bucket = hash & (ls->ls_rsbtbl_size - 1); |
446 | 450 | ||
@@ -1222,6 +1226,8 @@ static void set_lvb_lock_pc(struct dlm_rsb *r, struct dlm_lkb *lkb, | |||
1222 | b = dlm_lvb_operations[lkb->lkb_grmode + 1][lkb->lkb_rqmode + 1]; | 1226 | b = dlm_lvb_operations[lkb->lkb_grmode + 1][lkb->lkb_rqmode + 1]; |
1223 | if (b == 1) { | 1227 | if (b == 1) { |
1224 | int len = receive_extralen(ms); | 1228 | int len = receive_extralen(ms); |
1229 | if (len > DLM_RESNAME_MAXLEN) | ||
1230 | len = DLM_RESNAME_MAXLEN; | ||
1225 | memcpy(lkb->lkb_lvbptr, ms->m_extra, len); | 1231 | memcpy(lkb->lkb_lvbptr, ms->m_extra, len); |
1226 | lkb->lkb_lvbseq = ms->m_lvbseq; | 1232 | lkb->lkb_lvbseq = ms->m_lvbseq; |
1227 | } | 1233 | } |
@@ -1775,7 +1781,7 @@ static void grant_pending_locks(struct dlm_rsb *r) | |||
1775 | */ | 1781 | */ |
1776 | 1782 | ||
1777 | list_for_each_entry_safe(lkb, s, &r->res_grantqueue, lkb_statequeue) { | 1783 | list_for_each_entry_safe(lkb, s, &r->res_grantqueue, lkb_statequeue) { |
1778 | if (lkb->lkb_bastaddr && lock_requires_bast(lkb, high, cw)) { | 1784 | if (lkb->lkb_bastfn && lock_requires_bast(lkb, high, cw)) { |
1779 | if (cw && high == DLM_LOCK_PR) | 1785 | if (cw && high == DLM_LOCK_PR) |
1780 | queue_bast(r, lkb, DLM_LOCK_CW); | 1786 | queue_bast(r, lkb, DLM_LOCK_CW); |
1781 | else | 1787 | else |
@@ -1805,7 +1811,7 @@ static void send_bast_queue(struct dlm_rsb *r, struct list_head *head, | |||
1805 | struct dlm_lkb *gr; | 1811 | struct dlm_lkb *gr; |
1806 | 1812 | ||
1807 | list_for_each_entry(gr, head, lkb_statequeue) { | 1813 | list_for_each_entry(gr, head, lkb_statequeue) { |
1808 | if (gr->lkb_bastaddr && modes_require_bast(gr, lkb)) { | 1814 | if (gr->lkb_bastfn && modes_require_bast(gr, lkb)) { |
1809 | queue_bast(r, gr, lkb->lkb_rqmode); | 1815 | queue_bast(r, gr, lkb->lkb_rqmode); |
1810 | gr->lkb_highbast = lkb->lkb_rqmode; | 1816 | gr->lkb_highbast = lkb->lkb_rqmode; |
1811 | } | 1817 | } |
@@ -1960,8 +1966,11 @@ static void confirm_master(struct dlm_rsb *r, int error) | |||
1960 | } | 1966 | } |
1961 | 1967 | ||
1962 | static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags, | 1968 | static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags, |
1963 | int namelen, unsigned long timeout_cs, void *ast, | 1969 | int namelen, unsigned long timeout_cs, |
1964 | void *astarg, void *bast, struct dlm_args *args) | 1970 | void (*ast) (void *astparam), |
1971 | void *astparam, | ||
1972 | void (*bast) (void *astparam, int mode), | ||
1973 | struct dlm_args *args) | ||
1965 | { | 1974 | { |
1966 | int rv = -EINVAL; | 1975 | int rv = -EINVAL; |
1967 | 1976 | ||
@@ -2011,9 +2020,9 @@ static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags, | |||
2011 | an active lkb cannot be modified before locking the rsb */ | 2020 | an active lkb cannot be modified before locking the rsb */ |
2012 | 2021 | ||
2013 | args->flags = flags; | 2022 | args->flags = flags; |
2014 | args->astaddr = ast; | 2023 | args->astfn = ast; |
2015 | args->astparam = (long) astarg; | 2024 | args->astparam = astparam; |
2016 | args->bastaddr = bast; | 2025 | args->bastfn = bast; |
2017 | args->timeout = timeout_cs; | 2026 | args->timeout = timeout_cs; |
2018 | args->mode = mode; | 2027 | args->mode = mode; |
2019 | args->lksb = lksb; | 2028 | args->lksb = lksb; |
@@ -2032,7 +2041,7 @@ static int set_unlock_args(uint32_t flags, void *astarg, struct dlm_args *args) | |||
2032 | return -EINVAL; | 2041 | return -EINVAL; |
2033 | 2042 | ||
2034 | args->flags = flags; | 2043 | args->flags = flags; |
2035 | args->astparam = (long) astarg; | 2044 | args->astparam = astarg; |
2036 | return 0; | 2045 | return 0; |
2037 | } | 2046 | } |
2038 | 2047 | ||
@@ -2062,9 +2071,9 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | |||
2062 | 2071 | ||
2063 | lkb->lkb_exflags = args->flags; | 2072 | lkb->lkb_exflags = args->flags; |
2064 | lkb->lkb_sbflags = 0; | 2073 | lkb->lkb_sbflags = 0; |
2065 | lkb->lkb_astaddr = args->astaddr; | 2074 | lkb->lkb_astfn = args->astfn; |
2066 | lkb->lkb_astparam = args->astparam; | 2075 | lkb->lkb_astparam = args->astparam; |
2067 | lkb->lkb_bastaddr = args->bastaddr; | 2076 | lkb->lkb_bastfn = args->bastfn; |
2068 | lkb->lkb_rqmode = args->mode; | 2077 | lkb->lkb_rqmode = args->mode; |
2069 | lkb->lkb_lksb = args->lksb; | 2078 | lkb->lkb_lksb = args->lksb; |
2070 | lkb->lkb_lvbptr = args->lksb->sb_lvbptr; | 2079 | lkb->lkb_lvbptr = args->lksb->sb_lvbptr; |
@@ -2711,9 +2720,9 @@ static void send_args(struct dlm_rsb *r, struct dlm_lkb *lkb, | |||
2711 | /* m_result and m_bastmode are set from function args, | 2720 | /* m_result and m_bastmode are set from function args, |
2712 | not from lkb fields */ | 2721 | not from lkb fields */ |
2713 | 2722 | ||
2714 | if (lkb->lkb_bastaddr) | 2723 | if (lkb->lkb_bastfn) |
2715 | ms->m_asts |= AST_BAST; | 2724 | ms->m_asts |= AST_BAST; |
2716 | if (lkb->lkb_astaddr) | 2725 | if (lkb->lkb_astfn) |
2717 | ms->m_asts |= AST_COMP; | 2726 | ms->m_asts |= AST_COMP; |
2718 | 2727 | ||
2719 | /* compare with switch in create_message; send_remove() doesn't | 2728 | /* compare with switch in create_message; send_remove() doesn't |
@@ -2989,11 +2998,23 @@ static int receive_lvb(struct dlm_ls *ls, struct dlm_lkb *lkb, | |||
2989 | if (!lkb->lkb_lvbptr) | 2998 | if (!lkb->lkb_lvbptr) |
2990 | return -ENOMEM; | 2999 | return -ENOMEM; |
2991 | len = receive_extralen(ms); | 3000 | len = receive_extralen(ms); |
3001 | if (len > DLM_RESNAME_MAXLEN) | ||
3002 | len = DLM_RESNAME_MAXLEN; | ||
2992 | memcpy(lkb->lkb_lvbptr, ms->m_extra, len); | 3003 | memcpy(lkb->lkb_lvbptr, ms->m_extra, len); |
2993 | } | 3004 | } |
2994 | return 0; | 3005 | return 0; |
2995 | } | 3006 | } |
2996 | 3007 | ||
3008 | static void fake_bastfn(void *astparam, int mode) | ||
3009 | { | ||
3010 | log_print("fake_bastfn should not be called"); | ||
3011 | } | ||
3012 | |||
3013 | static void fake_astfn(void *astparam) | ||
3014 | { | ||
3015 | log_print("fake_astfn should not be called"); | ||
3016 | } | ||
3017 | |||
2997 | static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | 3018 | static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb, |
2998 | struct dlm_message *ms) | 3019 | struct dlm_message *ms) |
2999 | { | 3020 | { |
@@ -3002,8 +3023,9 @@ static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | |||
3002 | lkb->lkb_remid = ms->m_lkid; | 3023 | lkb->lkb_remid = ms->m_lkid; |
3003 | lkb->lkb_grmode = DLM_LOCK_IV; | 3024 | lkb->lkb_grmode = DLM_LOCK_IV; |
3004 | lkb->lkb_rqmode = ms->m_rqmode; | 3025 | lkb->lkb_rqmode = ms->m_rqmode; |
3005 | lkb->lkb_bastaddr = (void *) (long) (ms->m_asts & AST_BAST); | 3026 | |
3006 | lkb->lkb_astaddr = (void *) (long) (ms->m_asts & AST_COMP); | 3027 | lkb->lkb_bastfn = (ms->m_asts & AST_BAST) ? &fake_bastfn : NULL; |
3028 | lkb->lkb_astfn = (ms->m_asts & AST_COMP) ? &fake_astfn : NULL; | ||
3007 | 3029 | ||
3008 | if (lkb->lkb_exflags & DLM_LKF_VALBLK) { | 3030 | if (lkb->lkb_exflags & DLM_LKF_VALBLK) { |
3009 | /* lkb was just created so there won't be an lvb yet */ | 3031 | /* lkb was just created so there won't be an lvb yet */ |
@@ -3802,7 +3824,7 @@ static void dlm_receive_message(struct dlm_ls *ls, struct dlm_message *ms, | |||
3802 | int nodeid) | 3824 | int nodeid) |
3803 | { | 3825 | { |
3804 | if (dlm_locking_stopped(ls)) { | 3826 | if (dlm_locking_stopped(ls)) { |
3805 | dlm_add_requestqueue(ls, nodeid, (struct dlm_header *) ms); | 3827 | dlm_add_requestqueue(ls, nodeid, ms); |
3806 | } else { | 3828 | } else { |
3807 | dlm_wait_requestqueue(ls); | 3829 | dlm_wait_requestqueue(ls); |
3808 | _receive_message(ls, ms); | 3830 | _receive_message(ls, ms); |
@@ -3822,21 +3844,20 @@ void dlm_receive_message_saved(struct dlm_ls *ls, struct dlm_message *ms) | |||
3822 | standard locking activity) or an RCOM (recovery message sent as part of | 3844 | standard locking activity) or an RCOM (recovery message sent as part of |
3823 | lockspace recovery). */ | 3845 | lockspace recovery). */ |
3824 | 3846 | ||
3825 | void dlm_receive_buffer(struct dlm_header *hd, int nodeid) | 3847 | void dlm_receive_buffer(union dlm_packet *p, int nodeid) |
3826 | { | 3848 | { |
3827 | struct dlm_message *ms = (struct dlm_message *) hd; | 3849 | struct dlm_header *hd = &p->header; |
3828 | struct dlm_rcom *rc = (struct dlm_rcom *) hd; | ||
3829 | struct dlm_ls *ls; | 3850 | struct dlm_ls *ls; |
3830 | int type = 0; | 3851 | int type = 0; |
3831 | 3852 | ||
3832 | switch (hd->h_cmd) { | 3853 | switch (hd->h_cmd) { |
3833 | case DLM_MSG: | 3854 | case DLM_MSG: |
3834 | dlm_message_in(ms); | 3855 | dlm_message_in(&p->message); |
3835 | type = ms->m_type; | 3856 | type = p->message.m_type; |
3836 | break; | 3857 | break; |
3837 | case DLM_RCOM: | 3858 | case DLM_RCOM: |
3838 | dlm_rcom_in(rc); | 3859 | dlm_rcom_in(&p->rcom); |
3839 | type = rc->rc_type; | 3860 | type = p->rcom.rc_type; |
3840 | break; | 3861 | break; |
3841 | default: | 3862 | default: |
3842 | log_print("invalid h_cmd %d from %u", hd->h_cmd, nodeid); | 3863 | log_print("invalid h_cmd %d from %u", hd->h_cmd, nodeid); |
@@ -3856,7 +3877,7 @@ void dlm_receive_buffer(struct dlm_header *hd, int nodeid) | |||
3856 | hd->h_lockspace, nodeid, hd->h_cmd, type); | 3877 | hd->h_lockspace, nodeid, hd->h_cmd, type); |
3857 | 3878 | ||
3858 | if (hd->h_cmd == DLM_RCOM && type == DLM_RCOM_STATUS) | 3879 | if (hd->h_cmd == DLM_RCOM && type == DLM_RCOM_STATUS) |
3859 | dlm_send_ls_not_ready(nodeid, rc); | 3880 | dlm_send_ls_not_ready(nodeid, &p->rcom); |
3860 | return; | 3881 | return; |
3861 | } | 3882 | } |
3862 | 3883 | ||
@@ -3865,9 +3886,9 @@ void dlm_receive_buffer(struct dlm_header *hd, int nodeid) | |||
3865 | 3886 | ||
3866 | down_read(&ls->ls_recv_active); | 3887 | down_read(&ls->ls_recv_active); |
3867 | if (hd->h_cmd == DLM_MSG) | 3888 | if (hd->h_cmd == DLM_MSG) |
3868 | dlm_receive_message(ls, ms, nodeid); | 3889 | dlm_receive_message(ls, &p->message, nodeid); |
3869 | else | 3890 | else |
3870 | dlm_receive_rcom(ls, rc, nodeid); | 3891 | dlm_receive_rcom(ls, &p->rcom, nodeid); |
3871 | up_read(&ls->ls_recv_active); | 3892 | up_read(&ls->ls_recv_active); |
3872 | 3893 | ||
3873 | dlm_put_lockspace(ls); | 3894 | dlm_put_lockspace(ls); |
@@ -4267,32 +4288,34 @@ static struct dlm_lkb *search_remid(struct dlm_rsb *r, int nodeid, | |||
4267 | return NULL; | 4288 | return NULL; |
4268 | } | 4289 | } |
4269 | 4290 | ||
4291 | /* needs at least dlm_rcom + rcom_lock */ | ||
4270 | static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | 4292 | static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, |
4271 | struct dlm_rsb *r, struct dlm_rcom *rc) | 4293 | struct dlm_rsb *r, struct dlm_rcom *rc) |
4272 | { | 4294 | { |
4273 | struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; | 4295 | struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; |
4274 | int lvblen; | ||
4275 | 4296 | ||
4276 | lkb->lkb_nodeid = rc->rc_header.h_nodeid; | 4297 | lkb->lkb_nodeid = rc->rc_header.h_nodeid; |
4277 | lkb->lkb_ownpid = rl->rl_ownpid; | 4298 | lkb->lkb_ownpid = le32_to_cpu(rl->rl_ownpid); |
4278 | lkb->lkb_remid = rl->rl_lkid; | 4299 | lkb->lkb_remid = le32_to_cpu(rl->rl_lkid); |
4279 | lkb->lkb_exflags = rl->rl_exflags; | 4300 | lkb->lkb_exflags = le32_to_cpu(rl->rl_exflags); |
4280 | lkb->lkb_flags = rl->rl_flags & 0x0000FFFF; | 4301 | lkb->lkb_flags = le32_to_cpu(rl->rl_flags) & 0x0000FFFF; |
4281 | lkb->lkb_flags |= DLM_IFL_MSTCPY; | 4302 | lkb->lkb_flags |= DLM_IFL_MSTCPY; |
4282 | lkb->lkb_lvbseq = rl->rl_lvbseq; | 4303 | lkb->lkb_lvbseq = le32_to_cpu(rl->rl_lvbseq); |
4283 | lkb->lkb_rqmode = rl->rl_rqmode; | 4304 | lkb->lkb_rqmode = rl->rl_rqmode; |
4284 | lkb->lkb_grmode = rl->rl_grmode; | 4305 | lkb->lkb_grmode = rl->rl_grmode; |
4285 | /* don't set lkb_status because add_lkb wants to itself */ | 4306 | /* don't set lkb_status because add_lkb wants to itself */ |
4286 | 4307 | ||
4287 | lkb->lkb_bastaddr = (void *) (long) (rl->rl_asts & AST_BAST); | 4308 | lkb->lkb_bastfn = (rl->rl_asts & AST_BAST) ? &fake_bastfn : NULL; |
4288 | lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP); | 4309 | lkb->lkb_astfn = (rl->rl_asts & AST_COMP) ? &fake_astfn : NULL; |
4289 | 4310 | ||
4290 | if (lkb->lkb_exflags & DLM_LKF_VALBLK) { | 4311 | if (lkb->lkb_exflags & DLM_LKF_VALBLK) { |
4312 | int lvblen = rc->rc_header.h_length - sizeof(struct dlm_rcom) - | ||
4313 | sizeof(struct rcom_lock); | ||
4314 | if (lvblen > ls->ls_lvblen) | ||
4315 | return -EINVAL; | ||
4291 | lkb->lkb_lvbptr = dlm_allocate_lvb(ls); | 4316 | lkb->lkb_lvbptr = dlm_allocate_lvb(ls); |
4292 | if (!lkb->lkb_lvbptr) | 4317 | if (!lkb->lkb_lvbptr) |
4293 | return -ENOMEM; | 4318 | return -ENOMEM; |
4294 | lvblen = rc->rc_header.h_length - sizeof(struct dlm_rcom) - | ||
4295 | sizeof(struct rcom_lock); | ||
4296 | memcpy(lkb->lkb_lvbptr, rl->rl_lvb, lvblen); | 4319 | memcpy(lkb->lkb_lvbptr, rl->rl_lvb, lvblen); |
4297 | } | 4320 | } |
4298 | 4321 | ||
@@ -4300,7 +4323,8 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | |||
4300 | The real granted mode of these converting locks cannot be determined | 4323 | The real granted mode of these converting locks cannot be determined |
4301 | until all locks have been rebuilt on the rsb (recover_conversion) */ | 4324 | until all locks have been rebuilt on the rsb (recover_conversion) */ |
4302 | 4325 | ||
4303 | if (rl->rl_wait_type == DLM_MSG_CONVERT && middle_conversion(lkb)) { | 4326 | if (rl->rl_wait_type == cpu_to_le16(DLM_MSG_CONVERT) && |
4327 | middle_conversion(lkb)) { | ||
4304 | rl->rl_status = DLM_LKSTS_CONVERT; | 4328 | rl->rl_status = DLM_LKSTS_CONVERT; |
4305 | lkb->lkb_grmode = DLM_LOCK_IV; | 4329 | lkb->lkb_grmode = DLM_LOCK_IV; |
4306 | rsb_set_flag(r, RSB_RECOVER_CONVERT); | 4330 | rsb_set_flag(r, RSB_RECOVER_CONVERT); |
@@ -4315,6 +4339,7 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | |||
4315 | the given values and send back our lkid. We send back our lkid by sending | 4339 | the given values and send back our lkid. We send back our lkid by sending |
4316 | back the rcom_lock struct we got but with the remid field filled in. */ | 4340 | back the rcom_lock struct we got but with the remid field filled in. */ |
4317 | 4341 | ||
4342 | /* needs at least dlm_rcom + rcom_lock */ | ||
4318 | int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc) | 4343 | int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc) |
4319 | { | 4344 | { |
4320 | struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; | 4345 | struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; |
@@ -4327,13 +4352,14 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc) | |||
4327 | goto out; | 4352 | goto out; |
4328 | } | 4353 | } |
4329 | 4354 | ||
4330 | error = find_rsb(ls, rl->rl_name, rl->rl_namelen, R_MASTER, &r); | 4355 | error = find_rsb(ls, rl->rl_name, le16_to_cpu(rl->rl_namelen), |
4356 | R_MASTER, &r); | ||
4331 | if (error) | 4357 | if (error) |
4332 | goto out; | 4358 | goto out; |
4333 | 4359 | ||
4334 | lock_rsb(r); | 4360 | lock_rsb(r); |
4335 | 4361 | ||
4336 | lkb = search_remid(r, rc->rc_header.h_nodeid, rl->rl_lkid); | 4362 | lkb = search_remid(r, rc->rc_header.h_nodeid, le32_to_cpu(rl->rl_lkid)); |
4337 | if (lkb) { | 4363 | if (lkb) { |
4338 | error = -EEXIST; | 4364 | error = -EEXIST; |
4339 | goto out_remid; | 4365 | goto out_remid; |
@@ -4356,18 +4382,20 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc) | |||
4356 | out_remid: | 4382 | out_remid: |
4357 | /* this is the new value returned to the lock holder for | 4383 | /* this is the new value returned to the lock holder for |
4358 | saving in its process-copy lkb */ | 4384 | saving in its process-copy lkb */ |
4359 | rl->rl_remid = lkb->lkb_id; | 4385 | rl->rl_remid = cpu_to_le32(lkb->lkb_id); |
4360 | 4386 | ||
4361 | out_unlock: | 4387 | out_unlock: |
4362 | unlock_rsb(r); | 4388 | unlock_rsb(r); |
4363 | put_rsb(r); | 4389 | put_rsb(r); |
4364 | out: | 4390 | out: |
4365 | if (error) | 4391 | if (error) |
4366 | log_debug(ls, "recover_master_copy %d %x", error, rl->rl_lkid); | 4392 | log_debug(ls, "recover_master_copy %d %x", error, |
4367 | rl->rl_result = error; | 4393 | le32_to_cpu(rl->rl_lkid)); |
4394 | rl->rl_result = cpu_to_le32(error); | ||
4368 | return error; | 4395 | return error; |
4369 | } | 4396 | } |
4370 | 4397 | ||
4398 | /* needs at least dlm_rcom + rcom_lock */ | ||
4371 | int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) | 4399 | int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) |
4372 | { | 4400 | { |
4373 | struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; | 4401 | struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; |
@@ -4375,15 +4403,16 @@ int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) | |||
4375 | struct dlm_lkb *lkb; | 4403 | struct dlm_lkb *lkb; |
4376 | int error; | 4404 | int error; |
4377 | 4405 | ||
4378 | error = find_lkb(ls, rl->rl_lkid, &lkb); | 4406 | error = find_lkb(ls, le32_to_cpu(rl->rl_lkid), &lkb); |
4379 | if (error) { | 4407 | if (error) { |
4380 | log_error(ls, "recover_process_copy no lkid %x", rl->rl_lkid); | 4408 | log_error(ls, "recover_process_copy no lkid %x", |
4409 | le32_to_cpu(rl->rl_lkid)); | ||
4381 | return error; | 4410 | return error; |
4382 | } | 4411 | } |
4383 | 4412 | ||
4384 | DLM_ASSERT(is_process_copy(lkb), dlm_print_lkb(lkb);); | 4413 | DLM_ASSERT(is_process_copy(lkb), dlm_print_lkb(lkb);); |
4385 | 4414 | ||
4386 | error = rl->rl_result; | 4415 | error = le32_to_cpu(rl->rl_result); |
4387 | 4416 | ||
4388 | r = lkb->lkb_resource; | 4417 | r = lkb->lkb_resource; |
4389 | hold_rsb(r); | 4418 | hold_rsb(r); |
@@ -4402,7 +4431,7 @@ int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) | |||
4402 | log_debug(ls, "master copy exists %x", lkb->lkb_id); | 4431 | log_debug(ls, "master copy exists %x", lkb->lkb_id); |
4403 | /* fall through */ | 4432 | /* fall through */ |
4404 | case 0: | 4433 | case 0: |
4405 | lkb->lkb_remid = rl->rl_remid; | 4434 | lkb->lkb_remid = le32_to_cpu(rl->rl_remid); |
4406 | break; | 4435 | break; |
4407 | default: | 4436 | default: |
4408 | log_error(ls, "dlm_recover_process_copy unknown error %d %x", | 4437 | log_error(ls, "dlm_recover_process_copy unknown error %d %x", |
@@ -4451,7 +4480,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua, | |||
4451 | lock and that lkb_astparam is the dlm_user_args structure. */ | 4480 | lock and that lkb_astparam is the dlm_user_args structure. */ |
4452 | 4481 | ||
4453 | error = set_lock_args(mode, &ua->lksb, flags, namelen, timeout_cs, | 4482 | error = set_lock_args(mode, &ua->lksb, flags, namelen, timeout_cs, |
4454 | DLM_FAKE_USER_AST, ua, DLM_FAKE_USER_AST, &args); | 4483 | fake_astfn, ua, fake_bastfn, &args); |
4455 | lkb->lkb_flags |= DLM_IFL_USER; | 4484 | lkb->lkb_flags |= DLM_IFL_USER; |
4456 | ua->old_mode = DLM_LOCK_IV; | 4485 | ua->old_mode = DLM_LOCK_IV; |
4457 | 4486 | ||
@@ -4504,7 +4533,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, | |||
4504 | /* user can change the params on its lock when it converts it, or | 4533 | /* user can change the params on its lock when it converts it, or |
4505 | add an lvb that didn't exist before */ | 4534 | add an lvb that didn't exist before */ |
4506 | 4535 | ||
4507 | ua = (struct dlm_user_args *)lkb->lkb_astparam; | 4536 | ua = lkb->lkb_ua; |
4508 | 4537 | ||
4509 | if (flags & DLM_LKF_VALBLK && !ua->lksb.sb_lvbptr) { | 4538 | if (flags & DLM_LKF_VALBLK && !ua->lksb.sb_lvbptr) { |
4510 | ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL); | 4539 | ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL); |
@@ -4525,7 +4554,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, | |||
4525 | ua->old_mode = lkb->lkb_grmode; | 4554 | ua->old_mode = lkb->lkb_grmode; |
4526 | 4555 | ||
4527 | error = set_lock_args(mode, &ua->lksb, flags, 0, timeout_cs, | 4556 | error = set_lock_args(mode, &ua->lksb, flags, 0, timeout_cs, |
4528 | DLM_FAKE_USER_AST, ua, DLM_FAKE_USER_AST, &args); | 4557 | fake_astfn, ua, fake_bastfn, &args); |
4529 | if (error) | 4558 | if (error) |
4530 | goto out_put; | 4559 | goto out_put; |
4531 | 4560 | ||
@@ -4555,7 +4584,7 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, | |||
4555 | if (error) | 4584 | if (error) |
4556 | goto out; | 4585 | goto out; |
4557 | 4586 | ||
4558 | ua = (struct dlm_user_args *)lkb->lkb_astparam; | 4587 | ua = lkb->lkb_ua; |
4559 | 4588 | ||
4560 | if (lvb_in && ua->lksb.sb_lvbptr) | 4589 | if (lvb_in && ua->lksb.sb_lvbptr) |
4561 | memcpy(ua->lksb.sb_lvbptr, lvb_in, DLM_USER_LVB_LEN); | 4590 | memcpy(ua->lksb.sb_lvbptr, lvb_in, DLM_USER_LVB_LEN); |
@@ -4604,7 +4633,7 @@ int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, | |||
4604 | if (error) | 4633 | if (error) |
4605 | goto out; | 4634 | goto out; |
4606 | 4635 | ||
4607 | ua = (struct dlm_user_args *)lkb->lkb_astparam; | 4636 | ua = lkb->lkb_ua; |
4608 | if (ua_tmp->castparam) | 4637 | if (ua_tmp->castparam) |
4609 | ua->castparam = ua_tmp->castparam; | 4638 | ua->castparam = ua_tmp->castparam; |
4610 | ua->user_lksb = ua_tmp->user_lksb; | 4639 | ua->user_lksb = ua_tmp->user_lksb; |
@@ -4642,7 +4671,7 @@ int dlm_user_deadlock(struct dlm_ls *ls, uint32_t flags, uint32_t lkid) | |||
4642 | if (error) | 4671 | if (error) |
4643 | goto out; | 4672 | goto out; |
4644 | 4673 | ||
4645 | ua = (struct dlm_user_args *)lkb->lkb_astparam; | 4674 | ua = lkb->lkb_ua; |
4646 | 4675 | ||
4647 | error = set_unlock_args(flags, ua, &args); | 4676 | error = set_unlock_args(flags, ua, &args); |
4648 | if (error) | 4677 | if (error) |
@@ -4681,7 +4710,6 @@ int dlm_user_deadlock(struct dlm_ls *ls, uint32_t flags, uint32_t lkid) | |||
4681 | 4710 | ||
4682 | static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) | 4711 | static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) |
4683 | { | 4712 | { |
4684 | struct dlm_user_args *ua = (struct dlm_user_args *)lkb->lkb_astparam; | ||
4685 | struct dlm_args args; | 4713 | struct dlm_args args; |
4686 | int error; | 4714 | int error; |
4687 | 4715 | ||
@@ -4690,7 +4718,7 @@ static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) | |||
4690 | list_add_tail(&lkb->lkb_ownqueue, &ls->ls_orphans); | 4718 | list_add_tail(&lkb->lkb_ownqueue, &ls->ls_orphans); |
4691 | mutex_unlock(&ls->ls_orphans_mutex); | 4719 | mutex_unlock(&ls->ls_orphans_mutex); |
4692 | 4720 | ||
4693 | set_unlock_args(0, ua, &args); | 4721 | set_unlock_args(0, lkb->lkb_ua, &args); |
4694 | 4722 | ||
4695 | error = cancel_lock(ls, lkb, &args); | 4723 | error = cancel_lock(ls, lkb, &args); |
4696 | if (error == -DLM_ECANCEL) | 4724 | if (error == -DLM_ECANCEL) |
@@ -4703,11 +4731,10 @@ static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) | |||
4703 | 4731 | ||
4704 | static int unlock_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) | 4732 | static int unlock_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) |
4705 | { | 4733 | { |
4706 | struct dlm_user_args *ua = (struct dlm_user_args *)lkb->lkb_astparam; | ||
4707 | struct dlm_args args; | 4734 | struct dlm_args args; |
4708 | int error; | 4735 | int error; |
4709 | 4736 | ||
4710 | set_unlock_args(DLM_LKF_FORCEUNLOCK, ua, &args); | 4737 | set_unlock_args(DLM_LKF_FORCEUNLOCK, lkb->lkb_ua, &args); |
4711 | 4738 | ||
4712 | error = unlock_lock(ls, lkb, &args); | 4739 | error = unlock_lock(ls, lkb, &args); |
4713 | if (error == -DLM_EUNLOCK) | 4740 | if (error == -DLM_EUNLOCK) |
diff --git a/fs/dlm/lock.h b/fs/dlm/lock.h index 27b6ed302911..05d9c82e646b 100644 --- a/fs/dlm/lock.h +++ b/fs/dlm/lock.h | |||
@@ -17,7 +17,7 @@ void dlm_print_rsb(struct dlm_rsb *r); | |||
17 | void dlm_dump_rsb(struct dlm_rsb *r); | 17 | void dlm_dump_rsb(struct dlm_rsb *r); |
18 | void dlm_print_lkb(struct dlm_lkb *lkb); | 18 | void dlm_print_lkb(struct dlm_lkb *lkb); |
19 | void dlm_receive_message_saved(struct dlm_ls *ls, struct dlm_message *ms); | 19 | void dlm_receive_message_saved(struct dlm_ls *ls, struct dlm_message *ms); |
20 | void dlm_receive_buffer(struct dlm_header *hd, int nodeid); | 20 | void dlm_receive_buffer(union dlm_packet *p, int nodeid); |
21 | int dlm_modes_compat(int mode1, int mode2); | 21 | int dlm_modes_compat(int mode1, int mode2); |
22 | void dlm_put_rsb(struct dlm_rsb *r); | 22 | void dlm_put_rsb(struct dlm_rsb *r); |
23 | void dlm_hold_rsb(struct dlm_rsb *r); | 23 | void dlm_hold_rsb(struct dlm_rsb *r); |
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index b180fdc51085..b64e55e0515d 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c | |||
@@ -191,7 +191,7 @@ static int do_uevent(struct dlm_ls *ls, int in) | |||
191 | } | 191 | } |
192 | 192 | ||
193 | 193 | ||
194 | int dlm_lockspace_init(void) | 194 | int __init dlm_lockspace_init(void) |
195 | { | 195 | { |
196 | ls_count = 0; | 196 | ls_count = 0; |
197 | mutex_init(&ls_lock); | 197 | mutex_init(&ls_lock); |
diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c index f7783867491a..54c14c6d06cb 100644 --- a/fs/dlm/memory.c +++ b/fs/dlm/memory.c | |||
@@ -18,7 +18,7 @@ | |||
18 | static struct kmem_cache *lkb_cache; | 18 | static struct kmem_cache *lkb_cache; |
19 | 19 | ||
20 | 20 | ||
21 | int dlm_memory_init(void) | 21 | int __init dlm_memory_init(void) |
22 | { | 22 | { |
23 | int ret = 0; | 23 | int ret = 0; |
24 | 24 | ||
@@ -80,7 +80,7 @@ void dlm_free_lkb(struct dlm_lkb *lkb) | |||
80 | { | 80 | { |
81 | if (lkb->lkb_flags & DLM_IFL_USER) { | 81 | if (lkb->lkb_flags & DLM_IFL_USER) { |
82 | struct dlm_user_args *ua; | 82 | struct dlm_user_args *ua; |
83 | ua = (struct dlm_user_args *)lkb->lkb_astparam; | 83 | ua = lkb->lkb_ua; |
84 | if (ua) { | 84 | if (ua) { |
85 | if (ua->lksb.sb_lvbptr) | 85 | if (ua->lksb.sb_lvbptr) |
86 | kfree(ua->lksb.sb_lvbptr); | 86 | kfree(ua->lksb.sb_lvbptr); |
diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c index e69926e984db..07ac709f3ed7 100644 --- a/fs/dlm/midcomms.c +++ b/fs/dlm/midcomms.c | |||
@@ -61,9 +61,9 @@ int dlm_process_incoming_buffer(int nodeid, const void *base, | |||
61 | union { | 61 | union { |
62 | unsigned char __buf[DLM_INBUF_LEN]; | 62 | unsigned char __buf[DLM_INBUF_LEN]; |
63 | /* this is to force proper alignment on some arches */ | 63 | /* this is to force proper alignment on some arches */ |
64 | struct dlm_header dlm; | 64 | union dlm_packet p; |
65 | } __tmp; | 65 | } __tmp; |
66 | struct dlm_header *msg = &__tmp.dlm; | 66 | union dlm_packet *p = &__tmp.p; |
67 | int ret = 0; | 67 | int ret = 0; |
68 | int err = 0; | 68 | int err = 0; |
69 | uint16_t msglen; | 69 | uint16_t msglen; |
@@ -75,15 +75,22 @@ int dlm_process_incoming_buffer(int nodeid, const void *base, | |||
75 | message may wrap around the end of the buffer back to the | 75 | message may wrap around the end of the buffer back to the |
76 | start, so we need to use a temp buffer and copy_from_cb. */ | 76 | start, so we need to use a temp buffer and copy_from_cb. */ |
77 | 77 | ||
78 | copy_from_cb(msg, base, offset, sizeof(struct dlm_header), | 78 | copy_from_cb(p, base, offset, sizeof(struct dlm_header), |
79 | limit); | 79 | limit); |
80 | 80 | ||
81 | msglen = le16_to_cpu(msg->h_length); | 81 | msglen = le16_to_cpu(p->header.h_length); |
82 | lockspace = msg->h_lockspace; | 82 | lockspace = p->header.h_lockspace; |
83 | 83 | ||
84 | err = -EINVAL; | 84 | err = -EINVAL; |
85 | if (msglen < sizeof(struct dlm_header)) | 85 | if (msglen < sizeof(struct dlm_header)) |
86 | break; | 86 | break; |
87 | if (p->header.h_cmd == DLM_MSG) { | ||
88 | if (msglen < sizeof(struct dlm_message)) | ||
89 | break; | ||
90 | } else { | ||
91 | if (msglen < sizeof(struct dlm_rcom)) | ||
92 | break; | ||
93 | } | ||
87 | err = -E2BIG; | 94 | err = -E2BIG; |
88 | if (msglen > dlm_config.ci_buffer_size) { | 95 | if (msglen > dlm_config.ci_buffer_size) { |
89 | log_print("message size %d from %d too big, buf len %d", | 96 | log_print("message size %d from %d too big, buf len %d", |
@@ -104,26 +111,26 @@ int dlm_process_incoming_buffer(int nodeid, const void *base, | |||
104 | in the buffer on the stack (which should work for most | 111 | in the buffer on the stack (which should work for most |
105 | ordinary messages). */ | 112 | ordinary messages). */ |
106 | 113 | ||
107 | if (msglen > DLM_INBUF_LEN && msg == &__tmp.dlm) { | 114 | if (msglen > sizeof(__tmp) && p == &__tmp.p) { |
108 | msg = kmalloc(dlm_config.ci_buffer_size, GFP_KERNEL); | 115 | p = kmalloc(dlm_config.ci_buffer_size, GFP_KERNEL); |
109 | if (msg == NULL) | 116 | if (p == NULL) |
110 | return ret; | 117 | return ret; |
111 | } | 118 | } |
112 | 119 | ||
113 | copy_from_cb(msg, base, offset, msglen, limit); | 120 | copy_from_cb(p, base, offset, msglen, limit); |
114 | 121 | ||
115 | BUG_ON(lockspace != msg->h_lockspace); | 122 | BUG_ON(lockspace != p->header.h_lockspace); |
116 | 123 | ||
117 | ret += msglen; | 124 | ret += msglen; |
118 | offset += msglen; | 125 | offset += msglen; |
119 | offset &= (limit - 1); | 126 | offset &= (limit - 1); |
120 | len -= msglen; | 127 | len -= msglen; |
121 | 128 | ||
122 | dlm_receive_buffer(msg, nodeid); | 129 | dlm_receive_buffer(p, nodeid); |
123 | } | 130 | } |
124 | 131 | ||
125 | if (msg != &__tmp.dlm) | 132 | if (p != &__tmp.p) |
126 | kfree(msg); | 133 | kfree(p); |
127 | 134 | ||
128 | return err ? err : ret; | 135 | return err ? err : ret; |
129 | } | 136 | } |
diff --git a/fs/dlm/netlink.c b/fs/dlm/netlink.c index 863b87d0dc71..714593621f4f 100644 --- a/fs/dlm/netlink.c +++ b/fs/dlm/netlink.c | |||
@@ -78,7 +78,7 @@ static struct genl_ops dlm_nl_ops = { | |||
78 | .doit = user_cmd, | 78 | .doit = user_cmd, |
79 | }; | 79 | }; |
80 | 80 | ||
81 | int dlm_netlink_init(void) | 81 | int __init dlm_netlink_init(void) |
82 | { | 82 | { |
83 | int rv; | 83 | int rv; |
84 | 84 | ||
@@ -95,7 +95,7 @@ int dlm_netlink_init(void) | |||
95 | return rv; | 95 | return rv; |
96 | } | 96 | } |
97 | 97 | ||
98 | void dlm_netlink_exit(void) | 98 | void __exit dlm_netlink_exit(void) |
99 | { | 99 | { |
100 | genl_unregister_ops(&family, &dlm_nl_ops); | 100 | genl_unregister_ops(&family, &dlm_nl_ops); |
101 | genl_unregister_family(&family); | 101 | genl_unregister_family(&family); |
@@ -104,7 +104,6 @@ void dlm_netlink_exit(void) | |||
104 | static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb) | 104 | static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb) |
105 | { | 105 | { |
106 | struct dlm_rsb *r = lkb->lkb_resource; | 106 | struct dlm_rsb *r = lkb->lkb_resource; |
107 | struct dlm_user_args *ua = (struct dlm_user_args *) lkb->lkb_astparam; | ||
108 | 107 | ||
109 | memset(data, 0, sizeof(struct dlm_lock_data)); | 108 | memset(data, 0, sizeof(struct dlm_lock_data)); |
110 | 109 | ||
@@ -117,8 +116,8 @@ static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb) | |||
117 | data->grmode = lkb->lkb_grmode; | 116 | data->grmode = lkb->lkb_grmode; |
118 | data->rqmode = lkb->lkb_rqmode; | 117 | data->rqmode = lkb->lkb_rqmode; |
119 | data->timestamp = lkb->lkb_timestamp; | 118 | data->timestamp = lkb->lkb_timestamp; |
120 | if (ua) | 119 | if (lkb->lkb_ua) |
121 | data->xid = ua->xid; | 120 | data->xid = lkb->lkb_ua->xid; |
122 | if (r) { | 121 | if (r) { |
123 | data->lockspace_id = r->res_ls->ls_global_id; | 122 | data->lockspace_id = r->res_ls->ls_global_id; |
124 | data->resource_namelen = r->res_length; | 123 | data->resource_namelen = r->res_length; |
diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c index 026824cd3acb..035e6f9990b0 100644 --- a/fs/dlm/rcom.c +++ b/fs/dlm/rcom.c | |||
@@ -78,13 +78,14 @@ static void send_rcom(struct dlm_ls *ls, struct dlm_mhandle *mh, | |||
78 | 78 | ||
79 | static void make_config(struct dlm_ls *ls, struct rcom_config *rf) | 79 | static void make_config(struct dlm_ls *ls, struct rcom_config *rf) |
80 | { | 80 | { |
81 | rf->rf_lvblen = ls->ls_lvblen; | 81 | rf->rf_lvblen = cpu_to_le32(ls->ls_lvblen); |
82 | rf->rf_lsflags = ls->ls_exflags; | 82 | rf->rf_lsflags = cpu_to_le32(ls->ls_exflags); |
83 | } | 83 | } |
84 | 84 | ||
85 | static int check_config(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid) | 85 | static int check_config(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid) |
86 | { | 86 | { |
87 | struct rcom_config *rf = (struct rcom_config *) rc->rc_buf; | 87 | struct rcom_config *rf = (struct rcom_config *) rc->rc_buf; |
88 | size_t conf_size = sizeof(struct dlm_rcom) + sizeof(struct rcom_config); | ||
88 | 89 | ||
89 | if ((rc->rc_header.h_version & 0xFFFF0000) != DLM_HEADER_MAJOR) { | 90 | if ((rc->rc_header.h_version & 0xFFFF0000) != DLM_HEADER_MAJOR) { |
90 | log_error(ls, "version mismatch: %x nodeid %d: %x", | 91 | log_error(ls, "version mismatch: %x nodeid %d: %x", |
@@ -93,11 +94,18 @@ static int check_config(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid) | |||
93 | return -EPROTO; | 94 | return -EPROTO; |
94 | } | 95 | } |
95 | 96 | ||
96 | if (rf->rf_lvblen != ls->ls_lvblen || | 97 | if (rc->rc_header.h_length < conf_size) { |
97 | rf->rf_lsflags != ls->ls_exflags) { | 98 | log_error(ls, "config too short: %d nodeid %d", |
99 | rc->rc_header.h_length, nodeid); | ||
100 | return -EPROTO; | ||
101 | } | ||
102 | |||
103 | if (le32_to_cpu(rf->rf_lvblen) != ls->ls_lvblen || | ||
104 | le32_to_cpu(rf->rf_lsflags) != ls->ls_exflags) { | ||
98 | log_error(ls, "config mismatch: %d,%x nodeid %d: %d,%x", | 105 | log_error(ls, "config mismatch: %d,%x nodeid %d: %d,%x", |
99 | ls->ls_lvblen, ls->ls_exflags, | 106 | ls->ls_lvblen, ls->ls_exflags, nodeid, |
100 | nodeid, rf->rf_lvblen, rf->rf_lsflags); | 107 | le32_to_cpu(rf->rf_lvblen), |
108 | le32_to_cpu(rf->rf_lsflags)); | ||
101 | return -EPROTO; | 109 | return -EPROTO; |
102 | } | 110 | } |
103 | return 0; | 111 | return 0; |
@@ -128,7 +136,7 @@ int dlm_rcom_status(struct dlm_ls *ls, int nodeid) | |||
128 | ls->ls_recover_nodeid = nodeid; | 136 | ls->ls_recover_nodeid = nodeid; |
129 | 137 | ||
130 | if (nodeid == dlm_our_nodeid()) { | 138 | if (nodeid == dlm_our_nodeid()) { |
131 | rc = (struct dlm_rcom *) ls->ls_recover_buf; | 139 | rc = ls->ls_recover_buf; |
132 | rc->rc_result = dlm_recover_status(ls); | 140 | rc->rc_result = dlm_recover_status(ls); |
133 | goto out; | 141 | goto out; |
134 | } | 142 | } |
@@ -147,7 +155,7 @@ int dlm_rcom_status(struct dlm_ls *ls, int nodeid) | |||
147 | if (error) | 155 | if (error) |
148 | goto out; | 156 | goto out; |
149 | 157 | ||
150 | rc = (struct dlm_rcom *) ls->ls_recover_buf; | 158 | rc = ls->ls_recover_buf; |
151 | 159 | ||
152 | if (rc->rc_result == -ESRCH) { | 160 | if (rc->rc_result == -ESRCH) { |
153 | /* we pretend the remote lockspace exists with 0 status */ | 161 | /* we pretend the remote lockspace exists with 0 status */ |
@@ -201,14 +209,15 @@ int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, int last_len) | |||
201 | { | 209 | { |
202 | struct dlm_rcom *rc; | 210 | struct dlm_rcom *rc; |
203 | struct dlm_mhandle *mh; | 211 | struct dlm_mhandle *mh; |
204 | int error = 0, len = sizeof(struct dlm_rcom); | 212 | int error = 0; |
213 | int max_size = dlm_config.ci_buffer_size - sizeof(struct dlm_rcom); | ||
205 | 214 | ||
206 | ls->ls_recover_nodeid = nodeid; | 215 | ls->ls_recover_nodeid = nodeid; |
207 | 216 | ||
208 | if (nodeid == dlm_our_nodeid()) { | 217 | if (nodeid == dlm_our_nodeid()) { |
209 | dlm_copy_master_names(ls, last_name, last_len, | 218 | dlm_copy_master_names(ls, last_name, last_len, |
210 | ls->ls_recover_buf + len, | 219 | ls->ls_recover_buf->rc_buf, |
211 | dlm_config.ci_buffer_size - len, nodeid); | 220 | max_size, nodeid); |
212 | goto out; | 221 | goto out; |
213 | } | 222 | } |
214 | 223 | ||
@@ -299,22 +308,22 @@ static void pack_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb, | |||
299 | { | 308 | { |
300 | memset(rl, 0, sizeof(*rl)); | 309 | memset(rl, 0, sizeof(*rl)); |
301 | 310 | ||
302 | rl->rl_ownpid = lkb->lkb_ownpid; | 311 | rl->rl_ownpid = cpu_to_le32(lkb->lkb_ownpid); |
303 | rl->rl_lkid = lkb->lkb_id; | 312 | rl->rl_lkid = cpu_to_le32(lkb->lkb_id); |
304 | rl->rl_exflags = lkb->lkb_exflags; | 313 | rl->rl_exflags = cpu_to_le32(lkb->lkb_exflags); |
305 | rl->rl_flags = lkb->lkb_flags; | 314 | rl->rl_flags = cpu_to_le32(lkb->lkb_flags); |
306 | rl->rl_lvbseq = lkb->lkb_lvbseq; | 315 | rl->rl_lvbseq = cpu_to_le32(lkb->lkb_lvbseq); |
307 | rl->rl_rqmode = lkb->lkb_rqmode; | 316 | rl->rl_rqmode = lkb->lkb_rqmode; |
308 | rl->rl_grmode = lkb->lkb_grmode; | 317 | rl->rl_grmode = lkb->lkb_grmode; |
309 | rl->rl_status = lkb->lkb_status; | 318 | rl->rl_status = lkb->lkb_status; |
310 | rl->rl_wait_type = lkb->lkb_wait_type; | 319 | rl->rl_wait_type = cpu_to_le16(lkb->lkb_wait_type); |
311 | 320 | ||
312 | if (lkb->lkb_bastaddr) | 321 | if (lkb->lkb_bastfn) |
313 | rl->rl_asts |= AST_BAST; | 322 | rl->rl_asts |= AST_BAST; |
314 | if (lkb->lkb_astaddr) | 323 | if (lkb->lkb_astfn) |
315 | rl->rl_asts |= AST_COMP; | 324 | rl->rl_asts |= AST_COMP; |
316 | 325 | ||
317 | rl->rl_namelen = r->res_length; | 326 | rl->rl_namelen = cpu_to_le16(r->res_length); |
318 | memcpy(rl->rl_name, r->res_name, r->res_length); | 327 | memcpy(rl->rl_name, r->res_name, r->res_length); |
319 | 328 | ||
320 | /* FIXME: might we have an lvb without DLM_LKF_VALBLK set ? | 329 | /* FIXME: might we have an lvb without DLM_LKF_VALBLK set ? |
@@ -348,6 +357,7 @@ int dlm_send_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb) | |||
348 | return error; | 357 | return error; |
349 | } | 358 | } |
350 | 359 | ||
360 | /* needs at least dlm_rcom + rcom_lock */ | ||
351 | static void receive_rcom_lock(struct dlm_ls *ls, struct dlm_rcom *rc_in) | 361 | static void receive_rcom_lock(struct dlm_ls *ls, struct dlm_rcom *rc_in) |
352 | { | 362 | { |
353 | struct dlm_rcom *rc; | 363 | struct dlm_rcom *rc; |
@@ -401,7 +411,7 @@ int dlm_send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in) | |||
401 | rc->rc_result = -ESRCH; | 411 | rc->rc_result = -ESRCH; |
402 | 412 | ||
403 | rf = (struct rcom_config *) rc->rc_buf; | 413 | rf = (struct rcom_config *) rc->rc_buf; |
404 | rf->rf_lvblen = -1; | 414 | rf->rf_lvblen = cpu_to_le32(~0U); |
405 | 415 | ||
406 | dlm_rcom_out(rc); | 416 | dlm_rcom_out(rc); |
407 | dlm_lowcomms_commit_buffer(mh); | 417 | dlm_lowcomms_commit_buffer(mh); |
@@ -439,6 +449,8 @@ static int is_old_reply(struct dlm_ls *ls, struct dlm_rcom *rc) | |||
439 | 449 | ||
440 | void dlm_receive_rcom(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid) | 450 | void dlm_receive_rcom(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid) |
441 | { | 451 | { |
452 | int lock_size = sizeof(struct dlm_rcom) + sizeof(struct rcom_lock); | ||
453 | |||
442 | if (dlm_recovery_stopped(ls) && (rc->rc_type != DLM_RCOM_STATUS)) { | 454 | if (dlm_recovery_stopped(ls) && (rc->rc_type != DLM_RCOM_STATUS)) { |
443 | log_debug(ls, "ignoring recovery message %x from %d", | 455 | log_debug(ls, "ignoring recovery message %x from %d", |
444 | rc->rc_type, nodeid); | 456 | rc->rc_type, nodeid); |
@@ -462,6 +474,8 @@ void dlm_receive_rcom(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid) | |||
462 | break; | 474 | break; |
463 | 475 | ||
464 | case DLM_RCOM_LOCK: | 476 | case DLM_RCOM_LOCK: |
477 | if (rc->rc_header.h_length < lock_size) | ||
478 | goto Eshort; | ||
465 | receive_rcom_lock(ls, rc); | 479 | receive_rcom_lock(ls, rc); |
466 | break; | 480 | break; |
467 | 481 | ||
@@ -478,13 +492,18 @@ void dlm_receive_rcom(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid) | |||
478 | break; | 492 | break; |
479 | 493 | ||
480 | case DLM_RCOM_LOCK_REPLY: | 494 | case DLM_RCOM_LOCK_REPLY: |
495 | if (rc->rc_header.h_length < lock_size) | ||
496 | goto Eshort; | ||
481 | dlm_recover_process_copy(ls, rc); | 497 | dlm_recover_process_copy(ls, rc); |
482 | break; | 498 | break; |
483 | 499 | ||
484 | default: | 500 | default: |
485 | log_error(ls, "receive_rcom bad type %d", rc->rc_type); | 501 | log_error(ls, "receive_rcom bad type %d", rc->rc_type); |
486 | } | 502 | } |
487 | out: | 503 | out: |
488 | return; | 504 | return; |
505 | Eshort: | ||
506 | log_error(ls, "recovery message %x from %d is too short", | ||
507 | rc->rc_type, nodeid); | ||
489 | } | 508 | } |
490 | 509 | ||
diff --git a/fs/dlm/recover.c b/fs/dlm/recover.c index df075dc300fa..80aba5bdd4a4 100644 --- a/fs/dlm/recover.c +++ b/fs/dlm/recover.c | |||
@@ -94,7 +94,7 @@ void dlm_set_recover_status(struct dlm_ls *ls, uint32_t status) | |||
94 | 94 | ||
95 | static int wait_status_all(struct dlm_ls *ls, uint32_t wait_status) | 95 | static int wait_status_all(struct dlm_ls *ls, uint32_t wait_status) |
96 | { | 96 | { |
97 | struct dlm_rcom *rc = (struct dlm_rcom *) ls->ls_recover_buf; | 97 | struct dlm_rcom *rc = ls->ls_recover_buf; |
98 | struct dlm_member *memb; | 98 | struct dlm_member *memb; |
99 | int error = 0, delay; | 99 | int error = 0, delay; |
100 | 100 | ||
@@ -123,7 +123,7 @@ static int wait_status_all(struct dlm_ls *ls, uint32_t wait_status) | |||
123 | 123 | ||
124 | static int wait_status_low(struct dlm_ls *ls, uint32_t wait_status) | 124 | static int wait_status_low(struct dlm_ls *ls, uint32_t wait_status) |
125 | { | 125 | { |
126 | struct dlm_rcom *rc = (struct dlm_rcom *) ls->ls_recover_buf; | 126 | struct dlm_rcom *rc = ls->ls_recover_buf; |
127 | int error = 0, delay = 0, nodeid = ls->ls_low_nodeid; | 127 | int error = 0, delay = 0, nodeid = ls->ls_low_nodeid; |
128 | 128 | ||
129 | for (;;) { | 129 | for (;;) { |
diff --git a/fs/dlm/requestqueue.c b/fs/dlm/requestqueue.c index 0de04f17ccea..daa4183fbb84 100644 --- a/fs/dlm/requestqueue.c +++ b/fs/dlm/requestqueue.c | |||
@@ -20,7 +20,7 @@ | |||
20 | struct rq_entry { | 20 | struct rq_entry { |
21 | struct list_head list; | 21 | struct list_head list; |
22 | int nodeid; | 22 | int nodeid; |
23 | char request[0]; | 23 | struct dlm_message request; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | /* | 26 | /* |
@@ -30,10 +30,10 @@ struct rq_entry { | |||
30 | * lockspace is enabled on some while still suspended on others. | 30 | * lockspace is enabled on some while still suspended on others. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd) | 33 | void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms) |
34 | { | 34 | { |
35 | struct rq_entry *e; | 35 | struct rq_entry *e; |
36 | int length = hd->h_length; | 36 | int length = ms->m_header.h_length - sizeof(struct dlm_message); |
37 | 37 | ||
38 | e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL); | 38 | e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL); |
39 | if (!e) { | 39 | if (!e) { |
@@ -42,7 +42,7 @@ void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd) | |||
42 | } | 42 | } |
43 | 43 | ||
44 | e->nodeid = nodeid; | 44 | e->nodeid = nodeid; |
45 | memcpy(e->request, hd, length); | 45 | memcpy(&e->request, ms, ms->m_header.h_length); |
46 | 46 | ||
47 | mutex_lock(&ls->ls_requestqueue_mutex); | 47 | mutex_lock(&ls->ls_requestqueue_mutex); |
48 | list_add_tail(&e->list, &ls->ls_requestqueue); | 48 | list_add_tail(&e->list, &ls->ls_requestqueue); |
@@ -76,7 +76,7 @@ int dlm_process_requestqueue(struct dlm_ls *ls) | |||
76 | e = list_entry(ls->ls_requestqueue.next, struct rq_entry, list); | 76 | e = list_entry(ls->ls_requestqueue.next, struct rq_entry, list); |
77 | mutex_unlock(&ls->ls_requestqueue_mutex); | 77 | mutex_unlock(&ls->ls_requestqueue_mutex); |
78 | 78 | ||
79 | dlm_receive_message_saved(ls, (struct dlm_message *)e->request); | 79 | dlm_receive_message_saved(ls, &e->request); |
80 | 80 | ||
81 | mutex_lock(&ls->ls_requestqueue_mutex); | 81 | mutex_lock(&ls->ls_requestqueue_mutex); |
82 | list_del(&e->list); | 82 | list_del(&e->list); |
@@ -176,7 +176,7 @@ void dlm_purge_requestqueue(struct dlm_ls *ls) | |||
176 | 176 | ||
177 | mutex_lock(&ls->ls_requestqueue_mutex); | 177 | mutex_lock(&ls->ls_requestqueue_mutex); |
178 | list_for_each_entry_safe(e, safe, &ls->ls_requestqueue, list) { | 178 | list_for_each_entry_safe(e, safe, &ls->ls_requestqueue, list) { |
179 | ms = (struct dlm_message *) e->request; | 179 | ms = &e->request; |
180 | 180 | ||
181 | if (purge_request(ls, ms, e->nodeid)) { | 181 | if (purge_request(ls, ms, e->nodeid)) { |
182 | list_del(&e->list); | 182 | list_del(&e->list); |
diff --git a/fs/dlm/requestqueue.h b/fs/dlm/requestqueue.h index aba34fc05ee4..10ce449b77da 100644 --- a/fs/dlm/requestqueue.h +++ b/fs/dlm/requestqueue.h | |||
@@ -13,7 +13,7 @@ | |||
13 | #ifndef __REQUESTQUEUE_DOT_H__ | 13 | #ifndef __REQUESTQUEUE_DOT_H__ |
14 | #define __REQUESTQUEUE_DOT_H__ | 14 | #define __REQUESTQUEUE_DOT_H__ |
15 | 15 | ||
16 | void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd); | 16 | void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms); |
17 | int dlm_process_requestqueue(struct dlm_ls *ls); | 17 | int dlm_process_requestqueue(struct dlm_ls *ls); |
18 | void dlm_wait_requestqueue(struct dlm_ls *ls); | 18 | void dlm_wait_requestqueue(struct dlm_ls *ls); |
19 | void dlm_purge_requestqueue(struct dlm_ls *ls); | 19 | void dlm_purge_requestqueue(struct dlm_ls *ls); |
diff --git a/fs/dlm/user.c b/fs/dlm/user.c index 7cbc6826239b..ebbcf38fd33b 100644 --- a/fs/dlm/user.c +++ b/fs/dlm/user.c | |||
@@ -82,7 +82,7 @@ struct dlm_lock_result32 { | |||
82 | 82 | ||
83 | static void compat_input(struct dlm_write_request *kb, | 83 | static void compat_input(struct dlm_write_request *kb, |
84 | struct dlm_write_request32 *kb32, | 84 | struct dlm_write_request32 *kb32, |
85 | int max_namelen) | 85 | size_t count) |
86 | { | 86 | { |
87 | kb->version[0] = kb32->version[0]; | 87 | kb->version[0] = kb32->version[0]; |
88 | kb->version[1] = kb32->version[1]; | 88 | kb->version[1] = kb32->version[1]; |
@@ -94,7 +94,8 @@ static void compat_input(struct dlm_write_request *kb, | |||
94 | kb->cmd == DLM_USER_REMOVE_LOCKSPACE) { | 94 | kb->cmd == DLM_USER_REMOVE_LOCKSPACE) { |
95 | kb->i.lspace.flags = kb32->i.lspace.flags; | 95 | kb->i.lspace.flags = kb32->i.lspace.flags; |
96 | kb->i.lspace.minor = kb32->i.lspace.minor; | 96 | kb->i.lspace.minor = kb32->i.lspace.minor; |
97 | strcpy(kb->i.lspace.name, kb32->i.lspace.name); | 97 | memcpy(kb->i.lspace.name, kb32->i.lspace.name, count - |
98 | offsetof(struct dlm_write_request32, i.lspace.name)); | ||
98 | } else if (kb->cmd == DLM_USER_PURGE) { | 99 | } else if (kb->cmd == DLM_USER_PURGE) { |
99 | kb->i.purge.nodeid = kb32->i.purge.nodeid; | 100 | kb->i.purge.nodeid = kb32->i.purge.nodeid; |
100 | kb->i.purge.pid = kb32->i.purge.pid; | 101 | kb->i.purge.pid = kb32->i.purge.pid; |
@@ -112,11 +113,8 @@ static void compat_input(struct dlm_write_request *kb, | |||
112 | kb->i.lock.bastaddr = (void *)(long)kb32->i.lock.bastaddr; | 113 | kb->i.lock.bastaddr = (void *)(long)kb32->i.lock.bastaddr; |
113 | kb->i.lock.lksb = (void *)(long)kb32->i.lock.lksb; | 114 | kb->i.lock.lksb = (void *)(long)kb32->i.lock.lksb; |
114 | memcpy(kb->i.lock.lvb, kb32->i.lock.lvb, DLM_USER_LVB_LEN); | 115 | memcpy(kb->i.lock.lvb, kb32->i.lock.lvb, DLM_USER_LVB_LEN); |
115 | if (kb->i.lock.namelen <= max_namelen) | 116 | memcpy(kb->i.lock.name, kb32->i.lock.name, count - |
116 | memcpy(kb->i.lock.name, kb32->i.lock.name, | 117 | offsetof(struct dlm_write_request32, i.lock.name)); |
117 | kb->i.lock.namelen); | ||
118 | else | ||
119 | kb->i.lock.namelen = max_namelen; | ||
120 | } | 118 | } |
121 | } | 119 | } |
122 | 120 | ||
@@ -197,8 +195,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type) | |||
197 | if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD)) | 195 | if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD)) |
198 | goto out; | 196 | goto out; |
199 | 197 | ||
200 | DLM_ASSERT(lkb->lkb_astparam, dlm_print_lkb(lkb);); | 198 | DLM_ASSERT(lkb->lkb_ua, dlm_print_lkb(lkb);); |
201 | ua = (struct dlm_user_args *)lkb->lkb_astparam; | 199 | ua = lkb->lkb_ua; |
202 | proc = ua->proc; | 200 | proc = ua->proc; |
203 | 201 | ||
204 | if (type == AST_BAST && ua->bastaddr == NULL) | 202 | if (type == AST_BAST && ua->bastaddr == NULL) |
@@ -508,7 +506,7 @@ static ssize_t device_write(struct file *file, const char __user *buf, | |||
508 | #endif | 506 | #endif |
509 | return -EINVAL; | 507 | return -EINVAL; |
510 | 508 | ||
511 | kbuf = kmalloc(count, GFP_KERNEL); | 509 | kbuf = kzalloc(count + 1, GFP_KERNEL); |
512 | if (!kbuf) | 510 | if (!kbuf) |
513 | return -ENOMEM; | 511 | return -ENOMEM; |
514 | 512 | ||
@@ -526,15 +524,14 @@ static ssize_t device_write(struct file *file, const char __user *buf, | |||
526 | if (!kbuf->is64bit) { | 524 | if (!kbuf->is64bit) { |
527 | struct dlm_write_request32 *k32buf; | 525 | struct dlm_write_request32 *k32buf; |
528 | k32buf = (struct dlm_write_request32 *)kbuf; | 526 | k32buf = (struct dlm_write_request32 *)kbuf; |
529 | kbuf = kmalloc(count + (sizeof(struct dlm_write_request) - | 527 | kbuf = kmalloc(count + 1 + (sizeof(struct dlm_write_request) - |
530 | sizeof(struct dlm_write_request32)), GFP_KERNEL); | 528 | sizeof(struct dlm_write_request32)), GFP_KERNEL); |
531 | if (!kbuf) | 529 | if (!kbuf) |
532 | return -ENOMEM; | 530 | return -ENOMEM; |
533 | 531 | ||
534 | if (proc) | 532 | if (proc) |
535 | set_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags); | 533 | set_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags); |
536 | compat_input(kbuf, k32buf, | 534 | compat_input(kbuf, k32buf, count + 1); |
537 | count - sizeof(struct dlm_write_request32)); | ||
538 | kfree(k32buf); | 535 | kfree(k32buf); |
539 | } | 536 | } |
540 | #endif | 537 | #endif |
@@ -774,7 +771,6 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count, | |||
774 | { | 771 | { |
775 | struct dlm_user_proc *proc = file->private_data; | 772 | struct dlm_user_proc *proc = file->private_data; |
776 | struct dlm_lkb *lkb; | 773 | struct dlm_lkb *lkb; |
777 | struct dlm_user_args *ua; | ||
778 | DECLARE_WAITQUEUE(wait, current); | 774 | DECLARE_WAITQUEUE(wait, current); |
779 | int error, type=0, bmode=0, removed = 0; | 775 | int error, type=0, bmode=0, removed = 0; |
780 | 776 | ||
@@ -845,8 +841,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count, | |||
845 | } | 841 | } |
846 | spin_unlock(&proc->asts_spin); | 842 | spin_unlock(&proc->asts_spin); |
847 | 843 | ||
848 | ua = (struct dlm_user_args *)lkb->lkb_astparam; | 844 | error = copy_result_to_user(lkb->lkb_ua, |
849 | error = copy_result_to_user(ua, | ||
850 | test_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags), | 845 | test_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags), |
851 | type, bmode, buf, count); | 846 | type, bmode, buf, count); |
852 | 847 | ||
@@ -907,7 +902,7 @@ static struct miscdevice ctl_device = { | |||
907 | .minor = MISC_DYNAMIC_MINOR, | 902 | .minor = MISC_DYNAMIC_MINOR, |
908 | }; | 903 | }; |
909 | 904 | ||
910 | int dlm_user_init(void) | 905 | int __init dlm_user_init(void) |
911 | { | 906 | { |
912 | int error; | 907 | int error; |
913 | 908 | ||
diff --git a/fs/dlm/util.c b/fs/dlm/util.c index 4d9c1f4e1bd1..e36520af7cc0 100644 --- a/fs/dlm/util.c +++ b/fs/dlm/util.c | |||
@@ -131,52 +131,8 @@ void dlm_message_in(struct dlm_message *ms) | |||
131 | ms->m_result = from_dlm_errno(le32_to_cpu(ms->m_result)); | 131 | ms->m_result = from_dlm_errno(le32_to_cpu(ms->m_result)); |
132 | } | 132 | } |
133 | 133 | ||
134 | static void rcom_lock_out(struct rcom_lock *rl) | ||
135 | { | ||
136 | rl->rl_ownpid = cpu_to_le32(rl->rl_ownpid); | ||
137 | rl->rl_lkid = cpu_to_le32(rl->rl_lkid); | ||
138 | rl->rl_remid = cpu_to_le32(rl->rl_remid); | ||
139 | rl->rl_parent_lkid = cpu_to_le32(rl->rl_parent_lkid); | ||
140 | rl->rl_parent_remid = cpu_to_le32(rl->rl_parent_remid); | ||
141 | rl->rl_exflags = cpu_to_le32(rl->rl_exflags); | ||
142 | rl->rl_flags = cpu_to_le32(rl->rl_flags); | ||
143 | rl->rl_lvbseq = cpu_to_le32(rl->rl_lvbseq); | ||
144 | rl->rl_result = cpu_to_le32(rl->rl_result); | ||
145 | rl->rl_wait_type = cpu_to_le16(rl->rl_wait_type); | ||
146 | rl->rl_namelen = cpu_to_le16(rl->rl_namelen); | ||
147 | } | ||
148 | |||
149 | static void rcom_lock_in(struct rcom_lock *rl) | ||
150 | { | ||
151 | rl->rl_ownpid = le32_to_cpu(rl->rl_ownpid); | ||
152 | rl->rl_lkid = le32_to_cpu(rl->rl_lkid); | ||
153 | rl->rl_remid = le32_to_cpu(rl->rl_remid); | ||
154 | rl->rl_parent_lkid = le32_to_cpu(rl->rl_parent_lkid); | ||
155 | rl->rl_parent_remid = le32_to_cpu(rl->rl_parent_remid); | ||
156 | rl->rl_exflags = le32_to_cpu(rl->rl_exflags); | ||
157 | rl->rl_flags = le32_to_cpu(rl->rl_flags); | ||
158 | rl->rl_lvbseq = le32_to_cpu(rl->rl_lvbseq); | ||
159 | rl->rl_result = le32_to_cpu(rl->rl_result); | ||
160 | rl->rl_wait_type = le16_to_cpu(rl->rl_wait_type); | ||
161 | rl->rl_namelen = le16_to_cpu(rl->rl_namelen); | ||
162 | } | ||
163 | |||
164 | static void rcom_config_out(struct rcom_config *rf) | ||
165 | { | ||
166 | rf->rf_lvblen = cpu_to_le32(rf->rf_lvblen); | ||
167 | rf->rf_lsflags = cpu_to_le32(rf->rf_lsflags); | ||
168 | } | ||
169 | |||
170 | static void rcom_config_in(struct rcom_config *rf) | ||
171 | { | ||
172 | rf->rf_lvblen = le32_to_cpu(rf->rf_lvblen); | ||
173 | rf->rf_lsflags = le32_to_cpu(rf->rf_lsflags); | ||
174 | } | ||
175 | |||
176 | void dlm_rcom_out(struct dlm_rcom *rc) | 134 | void dlm_rcom_out(struct dlm_rcom *rc) |
177 | { | 135 | { |
178 | int type = rc->rc_type; | ||
179 | |||
180 | header_out(&rc->rc_header); | 136 | header_out(&rc->rc_header); |
181 | 137 | ||
182 | rc->rc_type = cpu_to_le32(rc->rc_type); | 138 | rc->rc_type = cpu_to_le32(rc->rc_type); |
@@ -184,18 +140,10 @@ void dlm_rcom_out(struct dlm_rcom *rc) | |||
184 | rc->rc_id = cpu_to_le64(rc->rc_id); | 140 | rc->rc_id = cpu_to_le64(rc->rc_id); |
185 | rc->rc_seq = cpu_to_le64(rc->rc_seq); | 141 | rc->rc_seq = cpu_to_le64(rc->rc_seq); |
186 | rc->rc_seq_reply = cpu_to_le64(rc->rc_seq_reply); | 142 | rc->rc_seq_reply = cpu_to_le64(rc->rc_seq_reply); |
187 | |||
188 | if ((type == DLM_RCOM_LOCK) || (type == DLM_RCOM_LOCK_REPLY)) | ||
189 | rcom_lock_out((struct rcom_lock *) rc->rc_buf); | ||
190 | |||
191 | else if (type == DLM_RCOM_STATUS_REPLY) | ||
192 | rcom_config_out((struct rcom_config *) rc->rc_buf); | ||
193 | } | 143 | } |
194 | 144 | ||
195 | void dlm_rcom_in(struct dlm_rcom *rc) | 145 | void dlm_rcom_in(struct dlm_rcom *rc) |
196 | { | 146 | { |
197 | int type; | ||
198 | |||
199 | header_in(&rc->rc_header); | 147 | header_in(&rc->rc_header); |
200 | 148 | ||
201 | rc->rc_type = le32_to_cpu(rc->rc_type); | 149 | rc->rc_type = le32_to_cpu(rc->rc_type); |
@@ -203,13 +151,4 @@ void dlm_rcom_in(struct dlm_rcom *rc) | |||
203 | rc->rc_id = le64_to_cpu(rc->rc_id); | 151 | rc->rc_id = le64_to_cpu(rc->rc_id); |
204 | rc->rc_seq = le64_to_cpu(rc->rc_seq); | 152 | rc->rc_seq = le64_to_cpu(rc->rc_seq); |
205 | rc->rc_seq_reply = le64_to_cpu(rc->rc_seq_reply); | 153 | rc->rc_seq_reply = le64_to_cpu(rc->rc_seq_reply); |
206 | |||
207 | type = rc->rc_type; | ||
208 | |||
209 | if ((type == DLM_RCOM_LOCK) || (type == DLM_RCOM_LOCK_REPLY)) | ||
210 | rcom_lock_in((struct rcom_lock *) rc->rc_buf); | ||
211 | |||
212 | else if (type == DLM_RCOM_STATUS_REPLY) | ||
213 | rcom_config_in((struct rcom_config *) rc->rc_buf); | ||
214 | } | 154 | } |
215 | |||
@@ -119,7 +119,7 @@ asmlinkage long sys_uselib(const char __user * library) | |||
119 | if (error) | 119 | if (error) |
120 | goto exit; | 120 | goto exit; |
121 | 121 | ||
122 | file = nameidata_to_filp(&nd, O_RDONLY); | 122 | file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); |
123 | error = PTR_ERR(file); | 123 | error = PTR_ERR(file); |
124 | if (IS_ERR(file)) | 124 | if (IS_ERR(file)) |
125 | goto out; | 125 | goto out; |
@@ -658,7 +658,8 @@ struct file *open_exec(const char *name) | |||
658 | int err = vfs_permission(&nd, MAY_EXEC); | 658 | int err = vfs_permission(&nd, MAY_EXEC); |
659 | file = ERR_PTR(err); | 659 | file = ERR_PTR(err); |
660 | if (!err) { | 660 | if (!err) { |
661 | file = nameidata_to_filp(&nd, O_RDONLY); | 661 | file = nameidata_to_filp(&nd, |
662 | O_RDONLY|O_LARGEFILE); | ||
662 | if (!IS_ERR(file)) { | 663 | if (!IS_ERR(file)) { |
663 | err = deny_write_access(file); | 664 | err = deny_write_access(file); |
664 | if (err) { | 665 | if (err) { |
@@ -782,26 +783,8 @@ static int de_thread(struct task_struct *tsk) | |||
782 | zap_other_threads(tsk); | 783 | zap_other_threads(tsk); |
783 | read_unlock(&tasklist_lock); | 784 | read_unlock(&tasklist_lock); |
784 | 785 | ||
785 | /* | 786 | /* Account for the thread group leader hanging around: */ |
786 | * Account for the thread group leader hanging around: | 787 | count = thread_group_leader(tsk) ? 1 : 2; |
787 | */ | ||
788 | count = 1; | ||
789 | if (!thread_group_leader(tsk)) { | ||
790 | count = 2; | ||
791 | /* | ||
792 | * The SIGALRM timer survives the exec, but needs to point | ||
793 | * at us as the new group leader now. We have a race with | ||
794 | * a timer firing now getting the old leader, so we need to | ||
795 | * synchronize with any firing (by calling del_timer_sync) | ||
796 | * before we can safely let the old group leader die. | ||
797 | */ | ||
798 | sig->tsk = tsk; | ||
799 | spin_unlock_irq(lock); | ||
800 | if (hrtimer_cancel(&sig->real_timer)) | ||
801 | hrtimer_restart(&sig->real_timer); | ||
802 | spin_lock_irq(lock); | ||
803 | } | ||
804 | |||
805 | sig->notify_count = count; | 788 | sig->notify_count = count; |
806 | while (atomic_read(&sig->count) > count) { | 789 | while (atomic_read(&sig->count) > count) { |
807 | __set_current_state(TASK_UNINTERRUPTIBLE); | 790 | __set_current_state(TASK_UNINTERRUPTIBLE); |
@@ -1184,7 +1167,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) | |||
1184 | { | 1167 | { |
1185 | int try,retval; | 1168 | int try,retval; |
1186 | struct linux_binfmt *fmt; | 1169 | struct linux_binfmt *fmt; |
1187 | #ifdef __alpha__ | 1170 | #if defined(__alpha__) && defined(CONFIG_ARCH_SUPPORTS_AOUT) |
1188 | /* handle /sbin/loader.. */ | 1171 | /* handle /sbin/loader.. */ |
1189 | { | 1172 | { |
1190 | struct exec * eh = (struct exec *) bprm->buf; | 1173 | struct exec * eh = (struct exec *) bprm->buf; |
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index f1e5705e75f1..47d88da2d33b 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
@@ -126,7 +126,6 @@ extern unsigned long ext2_count_free (struct buffer_head *, unsigned); | |||
126 | /* inode.c */ | 126 | /* inode.c */ |
127 | extern struct inode *ext2_iget (struct super_block *, unsigned long); | 127 | extern struct inode *ext2_iget (struct super_block *, unsigned long); |
128 | extern int ext2_write_inode (struct inode *, int); | 128 | extern int ext2_write_inode (struct inode *, int); |
129 | extern void ext2_put_inode (struct inode *); | ||
130 | extern void ext2_delete_inode (struct inode *); | 129 | extern void ext2_delete_inode (struct inode *); |
131 | extern int ext2_sync_inode (struct inode *); | 130 | extern int ext2_sync_inode (struct inode *); |
132 | extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int); | 131 | extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int); |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 22f1010bf79f..088b011bb97e 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -285,6 +285,9 @@ static int ext2_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
285 | seq_puts(seq, ",xip"); | 285 | seq_puts(seq, ",xip"); |
286 | #endif | 286 | #endif |
287 | 287 | ||
288 | if (!test_opt(sb, RESERVATION)) | ||
289 | seq_puts(seq, ",noreservation"); | ||
290 | |||
288 | return 0; | 291 | return 0; |
289 | } | 292 | } |
290 | 293 | ||
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c index a75713031105..da0cb2c0e437 100644 --- a/fs/ext3/balloc.c +++ b/fs/ext3/balloc.c | |||
@@ -630,9 +630,7 @@ do_more: | |||
630 | jbd_unlock_bh_state(bitmap_bh); | 630 | jbd_unlock_bh_state(bitmap_bh); |
631 | 631 | ||
632 | spin_lock(sb_bgl_lock(sbi, block_group)); | 632 | spin_lock(sb_bgl_lock(sbi, block_group)); |
633 | desc->bg_free_blocks_count = | 633 | le16_add_cpu(&desc->bg_free_blocks_count, group_freed); |
634 | cpu_to_le16(le16_to_cpu(desc->bg_free_blocks_count) + | ||
635 | group_freed); | ||
636 | spin_unlock(sb_bgl_lock(sbi, block_group)); | 634 | spin_unlock(sb_bgl_lock(sbi, block_group)); |
637 | percpu_counter_add(&sbi->s_freeblocks_counter, count); | 635 | percpu_counter_add(&sbi->s_freeblocks_counter, count); |
638 | 636 | ||
@@ -1696,8 +1694,7 @@ allocated: | |||
1696 | ret_block, goal_hits, goal_attempts); | 1694 | ret_block, goal_hits, goal_attempts); |
1697 | 1695 | ||
1698 | spin_lock(sb_bgl_lock(sbi, group_no)); | 1696 | spin_lock(sb_bgl_lock(sbi, group_no)); |
1699 | gdp->bg_free_blocks_count = | 1697 | le16_add_cpu(&gdp->bg_free_blocks_count, -num); |
1700 | cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)-num); | ||
1701 | spin_unlock(sb_bgl_lock(sbi, group_no)); | 1698 | spin_unlock(sb_bgl_lock(sbi, group_no)); |
1702 | percpu_counter_sub(&sbi->s_freeblocks_counter, num); | 1699 | percpu_counter_sub(&sbi->s_freeblocks_counter, num); |
1703 | 1700 | ||
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 58ae2f943f12..4f4020c54683 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c | |||
@@ -164,11 +164,9 @@ void ext3_free_inode (handle_t *handle, struct inode * inode) | |||
164 | 164 | ||
165 | if (gdp) { | 165 | if (gdp) { |
166 | spin_lock(sb_bgl_lock(sbi, block_group)); | 166 | spin_lock(sb_bgl_lock(sbi, block_group)); |
167 | gdp->bg_free_inodes_count = cpu_to_le16( | 167 | le16_add_cpu(&gdp->bg_free_inodes_count, 1); |
168 | le16_to_cpu(gdp->bg_free_inodes_count) + 1); | ||
169 | if (is_directory) | 168 | if (is_directory) |
170 | gdp->bg_used_dirs_count = cpu_to_le16( | 169 | le16_add_cpu(&gdp->bg_used_dirs_count, -1); |
171 | le16_to_cpu(gdp->bg_used_dirs_count) - 1); | ||
172 | spin_unlock(sb_bgl_lock(sbi, block_group)); | 170 | spin_unlock(sb_bgl_lock(sbi, block_group)); |
173 | percpu_counter_inc(&sbi->s_freeinodes_counter); | 171 | percpu_counter_inc(&sbi->s_freeinodes_counter); |
174 | if (is_directory) | 172 | if (is_directory) |
@@ -527,11 +525,9 @@ got: | |||
527 | err = ext3_journal_get_write_access(handle, bh2); | 525 | err = ext3_journal_get_write_access(handle, bh2); |
528 | if (err) goto fail; | 526 | if (err) goto fail; |
529 | spin_lock(sb_bgl_lock(sbi, group)); | 527 | spin_lock(sb_bgl_lock(sbi, group)); |
530 | gdp->bg_free_inodes_count = | 528 | le16_add_cpu(&gdp->bg_free_inodes_count, -1); |
531 | cpu_to_le16(le16_to_cpu(gdp->bg_free_inodes_count) - 1); | ||
532 | if (S_ISDIR(mode)) { | 529 | if (S_ISDIR(mode)) { |
533 | gdp->bg_used_dirs_count = | 530 | le16_add_cpu(&gdp->bg_used_dirs_count, 1); |
534 | cpu_to_le16(le16_to_cpu(gdp->bg_used_dirs_count) + 1); | ||
535 | } | 531 | } |
536 | spin_unlock(sb_bgl_lock(sbi, group)); | 532 | spin_unlock(sb_bgl_lock(sbi, group)); |
537 | BUFFER_TRACE(bh2, "call ext3_journal_dirty_metadata"); | 533 | BUFFER_TRACE(bh2, "call ext3_journal_dirty_metadata"); |
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c index ebc05af7343a..9397d779c43d 100644 --- a/fs/ext3/resize.c +++ b/fs/ext3/resize.c | |||
@@ -518,8 +518,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, | |||
518 | EXT3_SB(sb)->s_gdb_count++; | 518 | EXT3_SB(sb)->s_gdb_count++; |
519 | kfree(o_group_desc); | 519 | kfree(o_group_desc); |
520 | 520 | ||
521 | es->s_reserved_gdt_blocks = | 521 | le16_add_cpu(&es->s_reserved_gdt_blocks, -1); |
522 | cpu_to_le16(le16_to_cpu(es->s_reserved_gdt_blocks) - 1); | ||
523 | ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); | 522 | ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); |
524 | 523 | ||
525 | return 0; | 524 | return 0; |
@@ -890,10 +889,8 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input) | |||
890 | * blocks/inodes before the group is live won't actually let us | 889 | * blocks/inodes before the group is live won't actually let us |
891 | * allocate the new space yet. | 890 | * allocate the new space yet. |
892 | */ | 891 | */ |
893 | es->s_blocks_count = cpu_to_le32(le32_to_cpu(es->s_blocks_count) + | 892 | le32_add_cpu(&es->s_blocks_count, input->blocks_count); |
894 | input->blocks_count); | 893 | le32_add_cpu(&es->s_inodes_count, EXT3_INODES_PER_GROUP(sb)); |
895 | es->s_inodes_count = cpu_to_le32(le32_to_cpu(es->s_inodes_count) + | ||
896 | EXT3_INODES_PER_GROUP(sb)); | ||
897 | 894 | ||
898 | /* | 895 | /* |
899 | * We need to protect s_groups_count against other CPUs seeing | 896 | * We need to protect s_groups_count against other CPUs seeing |
@@ -926,8 +923,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input) | |||
926 | 923 | ||
927 | /* Update the reserved block counts only once the new group is | 924 | /* Update the reserved block counts only once the new group is |
928 | * active. */ | 925 | * active. */ |
929 | es->s_r_blocks_count = cpu_to_le32(le32_to_cpu(es->s_r_blocks_count) + | 926 | le32_add_cpu(&es->s_r_blocks_count, input->reserved_blocks); |
930 | input->reserved_blocks); | ||
931 | 927 | ||
932 | /* Update the free space counts */ | 928 | /* Update the free space counts */ |
933 | percpu_counter_add(&sbi->s_freeblocks_counter, | 929 | percpu_counter_add(&sbi->s_freeblocks_counter, |
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index cf2a2c3660ec..8e02cbfb1123 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -1222,7 +1222,7 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, | |||
1222 | #endif | 1222 | #endif |
1223 | if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) | 1223 | if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) |
1224 | es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT); | 1224 | es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT); |
1225 | es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1); | 1225 | le16_add_cpu(&es->s_mnt_count, 1); |
1226 | es->s_mtime = cpu_to_le32(get_seconds()); | 1226 | es->s_mtime = cpu_to_le32(get_seconds()); |
1227 | ext3_update_dynamic_rev(sb); | 1227 | ext3_update_dynamic_rev(sb); |
1228 | EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); | 1228 | EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); |
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c index 408373819e34..fb89c299bece 100644 --- a/fs/ext3/xattr.c +++ b/fs/ext3/xattr.c | |||
@@ -492,8 +492,7 @@ ext3_xattr_release_block(handle_t *handle, struct inode *inode, | |||
492 | get_bh(bh); | 492 | get_bh(bh); |
493 | ext3_forget(handle, 1, inode, bh, bh->b_blocknr); | 493 | ext3_forget(handle, 1, inode, bh, bh->b_blocknr); |
494 | } else { | 494 | } else { |
495 | BHDR(bh)->h_refcount = cpu_to_le32( | 495 | le32_add_cpu(&BHDR(bh)->h_refcount, -1); |
496 | le32_to_cpu(BHDR(bh)->h_refcount) - 1); | ||
497 | error = ext3_journal_dirty_metadata(handle, bh); | 496 | error = ext3_journal_dirty_metadata(handle, bh); |
498 | if (IS_SYNC(inode)) | 497 | if (IS_SYNC(inode)) |
499 | handle->h_sync = 1; | 498 | handle->h_sync = 1; |
@@ -780,8 +779,7 @@ inserted: | |||
780 | if (error) | 779 | if (error) |
781 | goto cleanup_dquot; | 780 | goto cleanup_dquot; |
782 | lock_buffer(new_bh); | 781 | lock_buffer(new_bh); |
783 | BHDR(new_bh)->h_refcount = cpu_to_le32(1 + | 782 | le32_add_cpu(&BHDR(new_bh)->h_refcount, 1); |
784 | le32_to_cpu(BHDR(new_bh)->h_refcount)); | ||
785 | ea_bdebug(new_bh, "reusing; refcount now=%d", | 783 | ea_bdebug(new_bh, "reusing; refcount now=%d", |
786 | le32_to_cpu(BHDR(new_bh)->h_refcount)); | 784 | le32_to_cpu(BHDR(new_bh)->h_refcount)); |
787 | unlock_buffer(new_bh); | 785 | unlock_buffer(new_bh); |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 085269e07fb3..53f3cf62b7c1 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -837,6 +837,8 @@ static int fat_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
837 | if (!opts->numtail) | 837 | if (!opts->numtail) |
838 | seq_puts(m, ",nonumtail"); | 838 | seq_puts(m, ",nonumtail"); |
839 | } | 839 | } |
840 | if (sbi->options.flush) | ||
841 | seq_puts(m, ",flush"); | ||
840 | 842 | ||
841 | return 0; | 843 | return 0; |
842 | } | 844 | } |
diff --git a/fs/fcntl.c b/fs/fcntl.c index 8685263ccc4a..e632da761fc1 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <asm/siginfo.h> | 24 | #include <asm/siginfo.h> |
25 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
26 | 26 | ||
27 | void fastcall set_close_on_exec(unsigned int fd, int flag) | 27 | void set_close_on_exec(unsigned int fd, int flag) |
28 | { | 28 | { |
29 | struct files_struct *files = current->files; | 29 | struct files_struct *files = current->files; |
30 | struct fdtable *fdt; | 30 | struct fdtable *fdt; |
@@ -309,7 +309,7 @@ pid_t f_getown(struct file *filp) | |||
309 | { | 309 | { |
310 | pid_t pid; | 310 | pid_t pid; |
311 | read_lock(&filp->f_owner.lock); | 311 | read_lock(&filp->f_owner.lock); |
312 | pid = pid_nr_ns(filp->f_owner.pid, current->nsproxy->pid_ns); | 312 | pid = pid_vnr(filp->f_owner.pid); |
313 | if (filp->f_owner.pid_type == PIDTYPE_PGID) | 313 | if (filp->f_owner.pid_type == PIDTYPE_PGID) |
314 | pid = -pid; | 314 | pid = -pid; |
315 | read_unlock(&filp->f_owner.lock); | 315 | read_unlock(&filp->f_owner.lock); |
diff --git a/fs/file_table.c b/fs/file_table.c index 664e3f2309b8..6d27befe2d48 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
@@ -197,7 +197,7 @@ int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry, | |||
197 | } | 197 | } |
198 | EXPORT_SYMBOL(init_file); | 198 | EXPORT_SYMBOL(init_file); |
199 | 199 | ||
200 | void fastcall fput(struct file *file) | 200 | void fput(struct file *file) |
201 | { | 201 | { |
202 | if (atomic_dec_and_test(&file->f_count)) | 202 | if (atomic_dec_and_test(&file->f_count)) |
203 | __fput(file); | 203 | __fput(file); |
@@ -208,7 +208,7 @@ EXPORT_SYMBOL(fput); | |||
208 | /* __fput is called from task context when aio completion releases the last | 208 | /* __fput is called from task context when aio completion releases the last |
209 | * last use of a struct file *. Do not use otherwise. | 209 | * last use of a struct file *. Do not use otherwise. |
210 | */ | 210 | */ |
211 | void fastcall __fput(struct file *file) | 211 | void __fput(struct file *file) |
212 | { | 212 | { |
213 | struct dentry *dentry = file->f_path.dentry; | 213 | struct dentry *dentry = file->f_path.dentry; |
214 | struct vfsmount *mnt = file->f_path.mnt; | 214 | struct vfsmount *mnt = file->f_path.mnt; |
@@ -241,7 +241,7 @@ void fastcall __fput(struct file *file) | |||
241 | mntput(mnt); | 241 | mntput(mnt); |
242 | } | 242 | } |
243 | 243 | ||
244 | struct file fastcall *fget(unsigned int fd) | 244 | struct file *fget(unsigned int fd) |
245 | { | 245 | { |
246 | struct file *file; | 246 | struct file *file; |
247 | struct files_struct *files = current->files; | 247 | struct files_struct *files = current->files; |
@@ -269,7 +269,7 @@ EXPORT_SYMBOL(fget); | |||
269 | * and a flag is returned to be passed to the corresponding fput_light(). | 269 | * and a flag is returned to be passed to the corresponding fput_light(). |
270 | * There must not be a cloning between an fget_light/fput_light pair. | 270 | * There must not be a cloning between an fget_light/fput_light pair. |
271 | */ | 271 | */ |
272 | struct file fastcall *fget_light(unsigned int fd, int *fput_needed) | 272 | struct file *fget_light(unsigned int fd, int *fput_needed) |
273 | { | 273 | { |
274 | struct file *file; | 274 | struct file *file; |
275 | struct files_struct *files = current->files; | 275 | struct files_struct *files = current->files; |
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index db80ce9eb1d0..c0076077d338 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -655,7 +655,7 @@ int write_inode_now(struct inode *inode, int sync) | |||
655 | int ret; | 655 | int ret; |
656 | struct writeback_control wbc = { | 656 | struct writeback_control wbc = { |
657 | .nr_to_write = LONG_MAX, | 657 | .nr_to_write = LONG_MAX, |
658 | .sync_mode = WB_SYNC_ALL, | 658 | .sync_mode = sync ? WB_SYNC_ALL : WB_SYNC_NONE, |
659 | .range_start = 0, | 659 | .range_start = 0, |
660 | .range_end = LLONG_MAX, | 660 | .range_end = LLONG_MAX, |
661 | }; | 661 | }; |
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 574707409bbf..033f7bdd47e8 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -29,6 +29,8 @@ DEFINE_MUTEX(fuse_mutex); | |||
29 | 29 | ||
30 | #define FUSE_SUPER_MAGIC 0x65735546 | 30 | #define FUSE_SUPER_MAGIC 0x65735546 |
31 | 31 | ||
32 | #define FUSE_DEFAULT_BLKSIZE 512 | ||
33 | |||
32 | struct fuse_mount_data { | 34 | struct fuse_mount_data { |
33 | int fd; | 35 | int fd; |
34 | unsigned rootmode; | 36 | unsigned rootmode; |
@@ -355,7 +357,7 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev) | |||
355 | char *p; | 357 | char *p; |
356 | memset(d, 0, sizeof(struct fuse_mount_data)); | 358 | memset(d, 0, sizeof(struct fuse_mount_data)); |
357 | d->max_read = ~0; | 359 | d->max_read = ~0; |
358 | d->blksize = 512; | 360 | d->blksize = FUSE_DEFAULT_BLKSIZE; |
359 | 361 | ||
360 | while ((p = strsep(&opt, ",")) != NULL) { | 362 | while ((p = strsep(&opt, ",")) != NULL) { |
361 | int token; | 363 | int token; |
@@ -440,6 +442,9 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
440 | seq_puts(m, ",allow_other"); | 442 | seq_puts(m, ",allow_other"); |
441 | if (fc->max_read != ~0) | 443 | if (fc->max_read != ~0) |
442 | seq_printf(m, ",max_read=%u", fc->max_read); | 444 | seq_printf(m, ",max_read=%u", fc->max_read); |
445 | if (mnt->mnt_sb->s_bdev && | ||
446 | mnt->mnt_sb->s_blocksize != FUSE_DEFAULT_BLKSIZE) | ||
447 | seq_printf(m, ",blksize=%lu", mnt->mnt_sb->s_blocksize); | ||
443 | return 0; | 448 | return 0; |
444 | } | 449 | } |
445 | 450 | ||
diff --git a/fs/hfsplus/unicode.c b/fs/hfsplus/unicode.c index 9e10f9444b64..628ccf6fa402 100644 --- a/fs/hfsplus/unicode.c +++ b/fs/hfsplus/unicode.c | |||
@@ -325,7 +325,7 @@ int hfsplus_hash_dentry(struct dentry *dentry, struct qstr *str) | |||
325 | struct super_block *sb = dentry->d_sb; | 325 | struct super_block *sb = dentry->d_sb; |
326 | const char *astr; | 326 | const char *astr; |
327 | const u16 *dstr; | 327 | const u16 *dstr; |
328 | int casefold, decompose, size, dsize, len; | 328 | int casefold, decompose, size, len; |
329 | unsigned long hash; | 329 | unsigned long hash; |
330 | wchar_t c; | 330 | wchar_t c; |
331 | u16 c2; | 331 | u16 c2; |
@@ -336,6 +336,7 @@ int hfsplus_hash_dentry(struct dentry *dentry, struct qstr *str) | |||
336 | astr = str->name; | 336 | astr = str->name; |
337 | len = str->len; | 337 | len = str->len; |
338 | while (len > 0) { | 338 | while (len > 0) { |
339 | int uninitialized_var(dsize); | ||
339 | size = asc2unichar(sb, astr, len, &c); | 340 | size = asc2unichar(sb, astr, len, &c); |
340 | astr += size; | 341 | astr += size; |
341 | len -= size; | 342 | len -= size; |
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 2b9b35733aac..d0549cb4fb23 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
12 | #include <linux/pagemap.h> | 12 | #include <linux/pagemap.h> |
13 | #include <linux/statfs.h> | 13 | #include <linux/statfs.h> |
14 | #include <linux/seq_file.h> | ||
14 | #include "hostfs.h" | 15 | #include "hostfs.h" |
15 | #include "init.h" | 16 | #include "init.h" |
16 | #include "kern.h" | 17 | #include "kern.h" |
@@ -322,12 +323,25 @@ static void hostfs_destroy_inode(struct inode *inode) | |||
322 | kfree(HOSTFS_I(inode)); | 323 | kfree(HOSTFS_I(inode)); |
323 | } | 324 | } |
324 | 325 | ||
326 | static int hostfs_show_options(struct seq_file *seq, struct vfsmount *vfs) | ||
327 | { | ||
328 | struct inode *root = vfs->mnt_sb->s_root->d_inode; | ||
329 | const char *root_path = HOSTFS_I(root)->host_filename; | ||
330 | size_t offset = strlen(root_ino) + 1; | ||
331 | |||
332 | if (strlen(root_path) > offset) | ||
333 | seq_printf(seq, ",%s", root_path + offset); | ||
334 | |||
335 | return 0; | ||
336 | } | ||
337 | |||
325 | static const struct super_operations hostfs_sbops = { | 338 | static const struct super_operations hostfs_sbops = { |
326 | .alloc_inode = hostfs_alloc_inode, | 339 | .alloc_inode = hostfs_alloc_inode, |
327 | .drop_inode = generic_delete_inode, | 340 | .drop_inode = generic_delete_inode, |
328 | .delete_inode = hostfs_delete_inode, | 341 | .delete_inode = hostfs_delete_inode, |
329 | .destroy_inode = hostfs_destroy_inode, | 342 | .destroy_inode = hostfs_destroy_inode, |
330 | .statfs = hostfs_statfs, | 343 | .statfs = hostfs_statfs, |
344 | .show_options = hostfs_show_options, | ||
331 | }; | 345 | }; |
332 | 346 | ||
333 | int hostfs_readdir(struct file *file, void *ent, filldir_t filldir) | 347 | int hostfs_readdir(struct file *file, void *ent, filldir_t filldir) |
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index 00971d999964..f63a699ec659 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c | |||
@@ -386,6 +386,7 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) | |||
386 | int lowercase, conv, eas, chk, errs, chkdsk, timeshift; | 386 | int lowercase, conv, eas, chk, errs, chkdsk, timeshift; |
387 | int o; | 387 | int o; |
388 | struct hpfs_sb_info *sbi = hpfs_sb(s); | 388 | struct hpfs_sb_info *sbi = hpfs_sb(s); |
389 | char *new_opts = kstrdup(data, GFP_KERNEL); | ||
389 | 390 | ||
390 | *flags |= MS_NOATIME; | 391 | *flags |= MS_NOATIME; |
391 | 392 | ||
@@ -398,15 +399,15 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) | |||
398 | if (!(o = parse_opts(data, &uid, &gid, &umask, &lowercase, &conv, | 399 | if (!(o = parse_opts(data, &uid, &gid, &umask, &lowercase, &conv, |
399 | &eas, &chk, &errs, &chkdsk, ×hift))) { | 400 | &eas, &chk, &errs, &chkdsk, ×hift))) { |
400 | printk("HPFS: bad mount options.\n"); | 401 | printk("HPFS: bad mount options.\n"); |
401 | return 1; | 402 | goto out_err; |
402 | } | 403 | } |
403 | if (o == 2) { | 404 | if (o == 2) { |
404 | hpfs_help(); | 405 | hpfs_help(); |
405 | return 1; | 406 | goto out_err; |
406 | } | 407 | } |
407 | if (timeshift != sbi->sb_timeshift) { | 408 | if (timeshift != sbi->sb_timeshift) { |
408 | printk("HPFS: timeshift can't be changed using remount.\n"); | 409 | printk("HPFS: timeshift can't be changed using remount.\n"); |
409 | return 1; | 410 | goto out_err; |
410 | } | 411 | } |
411 | 412 | ||
412 | unmark_dirty(s); | 413 | unmark_dirty(s); |
@@ -419,7 +420,14 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) | |||
419 | 420 | ||
420 | if (!(*flags & MS_RDONLY)) mark_dirty(s); | 421 | if (!(*flags & MS_RDONLY)) mark_dirty(s); |
421 | 422 | ||
423 | kfree(s->s_options); | ||
424 | s->s_options = new_opts; | ||
425 | |||
422 | return 0; | 426 | return 0; |
427 | |||
428 | out_err: | ||
429 | kfree(new_opts); | ||
430 | return -EINVAL; | ||
423 | } | 431 | } |
424 | 432 | ||
425 | /* Super operations */ | 433 | /* Super operations */ |
@@ -432,6 +440,7 @@ static const struct super_operations hpfs_sops = | |||
432 | .put_super = hpfs_put_super, | 440 | .put_super = hpfs_put_super, |
433 | .statfs = hpfs_statfs, | 441 | .statfs = hpfs_statfs, |
434 | .remount_fs = hpfs_remount_fs, | 442 | .remount_fs = hpfs_remount_fs, |
443 | .show_options = generic_show_options, | ||
435 | }; | 444 | }; |
436 | 445 | ||
437 | static int hpfs_fill_super(struct super_block *s, void *options, int silent) | 446 | static int hpfs_fill_super(struct super_block *s, void *options, int silent) |
@@ -454,6 +463,8 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
454 | 463 | ||
455 | int o; | 464 | int o; |
456 | 465 | ||
466 | save_mount_options(s, options); | ||
467 | |||
457 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 468 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
458 | if (!sbi) | 469 | if (!sbi) |
459 | return -ENOMEM; | 470 | return -ENOMEM; |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 3b3cc28cdefc..eee9487ae47f 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -734,6 +734,7 @@ static const struct super_operations hugetlbfs_ops = { | |||
734 | .delete_inode = hugetlbfs_delete_inode, | 734 | .delete_inode = hugetlbfs_delete_inode, |
735 | .drop_inode = hugetlbfs_drop_inode, | 735 | .drop_inode = hugetlbfs_drop_inode, |
736 | .put_super = hugetlbfs_put_super, | 736 | .put_super = hugetlbfs_put_super, |
737 | .show_options = generic_show_options, | ||
737 | }; | 738 | }; |
738 | 739 | ||
739 | static int | 740 | static int |
@@ -817,6 +818,8 @@ hugetlbfs_fill_super(struct super_block *sb, void *data, int silent) | |||
817 | struct hugetlbfs_config config; | 818 | struct hugetlbfs_config config; |
818 | struct hugetlbfs_sb_info *sbinfo; | 819 | struct hugetlbfs_sb_info *sbinfo; |
819 | 820 | ||
821 | save_mount_options(sb, data); | ||
822 | |||
820 | config.nr_blocks = -1; /* No limit on size by default */ | 823 | config.nr_blocks = -1; /* No limit on size by default */ |
821 | config.nr_inodes = -1; /* No limit on number of inodes by default */ | 824 | config.nr_inodes = -1; /* No limit on number of inodes by default */ |
822 | config.uid = current->fsuid; | 825 | config.uid = current->fsuid; |
diff --git a/fs/inotify_user.c b/fs/inotify_user.c index a336c9709f3c..3ab09a65c456 100644 --- a/fs/inotify_user.c +++ b/fs/inotify_user.c | |||
@@ -283,7 +283,7 @@ static void inotify_dev_queue_event(struct inotify_watch *w, u32 wd, u32 mask, | |||
283 | /* we can safely put the watch as we don't reference it while | 283 | /* we can safely put the watch as we don't reference it while |
284 | * generating the event | 284 | * generating the event |
285 | */ | 285 | */ |
286 | if (mask & IN_IGNORED || mask & IN_ONESHOT) | 286 | if (mask & IN_IGNORED || w->mask & IN_ONESHOT) |
287 | put_inotify_watch(w); /* final put */ | 287 | put_inotify_watch(w); /* final put */ |
288 | 288 | ||
289 | /* coalescing: drop this event if it is a dupe of the previous */ | 289 | /* coalescing: drop this event if it is a dupe of the previous */ |
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 875d37fb6c70..044a254d526b 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c | |||
@@ -110,6 +110,7 @@ static const struct super_operations isofs_sops = { | |||
110 | .put_super = isofs_put_super, | 110 | .put_super = isofs_put_super, |
111 | .statfs = isofs_statfs, | 111 | .statfs = isofs_statfs, |
112 | .remount_fs = isofs_remount, | 112 | .remount_fs = isofs_remount, |
113 | .show_options = generic_show_options, | ||
113 | }; | 114 | }; |
114 | 115 | ||
115 | 116 | ||
@@ -144,7 +145,8 @@ struct iso9660_options{ | |||
144 | char nocompress; | 145 | char nocompress; |
145 | unsigned char check; | 146 | unsigned char check; |
146 | unsigned int blocksize; | 147 | unsigned int blocksize; |
147 | mode_t mode; | 148 | mode_t fmode; |
149 | mode_t dmode; | ||
148 | gid_t gid; | 150 | gid_t gid; |
149 | uid_t uid; | 151 | uid_t uid; |
150 | char *iocharset; | 152 | char *iocharset; |
@@ -305,7 +307,7 @@ enum { | |||
305 | Opt_block, Opt_check_r, Opt_check_s, Opt_cruft, Opt_gid, Opt_ignore, | 307 | Opt_block, Opt_check_r, Opt_check_s, Opt_cruft, Opt_gid, Opt_ignore, |
306 | Opt_iocharset, Opt_map_a, Opt_map_n, Opt_map_o, Opt_mode, Opt_nojoliet, | 308 | Opt_iocharset, Opt_map_a, Opt_map_n, Opt_map_o, Opt_mode, Opt_nojoliet, |
307 | Opt_norock, Opt_sb, Opt_session, Opt_uid, Opt_unhide, Opt_utf8, Opt_err, | 309 | Opt_norock, Opt_sb, Opt_session, Opt_uid, Opt_unhide, Opt_utf8, Opt_err, |
308 | Opt_nocompress, Opt_hide, Opt_showassoc, | 310 | Opt_nocompress, Opt_hide, Opt_showassoc, Opt_dmode, |
309 | }; | 311 | }; |
310 | 312 | ||
311 | static match_table_t tokens = { | 313 | static match_table_t tokens = { |
@@ -332,6 +334,7 @@ static match_table_t tokens = { | |||
332 | {Opt_uid, "uid=%u"}, | 334 | {Opt_uid, "uid=%u"}, |
333 | {Opt_gid, "gid=%u"}, | 335 | {Opt_gid, "gid=%u"}, |
334 | {Opt_mode, "mode=%u"}, | 336 | {Opt_mode, "mode=%u"}, |
337 | {Opt_dmode, "dmode=%u"}, | ||
335 | {Opt_block, "block=%u"}, | 338 | {Opt_block, "block=%u"}, |
336 | {Opt_ignore, "conv=binary"}, | 339 | {Opt_ignore, "conv=binary"}, |
337 | {Opt_ignore, "conv=b"}, | 340 | {Opt_ignore, "conv=b"}, |
@@ -359,7 +362,7 @@ static int parse_options(char *options, struct iso9660_options *popt) | |||
359 | popt->check = 'u'; /* unset */ | 362 | popt->check = 'u'; /* unset */ |
360 | popt->nocompress = 0; | 363 | popt->nocompress = 0; |
361 | popt->blocksize = 1024; | 364 | popt->blocksize = 1024; |
362 | popt->mode = S_IRUGO | S_IXUGO; /* | 365 | popt->fmode = popt->dmode = S_IRUGO | S_IXUGO; /* |
363 | * r-x for all. The disc could | 366 | * r-x for all. The disc could |
364 | * be shared with DOS machines so | 367 | * be shared with DOS machines so |
365 | * virtually anything could be | 368 | * virtually anything could be |
@@ -451,7 +454,12 @@ static int parse_options(char *options, struct iso9660_options *popt) | |||
451 | case Opt_mode: | 454 | case Opt_mode: |
452 | if (match_int(&args[0], &option)) | 455 | if (match_int(&args[0], &option)) |
453 | return 0; | 456 | return 0; |
454 | popt->mode = option; | 457 | popt->fmode = option; |
458 | break; | ||
459 | case Opt_dmode: | ||
460 | if (match_int(&args[0], &option)) | ||
461 | return 0; | ||
462 | popt->dmode = option; | ||
455 | break; | 463 | break; |
456 | case Opt_block: | 464 | case Opt_block: |
457 | if (match_int(&args[0], &option)) | 465 | if (match_int(&args[0], &option)) |
@@ -554,6 +562,8 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) | |||
554 | int table, error = -EINVAL; | 562 | int table, error = -EINVAL; |
555 | unsigned int vol_desc_start; | 563 | unsigned int vol_desc_start; |
556 | 564 | ||
565 | save_mount_options(s, data); | ||
566 | |||
557 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 567 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
558 | if (!sbi) | 568 | if (!sbi) |
559 | return -ENOMEM; | 569 | return -ENOMEM; |
@@ -801,7 +811,8 @@ root_found: | |||
801 | * on the disk as suid, so we merely allow them to set the default | 811 | * on the disk as suid, so we merely allow them to set the default |
802 | * permissions. | 812 | * permissions. |
803 | */ | 813 | */ |
804 | sbi->s_mode = opt.mode & 0777; | 814 | sbi->s_fmode = opt.fmode & 0777; |
815 | sbi->s_dmode = opt.dmode & 0777; | ||
805 | 816 | ||
806 | /* | 817 | /* |
807 | * Read the root inode, which _may_ result in changing | 818 | * Read the root inode, which _may_ result in changing |
@@ -1248,7 +1259,7 @@ static int isofs_read_inode(struct inode *inode) | |||
1248 | ei->i_file_format = isofs_file_normal; | 1259 | ei->i_file_format = isofs_file_normal; |
1249 | 1260 | ||
1250 | if (de->flags[-high_sierra] & 2) { | 1261 | if (de->flags[-high_sierra] & 2) { |
1251 | inode->i_mode = S_IRUGO | S_IXUGO | S_IFDIR; | 1262 | inode->i_mode = sbi->s_dmode | S_IFDIR; |
1252 | inode->i_nlink = 1; /* | 1263 | inode->i_nlink = 1; /* |
1253 | * Set to 1. We know there are 2, but | 1264 | * Set to 1. We know there are 2, but |
1254 | * the find utility tries to optimize | 1265 | * the find utility tries to optimize |
@@ -1258,9 +1269,8 @@ static int isofs_read_inode(struct inode *inode) | |||
1258 | */ | 1269 | */ |
1259 | } else { | 1270 | } else { |
1260 | /* Everybody gets to read the file. */ | 1271 | /* Everybody gets to read the file. */ |
1261 | inode->i_mode = sbi->s_mode; | 1272 | inode->i_mode = sbi->s_fmode | S_IFREG; |
1262 | inode->i_nlink = 1; | 1273 | inode->i_nlink = 1; |
1263 | inode->i_mode |= S_IFREG; | ||
1264 | } | 1274 | } |
1265 | inode->i_uid = sbi->s_uid; | 1275 | inode->i_uid = sbi->s_uid; |
1266 | inode->i_gid = sbi->s_gid; | 1276 | inode->i_gid = sbi->s_gid; |
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h index f3213f9f89af..d1bdf8adb351 100644 --- a/fs/isofs/isofs.h +++ b/fs/isofs/isofs.h | |||
@@ -51,7 +51,8 @@ struct isofs_sb_info { | |||
51 | unsigned char s_hide; | 51 | unsigned char s_hide; |
52 | unsigned char s_showassoc; | 52 | unsigned char s_showassoc; |
53 | 53 | ||
54 | mode_t s_mode; | 54 | mode_t s_fmode; |
55 | mode_t s_dmode; | ||
55 | gid_t s_gid; | 56 | gid_t s_gid; |
56 | uid_t s_uid; | 57 | uid_t s_uid; |
57 | struct nls_table *s_nls_iocharset; /* Native language support table */ | 58 | struct nls_table *s_nls_iocharset; /* Native language support table */ |
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c index 31853eb65b4c..8e08efcaede2 100644 --- a/fs/jbd/commit.c +++ b/fs/jbd/commit.c | |||
@@ -131,6 +131,8 @@ static int journal_write_commit_record(journal_t *journal, | |||
131 | barrier_done = 1; | 131 | barrier_done = 1; |
132 | } | 132 | } |
133 | ret = sync_dirty_buffer(bh); | 133 | ret = sync_dirty_buffer(bh); |
134 | if (barrier_done) | ||
135 | clear_buffer_ordered(bh); | ||
134 | /* is it possible for another commit to fail at roughly | 136 | /* is it possible for another commit to fail at roughly |
135 | * the same time as this one? If so, we don't want to | 137 | * the same time as this one? If so, we don't want to |
136 | * trust the barrier flag in the super, but instead want | 138 | * trust the barrier flag in the super, but instead want |
@@ -148,7 +150,6 @@ static int journal_write_commit_record(journal_t *journal, | |||
148 | spin_unlock(&journal->j_state_lock); | 150 | spin_unlock(&journal->j_state_lock); |
149 | 151 | ||
150 | /* And try again, without the barrier */ | 152 | /* And try again, without the barrier */ |
151 | clear_buffer_ordered(bh); | ||
152 | set_buffer_uptodate(bh); | 153 | set_buffer_uptodate(bh); |
153 | set_buffer_dirty(bh); | 154 | set_buffer_dirty(bh); |
154 | ret = sync_dirty_buffer(bh); | 155 | ret = sync_dirty_buffer(bh); |
diff --git a/fs/libfs.c b/fs/libfs.c index 5523bde96387..b004dfadd891 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -583,8 +583,8 @@ int simple_transaction_release(struct inode *inode, struct file *file) | |||
583 | /* Simple attribute files */ | 583 | /* Simple attribute files */ |
584 | 584 | ||
585 | struct simple_attr { | 585 | struct simple_attr { |
586 | u64 (*get)(void *); | 586 | int (*get)(void *, u64 *); |
587 | void (*set)(void *, u64); | 587 | int (*set)(void *, u64); |
588 | char get_buf[24]; /* enough to store a u64 and "\n\0" */ | 588 | char get_buf[24]; /* enough to store a u64 and "\n\0" */ |
589 | char set_buf[24]; | 589 | char set_buf[24]; |
590 | void *data; | 590 | void *data; |
@@ -595,7 +595,7 @@ struct simple_attr { | |||
595 | /* simple_attr_open is called by an actual attribute open file operation | 595 | /* simple_attr_open is called by an actual attribute open file operation |
596 | * to set the attribute specific access operations. */ | 596 | * to set the attribute specific access operations. */ |
597 | int simple_attr_open(struct inode *inode, struct file *file, | 597 | int simple_attr_open(struct inode *inode, struct file *file, |
598 | u64 (*get)(void *), void (*set)(void *, u64), | 598 | int (*get)(void *, u64 *), int (*set)(void *, u64), |
599 | const char *fmt) | 599 | const char *fmt) |
600 | { | 600 | { |
601 | struct simple_attr *attr; | 601 | struct simple_attr *attr; |
@@ -615,7 +615,7 @@ int simple_attr_open(struct inode *inode, struct file *file, | |||
615 | return nonseekable_open(inode, file); | 615 | return nonseekable_open(inode, file); |
616 | } | 616 | } |
617 | 617 | ||
618 | int simple_attr_close(struct inode *inode, struct file *file) | 618 | int simple_attr_release(struct inode *inode, struct file *file) |
619 | { | 619 | { |
620 | kfree(file->private_data); | 620 | kfree(file->private_data); |
621 | return 0; | 621 | return 0; |
@@ -634,15 +634,24 @@ ssize_t simple_attr_read(struct file *file, char __user *buf, | |||
634 | if (!attr->get) | 634 | if (!attr->get) |
635 | return -EACCES; | 635 | return -EACCES; |
636 | 636 | ||
637 | mutex_lock(&attr->mutex); | 637 | ret = mutex_lock_interruptible(&attr->mutex); |
638 | if (*ppos) /* continued read */ | 638 | if (ret) |
639 | return ret; | ||
640 | |||
641 | if (*ppos) { /* continued read */ | ||
639 | size = strlen(attr->get_buf); | 642 | size = strlen(attr->get_buf); |
640 | else /* first read */ | 643 | } else { /* first read */ |
644 | u64 val; | ||
645 | ret = attr->get(attr->data, &val); | ||
646 | if (ret) | ||
647 | goto out; | ||
648 | |||
641 | size = scnprintf(attr->get_buf, sizeof(attr->get_buf), | 649 | size = scnprintf(attr->get_buf, sizeof(attr->get_buf), |
642 | attr->fmt, | 650 | attr->fmt, (unsigned long long)val); |
643 | (unsigned long long)attr->get(attr->data)); | 651 | } |
644 | 652 | ||
645 | ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size); | 653 | ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size); |
654 | out: | ||
646 | mutex_unlock(&attr->mutex); | 655 | mutex_unlock(&attr->mutex); |
647 | return ret; | 656 | return ret; |
648 | } | 657 | } |
@@ -657,11 +666,13 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf, | |||
657 | ssize_t ret; | 666 | ssize_t ret; |
658 | 667 | ||
659 | attr = file->private_data; | 668 | attr = file->private_data; |
660 | |||
661 | if (!attr->set) | 669 | if (!attr->set) |
662 | return -EACCES; | 670 | return -EACCES; |
663 | 671 | ||
664 | mutex_lock(&attr->mutex); | 672 | ret = mutex_lock_interruptible(&attr->mutex); |
673 | if (ret) | ||
674 | return ret; | ||
675 | |||
665 | ret = -EFAULT; | 676 | ret = -EFAULT; |
666 | size = min(sizeof(attr->set_buf) - 1, len); | 677 | size = min(sizeof(attr->set_buf) - 1, len); |
667 | if (copy_from_user(attr->set_buf, buf, size)) | 678 | if (copy_from_user(attr->set_buf, buf, size)) |
@@ -793,6 +804,6 @@ EXPORT_SYMBOL(simple_transaction_get); | |||
793 | EXPORT_SYMBOL(simple_transaction_read); | 804 | EXPORT_SYMBOL(simple_transaction_read); |
794 | EXPORT_SYMBOL(simple_transaction_release); | 805 | EXPORT_SYMBOL(simple_transaction_release); |
795 | EXPORT_SYMBOL_GPL(simple_attr_open); | 806 | EXPORT_SYMBOL_GPL(simple_attr_open); |
796 | EXPORT_SYMBOL_GPL(simple_attr_close); | 807 | EXPORT_SYMBOL_GPL(simple_attr_release); |
797 | EXPORT_SYMBOL_GPL(simple_attr_read); | 808 | EXPORT_SYMBOL_GPL(simple_attr_read); |
798 | EXPORT_SYMBOL_GPL(simple_attr_write); | 809 | EXPORT_SYMBOL_GPL(simple_attr_write); |
diff --git a/fs/locks.c b/fs/locks.c index 49354b9c7dc1..f36f0e61558d 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -658,8 +658,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl) | |||
658 | if (cfl) { | 658 | if (cfl) { |
659 | __locks_copy_lock(fl, cfl); | 659 | __locks_copy_lock(fl, cfl); |
660 | if (cfl->fl_nspid) | 660 | if (cfl->fl_nspid) |
661 | fl->fl_pid = pid_nr_ns(cfl->fl_nspid, | 661 | fl->fl_pid = pid_vnr(cfl->fl_nspid); |
662 | task_active_pid_ns(current)); | ||
663 | } else | 662 | } else |
664 | fl->fl_type = F_UNLCK; | 663 | fl->fl_type = F_UNLCK; |
665 | unlock_kernel(); | 664 | unlock_kernel(); |
@@ -2084,7 +2083,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, | |||
2084 | unsigned int fl_pid; | 2083 | unsigned int fl_pid; |
2085 | 2084 | ||
2086 | if (fl->fl_nspid) | 2085 | if (fl->fl_nspid) |
2087 | fl_pid = pid_nr_ns(fl->fl_nspid, task_active_pid_ns(current)); | 2086 | fl_pid = pid_vnr(fl->fl_nspid); |
2088 | else | 2087 | else |
2089 | fl_pid = fl->fl_pid; | 2088 | fl_pid = fl->fl_pid; |
2090 | 2089 | ||
diff --git a/fs/namei.c b/fs/namei.c index 241cff423653..52703986323a 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -106,7 +106,7 @@ | |||
106 | * any extra contention... | 106 | * any extra contention... |
107 | */ | 107 | */ |
108 | 108 | ||
109 | static int fastcall link_path_walk(const char *name, struct nameidata *nd); | 109 | static int link_path_walk(const char *name, struct nameidata *nd); |
110 | 110 | ||
111 | /* In order to reduce some races, while at the same time doing additional | 111 | /* In order to reduce some races, while at the same time doing additional |
112 | * checking and hopefully speeding things up, we copy filenames to the | 112 | * checking and hopefully speeding things up, we copy filenames to the |
@@ -823,7 +823,7 @@ fail: | |||
823 | * Returns 0 and nd will have valid dentry and mnt on success. | 823 | * Returns 0 and nd will have valid dentry and mnt on success. |
824 | * Returns error and drops reference to input namei data on failure. | 824 | * Returns error and drops reference to input namei data on failure. |
825 | */ | 825 | */ |
826 | static fastcall int __link_path_walk(const char * name, struct nameidata *nd) | 826 | static int __link_path_walk(const char *name, struct nameidata *nd) |
827 | { | 827 | { |
828 | struct path next; | 828 | struct path next; |
829 | struct inode *inode; | 829 | struct inode *inode; |
@@ -1015,7 +1015,7 @@ return_err: | |||
1015 | * Retry the whole path once, forcing real lookup requests | 1015 | * Retry the whole path once, forcing real lookup requests |
1016 | * instead of relying on the dcache. | 1016 | * instead of relying on the dcache. |
1017 | */ | 1017 | */ |
1018 | static int fastcall link_path_walk(const char *name, struct nameidata *nd) | 1018 | static int link_path_walk(const char *name, struct nameidata *nd) |
1019 | { | 1019 | { |
1020 | struct nameidata save = *nd; | 1020 | struct nameidata save = *nd; |
1021 | int result; | 1021 | int result; |
@@ -1039,7 +1039,7 @@ static int fastcall link_path_walk(const char *name, struct nameidata *nd) | |||
1039 | return result; | 1039 | return result; |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | static int fastcall path_walk(const char * name, struct nameidata *nd) | 1042 | static int path_walk(const char *name, struct nameidata *nd) |
1043 | { | 1043 | { |
1044 | current->total_link_count = 0; | 1044 | current->total_link_count = 0; |
1045 | return link_path_walk(name, nd); | 1045 | return link_path_walk(name, nd); |
@@ -1116,7 +1116,7 @@ set_it: | |||
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ | 1118 | /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ |
1119 | static int fastcall do_path_lookup(int dfd, const char *name, | 1119 | static int do_path_lookup(int dfd, const char *name, |
1120 | unsigned int flags, struct nameidata *nd) | 1120 | unsigned int flags, struct nameidata *nd) |
1121 | { | 1121 | { |
1122 | int retval = 0; | 1122 | int retval = 0; |
@@ -1183,7 +1183,7 @@ fput_fail: | |||
1183 | goto out_fail; | 1183 | goto out_fail; |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | int fastcall path_lookup(const char *name, unsigned int flags, | 1186 | int path_lookup(const char *name, unsigned int flags, |
1187 | struct nameidata *nd) | 1187 | struct nameidata *nd) |
1188 | { | 1188 | { |
1189 | return do_path_lookup(AT_FDCWD, name, flags, nd); | 1189 | return do_path_lookup(AT_FDCWD, name, flags, nd); |
@@ -1409,7 +1409,7 @@ struct dentry *lookup_one_noperm(const char *name, struct dentry *base) | |||
1409 | return __lookup_hash(&this, base, NULL); | 1409 | return __lookup_hash(&this, base, NULL); |
1410 | } | 1410 | } |
1411 | 1411 | ||
1412 | int fastcall __user_walk_fd(int dfd, const char __user *name, unsigned flags, | 1412 | int __user_walk_fd(int dfd, const char __user *name, unsigned flags, |
1413 | struct nameidata *nd) | 1413 | struct nameidata *nd) |
1414 | { | 1414 | { |
1415 | char *tmp = getname(name); | 1415 | char *tmp = getname(name); |
@@ -1422,7 +1422,7 @@ int fastcall __user_walk_fd(int dfd, const char __user *name, unsigned flags, | |||
1422 | return err; | 1422 | return err; |
1423 | } | 1423 | } |
1424 | 1424 | ||
1425 | int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd) | 1425 | int __user_walk(const char __user *name, unsigned flags, struct nameidata *nd) |
1426 | { | 1426 | { |
1427 | return __user_walk_fd(AT_FDCWD, name, flags, nd); | 1427 | return __user_walk_fd(AT_FDCWD, name, flags, nd); |
1428 | } | 1428 | } |
diff --git a/fs/namespace.c b/fs/namespace.c index e9c10cd01e13..63ced21c12dc 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -320,6 +320,50 @@ void mnt_unpin(struct vfsmount *mnt) | |||
320 | 320 | ||
321 | EXPORT_SYMBOL(mnt_unpin); | 321 | EXPORT_SYMBOL(mnt_unpin); |
322 | 322 | ||
323 | static inline void mangle(struct seq_file *m, const char *s) | ||
324 | { | ||
325 | seq_escape(m, s, " \t\n\\"); | ||
326 | } | ||
327 | |||
328 | /* | ||
329 | * Simple .show_options callback for filesystems which don't want to | ||
330 | * implement more complex mount option showing. | ||
331 | * | ||
332 | * See also save_mount_options(). | ||
333 | */ | ||
334 | int generic_show_options(struct seq_file *m, struct vfsmount *mnt) | ||
335 | { | ||
336 | const char *options = mnt->mnt_sb->s_options; | ||
337 | |||
338 | if (options != NULL && options[0]) { | ||
339 | seq_putc(m, ','); | ||
340 | mangle(m, options); | ||
341 | } | ||
342 | |||
343 | return 0; | ||
344 | } | ||
345 | EXPORT_SYMBOL(generic_show_options); | ||
346 | |||
347 | /* | ||
348 | * If filesystem uses generic_show_options(), this function should be | ||
349 | * called from the fill_super() callback. | ||
350 | * | ||
351 | * The .remount_fs callback usually needs to be handled in a special | ||
352 | * way, to make sure, that previous options are not overwritten if the | ||
353 | * remount fails. | ||
354 | * | ||
355 | * Also note, that if the filesystem's .remount_fs function doesn't | ||
356 | * reset all options to their default value, but changes only newly | ||
357 | * given options, then the displayed options will not reflect reality | ||
358 | * any more. | ||
359 | */ | ||
360 | void save_mount_options(struct super_block *sb, char *options) | ||
361 | { | ||
362 | kfree(sb->s_options); | ||
363 | sb->s_options = kstrdup(options, GFP_KERNEL); | ||
364 | } | ||
365 | EXPORT_SYMBOL(save_mount_options); | ||
366 | |||
323 | /* iterator */ | 367 | /* iterator */ |
324 | static void *m_start(struct seq_file *m, loff_t *pos) | 368 | static void *m_start(struct seq_file *m, loff_t *pos) |
325 | { | 369 | { |
@@ -341,11 +385,6 @@ static void m_stop(struct seq_file *m, void *v) | |||
341 | up_read(&namespace_sem); | 385 | up_read(&namespace_sem); |
342 | } | 386 | } |
343 | 387 | ||
344 | static inline void mangle(struct seq_file *m, const char *s) | ||
345 | { | ||
346 | seq_escape(m, s, " \t\n\\"); | ||
347 | } | ||
348 | |||
349 | static int show_vfsmnt(struct seq_file *m, void *v) | 388 | static int show_vfsmnt(struct seq_file *m, void *v) |
350 | { | 389 | { |
351 | struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list); | 390 | struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list); |
@@ -897,8 +936,9 @@ out_unlock: | |||
897 | 936 | ||
898 | /* | 937 | /* |
899 | * recursively change the type of the mountpoint. | 938 | * recursively change the type of the mountpoint. |
939 | * noinline this do_mount helper to save do_mount stack space. | ||
900 | */ | 940 | */ |
901 | static int do_change_type(struct nameidata *nd, int flag) | 941 | static noinline int do_change_type(struct nameidata *nd, int flag) |
902 | { | 942 | { |
903 | struct vfsmount *m, *mnt = nd->mnt; | 943 | struct vfsmount *m, *mnt = nd->mnt; |
904 | int recurse = flag & MS_REC; | 944 | int recurse = flag & MS_REC; |
@@ -921,8 +961,10 @@ static int do_change_type(struct nameidata *nd, int flag) | |||
921 | 961 | ||
922 | /* | 962 | /* |
923 | * do loopback mount. | 963 | * do loopback mount. |
964 | * noinline this do_mount helper to save do_mount stack space. | ||
924 | */ | 965 | */ |
925 | static int do_loopback(struct nameidata *nd, char *old_name, int recurse) | 966 | static noinline int do_loopback(struct nameidata *nd, char *old_name, |
967 | int recurse) | ||
926 | { | 968 | { |
927 | struct nameidata old_nd; | 969 | struct nameidata old_nd; |
928 | struct vfsmount *mnt = NULL; | 970 | struct vfsmount *mnt = NULL; |
@@ -971,8 +1013,9 @@ out: | |||
971 | * change filesystem flags. dir should be a physical root of filesystem. | 1013 | * change filesystem flags. dir should be a physical root of filesystem. |
972 | * If you've mounted a non-root directory somewhere and want to do remount | 1014 | * If you've mounted a non-root directory somewhere and want to do remount |
973 | * on it - tough luck. | 1015 | * on it - tough luck. |
1016 | * noinline this do_mount helper to save do_mount stack space. | ||
974 | */ | 1017 | */ |
975 | static int do_remount(struct nameidata *nd, int flags, int mnt_flags, | 1018 | static noinline int do_remount(struct nameidata *nd, int flags, int mnt_flags, |
976 | void *data) | 1019 | void *data) |
977 | { | 1020 | { |
978 | int err; | 1021 | int err; |
@@ -1007,7 +1050,10 @@ static inline int tree_contains_unbindable(struct vfsmount *mnt) | |||
1007 | return 0; | 1050 | return 0; |
1008 | } | 1051 | } |
1009 | 1052 | ||
1010 | static int do_move_mount(struct nameidata *nd, char *old_name) | 1053 | /* |
1054 | * noinline this do_mount helper to save do_mount stack space. | ||
1055 | */ | ||
1056 | static noinline int do_move_mount(struct nameidata *nd, char *old_name) | ||
1011 | { | 1057 | { |
1012 | struct nameidata old_nd, parent_nd; | 1058 | struct nameidata old_nd, parent_nd; |
1013 | struct vfsmount *p; | 1059 | struct vfsmount *p; |
@@ -1082,8 +1128,9 @@ out: | |||
1082 | /* | 1128 | /* |
1083 | * create a new mount for userspace and request it to be added into the | 1129 | * create a new mount for userspace and request it to be added into the |
1084 | * namespace's tree | 1130 | * namespace's tree |
1131 | * noinline this do_mount helper to save do_mount stack space. | ||
1085 | */ | 1132 | */ |
1086 | static int do_new_mount(struct nameidata *nd, char *type, int flags, | 1133 | static noinline int do_new_mount(struct nameidata *nd, char *type, int flags, |
1087 | int mnt_flags, char *name, void *data) | 1134 | int mnt_flags, char *name, void *data) |
1088 | { | 1135 | { |
1089 | struct vfsmount *mnt; | 1136 | struct vfsmount *mnt; |
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index eff1f18d034f..fbbb9f7afa1a 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/smp_lock.h> | 29 | #include <linux/smp_lock.h> |
30 | #include <linux/vfs.h> | 30 | #include <linux/vfs.h> |
31 | #include <linux/mount.h> | ||
32 | #include <linux/seq_file.h> | ||
31 | 33 | ||
32 | #include <linux/ncp_fs.h> | 34 | #include <linux/ncp_fs.h> |
33 | 35 | ||
@@ -36,9 +38,15 @@ | |||
36 | #include "ncplib_kernel.h" | 38 | #include "ncplib_kernel.h" |
37 | #include "getopt.h" | 39 | #include "getopt.h" |
38 | 40 | ||
41 | #define NCP_DEFAULT_FILE_MODE 0600 | ||
42 | #define NCP_DEFAULT_DIR_MODE 0700 | ||
43 | #define NCP_DEFAULT_TIME_OUT 10 | ||
44 | #define NCP_DEFAULT_RETRY_COUNT 20 | ||
45 | |||
39 | static void ncp_delete_inode(struct inode *); | 46 | static void ncp_delete_inode(struct inode *); |
40 | static void ncp_put_super(struct super_block *); | 47 | static void ncp_put_super(struct super_block *); |
41 | static int ncp_statfs(struct dentry *, struct kstatfs *); | 48 | static int ncp_statfs(struct dentry *, struct kstatfs *); |
49 | static int ncp_show_options(struct seq_file *, struct vfsmount *); | ||
42 | 50 | ||
43 | static struct kmem_cache * ncp_inode_cachep; | 51 | static struct kmem_cache * ncp_inode_cachep; |
44 | 52 | ||
@@ -96,6 +104,7 @@ static const struct super_operations ncp_sops = | |||
96 | .put_super = ncp_put_super, | 104 | .put_super = ncp_put_super, |
97 | .statfs = ncp_statfs, | 105 | .statfs = ncp_statfs, |
98 | .remount_fs = ncp_remount, | 106 | .remount_fs = ncp_remount, |
107 | .show_options = ncp_show_options, | ||
99 | }; | 108 | }; |
100 | 109 | ||
101 | extern struct dentry_operations ncp_root_dentry_operations; | 110 | extern struct dentry_operations ncp_root_dentry_operations; |
@@ -304,6 +313,37 @@ static void ncp_stop_tasks(struct ncp_server *server) { | |||
304 | flush_scheduled_work(); | 313 | flush_scheduled_work(); |
305 | } | 314 | } |
306 | 315 | ||
316 | static int ncp_show_options(struct seq_file *seq, struct vfsmount *mnt) | ||
317 | { | ||
318 | struct ncp_server *server = NCP_SBP(mnt->mnt_sb); | ||
319 | unsigned int tmp; | ||
320 | |||
321 | if (server->m.uid != 0) | ||
322 | seq_printf(seq, ",uid=%u", server->m.uid); | ||
323 | if (server->m.gid != 0) | ||
324 | seq_printf(seq, ",gid=%u", server->m.gid); | ||
325 | if (server->m.mounted_uid != 0) | ||
326 | seq_printf(seq, ",owner=%u", server->m.mounted_uid); | ||
327 | tmp = server->m.file_mode & S_IALLUGO; | ||
328 | if (tmp != NCP_DEFAULT_FILE_MODE) | ||
329 | seq_printf(seq, ",mode=0%o", tmp); | ||
330 | tmp = server->m.dir_mode & S_IALLUGO; | ||
331 | if (tmp != NCP_DEFAULT_DIR_MODE) | ||
332 | seq_printf(seq, ",dirmode=0%o", tmp); | ||
333 | if (server->m.time_out != NCP_DEFAULT_TIME_OUT * HZ / 100) { | ||
334 | tmp = server->m.time_out * 100 / HZ; | ||
335 | seq_printf(seq, ",timeout=%u", tmp); | ||
336 | } | ||
337 | if (server->m.retry_count != NCP_DEFAULT_RETRY_COUNT) | ||
338 | seq_printf(seq, ",retry=%u", server->m.retry_count); | ||
339 | if (server->m.flags != 0) | ||
340 | seq_printf(seq, ",flags=%lu", server->m.flags); | ||
341 | if (server->m.wdog_pid != NULL) | ||
342 | seq_printf(seq, ",wdogpid=%u", pid_vnr(server->m.wdog_pid)); | ||
343 | |||
344 | return 0; | ||
345 | } | ||
346 | |||
307 | static const struct ncp_option ncp_opts[] = { | 347 | static const struct ncp_option ncp_opts[] = { |
308 | { "uid", OPT_INT, 'u' }, | 348 | { "uid", OPT_INT, 'u' }, |
309 | { "gid", OPT_INT, 'g' }, | 349 | { "gid", OPT_INT, 'g' }, |
@@ -331,12 +371,12 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options) | |||
331 | data->mounted_uid = 0; | 371 | data->mounted_uid = 0; |
332 | data->wdog_pid = NULL; | 372 | data->wdog_pid = NULL; |
333 | data->ncp_fd = ~0; | 373 | data->ncp_fd = ~0; |
334 | data->time_out = 10; | 374 | data->time_out = NCP_DEFAULT_TIME_OUT; |
335 | data->retry_count = 20; | 375 | data->retry_count = NCP_DEFAULT_RETRY_COUNT; |
336 | data->uid = 0; | 376 | data->uid = 0; |
337 | data->gid = 0; | 377 | data->gid = 0; |
338 | data->file_mode = 0600; | 378 | data->file_mode = NCP_DEFAULT_FILE_MODE; |
339 | data->dir_mode = 0700; | 379 | data->dir_mode = NCP_DEFAULT_DIR_MODE; |
340 | data->info_fd = -1; | 380 | data->info_fd = -1; |
341 | data->mounted_vol[0] = 0; | 381 | data->mounted_vol[0] = 0; |
342 | 382 | ||
@@ -982,6 +1022,7 @@ static struct file_system_type ncp_fs_type = { | |||
982 | .name = "ncpfs", | 1022 | .name = "ncpfs", |
983 | .get_sb = ncp_get_sb, | 1023 | .get_sb = ncp_get_sb, |
984 | .kill_sb = kill_anon_super, | 1024 | .kill_sb = kill_anon_super, |
1025 | .fs_flags = FS_BINARY_MOUNTDATA, | ||
985 | }; | 1026 | }; |
986 | 1027 | ||
987 | static int __init init_ncp_fs(void) | 1028 | static int __init init_ncp_fs(void) |
diff --git a/fs/ocfs2/cluster/endian.h b/fs/ocfs2/cluster/endian.h deleted file mode 100644 index 2df9082f4e35..000000000000 --- a/fs/ocfs2/cluster/endian.h +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | /* -*- mode: c; c-basic-offset: 8; -*- | ||
2 | * vim: noexpandtab sw=8 ts=8 sts=0: | ||
3 | * | ||
4 | * Copyright (C) 2005 Oracle. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public | ||
17 | * License along with this program; if not, write to the | ||
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
19 | * Boston, MA 021110-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef OCFS2_CLUSTER_ENDIAN_H | ||
23 | #define OCFS2_CLUSTER_ENDIAN_H | ||
24 | |||
25 | static inline void be32_add_cpu(__be32 *var, u32 val) | ||
26 | { | ||
27 | *var = cpu_to_be32(be32_to_cpu(*var) + val); | ||
28 | } | ||
29 | |||
30 | #endif /* OCFS2_CLUSTER_ENDIAN_H */ | ||
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index af2070da308b..709fba25bf7e 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/sysctl.h> | 24 | #include <linux/sysctl.h> |
25 | #include <linux/configfs.h> | 25 | #include <linux/configfs.h> |
26 | 26 | ||
27 | #include "endian.h" | ||
28 | #include "tcp.h" | 27 | #include "tcp.h" |
29 | #include "nodemanager.h" | 28 | #include "nodemanager.h" |
30 | #include "heartbeat.h" | 29 | #include "heartbeat.h" |
diff --git a/fs/ocfs2/dlm/dlmast.c b/fs/ocfs2/dlm/dlmast.c index 2fd8bded38f3..644bee55d8ba 100644 --- a/fs/ocfs2/dlm/dlmast.c +++ b/fs/ocfs2/dlm/dlmast.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #include "cluster/heartbeat.h" | 43 | #include "cluster/heartbeat.h" |
44 | #include "cluster/nodemanager.h" | 44 | #include "cluster/nodemanager.h" |
45 | #include "cluster/tcp.h" | 45 | #include "cluster/tcp.h" |
46 | #include "cluster/endian.h" | ||
47 | 46 | ||
48 | #include "dlmapi.h" | 47 | #include "dlmapi.h" |
49 | #include "dlmcommon.h" | 48 | #include "dlmcommon.h" |
diff --git a/fs/ocfs2/endian.h b/fs/ocfs2/endian.h deleted file mode 100644 index 1942e09f6ee5..000000000000 --- a/fs/ocfs2/endian.h +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /* -*- mode: c; c-basic-offset: 8; -*- | ||
2 | * vim: noexpandtab sw=8 ts=8 sts=0: | ||
3 | * | ||
4 | * Copyright (C) 2005 Oracle. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public | ||
17 | * License along with this program; if not, write to the | ||
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
19 | * Boston, MA 021110-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef OCFS2_ENDIAN_H | ||
23 | #define OCFS2_ENDIAN_H | ||
24 | |||
25 | static inline void le16_add_cpu(__le16 *var, u16 val) | ||
26 | { | ||
27 | *var = cpu_to_le16(le16_to_cpu(*var) + val); | ||
28 | } | ||
29 | |||
30 | static inline void le32_add_cpu(__le32 *var, u32 val) | ||
31 | { | ||
32 | *var = cpu_to_le32(le32_to_cpu(*var) + val); | ||
33 | } | ||
34 | |||
35 | static inline void le64_add_cpu(__le64 *var, u64 val) | ||
36 | { | ||
37 | *var = cpu_to_le64(le64_to_cpu(*var) + val); | ||
38 | } | ||
39 | |||
40 | static inline void be32_add_cpu(__be32 *var, u32 val) | ||
41 | { | ||
42 | *var = cpu_to_be32(be32_to_cpu(*var) + val); | ||
43 | } | ||
44 | |||
45 | #endif /* OCFS2_ENDIAN_H */ | ||
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index e8b7292e0152..6546cef212e3 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
@@ -43,7 +43,6 @@ | |||
43 | #include "dlm/dlmapi.h" | 43 | #include "dlm/dlmapi.h" |
44 | 44 | ||
45 | #include "ocfs2_fs.h" | 45 | #include "ocfs2_fs.h" |
46 | #include "endian.h" | ||
47 | #include "ocfs2_lockid.h" | 46 | #include "ocfs2_lockid.h" |
48 | 47 | ||
49 | /* Most user visible OCFS2 inodes will have very few pieces of | 48 | /* Most user visible OCFS2 inodes will have very few pieces of |
@@ -991,7 +991,7 @@ static void __put_unused_fd(struct files_struct *files, unsigned int fd) | |||
991 | files->next_fd = fd; | 991 | files->next_fd = fd; |
992 | } | 992 | } |
993 | 993 | ||
994 | void fastcall put_unused_fd(unsigned int fd) | 994 | void put_unused_fd(unsigned int fd) |
995 | { | 995 | { |
996 | struct files_struct *files = current->files; | 996 | struct files_struct *files = current->files; |
997 | spin_lock(&files->file_lock); | 997 | spin_lock(&files->file_lock); |
@@ -1014,7 +1014,7 @@ EXPORT_SYMBOL(put_unused_fd); | |||
1014 | * will follow. | 1014 | * will follow. |
1015 | */ | 1015 | */ |
1016 | 1016 | ||
1017 | void fastcall fd_install(unsigned int fd, struct file * file) | 1017 | void fd_install(unsigned int fd, struct file *file) |
1018 | { | 1018 | { |
1019 | struct files_struct *files = current->files; | 1019 | struct files_struct *files = current->files; |
1020 | struct fdtable *fdt; | 1020 | struct fdtable *fdt; |
@@ -1061,7 +1061,6 @@ asmlinkage long sys_open(const char __user *filename, int flags, int mode) | |||
1061 | prevent_tail_call(ret); | 1061 | prevent_tail_call(ret); |
1062 | return ret; | 1062 | return ret; |
1063 | } | 1063 | } |
1064 | EXPORT_UNUSED_SYMBOL_GPL(sys_open); /* To be deleted for 2.6.25 */ | ||
1065 | 1064 | ||
1066 | asmlinkage long sys_openat(int dfd, const char __user *filename, int flags, | 1065 | asmlinkage long sys_openat(int dfd, const char __user *filename, int flags, |
1067 | int mode) | 1066 | int mode) |
@@ -576,9 +576,7 @@ bad_pipe_w(struct file *filp, const char __user *buf, size_t count, | |||
576 | return -EBADF; | 576 | return -EBADF; |
577 | } | 577 | } |
578 | 578 | ||
579 | static int | 579 | static long pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
580 | pipe_ioctl(struct inode *pino, struct file *filp, | ||
581 | unsigned int cmd, unsigned long arg) | ||
582 | { | 580 | { |
583 | struct inode *inode = filp->f_path.dentry->d_inode; | 581 | struct inode *inode = filp->f_path.dentry->d_inode; |
584 | struct pipe_inode_info *pipe; | 582 | struct pipe_inode_info *pipe; |
@@ -785,7 +783,7 @@ const struct file_operations read_fifo_fops = { | |||
785 | .aio_read = pipe_read, | 783 | .aio_read = pipe_read, |
786 | .write = bad_pipe_w, | 784 | .write = bad_pipe_w, |
787 | .poll = pipe_poll, | 785 | .poll = pipe_poll, |
788 | .ioctl = pipe_ioctl, | 786 | .unlocked_ioctl = pipe_ioctl, |
789 | .open = pipe_read_open, | 787 | .open = pipe_read_open, |
790 | .release = pipe_read_release, | 788 | .release = pipe_read_release, |
791 | .fasync = pipe_read_fasync, | 789 | .fasync = pipe_read_fasync, |
@@ -797,7 +795,7 @@ const struct file_operations write_fifo_fops = { | |||
797 | .write = do_sync_write, | 795 | .write = do_sync_write, |
798 | .aio_write = pipe_write, | 796 | .aio_write = pipe_write, |
799 | .poll = pipe_poll, | 797 | .poll = pipe_poll, |
800 | .ioctl = pipe_ioctl, | 798 | .unlocked_ioctl = pipe_ioctl, |
801 | .open = pipe_write_open, | 799 | .open = pipe_write_open, |
802 | .release = pipe_write_release, | 800 | .release = pipe_write_release, |
803 | .fasync = pipe_write_fasync, | 801 | .fasync = pipe_write_fasync, |
@@ -810,7 +808,7 @@ const struct file_operations rdwr_fifo_fops = { | |||
810 | .write = do_sync_write, | 808 | .write = do_sync_write, |
811 | .aio_write = pipe_write, | 809 | .aio_write = pipe_write, |
812 | .poll = pipe_poll, | 810 | .poll = pipe_poll, |
813 | .ioctl = pipe_ioctl, | 811 | .unlocked_ioctl = pipe_ioctl, |
814 | .open = pipe_rdwr_open, | 812 | .open = pipe_rdwr_open, |
815 | .release = pipe_rdwr_release, | 813 | .release = pipe_rdwr_release, |
816 | .fasync = pipe_rdwr_fasync, | 814 | .fasync = pipe_rdwr_fasync, |
@@ -822,7 +820,7 @@ static const struct file_operations read_pipe_fops = { | |||
822 | .aio_read = pipe_read, | 820 | .aio_read = pipe_read, |
823 | .write = bad_pipe_w, | 821 | .write = bad_pipe_w, |
824 | .poll = pipe_poll, | 822 | .poll = pipe_poll, |
825 | .ioctl = pipe_ioctl, | 823 | .unlocked_ioctl = pipe_ioctl, |
826 | .open = pipe_read_open, | 824 | .open = pipe_read_open, |
827 | .release = pipe_read_release, | 825 | .release = pipe_read_release, |
828 | .fasync = pipe_read_fasync, | 826 | .fasync = pipe_read_fasync, |
@@ -834,7 +832,7 @@ static const struct file_operations write_pipe_fops = { | |||
834 | .write = do_sync_write, | 832 | .write = do_sync_write, |
835 | .aio_write = pipe_write, | 833 | .aio_write = pipe_write, |
836 | .poll = pipe_poll, | 834 | .poll = pipe_poll, |
837 | .ioctl = pipe_ioctl, | 835 | .unlocked_ioctl = pipe_ioctl, |
838 | .open = pipe_write_open, | 836 | .open = pipe_write_open, |
839 | .release = pipe_write_release, | 837 | .release = pipe_write_release, |
840 | .fasync = pipe_write_fasync, | 838 | .fasync = pipe_write_fasync, |
@@ -847,7 +845,7 @@ static const struct file_operations rdwr_pipe_fops = { | |||
847 | .write = do_sync_write, | 845 | .write = do_sync_write, |
848 | .aio_write = pipe_write, | 846 | .aio_write = pipe_write, |
849 | .poll = pipe_poll, | 847 | .poll = pipe_poll, |
850 | .ioctl = pipe_ioctl, | 848 | .unlocked_ioctl = pipe_ioctl, |
851 | .open = pipe_rdwr_open, | 849 | .open = pipe_rdwr_open, |
852 | .release = pipe_rdwr_release, | 850 | .release = pipe_rdwr_release, |
853 | .fasync = pipe_rdwr_fasync, | 851 | .fasync = pipe_rdwr_fasync, |
diff --git a/fs/proc/array.c b/fs/proc/array.c index 6ba2746e4517..07d6c4853fe8 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -77,6 +77,7 @@ | |||
77 | #include <linux/cpuset.h> | 77 | #include <linux/cpuset.h> |
78 | #include <linux/rcupdate.h> | 78 | #include <linux/rcupdate.h> |
79 | #include <linux/delayacct.h> | 79 | #include <linux/delayacct.h> |
80 | #include <linux/seq_file.h> | ||
80 | #include <linux/pid_namespace.h> | 81 | #include <linux/pid_namespace.h> |
81 | 82 | ||
82 | #include <asm/pgtable.h> | 83 | #include <asm/pgtable.h> |
@@ -88,18 +89,21 @@ | |||
88 | do { memcpy(buffer, string, strlen(string)); \ | 89 | do { memcpy(buffer, string, strlen(string)); \ |
89 | buffer += strlen(string); } while (0) | 90 | buffer += strlen(string); } while (0) |
90 | 91 | ||
91 | static inline char *task_name(struct task_struct *p, char *buf) | 92 | static inline void task_name(struct seq_file *m, struct task_struct *p) |
92 | { | 93 | { |
93 | int i; | 94 | int i; |
95 | char *buf, *end; | ||
94 | char *name; | 96 | char *name; |
95 | char tcomm[sizeof(p->comm)]; | 97 | char tcomm[sizeof(p->comm)]; |
96 | 98 | ||
97 | get_task_comm(tcomm, p); | 99 | get_task_comm(tcomm, p); |
98 | 100 | ||
99 | ADDBUF(buf, "Name:\t"); | 101 | seq_printf(m, "Name:\t"); |
102 | end = m->buf + m->size; | ||
103 | buf = m->buf + m->count; | ||
100 | name = tcomm; | 104 | name = tcomm; |
101 | i = sizeof(tcomm); | 105 | i = sizeof(tcomm); |
102 | do { | 106 | while (i && (buf < end)) { |
103 | unsigned char c = *name; | 107 | unsigned char c = *name; |
104 | name++; | 108 | name++; |
105 | i--; | 109 | i--; |
@@ -107,20 +111,21 @@ static inline char *task_name(struct task_struct *p, char *buf) | |||
107 | if (!c) | 111 | if (!c) |
108 | break; | 112 | break; |
109 | if (c == '\\') { | 113 | if (c == '\\') { |
110 | buf[1] = c; | 114 | buf++; |
111 | buf += 2; | 115 | if (buf < end) |
116 | *buf++ = c; | ||
112 | continue; | 117 | continue; |
113 | } | 118 | } |
114 | if (c == '\n') { | 119 | if (c == '\n') { |
115 | buf[0] = '\\'; | 120 | *buf++ = '\\'; |
116 | buf[1] = 'n'; | 121 | if (buf < end) |
117 | buf += 2; | 122 | *buf++ = 'n'; |
118 | continue; | 123 | continue; |
119 | } | 124 | } |
120 | buf++; | 125 | buf++; |
121 | } while (i); | 126 | } |
122 | *buf = '\n'; | 127 | m->count = buf - m->buf; |
123 | return buf+1; | 128 | seq_printf(m, "\n"); |
124 | } | 129 | } |
125 | 130 | ||
126 | /* | 131 | /* |
@@ -151,21 +156,20 @@ static inline const char *get_task_state(struct task_struct *tsk) | |||
151 | return *p; | 156 | return *p; |
152 | } | 157 | } |
153 | 158 | ||
154 | static inline char *task_state(struct task_struct *p, char *buffer) | 159 | static inline void task_state(struct seq_file *m, struct pid_namespace *ns, |
160 | struct pid *pid, struct task_struct *p) | ||
155 | { | 161 | { |
156 | struct group_info *group_info; | 162 | struct group_info *group_info; |
157 | int g; | 163 | int g; |
158 | struct fdtable *fdt = NULL; | 164 | struct fdtable *fdt = NULL; |
159 | struct pid_namespace *ns; | ||
160 | pid_t ppid, tpid; | 165 | pid_t ppid, tpid; |
161 | 166 | ||
162 | ns = current->nsproxy->pid_ns; | ||
163 | rcu_read_lock(); | 167 | rcu_read_lock(); |
164 | ppid = pid_alive(p) ? | 168 | ppid = pid_alive(p) ? |
165 | task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; | 169 | task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; |
166 | tpid = pid_alive(p) && p->ptrace ? | 170 | tpid = pid_alive(p) && p->ptrace ? |
167 | task_pid_nr_ns(rcu_dereference(p->parent), ns) : 0; | 171 | task_pid_nr_ns(rcu_dereference(p->parent), ns) : 0; |
168 | buffer += sprintf(buffer, | 172 | seq_printf(m, |
169 | "State:\t%s\n" | 173 | "State:\t%s\n" |
170 | "Tgid:\t%d\n" | 174 | "Tgid:\t%d\n" |
171 | "Pid:\t%d\n" | 175 | "Pid:\t%d\n" |
@@ -175,7 +179,7 @@ static inline char *task_state(struct task_struct *p, char *buffer) | |||
175 | "Gid:\t%d\t%d\t%d\t%d\n", | 179 | "Gid:\t%d\t%d\t%d\t%d\n", |
176 | get_task_state(p), | 180 | get_task_state(p), |
177 | task_tgid_nr_ns(p, ns), | 181 | task_tgid_nr_ns(p, ns), |
178 | task_pid_nr_ns(p, ns), | 182 | pid_nr_ns(pid, ns), |
179 | ppid, tpid, | 183 | ppid, tpid, |
180 | p->uid, p->euid, p->suid, p->fsuid, | 184 | p->uid, p->euid, p->suid, p->fsuid, |
181 | p->gid, p->egid, p->sgid, p->fsgid); | 185 | p->gid, p->egid, p->sgid, p->fsgid); |
@@ -183,7 +187,7 @@ static inline char *task_state(struct task_struct *p, char *buffer) | |||
183 | task_lock(p); | 187 | task_lock(p); |
184 | if (p->files) | 188 | if (p->files) |
185 | fdt = files_fdtable(p->files); | 189 | fdt = files_fdtable(p->files); |
186 | buffer += sprintf(buffer, | 190 | seq_printf(m, |
187 | "FDSize:\t%d\n" | 191 | "FDSize:\t%d\n" |
188 | "Groups:\t", | 192 | "Groups:\t", |
189 | fdt ? fdt->max_fds : 0); | 193 | fdt ? fdt->max_fds : 0); |
@@ -194,20 +198,18 @@ static inline char *task_state(struct task_struct *p, char *buffer) | |||
194 | task_unlock(p); | 198 | task_unlock(p); |
195 | 199 | ||
196 | for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++) | 200 | for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++) |
197 | buffer += sprintf(buffer, "%d ", GROUP_AT(group_info, g)); | 201 | seq_printf(m, "%d ", GROUP_AT(group_info, g)); |
198 | put_group_info(group_info); | 202 | put_group_info(group_info); |
199 | 203 | ||
200 | buffer += sprintf(buffer, "\n"); | 204 | seq_printf(m, "\n"); |
201 | return buffer; | ||
202 | } | 205 | } |
203 | 206 | ||
204 | static char *render_sigset_t(const char *header, sigset_t *set, char *buffer) | 207 | static void render_sigset_t(struct seq_file *m, const char *header, |
208 | sigset_t *set) | ||
205 | { | 209 | { |
206 | int i, len; | 210 | int i; |
207 | 211 | ||
208 | len = strlen(header); | 212 | seq_printf(m, "%s", header); |
209 | memcpy(buffer, header, len); | ||
210 | buffer += len; | ||
211 | 213 | ||
212 | i = _NSIG; | 214 | i = _NSIG; |
213 | do { | 215 | do { |
@@ -218,12 +220,10 @@ static char *render_sigset_t(const char *header, sigset_t *set, char *buffer) | |||
218 | if (sigismember(set, i+2)) x |= 2; | 220 | if (sigismember(set, i+2)) x |= 2; |
219 | if (sigismember(set, i+3)) x |= 4; | 221 | if (sigismember(set, i+3)) x |= 4; |
220 | if (sigismember(set, i+4)) x |= 8; | 222 | if (sigismember(set, i+4)) x |= 8; |
221 | *buffer++ = (x < 10 ? '0' : 'a' - 10) + x; | 223 | seq_printf(m, "%x", x); |
222 | } while (i >= 4); | 224 | } while (i >= 4); |
223 | 225 | ||
224 | *buffer++ = '\n'; | 226 | seq_printf(m, "\n"); |
225 | *buffer = 0; | ||
226 | return buffer; | ||
227 | } | 227 | } |
228 | 228 | ||
229 | static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign, | 229 | static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign, |
@@ -241,7 +241,7 @@ static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign, | |||
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | static inline char *task_sig(struct task_struct *p, char *buffer) | 244 | static inline void task_sig(struct seq_file *m, struct task_struct *p) |
245 | { | 245 | { |
246 | unsigned long flags; | 246 | unsigned long flags; |
247 | sigset_t pending, shpending, blocked, ignored, caught; | 247 | sigset_t pending, shpending, blocked, ignored, caught; |
@@ -268,67 +268,66 @@ static inline char *task_sig(struct task_struct *p, char *buffer) | |||
268 | } | 268 | } |
269 | rcu_read_unlock(); | 269 | rcu_read_unlock(); |
270 | 270 | ||
271 | buffer += sprintf(buffer, "Threads:\t%d\n", num_threads); | 271 | seq_printf(m, "Threads:\t%d\n", num_threads); |
272 | buffer += sprintf(buffer, "SigQ:\t%lu/%lu\n", qsize, qlim); | 272 | seq_printf(m, "SigQ:\t%lu/%lu\n", qsize, qlim); |
273 | 273 | ||
274 | /* render them all */ | 274 | /* render them all */ |
275 | buffer = render_sigset_t("SigPnd:\t", &pending, buffer); | 275 | render_sigset_t(m, "SigPnd:\t", &pending); |
276 | buffer = render_sigset_t("ShdPnd:\t", &shpending, buffer); | 276 | render_sigset_t(m, "ShdPnd:\t", &shpending); |
277 | buffer = render_sigset_t("SigBlk:\t", &blocked, buffer); | 277 | render_sigset_t(m, "SigBlk:\t", &blocked); |
278 | buffer = render_sigset_t("SigIgn:\t", &ignored, buffer); | 278 | render_sigset_t(m, "SigIgn:\t", &ignored); |
279 | buffer = render_sigset_t("SigCgt:\t", &caught, buffer); | 279 | render_sigset_t(m, "SigCgt:\t", &caught); |
280 | |||
281 | return buffer; | ||
282 | } | 280 | } |
283 | 281 | ||
284 | static char *render_cap_t(const char *header, kernel_cap_t *a, char *buffer) | 282 | static void render_cap_t(struct seq_file *m, const char *header, |
283 | kernel_cap_t *a) | ||
285 | { | 284 | { |
286 | unsigned __capi; | 285 | unsigned __capi; |
287 | 286 | ||
288 | buffer += sprintf(buffer, "%s", header); | 287 | seq_printf(m, "%s", header); |
289 | CAP_FOR_EACH_U32(__capi) { | 288 | CAP_FOR_EACH_U32(__capi) { |
290 | buffer += sprintf(buffer, "%08x", | 289 | seq_printf(m, "%08x", |
291 | a->cap[(_LINUX_CAPABILITY_U32S-1) - __capi]); | 290 | a->cap[(_LINUX_CAPABILITY_U32S-1) - __capi]); |
292 | } | 291 | } |
293 | return buffer + sprintf(buffer, "\n"); | 292 | seq_printf(m, "\n"); |
294 | } | 293 | } |
295 | 294 | ||
296 | static inline char *task_cap(struct task_struct *p, char *buffer) | 295 | static inline void task_cap(struct seq_file *m, struct task_struct *p) |
297 | { | 296 | { |
298 | buffer = render_cap_t("CapInh:\t", &p->cap_inheritable, buffer); | 297 | render_cap_t(m, "CapInh:\t", &p->cap_inheritable); |
299 | buffer = render_cap_t("CapPrm:\t", &p->cap_permitted, buffer); | 298 | render_cap_t(m, "CapPrm:\t", &p->cap_permitted); |
300 | return render_cap_t("CapEff:\t", &p->cap_effective, buffer); | 299 | render_cap_t(m, "CapEff:\t", &p->cap_effective); |
301 | } | 300 | } |
302 | 301 | ||
303 | static inline char *task_context_switch_counts(struct task_struct *p, | 302 | static inline void task_context_switch_counts(struct seq_file *m, |
304 | char *buffer) | 303 | struct task_struct *p) |
305 | { | 304 | { |
306 | return buffer + sprintf(buffer, "voluntary_ctxt_switches:\t%lu\n" | 305 | seq_printf(m, "voluntary_ctxt_switches:\t%lu\n" |
307 | "nonvoluntary_ctxt_switches:\t%lu\n", | 306 | "nonvoluntary_ctxt_switches:\t%lu\n", |
308 | p->nvcsw, | 307 | p->nvcsw, |
309 | p->nivcsw); | 308 | p->nivcsw); |
310 | } | 309 | } |
311 | 310 | ||
312 | int proc_pid_status(struct task_struct *task, char *buffer) | 311 | int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, |
312 | struct pid *pid, struct task_struct *task) | ||
313 | { | 313 | { |
314 | char *orig = buffer; | ||
315 | struct mm_struct *mm = get_task_mm(task); | 314 | struct mm_struct *mm = get_task_mm(task); |
316 | 315 | ||
317 | buffer = task_name(task, buffer); | 316 | task_name(m, task); |
318 | buffer = task_state(task, buffer); | 317 | task_state(m, ns, pid, task); |
319 | 318 | ||
320 | if (mm) { | 319 | if (mm) { |
321 | buffer = task_mem(mm, buffer); | 320 | task_mem(m, mm); |
322 | mmput(mm); | 321 | mmput(mm); |
323 | } | 322 | } |
324 | buffer = task_sig(task, buffer); | 323 | task_sig(m, task); |
325 | buffer = task_cap(task, buffer); | 324 | task_cap(m, task); |
326 | buffer = cpuset_task_status_allowed(task, buffer); | 325 | cpuset_task_status_allowed(m, task); |
327 | #if defined(CONFIG_S390) | 326 | #if defined(CONFIG_S390) |
328 | buffer = task_show_regs(task, buffer); | 327 | task_show_regs(m, task); |
329 | #endif | 328 | #endif |
330 | buffer = task_context_switch_counts(task, buffer); | 329 | task_context_switch_counts(m, task); |
331 | return buffer - orig; | 330 | return 0; |
332 | } | 331 | } |
333 | 332 | ||
334 | /* | 333 | /* |
@@ -390,14 +389,14 @@ static cputime_t task_gtime(struct task_struct *p) | |||
390 | return p->gtime; | 389 | return p->gtime; |
391 | } | 390 | } |
392 | 391 | ||
393 | static int do_task_stat(struct task_struct *task, char *buffer, int whole) | 392 | static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, |
393 | struct pid *pid, struct task_struct *task, int whole) | ||
394 | { | 394 | { |
395 | unsigned long vsize, eip, esp, wchan = ~0UL; | 395 | unsigned long vsize, eip, esp, wchan = ~0UL; |
396 | long priority, nice; | 396 | long priority, nice; |
397 | int tty_pgrp = -1, tty_nr = 0; | 397 | int tty_pgrp = -1, tty_nr = 0; |
398 | sigset_t sigign, sigcatch; | 398 | sigset_t sigign, sigcatch; |
399 | char state; | 399 | char state; |
400 | int res; | ||
401 | pid_t ppid = 0, pgid = -1, sid = -1; | 400 | pid_t ppid = 0, pgid = -1, sid = -1; |
402 | int num_threads = 0; | 401 | int num_threads = 0; |
403 | struct mm_struct *mm; | 402 | struct mm_struct *mm; |
@@ -409,9 +408,6 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |||
409 | unsigned long rsslim = 0; | 408 | unsigned long rsslim = 0; |
410 | char tcomm[sizeof(task->comm)]; | 409 | char tcomm[sizeof(task->comm)]; |
411 | unsigned long flags; | 410 | unsigned long flags; |
412 | struct pid_namespace *ns; | ||
413 | |||
414 | ns = current->nsproxy->pid_ns; | ||
415 | 411 | ||
416 | state = *get_task_state(task); | 412 | state = *get_task_state(task); |
417 | vsize = eip = esp = 0; | 413 | vsize = eip = esp = 0; |
@@ -498,10 +494,10 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |||
498 | /* convert nsec -> ticks */ | 494 | /* convert nsec -> ticks */ |
499 | start_time = nsec_to_clock_t(start_time); | 495 | start_time = nsec_to_clock_t(start_time); |
500 | 496 | ||
501 | res = sprintf(buffer, "%d (%s) %c %d %d %d %d %d %u %lu \ | 497 | seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \ |
502 | %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ | 498 | %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ |
503 | %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n", | 499 | %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n", |
504 | task_pid_nr_ns(task, ns), | 500 | pid_nr_ns(pid, ns), |
505 | tcomm, | 501 | tcomm, |
506 | state, | 502 | state, |
507 | ppid, | 503 | ppid, |
@@ -550,20 +546,23 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |||
550 | cputime_to_clock_t(cgtime)); | 546 | cputime_to_clock_t(cgtime)); |
551 | if (mm) | 547 | if (mm) |
552 | mmput(mm); | 548 | mmput(mm); |
553 | return res; | 549 | return 0; |
554 | } | 550 | } |
555 | 551 | ||
556 | int proc_tid_stat(struct task_struct *task, char *buffer) | 552 | int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns, |
553 | struct pid *pid, struct task_struct *task) | ||
557 | { | 554 | { |
558 | return do_task_stat(task, buffer, 0); | 555 | return do_task_stat(m, ns, pid, task, 0); |
559 | } | 556 | } |
560 | 557 | ||
561 | int proc_tgid_stat(struct task_struct *task, char *buffer) | 558 | int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns, |
559 | struct pid *pid, struct task_struct *task) | ||
562 | { | 560 | { |
563 | return do_task_stat(task, buffer, 1); | 561 | return do_task_stat(m, ns, pid, task, 1); |
564 | } | 562 | } |
565 | 563 | ||
566 | int proc_pid_statm(struct task_struct *task, char *buffer) | 564 | int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns, |
565 | struct pid *pid, struct task_struct *task) | ||
567 | { | 566 | { |
568 | int size = 0, resident = 0, shared = 0, text = 0, lib = 0, data = 0; | 567 | int size = 0, resident = 0, shared = 0, text = 0, lib = 0, data = 0; |
569 | struct mm_struct *mm = get_task_mm(task); | 568 | struct mm_struct *mm = get_task_mm(task); |
@@ -572,7 +571,8 @@ int proc_pid_statm(struct task_struct *task, char *buffer) | |||
572 | size = task_statm(mm, &shared, &text, &data, &resident); | 571 | size = task_statm(mm, &shared, &text, &data, &resident); |
573 | mmput(mm); | 572 | mmput(mm); |
574 | } | 573 | } |
574 | seq_printf(m, "%d %d %d %d %d %d %d\n", | ||
575 | size, resident, shared, text, lib, data, 0); | ||
575 | 576 | ||
576 | return sprintf(buffer, "%d %d %d %d %d %d %d\n", | 577 | return 0; |
577 | size, resident, shared, text, lib, data, 0); | ||
578 | } | 578 | } |
diff --git a/fs/proc/base.c b/fs/proc/base.c index c59852b38787..a0c4ba6c6e57 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -121,6 +121,10 @@ struct pid_entry { | |||
121 | NOD(NAME, (S_IFREG|(MODE)), \ | 121 | NOD(NAME, (S_IFREG|(MODE)), \ |
122 | NULL, &proc_info_file_operations, \ | 122 | NULL, &proc_info_file_operations, \ |
123 | { .proc_read = &proc_##OTYPE } ) | 123 | { .proc_read = &proc_##OTYPE } ) |
124 | #define ONE(NAME, MODE, OTYPE) \ | ||
125 | NOD(NAME, (S_IFREG|(MODE)), \ | ||
126 | NULL, &proc_single_file_operations, \ | ||
127 | { .proc_show = &proc_##OTYPE } ) | ||
124 | 128 | ||
125 | int maps_protect; | 129 | int maps_protect; |
126 | EXPORT_SYMBOL(maps_protect); | 130 | EXPORT_SYMBOL(maps_protect); |
@@ -502,7 +506,7 @@ static const struct inode_operations proc_def_inode_operations = { | |||
502 | .setattr = proc_setattr, | 506 | .setattr = proc_setattr, |
503 | }; | 507 | }; |
504 | 508 | ||
505 | extern struct seq_operations mounts_op; | 509 | extern const struct seq_operations mounts_op; |
506 | struct proc_mounts { | 510 | struct proc_mounts { |
507 | struct seq_file m; | 511 | struct seq_file m; |
508 | int event; | 512 | int event; |
@@ -581,7 +585,7 @@ static const struct file_operations proc_mounts_operations = { | |||
581 | .poll = mounts_poll, | 585 | .poll = mounts_poll, |
582 | }; | 586 | }; |
583 | 587 | ||
584 | extern struct seq_operations mountstats_op; | 588 | extern const struct seq_operations mountstats_op; |
585 | static int mountstats_open(struct inode *inode, struct file *file) | 589 | static int mountstats_open(struct inode *inode, struct file *file) |
586 | { | 590 | { |
587 | int ret = seq_open(file, &mountstats_op); | 591 | int ret = seq_open(file, &mountstats_op); |
@@ -658,6 +662,45 @@ static const struct file_operations proc_info_file_operations = { | |||
658 | .read = proc_info_read, | 662 | .read = proc_info_read, |
659 | }; | 663 | }; |
660 | 664 | ||
665 | static int proc_single_show(struct seq_file *m, void *v) | ||
666 | { | ||
667 | struct inode *inode = m->private; | ||
668 | struct pid_namespace *ns; | ||
669 | struct pid *pid; | ||
670 | struct task_struct *task; | ||
671 | int ret; | ||
672 | |||
673 | ns = inode->i_sb->s_fs_info; | ||
674 | pid = proc_pid(inode); | ||
675 | task = get_pid_task(pid, PIDTYPE_PID); | ||
676 | if (!task) | ||
677 | return -ESRCH; | ||
678 | |||
679 | ret = PROC_I(inode)->op.proc_show(m, ns, pid, task); | ||
680 | |||
681 | put_task_struct(task); | ||
682 | return ret; | ||
683 | } | ||
684 | |||
685 | static int proc_single_open(struct inode *inode, struct file *filp) | ||
686 | { | ||
687 | int ret; | ||
688 | ret = single_open(filp, proc_single_show, NULL); | ||
689 | if (!ret) { | ||
690 | struct seq_file *m = filp->private_data; | ||
691 | |||
692 | m->private = inode; | ||
693 | } | ||
694 | return ret; | ||
695 | } | ||
696 | |||
697 | static const struct file_operations proc_single_file_operations = { | ||
698 | .open = proc_single_open, | ||
699 | .read = seq_read, | ||
700 | .llseek = seq_lseek, | ||
701 | .release = single_release, | ||
702 | }; | ||
703 | |||
661 | static int mem_open(struct inode* inode, struct file* file) | 704 | static int mem_open(struct inode* inode, struct file* file) |
662 | { | 705 | { |
663 | file->private_data = (void*)((long)current->self_exec_id); | 706 | file->private_data = (void*)((long)current->self_exec_id); |
@@ -2058,15 +2101,23 @@ static const struct file_operations proc_coredump_filter_operations = { | |||
2058 | static int proc_self_readlink(struct dentry *dentry, char __user *buffer, | 2101 | static int proc_self_readlink(struct dentry *dentry, char __user *buffer, |
2059 | int buflen) | 2102 | int buflen) |
2060 | { | 2103 | { |
2104 | struct pid_namespace *ns = dentry->d_sb->s_fs_info; | ||
2105 | pid_t pid = task_pid_nr_ns(current, ns); | ||
2061 | char tmp[PROC_NUMBUF]; | 2106 | char tmp[PROC_NUMBUF]; |
2062 | sprintf(tmp, "%d", task_tgid_vnr(current)); | 2107 | if (!pid) |
2108 | return -ENOENT; | ||
2109 | sprintf(tmp, "%d", pid); | ||
2063 | return vfs_readlink(dentry,buffer,buflen,tmp); | 2110 | return vfs_readlink(dentry,buffer,buflen,tmp); |
2064 | } | 2111 | } |
2065 | 2112 | ||
2066 | static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd) | 2113 | static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd) |
2067 | { | 2114 | { |
2115 | struct pid_namespace *ns = dentry->d_sb->s_fs_info; | ||
2116 | pid_t pid = task_pid_nr_ns(current, ns); | ||
2068 | char tmp[PROC_NUMBUF]; | 2117 | char tmp[PROC_NUMBUF]; |
2069 | sprintf(tmp, "%d", task_tgid_vnr(current)); | 2118 | if (!pid) |
2119 | return ERR_PTR(-ENOENT); | ||
2120 | sprintf(tmp, "%d", pid); | ||
2070 | return ERR_PTR(vfs_follow_link(nd,tmp)); | 2121 | return ERR_PTR(vfs_follow_link(nd,tmp)); |
2071 | } | 2122 | } |
2072 | 2123 | ||
@@ -2231,14 +2282,14 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
2231 | DIR("fdinfo", S_IRUSR|S_IXUSR, fdinfo), | 2282 | DIR("fdinfo", S_IRUSR|S_IXUSR, fdinfo), |
2232 | REG("environ", S_IRUSR, environ), | 2283 | REG("environ", S_IRUSR, environ), |
2233 | INF("auxv", S_IRUSR, pid_auxv), | 2284 | INF("auxv", S_IRUSR, pid_auxv), |
2234 | INF("status", S_IRUGO, pid_status), | 2285 | ONE("status", S_IRUGO, pid_status), |
2235 | INF("limits", S_IRUSR, pid_limits), | 2286 | INF("limits", S_IRUSR, pid_limits), |
2236 | #ifdef CONFIG_SCHED_DEBUG | 2287 | #ifdef CONFIG_SCHED_DEBUG |
2237 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), | 2288 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), |
2238 | #endif | 2289 | #endif |
2239 | INF("cmdline", S_IRUGO, pid_cmdline), | 2290 | INF("cmdline", S_IRUGO, pid_cmdline), |
2240 | INF("stat", S_IRUGO, tgid_stat), | 2291 | ONE("stat", S_IRUGO, tgid_stat), |
2241 | INF("statm", S_IRUGO, pid_statm), | 2292 | ONE("statm", S_IRUGO, pid_statm), |
2242 | REG("maps", S_IRUGO, maps), | 2293 | REG("maps", S_IRUGO, maps), |
2243 | #ifdef CONFIG_NUMA | 2294 | #ifdef CONFIG_NUMA |
2244 | REG("numa_maps", S_IRUGO, numa_maps), | 2295 | REG("numa_maps", S_IRUGO, numa_maps), |
@@ -2562,14 +2613,14 @@ static const struct pid_entry tid_base_stuff[] = { | |||
2562 | DIR("fdinfo", S_IRUSR|S_IXUSR, fdinfo), | 2613 | DIR("fdinfo", S_IRUSR|S_IXUSR, fdinfo), |
2563 | REG("environ", S_IRUSR, environ), | 2614 | REG("environ", S_IRUSR, environ), |
2564 | INF("auxv", S_IRUSR, pid_auxv), | 2615 | INF("auxv", S_IRUSR, pid_auxv), |
2565 | INF("status", S_IRUGO, pid_status), | 2616 | ONE("status", S_IRUGO, pid_status), |
2566 | INF("limits", S_IRUSR, pid_limits), | 2617 | INF("limits", S_IRUSR, pid_limits), |
2567 | #ifdef CONFIG_SCHED_DEBUG | 2618 | #ifdef CONFIG_SCHED_DEBUG |
2568 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), | 2619 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), |
2569 | #endif | 2620 | #endif |
2570 | INF("cmdline", S_IRUGO, pid_cmdline), | 2621 | INF("cmdline", S_IRUGO, pid_cmdline), |
2571 | INF("stat", S_IRUGO, tid_stat), | 2622 | ONE("stat", S_IRUGO, tid_stat), |
2572 | INF("statm", S_IRUGO, pid_statm), | 2623 | ONE("statm", S_IRUGO, pid_statm), |
2573 | REG("maps", S_IRUGO, maps), | 2624 | REG("maps", S_IRUGO, maps), |
2574 | #ifdef CONFIG_NUMA | 2625 | #ifdef CONFIG_NUMA |
2575 | REG("numa_maps", S_IRUGO, numa_maps), | 2626 | REG("numa_maps", S_IRUGO, numa_maps), |
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 6a2fe5187b62..68971e66cd41 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -25,12 +25,6 @@ | |||
25 | 25 | ||
26 | #include "internal.h" | 26 | #include "internal.h" |
27 | 27 | ||
28 | static ssize_t proc_file_read(struct file *file, char __user *buf, | ||
29 | size_t nbytes, loff_t *ppos); | ||
30 | static ssize_t proc_file_write(struct file *file, const char __user *buffer, | ||
31 | size_t count, loff_t *ppos); | ||
32 | static loff_t proc_file_lseek(struct file *, loff_t, int); | ||
33 | |||
34 | DEFINE_SPINLOCK(proc_subdir_lock); | 28 | DEFINE_SPINLOCK(proc_subdir_lock); |
35 | 29 | ||
36 | static int proc_match(int len, const char *name, struct proc_dir_entry *de) | 30 | static int proc_match(int len, const char *name, struct proc_dir_entry *de) |
@@ -40,12 +34,6 @@ static int proc_match(int len, const char *name, struct proc_dir_entry *de) | |||
40 | return !memcmp(name, de->name, len); | 34 | return !memcmp(name, de->name, len); |
41 | } | 35 | } |
42 | 36 | ||
43 | static const struct file_operations proc_file_operations = { | ||
44 | .llseek = proc_file_lseek, | ||
45 | .read = proc_file_read, | ||
46 | .write = proc_file_write, | ||
47 | }; | ||
48 | |||
49 | /* buffer size is one page but our output routines use some slack for overruns */ | 37 | /* buffer size is one page but our output routines use some slack for overruns */ |
50 | #define PROC_BLOCK_SIZE (PAGE_SIZE - 1024) | 38 | #define PROC_BLOCK_SIZE (PAGE_SIZE - 1024) |
51 | 39 | ||
@@ -233,6 +221,12 @@ proc_file_lseek(struct file *file, loff_t offset, int orig) | |||
233 | return retval; | 221 | return retval; |
234 | } | 222 | } |
235 | 223 | ||
224 | static const struct file_operations proc_file_operations = { | ||
225 | .llseek = proc_file_lseek, | ||
226 | .read = proc_file_read, | ||
227 | .write = proc_file_write, | ||
228 | }; | ||
229 | |||
236 | static int proc_notify_change(struct dentry *dentry, struct iattr *iattr) | 230 | static int proc_notify_change(struct dentry *dentry, struct iattr *iattr) |
237 | { | 231 | { |
238 | struct inode *inode = dentry->d_inode; | 232 | struct inode *inode = dentry->d_inode; |
@@ -406,12 +400,12 @@ struct dentry *proc_lookup(struct inode * dir, struct dentry *dentry, struct nam | |||
406 | spin_unlock(&proc_subdir_lock); | 400 | spin_unlock(&proc_subdir_lock); |
407 | error = -EINVAL; | 401 | error = -EINVAL; |
408 | inode = proc_get_inode(dir->i_sb, ino, de); | 402 | inode = proc_get_inode(dir->i_sb, ino, de); |
409 | spin_lock(&proc_subdir_lock); | 403 | goto out_unlock; |
410 | break; | ||
411 | } | 404 | } |
412 | } | 405 | } |
413 | } | 406 | } |
414 | spin_unlock(&proc_subdir_lock); | 407 | spin_unlock(&proc_subdir_lock); |
408 | out_unlock: | ||
415 | unlock_kernel(); | 409 | unlock_kernel(); |
416 | 410 | ||
417 | if (inode) { | 411 | if (inode) { |
@@ -527,6 +521,7 @@ static const struct inode_operations proc_dir_inode_operations = { | |||
527 | static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp) | 521 | static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp) |
528 | { | 522 | { |
529 | unsigned int i; | 523 | unsigned int i; |
524 | struct proc_dir_entry *tmp; | ||
530 | 525 | ||
531 | i = get_inode_number(); | 526 | i = get_inode_number(); |
532 | if (i == 0) | 527 | if (i == 0) |
@@ -550,6 +545,15 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp | |||
550 | } | 545 | } |
551 | 546 | ||
552 | spin_lock(&proc_subdir_lock); | 547 | spin_lock(&proc_subdir_lock); |
548 | |||
549 | for (tmp = dir->subdir; tmp; tmp = tmp->next) | ||
550 | if (strcmp(tmp->name, dp->name) == 0) { | ||
551 | printk(KERN_WARNING "proc_dir_entry '%s' already " | ||
552 | "registered\n", dp->name); | ||
553 | dump_stack(); | ||
554 | break; | ||
555 | } | ||
556 | |||
553 | dp->next = dir->subdir; | 557 | dp->next = dir->subdir; |
554 | dp->parent = dir; | 558 | dp->parent = dir; |
555 | dir->subdir = dp; | 559 | dir->subdir = dp; |
@@ -558,7 +562,7 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp | |||
558 | return 0; | 562 | return 0; |
559 | } | 563 | } |
560 | 564 | ||
561 | static struct proc_dir_entry *proc_create(struct proc_dir_entry **parent, | 565 | static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, |
562 | const char *name, | 566 | const char *name, |
563 | mode_t mode, | 567 | mode_t mode, |
564 | nlink_t nlink) | 568 | nlink_t nlink) |
@@ -601,7 +605,7 @@ struct proc_dir_entry *proc_symlink(const char *name, | |||
601 | { | 605 | { |
602 | struct proc_dir_entry *ent; | 606 | struct proc_dir_entry *ent; |
603 | 607 | ||
604 | ent = proc_create(&parent,name, | 608 | ent = __proc_create(&parent, name, |
605 | (S_IFLNK | S_IRUGO | S_IWUGO | S_IXUGO),1); | 609 | (S_IFLNK | S_IRUGO | S_IWUGO | S_IXUGO),1); |
606 | 610 | ||
607 | if (ent) { | 611 | if (ent) { |
@@ -626,7 +630,7 @@ struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode, | |||
626 | { | 630 | { |
627 | struct proc_dir_entry *ent; | 631 | struct proc_dir_entry *ent; |
628 | 632 | ||
629 | ent = proc_create(&parent, name, S_IFDIR | mode, 2); | 633 | ent = __proc_create(&parent, name, S_IFDIR | mode, 2); |
630 | if (ent) { | 634 | if (ent) { |
631 | if (proc_register(parent, ent) < 0) { | 635 | if (proc_register(parent, ent) < 0) { |
632 | kfree(ent); | 636 | kfree(ent); |
@@ -660,7 +664,7 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, | |||
660 | nlink = 1; | 664 | nlink = 1; |
661 | } | 665 | } |
662 | 666 | ||
663 | ent = proc_create(&parent,name,mode,nlink); | 667 | ent = __proc_create(&parent, name, mode, nlink); |
664 | if (ent) { | 668 | if (ent) { |
665 | if (proc_register(parent, ent) < 0) { | 669 | if (proc_register(parent, ent) < 0) { |
666 | kfree(ent); | 670 | kfree(ent); |
@@ -670,6 +674,38 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, | |||
670 | return ent; | 674 | return ent; |
671 | } | 675 | } |
672 | 676 | ||
677 | struct proc_dir_entry *proc_create(const char *name, mode_t mode, | ||
678 | struct proc_dir_entry *parent, | ||
679 | const struct file_operations *proc_fops) | ||
680 | { | ||
681 | struct proc_dir_entry *pde; | ||
682 | nlink_t nlink; | ||
683 | |||
684 | if (S_ISDIR(mode)) { | ||
685 | if ((mode & S_IALLUGO) == 0) | ||
686 | mode |= S_IRUGO | S_IXUGO; | ||
687 | nlink = 2; | ||
688 | } else { | ||
689 | if ((mode & S_IFMT) == 0) | ||
690 | mode |= S_IFREG; | ||
691 | if ((mode & S_IALLUGO) == 0) | ||
692 | mode |= S_IRUGO; | ||
693 | nlink = 1; | ||
694 | } | ||
695 | |||
696 | pde = __proc_create(&parent, name, mode, nlink); | ||
697 | if (!pde) | ||
698 | goto out; | ||
699 | pde->proc_fops = proc_fops; | ||
700 | if (proc_register(parent, pde) < 0) | ||
701 | goto out_free; | ||
702 | return pde; | ||
703 | out_free: | ||
704 | kfree(pde); | ||
705 | out: | ||
706 | return NULL; | ||
707 | } | ||
708 | |||
673 | void free_proc_entry(struct proc_dir_entry *de) | 709 | void free_proc_entry(struct proc_dir_entry *de) |
674 | { | 710 | { |
675 | unsigned int ino = de->low_ino; | 711 | unsigned int ino = de->low_ino; |
@@ -679,7 +715,7 @@ void free_proc_entry(struct proc_dir_entry *de) | |||
679 | 715 | ||
680 | release_inode_number(ino); | 716 | release_inode_number(ino); |
681 | 717 | ||
682 | if (S_ISLNK(de->mode) && de->data) | 718 | if (S_ISLNK(de->mode)) |
683 | kfree(de->data); | 719 | kfree(de->data); |
684 | kfree(de); | 720 | kfree(de); |
685 | } | 721 | } |
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 6ecf6396f072..82b3a1b5a70b 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
@@ -467,4 +467,3 @@ out_no_root: | |||
467 | de_put(&proc_root); | 467 | de_put(&proc_root); |
468 | return -ENOMEM; | 468 | return -ENOMEM; |
469 | } | 469 | } |
470 | MODULE_LICENSE("GPL"); | ||
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 7d57e8069924..ea496ffeabe7 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h | |||
@@ -46,12 +46,17 @@ extern int nommu_vma_show(struct seq_file *, struct vm_area_struct *); | |||
46 | 46 | ||
47 | extern int maps_protect; | 47 | extern int maps_protect; |
48 | 48 | ||
49 | extern void create_seq_entry(char *name, mode_t mode, const struct file_operations *f); | 49 | extern void create_seq_entry(char *name, mode_t mode, |
50 | const struct file_operations *f); | ||
50 | extern int proc_exe_link(struct inode *, struct dentry **, struct vfsmount **); | 51 | extern int proc_exe_link(struct inode *, struct dentry **, struct vfsmount **); |
51 | extern int proc_tid_stat(struct task_struct *, char *); | 52 | extern int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns, |
52 | extern int proc_tgid_stat(struct task_struct *, char *); | 53 | struct pid *pid, struct task_struct *task); |
53 | extern int proc_pid_status(struct task_struct *, char *); | 54 | extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns, |
54 | extern int proc_pid_statm(struct task_struct *, char *); | 55 | struct pid *pid, struct task_struct *task); |
56 | extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, | ||
57 | struct pid *pid, struct task_struct *task); | ||
58 | extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns, | ||
59 | struct pid *pid, struct task_struct *task); | ||
55 | extern loff_t mem_lseek(struct file *file, loff_t offset, int orig); | 60 | extern loff_t mem_lseek(struct file *file, loff_t offset, int orig); |
56 | 61 | ||
57 | extern const struct file_operations proc_maps_operations; | 62 | extern const struct file_operations proc_maps_operations; |
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 7dd26e18cbfd..e78c81fcf547 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
13 | #include <linux/proc_fs.h> | 13 | #include <linux/proc_fs.h> |
14 | #include <linux/user.h> | 14 | #include <linux/user.h> |
15 | #include <linux/a.out.h> | ||
16 | #include <linux/capability.h> | 15 | #include <linux/capability.h> |
17 | #include <linux/elf.h> | 16 | #include <linux/elf.h> |
18 | #include <linux/elfcore.h> | 17 | #include <linux/elfcore.h> |
diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c index 22f789de3909..5d9147b9d738 100644 --- a/fs/proc/nommu.c +++ b/fs/proc/nommu.c | |||
@@ -116,7 +116,7 @@ static void *nommu_vma_list_next(struct seq_file *m, void *v, loff_t *pos) | |||
116 | return rb_next((struct rb_node *) v); | 116 | return rb_next((struct rb_node *) v); |
117 | } | 117 | } |
118 | 118 | ||
119 | static struct seq_operations proc_nommu_vma_list_seqop = { | 119 | static const struct seq_operations proc_nommu_vma_list_seqop = { |
120 | .start = nommu_vma_list_start, | 120 | .start = nommu_vma_list_start, |
121 | .next = nommu_vma_list_next, | 121 | .next = nommu_vma_list_next, |
122 | .stop = nommu_vma_list_stop, | 122 | .stop = nommu_vma_list_stop, |
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 2686592dbcb2..468805d40e2b 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c | |||
@@ -222,7 +222,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off, | |||
222 | #undef K | 222 | #undef K |
223 | } | 223 | } |
224 | 224 | ||
225 | extern struct seq_operations fragmentation_op; | 225 | extern const struct seq_operations fragmentation_op; |
226 | static int fragmentation_open(struct inode *inode, struct file *file) | 226 | static int fragmentation_open(struct inode *inode, struct file *file) |
227 | { | 227 | { |
228 | (void)inode; | 228 | (void)inode; |
@@ -236,7 +236,7 @@ static const struct file_operations fragmentation_file_operations = { | |||
236 | .release = seq_release, | 236 | .release = seq_release, |
237 | }; | 237 | }; |
238 | 238 | ||
239 | extern struct seq_operations pagetypeinfo_op; | 239 | extern const struct seq_operations pagetypeinfo_op; |
240 | static int pagetypeinfo_open(struct inode *inode, struct file *file) | 240 | static int pagetypeinfo_open(struct inode *inode, struct file *file) |
241 | { | 241 | { |
242 | return seq_open(file, &pagetypeinfo_op); | 242 | return seq_open(file, &pagetypeinfo_op); |
@@ -249,7 +249,7 @@ static const struct file_operations pagetypeinfo_file_ops = { | |||
249 | .release = seq_release, | 249 | .release = seq_release, |
250 | }; | 250 | }; |
251 | 251 | ||
252 | extern struct seq_operations zoneinfo_op; | 252 | extern const struct seq_operations zoneinfo_op; |
253 | static int zoneinfo_open(struct inode *inode, struct file *file) | 253 | static int zoneinfo_open(struct inode *inode, struct file *file) |
254 | { | 254 | { |
255 | return seq_open(file, &zoneinfo_op); | 255 | return seq_open(file, &zoneinfo_op); |
@@ -274,7 +274,7 @@ static int version_read_proc(char *page, char **start, off_t off, | |||
274 | return proc_calc_metrics(page, start, off, count, eof, len); | 274 | return proc_calc_metrics(page, start, off, count, eof, len); |
275 | } | 275 | } |
276 | 276 | ||
277 | extern struct seq_operations cpuinfo_op; | 277 | extern const struct seq_operations cpuinfo_op; |
278 | static int cpuinfo_open(struct inode *inode, struct file *file) | 278 | static int cpuinfo_open(struct inode *inode, struct file *file) |
279 | { | 279 | { |
280 | return seq_open(file, &cpuinfo_op); | 280 | return seq_open(file, &cpuinfo_op); |
@@ -327,7 +327,7 @@ static void devinfo_stop(struct seq_file *f, void *v) | |||
327 | /* Nothing to do */ | 327 | /* Nothing to do */ |
328 | } | 328 | } |
329 | 329 | ||
330 | static struct seq_operations devinfo_ops = { | 330 | static const struct seq_operations devinfo_ops = { |
331 | .start = devinfo_start, | 331 | .start = devinfo_start, |
332 | .next = devinfo_next, | 332 | .next = devinfo_next, |
333 | .stop = devinfo_stop, | 333 | .stop = devinfo_stop, |
@@ -346,7 +346,7 @@ static const struct file_operations proc_devinfo_operations = { | |||
346 | .release = seq_release, | 346 | .release = seq_release, |
347 | }; | 347 | }; |
348 | 348 | ||
349 | extern struct seq_operations vmstat_op; | 349 | extern const struct seq_operations vmstat_op; |
350 | static int vmstat_open(struct inode *inode, struct file *file) | 350 | static int vmstat_open(struct inode *inode, struct file *file) |
351 | { | 351 | { |
352 | return seq_open(file, &vmstat_op); | 352 | return seq_open(file, &vmstat_op); |
@@ -377,7 +377,7 @@ static int stram_read_proc(char *page, char **start, off_t off, | |||
377 | #endif | 377 | #endif |
378 | 378 | ||
379 | #ifdef CONFIG_BLOCK | 379 | #ifdef CONFIG_BLOCK |
380 | extern struct seq_operations partitions_op; | 380 | extern const struct seq_operations partitions_op; |
381 | static int partitions_open(struct inode *inode, struct file *file) | 381 | static int partitions_open(struct inode *inode, struct file *file) |
382 | { | 382 | { |
383 | return seq_open(file, &partitions_op); | 383 | return seq_open(file, &partitions_op); |
@@ -389,7 +389,7 @@ static const struct file_operations proc_partitions_operations = { | |||
389 | .release = seq_release, | 389 | .release = seq_release, |
390 | }; | 390 | }; |
391 | 391 | ||
392 | extern struct seq_operations diskstats_op; | 392 | extern const struct seq_operations diskstats_op; |
393 | static int diskstats_open(struct inode *inode, struct file *file) | 393 | static int diskstats_open(struct inode *inode, struct file *file) |
394 | { | 394 | { |
395 | return seq_open(file, &diskstats_op); | 395 | return seq_open(file, &diskstats_op); |
@@ -403,7 +403,7 @@ static const struct file_operations proc_diskstats_operations = { | |||
403 | #endif | 403 | #endif |
404 | 404 | ||
405 | #ifdef CONFIG_MODULES | 405 | #ifdef CONFIG_MODULES |
406 | extern struct seq_operations modules_op; | 406 | extern const struct seq_operations modules_op; |
407 | static int modules_open(struct inode *inode, struct file *file) | 407 | static int modules_open(struct inode *inode, struct file *file) |
408 | { | 408 | { |
409 | return seq_open(file, &modules_op); | 409 | return seq_open(file, &modules_op); |
@@ -430,7 +430,7 @@ static const struct file_operations proc_slabinfo_operations = { | |||
430 | }; | 430 | }; |
431 | 431 | ||
432 | #ifdef CONFIG_DEBUG_SLAB_LEAK | 432 | #ifdef CONFIG_DEBUG_SLAB_LEAK |
433 | extern struct seq_operations slabstats_op; | 433 | extern const struct seq_operations slabstats_op; |
434 | static int slabstats_open(struct inode *inode, struct file *file) | 434 | static int slabstats_open(struct inode *inode, struct file *file) |
435 | { | 435 | { |
436 | unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL); | 436 | unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL); |
@@ -604,7 +604,7 @@ static void int_seq_stop(struct seq_file *f, void *v) | |||
604 | } | 604 | } |
605 | 605 | ||
606 | 606 | ||
607 | static struct seq_operations int_seq_ops = { | 607 | static const struct seq_operations int_seq_ops = { |
608 | .start = int_seq_start, | 608 | .start = int_seq_start, |
609 | .next = int_seq_next, | 609 | .next = int_seq_next, |
610 | .stop = int_seq_stop, | 610 | .stop = int_seq_stop, |
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c index 4823c9677fac..14e9b5aaf863 100644 --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c | |||
@@ -67,12 +67,7 @@ EXPORT_SYMBOL_GPL(seq_release_net); | |||
67 | struct proc_dir_entry *proc_net_fops_create(struct net *net, | 67 | struct proc_dir_entry *proc_net_fops_create(struct net *net, |
68 | const char *name, mode_t mode, const struct file_operations *fops) | 68 | const char *name, mode_t mode, const struct file_operations *fops) |
69 | { | 69 | { |
70 | struct proc_dir_entry *res; | 70 | return proc_create(name, mode, net->proc_net, fops); |
71 | |||
72 | res = create_proc_entry(name, mode, net->proc_net); | ||
73 | if (res) | ||
74 | res->proc_fops = fops; | ||
75 | return res; | ||
76 | } | 71 | } |
77 | EXPORT_SYMBOL_GPL(proc_net_fops_create); | 72 | EXPORT_SYMBOL_GPL(proc_net_fops_create); |
78 | 73 | ||
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 4e57fcf85982..b9cb23c08f63 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -9,7 +9,7 @@ | |||
9 | 9 | ||
10 | static struct dentry_operations proc_sys_dentry_operations; | 10 | static struct dentry_operations proc_sys_dentry_operations; |
11 | static const struct file_operations proc_sys_file_operations; | 11 | static const struct file_operations proc_sys_file_operations; |
12 | static struct inode_operations proc_sys_inode_operations; | 12 | static const struct inode_operations proc_sys_inode_operations; |
13 | 13 | ||
14 | static void proc_sys_refresh_inode(struct inode *inode, struct ctl_table *table) | 14 | static void proc_sys_refresh_inode(struct inode *inode, struct ctl_table *table) |
15 | { | 15 | { |
@@ -446,7 +446,7 @@ static const struct file_operations proc_sys_file_operations = { | |||
446 | .readdir = proc_sys_readdir, | 446 | .readdir = proc_sys_readdir, |
447 | }; | 447 | }; |
448 | 448 | ||
449 | static struct inode_operations proc_sys_inode_operations = { | 449 | static const struct inode_operations proc_sys_inode_operations = { |
450 | .lookup = proc_sys_lookup, | 450 | .lookup = proc_sys_lookup, |
451 | .permission = proc_sys_permission, | 451 | .permission = proc_sys_permission, |
452 | .setattr = proc_sys_setattr, | 452 | .setattr = proc_sys_setattr, |
diff --git a/fs/proc/proc_tty.c b/fs/proc/proc_tty.c index 22846225acfa..49816e00b51a 100644 --- a/fs/proc/proc_tty.c +++ b/fs/proc/proc_tty.c | |||
@@ -15,9 +15,6 @@ | |||
15 | #include <linux/seq_file.h> | 15 | #include <linux/seq_file.h> |
16 | #include <linux/bitops.h> | 16 | #include <linux/bitops.h> |
17 | 17 | ||
18 | static int tty_ldiscs_read_proc(char *page, char **start, off_t off, | ||
19 | int count, int *eof, void *data); | ||
20 | |||
21 | /* | 18 | /* |
22 | * The /proc/tty directory inodes... | 19 | * The /proc/tty directory inodes... |
23 | */ | 20 | */ |
@@ -120,7 +117,7 @@ static void t_stop(struct seq_file *m, void *v) | |||
120 | mutex_unlock(&tty_mutex); | 117 | mutex_unlock(&tty_mutex); |
121 | } | 118 | } |
122 | 119 | ||
123 | static struct seq_operations tty_drivers_op = { | 120 | static const struct seq_operations tty_drivers_op = { |
124 | .start = t_start, | 121 | .start = t_start, |
125 | .next = t_next, | 122 | .next = t_next, |
126 | .stop = t_stop, | 123 | .stop = t_stop, |
diff --git a/fs/proc/root.c b/fs/proc/root.c index 81f99e691f99..ef0fb57fc9ef 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c | |||
@@ -232,6 +232,7 @@ void pid_ns_release_proc(struct pid_namespace *ns) | |||
232 | EXPORT_SYMBOL(proc_symlink); | 232 | EXPORT_SYMBOL(proc_symlink); |
233 | EXPORT_SYMBOL(proc_mkdir); | 233 | EXPORT_SYMBOL(proc_mkdir); |
234 | EXPORT_SYMBOL(create_proc_entry); | 234 | EXPORT_SYMBOL(create_proc_entry); |
235 | EXPORT_SYMBOL(proc_create); | ||
235 | EXPORT_SYMBOL(remove_proc_entry); | 236 | EXPORT_SYMBOL(remove_proc_entry); |
236 | EXPORT_SYMBOL(proc_root); | 237 | EXPORT_SYMBOL(proc_root); |
237 | EXPORT_SYMBOL(proc_root_fs); | 238 | EXPORT_SYMBOL(proc_root_fs); |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 38338ed98cc6..ae4d3f2c8cb2 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -9,13 +9,14 @@ | |||
9 | #include <linux/mempolicy.h> | 9 | #include <linux/mempolicy.h> |
10 | #include <linux/swap.h> | 10 | #include <linux/swap.h> |
11 | #include <linux/swapops.h> | 11 | #include <linux/swapops.h> |
12 | #include <linux/seq_file.h> | ||
12 | 13 | ||
13 | #include <asm/elf.h> | 14 | #include <asm/elf.h> |
14 | #include <asm/uaccess.h> | 15 | #include <asm/uaccess.h> |
15 | #include <asm/tlbflush.h> | 16 | #include <asm/tlbflush.h> |
16 | #include "internal.h" | 17 | #include "internal.h" |
17 | 18 | ||
18 | char *task_mem(struct mm_struct *mm, char *buffer) | 19 | void task_mem(struct seq_file *m, struct mm_struct *mm) |
19 | { | 20 | { |
20 | unsigned long data, text, lib; | 21 | unsigned long data, text, lib; |
21 | unsigned long hiwater_vm, total_vm, hiwater_rss, total_rss; | 22 | unsigned long hiwater_vm, total_vm, hiwater_rss, total_rss; |
@@ -37,7 +38,7 @@ char *task_mem(struct mm_struct *mm, char *buffer) | |||
37 | data = mm->total_vm - mm->shared_vm - mm->stack_vm; | 38 | data = mm->total_vm - mm->shared_vm - mm->stack_vm; |
38 | text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK)) >> 10; | 39 | text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK)) >> 10; |
39 | lib = (mm->exec_vm << (PAGE_SHIFT-10)) - text; | 40 | lib = (mm->exec_vm << (PAGE_SHIFT-10)) - text; |
40 | buffer += sprintf(buffer, | 41 | seq_printf(m, |
41 | "VmPeak:\t%8lu kB\n" | 42 | "VmPeak:\t%8lu kB\n" |
42 | "VmSize:\t%8lu kB\n" | 43 | "VmSize:\t%8lu kB\n" |
43 | "VmLck:\t%8lu kB\n" | 44 | "VmLck:\t%8lu kB\n" |
@@ -56,7 +57,6 @@ char *task_mem(struct mm_struct *mm, char *buffer) | |||
56 | data << (PAGE_SHIFT-10), | 57 | data << (PAGE_SHIFT-10), |
57 | mm->stack_vm << (PAGE_SHIFT-10), text, lib, | 58 | mm->stack_vm << (PAGE_SHIFT-10), text, lib, |
58 | (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10); | 59 | (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10); |
59 | return buffer; | ||
60 | } | 60 | } |
61 | 61 | ||
62 | unsigned long task_vsize(struct mm_struct *mm) | 62 | unsigned long task_vsize(struct mm_struct *mm) |
@@ -216,7 +216,7 @@ static void m_stop(struct seq_file *m, void *v) | |||
216 | } | 216 | } |
217 | 217 | ||
218 | static int do_maps_open(struct inode *inode, struct file *file, | 218 | static int do_maps_open(struct inode *inode, struct file *file, |
219 | struct seq_operations *ops) | 219 | const struct seq_operations *ops) |
220 | { | 220 | { |
221 | struct proc_maps_private *priv; | 221 | struct proc_maps_private *priv; |
222 | int ret = -ENOMEM; | 222 | int ret = -ENOMEM; |
@@ -299,7 +299,7 @@ static int show_map(struct seq_file *m, void *v) | |||
299 | return 0; | 299 | return 0; |
300 | } | 300 | } |
301 | 301 | ||
302 | static struct seq_operations proc_pid_maps_op = { | 302 | static const struct seq_operations proc_pid_maps_op = { |
303 | .start = m_start, | 303 | .start = m_start, |
304 | .next = m_next, | 304 | .next = m_next, |
305 | .stop = m_stop, | 305 | .stop = m_stop, |
@@ -434,7 +434,7 @@ static int show_smap(struct seq_file *m, void *v) | |||
434 | return ret; | 434 | return ret; |
435 | } | 435 | } |
436 | 436 | ||
437 | static struct seq_operations proc_pid_smaps_op = { | 437 | static const struct seq_operations proc_pid_smaps_op = { |
438 | .start = m_start, | 438 | .start = m_start, |
439 | .next = m_next, | 439 | .next = m_next, |
440 | .stop = m_stop, | 440 | .stop = m_stop, |
@@ -734,7 +734,7 @@ static int show_numa_map_checked(struct seq_file *m, void *v) | |||
734 | return show_numa_map(m, v); | 734 | return show_numa_map(m, v); |
735 | } | 735 | } |
736 | 736 | ||
737 | static struct seq_operations proc_pid_numa_maps_op = { | 737 | static const struct seq_operations proc_pid_numa_maps_op = { |
738 | .start = m_start, | 738 | .start = m_start, |
739 | .next = m_next, | 739 | .next = m_next, |
740 | .stop = m_stop, | 740 | .stop = m_stop, |
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index 1932c2ca3457..abfc6f5e56ca 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * each process that owns it. Non-shared memory is counted | 12 | * each process that owns it. Non-shared memory is counted |
13 | * accurately. | 13 | * accurately. |
14 | */ | 14 | */ |
15 | char *task_mem(struct mm_struct *mm, char *buffer) | 15 | void task_mem(struct seq_file *m, struct mm_struct *mm) |
16 | { | 16 | { |
17 | struct vm_list_struct *vml; | 17 | struct vm_list_struct *vml; |
18 | unsigned long bytes = 0, sbytes = 0, slack = 0; | 18 | unsigned long bytes = 0, sbytes = 0, slack = 0; |
@@ -58,14 +58,13 @@ char *task_mem(struct mm_struct *mm, char *buffer) | |||
58 | 58 | ||
59 | bytes += kobjsize(current); /* includes kernel stack */ | 59 | bytes += kobjsize(current); /* includes kernel stack */ |
60 | 60 | ||
61 | buffer += sprintf(buffer, | 61 | seq_printf(m, |
62 | "Mem:\t%8lu bytes\n" | 62 | "Mem:\t%8lu bytes\n" |
63 | "Slack:\t%8lu bytes\n" | 63 | "Slack:\t%8lu bytes\n" |
64 | "Shared:\t%8lu bytes\n", | 64 | "Shared:\t%8lu bytes\n", |
65 | bytes, slack, sbytes); | 65 | bytes, slack, sbytes); |
66 | 66 | ||
67 | up_read(&mm->mmap_sem); | 67 | up_read(&mm->mmap_sem); |
68 | return buffer; | ||
69 | } | 68 | } |
70 | 69 | ||
71 | unsigned long task_vsize(struct mm_struct *mm) | 70 | unsigned long task_vsize(struct mm_struct *mm) |
@@ -199,7 +198,7 @@ static void *m_next(struct seq_file *m, void *_vml, loff_t *pos) | |||
199 | return vml ? vml->next : NULL; | 198 | return vml ? vml->next : NULL; |
200 | } | 199 | } |
201 | 200 | ||
202 | static struct seq_operations proc_pid_maps_ops = { | 201 | static const struct seq_operations proc_pid_maps_ops = { |
203 | .start = m_start, | 202 | .start = m_start, |
204 | .next = m_next, | 203 | .next = m_next, |
205 | .stop = m_stop, | 204 | .stop = m_stop, |
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index 523e1098ae88..9ac0f5e064e0 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
11 | #include <linux/proc_fs.h> | 11 | #include <linux/proc_fs.h> |
12 | #include <linux/user.h> | 12 | #include <linux/user.h> |
13 | #include <linux/a.out.h> | ||
14 | #include <linux/elf.h> | 13 | #include <linux/elf.h> |
15 | #include <linux/elfcore.h> | 14 | #include <linux/elfcore.h> |
16 | #include <linux/highmem.h> | 15 | #include <linux/highmem.h> |
diff --git a/fs/read_write.c b/fs/read_write.c index 1c177f29e1b7..49a98718ecdf 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -366,7 +366,6 @@ asmlinkage ssize_t sys_read(unsigned int fd, char __user * buf, size_t count) | |||
366 | 366 | ||
367 | return ret; | 367 | return ret; |
368 | } | 368 | } |
369 | EXPORT_UNUSED_SYMBOL_GPL(sys_read); /* to be deleted for 2.6.25 */ | ||
370 | 369 | ||
371 | asmlinkage ssize_t sys_write(unsigned int fd, const char __user * buf, size_t count) | 370 | asmlinkage ssize_t sys_write(unsigned int fd, const char __user * buf, size_t count) |
372 | { | 371 | { |
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c index 001144621672..8f86c52b30d8 100644 --- a/fs/reiserfs/procfs.c +++ b/fs/reiserfs/procfs.c | |||
@@ -444,7 +444,7 @@ static int r_show(struct seq_file *m, void *v) | |||
444 | return show(m, v); | 444 | return show(m, v); |
445 | } | 445 | } |
446 | 446 | ||
447 | static struct seq_operations r_ops = { | 447 | static const struct seq_operations r_ops = { |
448 | .start = r_start, | 448 | .start = r_start, |
449 | .next = r_next, | 449 | .next = r_next, |
450 | .stop = r_stop, | 450 | .stop = r_stop, |
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 5cd85fe5df5d..6033f0c3bd0b 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
@@ -617,6 +617,7 @@ static const struct super_operations reiserfs_sops = { | |||
617 | .unlockfs = reiserfs_unlockfs, | 617 | .unlockfs = reiserfs_unlockfs, |
618 | .statfs = reiserfs_statfs, | 618 | .statfs = reiserfs_statfs, |
619 | .remount_fs = reiserfs_remount, | 619 | .remount_fs = reiserfs_remount, |
620 | .show_options = generic_show_options, | ||
620 | #ifdef CONFIG_QUOTA | 621 | #ifdef CONFIG_QUOTA |
621 | .quota_read = reiserfs_quota_read, | 622 | .quota_read = reiserfs_quota_read, |
622 | .quota_write = reiserfs_quota_write, | 623 | .quota_write = reiserfs_quota_write, |
@@ -1138,6 +1139,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1138 | unsigned long safe_mask = 0; | 1139 | unsigned long safe_mask = 0; |
1139 | unsigned int commit_max_age = (unsigned int)-1; | 1140 | unsigned int commit_max_age = (unsigned int)-1; |
1140 | struct reiserfs_journal *journal = SB_JOURNAL(s); | 1141 | struct reiserfs_journal *journal = SB_JOURNAL(s); |
1142 | char *new_opts = kstrdup(arg, GFP_KERNEL); | ||
1141 | int err; | 1143 | int err; |
1142 | #ifdef CONFIG_QUOTA | 1144 | #ifdef CONFIG_QUOTA |
1143 | int i; | 1145 | int i; |
@@ -1153,7 +1155,8 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1153 | REISERFS_SB(s)->s_qf_names[i] = NULL; | 1155 | REISERFS_SB(s)->s_qf_names[i] = NULL; |
1154 | } | 1156 | } |
1155 | #endif | 1157 | #endif |
1156 | return -EINVAL; | 1158 | err = -EINVAL; |
1159 | goto out_err; | ||
1157 | } | 1160 | } |
1158 | 1161 | ||
1159 | handle_attrs(s); | 1162 | handle_attrs(s); |
@@ -1191,9 +1194,9 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1191 | } | 1194 | } |
1192 | 1195 | ||
1193 | if (blocks) { | 1196 | if (blocks) { |
1194 | int rc = reiserfs_resize(s, blocks); | 1197 | err = reiserfs_resize(s, blocks); |
1195 | if (rc != 0) | 1198 | if (err != 0) |
1196 | return rc; | 1199 | goto out_err; |
1197 | } | 1200 | } |
1198 | 1201 | ||
1199 | if (*mount_flags & MS_RDONLY) { | 1202 | if (*mount_flags & MS_RDONLY) { |
@@ -1201,16 +1204,16 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1201 | /* remount read-only */ | 1204 | /* remount read-only */ |
1202 | if (s->s_flags & MS_RDONLY) | 1205 | if (s->s_flags & MS_RDONLY) |
1203 | /* it is read-only already */ | 1206 | /* it is read-only already */ |
1204 | return 0; | 1207 | goto out_ok; |
1205 | /* try to remount file system with read-only permissions */ | 1208 | /* try to remount file system with read-only permissions */ |
1206 | if (sb_umount_state(rs) == REISERFS_VALID_FS | 1209 | if (sb_umount_state(rs) == REISERFS_VALID_FS |
1207 | || REISERFS_SB(s)->s_mount_state != REISERFS_VALID_FS) { | 1210 | || REISERFS_SB(s)->s_mount_state != REISERFS_VALID_FS) { |
1208 | return 0; | 1211 | goto out_ok; |
1209 | } | 1212 | } |
1210 | 1213 | ||
1211 | err = journal_begin(&th, s, 10); | 1214 | err = journal_begin(&th, s, 10); |
1212 | if (err) | 1215 | if (err) |
1213 | return err; | 1216 | goto out_err; |
1214 | 1217 | ||
1215 | /* Mounting a rw partition read-only. */ | 1218 | /* Mounting a rw partition read-only. */ |
1216 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); | 1219 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); |
@@ -1220,11 +1223,13 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1220 | /* remount read-write */ | 1223 | /* remount read-write */ |
1221 | if (!(s->s_flags & MS_RDONLY)) { | 1224 | if (!(s->s_flags & MS_RDONLY)) { |
1222 | reiserfs_xattr_init(s, *mount_flags); | 1225 | reiserfs_xattr_init(s, *mount_flags); |
1223 | return 0; /* We are read-write already */ | 1226 | goto out_ok; /* We are read-write already */ |
1224 | } | 1227 | } |
1225 | 1228 | ||
1226 | if (reiserfs_is_journal_aborted(journal)) | 1229 | if (reiserfs_is_journal_aborted(journal)) { |
1227 | return journal->j_errno; | 1230 | err = journal->j_errno; |
1231 | goto out_err; | ||
1232 | } | ||
1228 | 1233 | ||
1229 | handle_data_mode(s, mount_options); | 1234 | handle_data_mode(s, mount_options); |
1230 | handle_barrier_mode(s, mount_options); | 1235 | handle_barrier_mode(s, mount_options); |
@@ -1232,7 +1237,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1232 | s->s_flags &= ~MS_RDONLY; /* now it is safe to call journal_begin */ | 1237 | s->s_flags &= ~MS_RDONLY; /* now it is safe to call journal_begin */ |
1233 | err = journal_begin(&th, s, 10); | 1238 | err = journal_begin(&th, s, 10); |
1234 | if (err) | 1239 | if (err) |
1235 | return err; | 1240 | goto out_err; |
1236 | 1241 | ||
1237 | /* Mount a partition which is read-only, read-write */ | 1242 | /* Mount a partition which is read-only, read-write */ |
1238 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); | 1243 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); |
@@ -1247,7 +1252,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1247 | SB_JOURNAL(s)->j_must_wait = 1; | 1252 | SB_JOURNAL(s)->j_must_wait = 1; |
1248 | err = journal_end(&th, s, 10); | 1253 | err = journal_end(&th, s, 10); |
1249 | if (err) | 1254 | if (err) |
1250 | return err; | 1255 | goto out_err; |
1251 | s->s_dirt = 0; | 1256 | s->s_dirt = 0; |
1252 | 1257 | ||
1253 | if (!(*mount_flags & MS_RDONLY)) { | 1258 | if (!(*mount_flags & MS_RDONLY)) { |
@@ -1255,7 +1260,14 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1255 | reiserfs_xattr_init(s, *mount_flags); | 1260 | reiserfs_xattr_init(s, *mount_flags); |
1256 | } | 1261 | } |
1257 | 1262 | ||
1263 | out_ok: | ||
1264 | kfree(s->s_options); | ||
1265 | s->s_options = new_opts; | ||
1258 | return 0; | 1266 | return 0; |
1267 | |||
1268 | out_err: | ||
1269 | kfree(new_opts); | ||
1270 | return err; | ||
1259 | } | 1271 | } |
1260 | 1272 | ||
1261 | static int read_super_block(struct super_block *s, int offset) | 1273 | static int read_super_block(struct super_block *s, int offset) |
@@ -1559,6 +1571,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1559 | struct reiserfs_sb_info *sbi; | 1571 | struct reiserfs_sb_info *sbi; |
1560 | int errval = -EINVAL; | 1572 | int errval = -EINVAL; |
1561 | 1573 | ||
1574 | save_mount_options(s, data); | ||
1575 | |||
1562 | sbi = kzalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL); | 1576 | sbi = kzalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL); |
1563 | if (!sbi) { | 1577 | if (!sbi) { |
1564 | errval = -ENOMEM; | 1578 | errval = -ENOMEM; |
diff --git a/fs/splice.c b/fs/splice.c index 4ee49e86edde..14e2262c0a04 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -1179,6 +1179,9 @@ static int copy_from_user_mmap_sem(void *dst, const void __user *src, size_t n) | |||
1179 | { | 1179 | { |
1180 | int partial; | 1180 | int partial; |
1181 | 1181 | ||
1182 | if (!access_ok(VERIFY_READ, src, n)) | ||
1183 | return -EFAULT; | ||
1184 | |||
1182 | pagefault_disable(); | 1185 | pagefault_disable(); |
1183 | partial = __copy_from_user_inatomic(dst, src, n); | 1186 | partial = __copy_from_user_inatomic(dst, src, n); |
1184 | pagefault_enable(); | 1187 | pagefault_enable(); |
@@ -1387,6 +1390,11 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *iov, | |||
1387 | break; | 1390 | break; |
1388 | } | 1391 | } |
1389 | 1392 | ||
1393 | if (unlikely(!access_ok(VERIFY_WRITE, base, len))) { | ||
1394 | error = -EFAULT; | ||
1395 | break; | ||
1396 | } | ||
1397 | |||
1390 | sd.len = 0; | 1398 | sd.len = 0; |
1391 | sd.total_len = len; | 1399 | sd.total_len = len; |
1392 | sd.flags = flags; | 1400 | sd.flags = flags; |
diff --git a/fs/super.c b/fs/super.c index ceaf2e3d594c..88811f60c8de 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -105,6 +105,7 @@ static inline void destroy_super(struct super_block *s) | |||
105 | { | 105 | { |
106 | security_sb_free(s); | 106 | security_sb_free(s); |
107 | kfree(s->s_subtype); | 107 | kfree(s->s_subtype); |
108 | kfree(s->s_options); | ||
108 | kfree(s); | 109 | kfree(s); |
109 | } | 110 | } |
110 | 111 | ||
@@ -603,6 +604,7 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) | |||
603 | mark_files_ro(sb); | 604 | mark_files_ro(sb); |
604 | else if (!fs_may_remount_ro(sb)) | 605 | else if (!fs_may_remount_ro(sb)) |
605 | return -EBUSY; | 606 | return -EBUSY; |
607 | DQUOT_OFF(sb); | ||
606 | } | 608 | } |
607 | 609 | ||
608 | if (sb->s_op->remount_fs) { | 610 | if (sb->s_op->remount_fs) { |
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index ab26176f6b91..d721a1af1972 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c | |||
@@ -28,15 +28,16 @@ | |||
28 | #include "udf_i.h" | 28 | #include "udf_i.h" |
29 | #include "udf_sb.h" | 29 | #include "udf_sb.h" |
30 | 30 | ||
31 | #define udf_clear_bit(nr,addr) ext2_clear_bit(nr,addr) | 31 | #define udf_clear_bit(nr, addr) ext2_clear_bit(nr, addr) |
32 | #define udf_set_bit(nr,addr) ext2_set_bit(nr,addr) | 32 | #define udf_set_bit(nr, addr) ext2_set_bit(nr, addr) |
33 | #define udf_test_bit(nr, addr) ext2_test_bit(nr, addr) | 33 | #define udf_test_bit(nr, addr) ext2_test_bit(nr, addr) |
34 | #define udf_find_first_one_bit(addr, size) find_first_one_bit(addr, size) | 34 | #define udf_find_first_one_bit(addr, size) find_first_one_bit(addr, size) |
35 | #define udf_find_next_one_bit(addr, size, offset) find_next_one_bit(addr, size, offset) | 35 | #define udf_find_next_one_bit(addr, size, offset) \ |
36 | find_next_one_bit(addr, size, offset) | ||
36 | 37 | ||
37 | #define leBPL_to_cpup(x) leNUM_to_cpup(BITS_PER_LONG, x) | 38 | #define leBPL_to_cpup(x) leNUM_to_cpup(BITS_PER_LONG, x) |
38 | #define leNUM_to_cpup(x,y) xleNUM_to_cpup(x,y) | 39 | #define leNUM_to_cpup(x, y) xleNUM_to_cpup(x, y) |
39 | #define xleNUM_to_cpup(x,y) (le ## x ## _to_cpup(y)) | 40 | #define xleNUM_to_cpup(x, y) (le ## x ## _to_cpup(y)) |
40 | #define uintBPL_t uint(BITS_PER_LONG) | 41 | #define uintBPL_t uint(BITS_PER_LONG) |
41 | #define uint(x) xuint(x) | 42 | #define uint(x) xuint(x) |
42 | #define xuint(x) __le ## x | 43 | #define xuint(x) __le ## x |
@@ -62,7 +63,8 @@ static inline int find_next_one_bit(void *addr, int size, int offset) | |||
62 | result += BITS_PER_LONG; | 63 | result += BITS_PER_LONG; |
63 | } | 64 | } |
64 | while (size & ~(BITS_PER_LONG - 1)) { | 65 | while (size & ~(BITS_PER_LONG - 1)) { |
65 | if ((tmp = leBPL_to_cpup(p++))) | 66 | tmp = leBPL_to_cpup(p++); |
67 | if (tmp) | ||
66 | goto found_middle; | 68 | goto found_middle; |
67 | result += BITS_PER_LONG; | 69 | result += BITS_PER_LONG; |
68 | size -= BITS_PER_LONG; | 70 | size -= BITS_PER_LONG; |
@@ -88,12 +90,12 @@ static int read_block_bitmap(struct super_block *sb, | |||
88 | kernel_lb_addr loc; | 90 | kernel_lb_addr loc; |
89 | 91 | ||
90 | loc.logicalBlockNum = bitmap->s_extPosition; | 92 | loc.logicalBlockNum = bitmap->s_extPosition; |
91 | loc.partitionReferenceNum = UDF_SB_PARTITION(sb); | 93 | loc.partitionReferenceNum = UDF_SB(sb)->s_partition; |
92 | 94 | ||
93 | bh = udf_tread(sb, udf_get_lb_pblock(sb, loc, block)); | 95 | bh = udf_tread(sb, udf_get_lb_pblock(sb, loc, block)); |
94 | if (!bh) { | 96 | if (!bh) |
95 | retval = -EIO; | 97 | retval = -EIO; |
96 | } | 98 | |
97 | bitmap->s_block_bitmap[bitmap_nr] = bh; | 99 | bitmap->s_block_bitmap[bitmap_nr] = bh; |
98 | return retval; | 100 | return retval; |
99 | } | 101 | } |
@@ -138,6 +140,20 @@ static inline int load_block_bitmap(struct super_block *sb, | |||
138 | return slot; | 140 | return slot; |
139 | } | 141 | } |
140 | 142 | ||
143 | static bool udf_add_free_space(struct udf_sb_info *sbi, | ||
144 | u16 partition, u32 cnt) | ||
145 | { | ||
146 | struct logicalVolIntegrityDesc *lvid; | ||
147 | |||
148 | if (sbi->s_lvid_bh) | ||
149 | return false; | ||
150 | |||
151 | lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; | ||
152 | lvid->freeSpaceTable[partition] = cpu_to_le32(le32_to_cpu( | ||
153 | lvid->freeSpaceTable[partition]) + cnt); | ||
154 | return true; | ||
155 | } | ||
156 | |||
141 | static void udf_bitmap_free_blocks(struct super_block *sb, | 157 | static void udf_bitmap_free_blocks(struct super_block *sb, |
142 | struct inode *inode, | 158 | struct inode *inode, |
143 | struct udf_bitmap *bitmap, | 159 | struct udf_bitmap *bitmap, |
@@ -155,57 +171,58 @@ static void udf_bitmap_free_blocks(struct super_block *sb, | |||
155 | 171 | ||
156 | mutex_lock(&sbi->s_alloc_mutex); | 172 | mutex_lock(&sbi->s_alloc_mutex); |
157 | if (bloc.logicalBlockNum < 0 || | 173 | if (bloc.logicalBlockNum < 0 || |
158 | (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) { | 174 | (bloc.logicalBlockNum + count) > |
175 | sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len) { | ||
159 | udf_debug("%d < %d || %d + %d > %d\n", | 176 | udf_debug("%d < %d || %d + %d > %d\n", |
160 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, | 177 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, |
161 | UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)); | 178 | sbi->s_partmaps[bloc.partitionReferenceNum]. |
179 | s_partition_len); | ||
162 | goto error_return; | 180 | goto error_return; |
163 | } | 181 | } |
164 | 182 | ||
165 | block = bloc.logicalBlockNum + offset + (sizeof(struct spaceBitmapDesc) << 3); | 183 | block = bloc.logicalBlockNum + offset + |
184 | (sizeof(struct spaceBitmapDesc) << 3); | ||
166 | 185 | ||
167 | do_more: | 186 | do { |
168 | overflow = 0; | 187 | overflow = 0; |
169 | block_group = block >> (sb->s_blocksize_bits + 3); | 188 | block_group = block >> (sb->s_blocksize_bits + 3); |
170 | bit = block % (sb->s_blocksize << 3); | 189 | bit = block % (sb->s_blocksize << 3); |
171 | 190 | ||
172 | /* | 191 | /* |
173 | * Check to see if we are freeing blocks across a group boundary. | 192 | * Check to see if we are freeing blocks across a group boundary. |
174 | */ | 193 | */ |
175 | if (bit + count > (sb->s_blocksize << 3)) { | 194 | if (bit + count > (sb->s_blocksize << 3)) { |
176 | overflow = bit + count - (sb->s_blocksize << 3); | 195 | overflow = bit + count - (sb->s_blocksize << 3); |
177 | count -= overflow; | 196 | count -= overflow; |
178 | } | 197 | } |
179 | bitmap_nr = load_block_bitmap(sb, bitmap, block_group); | 198 | bitmap_nr = load_block_bitmap(sb, bitmap, block_group); |
180 | if (bitmap_nr < 0) | 199 | if (bitmap_nr < 0) |
181 | goto error_return; | 200 | goto error_return; |
182 | 201 | ||
183 | bh = bitmap->s_block_bitmap[bitmap_nr]; | 202 | bh = bitmap->s_block_bitmap[bitmap_nr]; |
184 | for (i = 0; i < count; i++) { | 203 | for (i = 0; i < count; i++) { |
185 | if (udf_set_bit(bit + i, bh->b_data)) { | 204 | if (udf_set_bit(bit + i, bh->b_data)) { |
186 | udf_debug("bit %ld already set\n", bit + i); | 205 | udf_debug("bit %ld already set\n", bit + i); |
187 | udf_debug("byte=%2x\n", ((char *)bh->b_data)[(bit + i) >> 3]); | 206 | udf_debug("byte=%2x\n", |
188 | } else { | 207 | ((char *)bh->b_data)[(bit + i) >> 3]); |
189 | if (inode) | 208 | } else { |
190 | DQUOT_FREE_BLOCK(inode, 1); | 209 | if (inode) |
191 | if (UDF_SB_LVIDBH(sb)) { | 210 | DQUOT_FREE_BLOCK(inode, 1); |
192 | UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] = | 211 | udf_add_free_space(sbi, sbi->s_partition, 1); |
193 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + 1); | ||
194 | } | 212 | } |
195 | } | 213 | } |
196 | } | 214 | mark_buffer_dirty(bh); |
197 | mark_buffer_dirty(bh); | 215 | if (overflow) { |
198 | if (overflow) { | 216 | block += count; |
199 | block += count; | 217 | count = overflow; |
200 | count = overflow; | 218 | } |
201 | goto do_more; | 219 | } while (overflow); |
202 | } | 220 | |
203 | error_return: | 221 | error_return: |
204 | sb->s_dirt = 1; | 222 | sb->s_dirt = 1; |
205 | if (UDF_SB_LVIDBH(sb)) | 223 | if (sbi->s_lvid_bh) |
206 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 224 | mark_buffer_dirty(sbi->s_lvid_bh); |
207 | mutex_unlock(&sbi->s_alloc_mutex); | 225 | mutex_unlock(&sbi->s_alloc_mutex); |
208 | return; | ||
209 | } | 226 | } |
210 | 227 | ||
211 | static int udf_bitmap_prealloc_blocks(struct super_block *sb, | 228 | static int udf_bitmap_prealloc_blocks(struct super_block *sb, |
@@ -219,53 +236,50 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb, | |||
219 | int bit, block, block_group, group_start; | 236 | int bit, block, block_group, group_start; |
220 | int nr_groups, bitmap_nr; | 237 | int nr_groups, bitmap_nr; |
221 | struct buffer_head *bh; | 238 | struct buffer_head *bh; |
239 | __u32 part_len; | ||
222 | 240 | ||
223 | mutex_lock(&sbi->s_alloc_mutex); | 241 | mutex_lock(&sbi->s_alloc_mutex); |
224 | if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition)) | 242 | part_len = sbi->s_partmaps[partition].s_partition_len; |
243 | if (first_block < 0 || first_block >= part_len) | ||
225 | goto out; | 244 | goto out; |
226 | 245 | ||
227 | if (first_block + block_count > UDF_SB_PARTLEN(sb, partition)) | 246 | if (first_block + block_count > part_len) |
228 | block_count = UDF_SB_PARTLEN(sb, partition) - first_block; | 247 | block_count = part_len - first_block; |
229 | 248 | ||
230 | repeat: | 249 | do { |
231 | nr_groups = (UDF_SB_PARTLEN(sb, partition) + | 250 | nr_groups = udf_compute_nr_groups(sb, partition); |
232 | (sizeof(struct spaceBitmapDesc) << 3) + | 251 | block = first_block + (sizeof(struct spaceBitmapDesc) << 3); |
233 | (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8); | 252 | block_group = block >> (sb->s_blocksize_bits + 3); |
234 | block = first_block + (sizeof(struct spaceBitmapDesc) << 3); | 253 | group_start = block_group ? 0 : sizeof(struct spaceBitmapDesc); |
235 | block_group = block >> (sb->s_blocksize_bits + 3); | ||
236 | group_start = block_group ? 0 : sizeof(struct spaceBitmapDesc); | ||
237 | 254 | ||
238 | bitmap_nr = load_block_bitmap(sb, bitmap, block_group); | 255 | bitmap_nr = load_block_bitmap(sb, bitmap, block_group); |
239 | if (bitmap_nr < 0) | 256 | if (bitmap_nr < 0) |
240 | goto out; | 257 | goto out; |
241 | bh = bitmap->s_block_bitmap[bitmap_nr]; | 258 | bh = bitmap->s_block_bitmap[bitmap_nr]; |
242 | 259 | ||
243 | bit = block % (sb->s_blocksize << 3); | 260 | bit = block % (sb->s_blocksize << 3); |
244 | 261 | ||
245 | while (bit < (sb->s_blocksize << 3) && block_count > 0) { | 262 | while (bit < (sb->s_blocksize << 3) && block_count > 0) { |
246 | if (!udf_test_bit(bit, bh->b_data)) { | 263 | if (!udf_test_bit(bit, bh->b_data)) |
247 | goto out; | 264 | goto out; |
248 | } else if (DQUOT_PREALLOC_BLOCK(inode, 1)) { | 265 | else if (DQUOT_PREALLOC_BLOCK(inode, 1)) |
249 | goto out; | 266 | goto out; |
250 | } else if (!udf_clear_bit(bit, bh->b_data)) { | 267 | else if (!udf_clear_bit(bit, bh->b_data)) { |
251 | udf_debug("bit already cleared for block %d\n", bit); | 268 | udf_debug("bit already cleared for block %d\n", bit); |
252 | DQUOT_FREE_BLOCK(inode, 1); | 269 | DQUOT_FREE_BLOCK(inode, 1); |
253 | goto out; | 270 | goto out; |
271 | } | ||
272 | block_count--; | ||
273 | alloc_count++; | ||
274 | bit++; | ||
275 | block++; | ||
254 | } | 276 | } |
255 | block_count--; | 277 | mark_buffer_dirty(bh); |
256 | alloc_count++; | 278 | } while (block_count > 0); |
257 | bit++; | 279 | |
258 | block++; | ||
259 | } | ||
260 | mark_buffer_dirty(bh); | ||
261 | if (block_count > 0) | ||
262 | goto repeat; | ||
263 | out: | 280 | out: |
264 | if (UDF_SB_LVIDBH(sb)) { | 281 | if (udf_add_free_space(sbi, partition, -alloc_count)) |
265 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 282 | mark_buffer_dirty(sbi->s_lvid_bh); |
266 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count); | ||
267 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | ||
268 | } | ||
269 | sb->s_dirt = 1; | 283 | sb->s_dirt = 1; |
270 | mutex_unlock(&sbi->s_alloc_mutex); | 284 | mutex_unlock(&sbi->s_alloc_mutex); |
271 | return alloc_count; | 285 | return alloc_count; |
@@ -287,7 +301,7 @@ static int udf_bitmap_new_block(struct super_block *sb, | |||
287 | mutex_lock(&sbi->s_alloc_mutex); | 301 | mutex_lock(&sbi->s_alloc_mutex); |
288 | 302 | ||
289 | repeat: | 303 | repeat: |
290 | if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition)) | 304 | if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len) |
291 | goal = 0; | 305 | goal = 0; |
292 | 306 | ||
293 | nr_groups = bitmap->s_nr_groups; | 307 | nr_groups = bitmap->s_nr_groups; |
@@ -312,14 +326,16 @@ repeat: | |||
312 | if (bit < end_goal) | 326 | if (bit < end_goal) |
313 | goto got_block; | 327 | goto got_block; |
314 | 328 | ||
315 | ptr = memscan((char *)bh->b_data + (bit >> 3), 0xFF, sb->s_blocksize - ((bit + 7) >> 3)); | 329 | ptr = memscan((char *)bh->b_data + (bit >> 3), 0xFF, |
330 | sb->s_blocksize - ((bit + 7) >> 3)); | ||
316 | newbit = (ptr - ((char *)bh->b_data)) << 3; | 331 | newbit = (ptr - ((char *)bh->b_data)) << 3; |
317 | if (newbit < sb->s_blocksize << 3) { | 332 | if (newbit < sb->s_blocksize << 3) { |
318 | bit = newbit; | 333 | bit = newbit; |
319 | goto search_back; | 334 | goto search_back; |
320 | } | 335 | } |
321 | 336 | ||
322 | newbit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, bit); | 337 | newbit = udf_find_next_one_bit(bh->b_data, |
338 | sb->s_blocksize << 3, bit); | ||
323 | if (newbit < sb->s_blocksize << 3) { | 339 | if (newbit < sb->s_blocksize << 3) { |
324 | bit = newbit; | 340 | bit = newbit; |
325 | goto got_block; | 341 | goto got_block; |
@@ -358,15 +374,20 @@ repeat: | |||
358 | if (bit < sb->s_blocksize << 3) | 374 | if (bit < sb->s_blocksize << 3) |
359 | goto search_back; | 375 | goto search_back; |
360 | else | 376 | else |
361 | bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, group_start << 3); | 377 | bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, |
378 | group_start << 3); | ||
362 | if (bit >= sb->s_blocksize << 3) { | 379 | if (bit >= sb->s_blocksize << 3) { |
363 | mutex_unlock(&sbi->s_alloc_mutex); | 380 | mutex_unlock(&sbi->s_alloc_mutex); |
364 | return 0; | 381 | return 0; |
365 | } | 382 | } |
366 | 383 | ||
367 | search_back: | 384 | search_back: |
368 | for (i = 0; i < 7 && bit > (group_start << 3) && udf_test_bit(bit - 1, bh->b_data); i++, bit--) | 385 | i = 0; |
369 | ; /* empty loop */ | 386 | while (i < 7 && bit > (group_start << 3) && |
387 | udf_test_bit(bit - 1, bh->b_data)) { | ||
388 | ++i; | ||
389 | --bit; | ||
390 | } | ||
370 | 391 | ||
371 | got_block: | 392 | got_block: |
372 | 393 | ||
@@ -389,11 +410,8 @@ got_block: | |||
389 | 410 | ||
390 | mark_buffer_dirty(bh); | 411 | mark_buffer_dirty(bh); |
391 | 412 | ||
392 | if (UDF_SB_LVIDBH(sb)) { | 413 | if (udf_add_free_space(sbi, partition, -1)) |
393 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 414 | mark_buffer_dirty(sbi->s_lvid_bh); |
394 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1); | ||
395 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | ||
396 | } | ||
397 | sb->s_dirt = 1; | 415 | sb->s_dirt = 1; |
398 | mutex_unlock(&sbi->s_alloc_mutex); | 416 | mutex_unlock(&sbi->s_alloc_mutex); |
399 | *err = 0; | 417 | *err = 0; |
@@ -418,56 +436,70 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
418 | struct extent_position oepos, epos; | 436 | struct extent_position oepos, epos; |
419 | int8_t etype; | 437 | int8_t etype; |
420 | int i; | 438 | int i; |
439 | struct udf_inode_info *iinfo; | ||
421 | 440 | ||
422 | mutex_lock(&sbi->s_alloc_mutex); | 441 | mutex_lock(&sbi->s_alloc_mutex); |
423 | if (bloc.logicalBlockNum < 0 || | 442 | if (bloc.logicalBlockNum < 0 || |
424 | (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) { | 443 | (bloc.logicalBlockNum + count) > |
444 | sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len) { | ||
425 | udf_debug("%d < %d || %d + %d > %d\n", | 445 | udf_debug("%d < %d || %d + %d > %d\n", |
426 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, | 446 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, |
427 | UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)); | 447 | sbi->s_partmaps[bloc.partitionReferenceNum]. |
448 | s_partition_len); | ||
428 | goto error_return; | 449 | goto error_return; |
429 | } | 450 | } |
430 | 451 | ||
431 | /* We do this up front - There are some error conditions that could occure, | 452 | iinfo = UDF_I(table); |
432 | but.. oh well */ | 453 | /* We do this up front - There are some error conditions that |
454 | could occure, but.. oh well */ | ||
433 | if (inode) | 455 | if (inode) |
434 | DQUOT_FREE_BLOCK(inode, count); | 456 | DQUOT_FREE_BLOCK(inode, count); |
435 | if (UDF_SB_LVIDBH(sb)) { | 457 | if (udf_add_free_space(sbi, sbi->s_partition, count)) |
436 | UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] = | 458 | mark_buffer_dirty(sbi->s_lvid_bh); |
437 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + count); | ||
438 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | ||
439 | } | ||
440 | 459 | ||
441 | start = bloc.logicalBlockNum + offset; | 460 | start = bloc.logicalBlockNum + offset; |
442 | end = bloc.logicalBlockNum + offset + count - 1; | 461 | end = bloc.logicalBlockNum + offset + count - 1; |
443 | 462 | ||
444 | epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry); | 463 | epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry); |
445 | elen = 0; | 464 | elen = 0; |
446 | epos.block = oepos.block = UDF_I_LOCATION(table); | 465 | epos.block = oepos.block = iinfo->i_location; |
447 | epos.bh = oepos.bh = NULL; | 466 | epos.bh = oepos.bh = NULL; |
448 | 467 | ||
449 | while (count && | 468 | while (count && |
450 | (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { | 469 | (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { |
451 | if (((eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits)) == start)) { | 470 | if (((eloc.logicalBlockNum + |
452 | if ((0x3FFFFFFF - elen) < (count << sb->s_blocksize_bits)) { | 471 | (elen >> sb->s_blocksize_bits)) == start)) { |
453 | count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); | 472 | if ((0x3FFFFFFF - elen) < |
454 | start += ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); | 473 | (count << sb->s_blocksize_bits)) { |
455 | elen = (etype << 30) | (0x40000000 - sb->s_blocksize); | 474 | uint32_t tmp = ((0x3FFFFFFF - elen) >> |
475 | sb->s_blocksize_bits); | ||
476 | count -= tmp; | ||
477 | start += tmp; | ||
478 | elen = (etype << 30) | | ||
479 | (0x40000000 - sb->s_blocksize); | ||
456 | } else { | 480 | } else { |
457 | elen = (etype << 30) | (elen + (count << sb->s_blocksize_bits)); | 481 | elen = (etype << 30) | |
482 | (elen + | ||
483 | (count << sb->s_blocksize_bits)); | ||
458 | start += count; | 484 | start += count; |
459 | count = 0; | 485 | count = 0; |
460 | } | 486 | } |
461 | udf_write_aext(table, &oepos, eloc, elen, 1); | 487 | udf_write_aext(table, &oepos, eloc, elen, 1); |
462 | } else if (eloc.logicalBlockNum == (end + 1)) { | 488 | } else if (eloc.logicalBlockNum == (end + 1)) { |
463 | if ((0x3FFFFFFF - elen) < (count << sb->s_blocksize_bits)) { | 489 | if ((0x3FFFFFFF - elen) < |
464 | count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); | 490 | (count << sb->s_blocksize_bits)) { |
465 | end -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); | 491 | uint32_t tmp = ((0x3FFFFFFF - elen) >> |
466 | eloc.logicalBlockNum -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); | 492 | sb->s_blocksize_bits); |
467 | elen = (etype << 30) | (0x40000000 - sb->s_blocksize); | 493 | count -= tmp; |
494 | end -= tmp; | ||
495 | eloc.logicalBlockNum -= tmp; | ||
496 | elen = (etype << 30) | | ||
497 | (0x40000000 - sb->s_blocksize); | ||
468 | } else { | 498 | } else { |
469 | eloc.logicalBlockNum = start; | 499 | eloc.logicalBlockNum = start; |
470 | elen = (etype << 30) | (elen + (count << sb->s_blocksize_bits)); | 500 | elen = (etype << 30) | |
501 | (elen + | ||
502 | (count << sb->s_blocksize_bits)); | ||
471 | end -= count; | 503 | end -= count; |
472 | count = 0; | 504 | count = 0; |
473 | } | 505 | } |
@@ -488,9 +520,9 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
488 | 520 | ||
489 | if (count) { | 521 | if (count) { |
490 | /* | 522 | /* |
491 | * NOTE: we CANNOT use udf_add_aext here, as it can try to allocate | 523 | * NOTE: we CANNOT use udf_add_aext here, as it can try to |
492 | * a new block, and since we hold the super block lock already | 524 | * allocate a new block, and since we hold the super block |
493 | * very bad things would happen :) | 525 | * lock already very bad things would happen :) |
494 | * | 526 | * |
495 | * We copy the behavior of udf_add_aext, but instead of | 527 | * We copy the behavior of udf_add_aext, but instead of |
496 | * trying to allocate a new block close to the existing one, | 528 | * trying to allocate a new block close to the existing one, |
@@ -509,11 +541,11 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
509 | elen = EXT_RECORDED_ALLOCATED | | 541 | elen = EXT_RECORDED_ALLOCATED | |
510 | (count << sb->s_blocksize_bits); | 542 | (count << sb->s_blocksize_bits); |
511 | 543 | ||
512 | if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT) { | 544 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
513 | adsize = sizeof(short_ad); | 545 | adsize = sizeof(short_ad); |
514 | } else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG) { | 546 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
515 | adsize = sizeof(long_ad); | 547 | adsize = sizeof(long_ad); |
516 | } else { | 548 | else { |
517 | brelse(oepos.bh); | 549 | brelse(oepos.bh); |
518 | brelse(epos.bh); | 550 | brelse(epos.bh); |
519 | goto error_return; | 551 | goto error_return; |
@@ -531,56 +563,70 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
531 | eloc.logicalBlockNum++; | 563 | eloc.logicalBlockNum++; |
532 | elen -= sb->s_blocksize; | 564 | elen -= sb->s_blocksize; |
533 | 565 | ||
534 | if (!(epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, epos.block, 0)))) { | 566 | epos.bh = udf_tread(sb, |
567 | udf_get_lb_pblock(sb, epos.block, 0)); | ||
568 | if (!epos.bh) { | ||
535 | brelse(oepos.bh); | 569 | brelse(oepos.bh); |
536 | goto error_return; | 570 | goto error_return; |
537 | } | 571 | } |
538 | aed = (struct allocExtDesc *)(epos.bh->b_data); | 572 | aed = (struct allocExtDesc *)(epos.bh->b_data); |
539 | aed->previousAllocExtLocation = cpu_to_le32(oepos.block.logicalBlockNum); | 573 | aed->previousAllocExtLocation = |
574 | cpu_to_le32(oepos.block.logicalBlockNum); | ||
540 | if (epos.offset + adsize > sb->s_blocksize) { | 575 | if (epos.offset + adsize > sb->s_blocksize) { |
541 | loffset = epos.offset; | 576 | loffset = epos.offset; |
542 | aed->lengthAllocDescs = cpu_to_le32(adsize); | 577 | aed->lengthAllocDescs = cpu_to_le32(adsize); |
543 | sptr = UDF_I_DATA(table) + epos.offset - adsize; | 578 | sptr = iinfo->i_ext.i_data + epos.offset |
544 | dptr = epos.bh->b_data + sizeof(struct allocExtDesc); | 579 | - adsize; |
580 | dptr = epos.bh->b_data + | ||
581 | sizeof(struct allocExtDesc); | ||
545 | memcpy(dptr, sptr, adsize); | 582 | memcpy(dptr, sptr, adsize); |
546 | epos.offset = sizeof(struct allocExtDesc) + adsize; | 583 | epos.offset = sizeof(struct allocExtDesc) + |
584 | adsize; | ||
547 | } else { | 585 | } else { |
548 | loffset = epos.offset + adsize; | 586 | loffset = epos.offset + adsize; |
549 | aed->lengthAllocDescs = cpu_to_le32(0); | 587 | aed->lengthAllocDescs = cpu_to_le32(0); |
550 | if (oepos.bh) { | 588 | if (oepos.bh) { |
551 | sptr = oepos.bh->b_data + epos.offset; | 589 | sptr = oepos.bh->b_data + epos.offset; |
552 | aed = (struct allocExtDesc *)oepos.bh->b_data; | 590 | aed = (struct allocExtDesc *) |
591 | oepos.bh->b_data; | ||
553 | aed->lengthAllocDescs = | 592 | aed->lengthAllocDescs = |
554 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); | 593 | cpu_to_le32(le32_to_cpu( |
594 | aed->lengthAllocDescs) + | ||
595 | adsize); | ||
555 | } else { | 596 | } else { |
556 | sptr = UDF_I_DATA(table) + epos.offset; | 597 | sptr = iinfo->i_ext.i_data + |
557 | UDF_I_LENALLOC(table) += adsize; | 598 | epos.offset; |
599 | iinfo->i_lenAlloc += adsize; | ||
558 | mark_inode_dirty(table); | 600 | mark_inode_dirty(table); |
559 | } | 601 | } |
560 | epos.offset = sizeof(struct allocExtDesc); | 602 | epos.offset = sizeof(struct allocExtDesc); |
561 | } | 603 | } |
562 | if (UDF_SB_UDFREV(sb) >= 0x0200) | 604 | if (sbi->s_udfrev >= 0x0200) |
563 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3, 1, | 605 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, |
564 | epos.block.logicalBlockNum, sizeof(tag)); | 606 | 3, 1, epos.block.logicalBlockNum, |
607 | sizeof(tag)); | ||
565 | else | 608 | else |
566 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 2, 1, | 609 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, |
567 | epos.block.logicalBlockNum, sizeof(tag)); | 610 | 2, 1, epos.block.logicalBlockNum, |
568 | 611 | sizeof(tag)); | |
569 | switch (UDF_I_ALLOCTYPE(table)) { | 612 | |
570 | case ICBTAG_FLAG_AD_SHORT: | 613 | switch (iinfo->i_alloc_type) { |
571 | sad = (short_ad *)sptr; | 614 | case ICBTAG_FLAG_AD_SHORT: |
572 | sad->extLength = cpu_to_le32( | 615 | sad = (short_ad *)sptr; |
573 | EXT_NEXT_EXTENT_ALLOCDECS | | 616 | sad->extLength = cpu_to_le32( |
574 | sb->s_blocksize); | 617 | EXT_NEXT_EXTENT_ALLOCDECS | |
575 | sad->extPosition = cpu_to_le32(epos.block.logicalBlockNum); | 618 | sb->s_blocksize); |
576 | break; | 619 | sad->extPosition = |
577 | case ICBTAG_FLAG_AD_LONG: | 620 | cpu_to_le32(epos.block.logicalBlockNum); |
578 | lad = (long_ad *)sptr; | 621 | break; |
579 | lad->extLength = cpu_to_le32( | 622 | case ICBTAG_FLAG_AD_LONG: |
580 | EXT_NEXT_EXTENT_ALLOCDECS | | 623 | lad = (long_ad *)sptr; |
581 | sb->s_blocksize); | 624 | lad->extLength = cpu_to_le32( |
582 | lad->extLocation = cpu_to_lelb(epos.block); | 625 | EXT_NEXT_EXTENT_ALLOCDECS | |
583 | break; | 626 | sb->s_blocksize); |
627 | lad->extLocation = | ||
628 | cpu_to_lelb(epos.block); | ||
629 | break; | ||
584 | } | 630 | } |
585 | if (oepos.bh) { | 631 | if (oepos.bh) { |
586 | udf_update_tag(oepos.bh->b_data, loffset); | 632 | udf_update_tag(oepos.bh->b_data, loffset); |
@@ -590,16 +636,18 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
590 | } | 636 | } |
591 | } | 637 | } |
592 | 638 | ||
593 | if (elen) { /* It's possible that stealing the block emptied the extent */ | 639 | /* It's possible that stealing the block emptied the extent */ |
640 | if (elen) { | ||
594 | udf_write_aext(table, &epos, eloc, elen, 1); | 641 | udf_write_aext(table, &epos, eloc, elen, 1); |
595 | 642 | ||
596 | if (!epos.bh) { | 643 | if (!epos.bh) { |
597 | UDF_I_LENALLOC(table) += adsize; | 644 | iinfo->i_lenAlloc += adsize; |
598 | mark_inode_dirty(table); | 645 | mark_inode_dirty(table); |
599 | } else { | 646 | } else { |
600 | aed = (struct allocExtDesc *)epos.bh->b_data; | 647 | aed = (struct allocExtDesc *)epos.bh->b_data; |
601 | aed->lengthAllocDescs = | 648 | aed->lengthAllocDescs = |
602 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); | 649 | cpu_to_le32(le32_to_cpu( |
650 | aed->lengthAllocDescs) + adsize); | ||
603 | udf_update_tag(epos.bh->b_data, epos.offset); | 651 | udf_update_tag(epos.bh->b_data, epos.offset); |
604 | mark_buffer_dirty(epos.bh); | 652 | mark_buffer_dirty(epos.bh); |
605 | } | 653 | } |
@@ -626,20 +674,23 @@ static int udf_table_prealloc_blocks(struct super_block *sb, | |||
626 | kernel_lb_addr eloc; | 674 | kernel_lb_addr eloc; |
627 | struct extent_position epos; | 675 | struct extent_position epos; |
628 | int8_t etype = -1; | 676 | int8_t etype = -1; |
677 | struct udf_inode_info *iinfo; | ||
629 | 678 | ||
630 | if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition)) | 679 | if (first_block < 0 || |
680 | first_block >= sbi->s_partmaps[partition].s_partition_len) | ||
631 | return 0; | 681 | return 0; |
632 | 682 | ||
633 | if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT) | 683 | iinfo = UDF_I(table); |
684 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | ||
634 | adsize = sizeof(short_ad); | 685 | adsize = sizeof(short_ad); |
635 | else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG) | 686 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
636 | adsize = sizeof(long_ad); | 687 | adsize = sizeof(long_ad); |
637 | else | 688 | else |
638 | return 0; | 689 | return 0; |
639 | 690 | ||
640 | mutex_lock(&sbi->s_alloc_mutex); | 691 | mutex_lock(&sbi->s_alloc_mutex); |
641 | epos.offset = sizeof(struct unallocSpaceEntry); | 692 | epos.offset = sizeof(struct unallocSpaceEntry); |
642 | epos.block = UDF_I_LOCATION(table); | 693 | epos.block = iinfo->i_location; |
643 | epos.bh = NULL; | 694 | epos.bh = NULL; |
644 | eloc.logicalBlockNum = 0xFFFFFFFF; | 695 | eloc.logicalBlockNum = 0xFFFFFFFF; |
645 | 696 | ||
@@ -654,26 +705,26 @@ static int udf_table_prealloc_blocks(struct super_block *sb, | |||
654 | epos.offset -= adsize; | 705 | epos.offset -= adsize; |
655 | 706 | ||
656 | alloc_count = (elen >> sb->s_blocksize_bits); | 707 | alloc_count = (elen >> sb->s_blocksize_bits); |
657 | if (inode && DQUOT_PREALLOC_BLOCK(inode, alloc_count > block_count ? block_count : alloc_count)) { | 708 | if (inode && DQUOT_PREALLOC_BLOCK(inode, |
709 | alloc_count > block_count ? block_count : alloc_count)) | ||
658 | alloc_count = 0; | 710 | alloc_count = 0; |
659 | } else if (alloc_count > block_count) { | 711 | else if (alloc_count > block_count) { |
660 | alloc_count = block_count; | 712 | alloc_count = block_count; |
661 | eloc.logicalBlockNum += alloc_count; | 713 | eloc.logicalBlockNum += alloc_count; |
662 | elen -= (alloc_count << sb->s_blocksize_bits); | 714 | elen -= (alloc_count << sb->s_blocksize_bits); |
663 | udf_write_aext(table, &epos, eloc, (etype << 30) | elen, 1); | 715 | udf_write_aext(table, &epos, eloc, |
664 | } else { | 716 | (etype << 30) | elen, 1); |
665 | udf_delete_aext(table, epos, eloc, (etype << 30) | elen); | 717 | } else |
666 | } | 718 | udf_delete_aext(table, epos, eloc, |
719 | (etype << 30) | elen); | ||
667 | } else { | 720 | } else { |
668 | alloc_count = 0; | 721 | alloc_count = 0; |
669 | } | 722 | } |
670 | 723 | ||
671 | brelse(epos.bh); | 724 | brelse(epos.bh); |
672 | 725 | ||
673 | if (alloc_count && UDF_SB_LVIDBH(sb)) { | 726 | if (alloc_count && udf_add_free_space(sbi, partition, -alloc_count)) { |
674 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 727 | mark_buffer_dirty(sbi->s_lvid_bh); |
675 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count); | ||
676 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | ||
677 | sb->s_dirt = 1; | 728 | sb->s_dirt = 1; |
678 | } | 729 | } |
679 | mutex_unlock(&sbi->s_alloc_mutex); | 730 | mutex_unlock(&sbi->s_alloc_mutex); |
@@ -692,33 +743,35 @@ static int udf_table_new_block(struct super_block *sb, | |||
692 | kernel_lb_addr eloc, uninitialized_var(goal_eloc); | 743 | kernel_lb_addr eloc, uninitialized_var(goal_eloc); |
693 | struct extent_position epos, goal_epos; | 744 | struct extent_position epos, goal_epos; |
694 | int8_t etype; | 745 | int8_t etype; |
746 | struct udf_inode_info *iinfo = UDF_I(table); | ||
695 | 747 | ||
696 | *err = -ENOSPC; | 748 | *err = -ENOSPC; |
697 | 749 | ||
698 | if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT) | 750 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
699 | adsize = sizeof(short_ad); | 751 | adsize = sizeof(short_ad); |
700 | else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG) | 752 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
701 | adsize = sizeof(long_ad); | 753 | adsize = sizeof(long_ad); |
702 | else | 754 | else |
703 | return newblock; | 755 | return newblock; |
704 | 756 | ||
705 | mutex_lock(&sbi->s_alloc_mutex); | 757 | mutex_lock(&sbi->s_alloc_mutex); |
706 | if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition)) | 758 | if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len) |
707 | goal = 0; | 759 | goal = 0; |
708 | 760 | ||
709 | /* We search for the closest matching block to goal. If we find a exact hit, | 761 | /* We search for the closest matching block to goal. If we find |
710 | we stop. Otherwise we keep going till we run out of extents. | 762 | a exact hit, we stop. Otherwise we keep going till we run out |
711 | We store the buffer_head, bloc, and extoffset of the current closest | 763 | of extents. We store the buffer_head, bloc, and extoffset |
712 | match and use that when we are done. | 764 | of the current closest match and use that when we are done. |
713 | */ | 765 | */ |
714 | epos.offset = sizeof(struct unallocSpaceEntry); | 766 | epos.offset = sizeof(struct unallocSpaceEntry); |
715 | epos.block = UDF_I_LOCATION(table); | 767 | epos.block = iinfo->i_location; |
716 | epos.bh = goal_epos.bh = NULL; | 768 | epos.bh = goal_epos.bh = NULL; |
717 | 769 | ||
718 | while (spread && | 770 | while (spread && |
719 | (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { | 771 | (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { |
720 | if (goal >= eloc.logicalBlockNum) { | 772 | if (goal >= eloc.logicalBlockNum) { |
721 | if (goal < eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits)) | 773 | if (goal < eloc.logicalBlockNum + |
774 | (elen >> sb->s_blocksize_bits)) | ||
722 | nspread = 0; | 775 | nspread = 0; |
723 | else | 776 | else |
724 | nspread = goal - eloc.logicalBlockNum - | 777 | nspread = goal - eloc.logicalBlockNum - |
@@ -771,11 +824,8 @@ static int udf_table_new_block(struct super_block *sb, | |||
771 | udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); | 824 | udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); |
772 | brelse(goal_epos.bh); | 825 | brelse(goal_epos.bh); |
773 | 826 | ||
774 | if (UDF_SB_LVIDBH(sb)) { | 827 | if (udf_add_free_space(sbi, partition, -1)) |
775 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 828 | mark_buffer_dirty(sbi->s_lvid_bh); |
776 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1); | ||
777 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | ||
778 | } | ||
779 | 829 | ||
780 | sb->s_dirt = 1; | 830 | sb->s_dirt = 1; |
781 | mutex_unlock(&sbi->s_alloc_mutex); | 831 | mutex_unlock(&sbi->s_alloc_mutex); |
@@ -789,22 +839,23 @@ inline void udf_free_blocks(struct super_block *sb, | |||
789 | uint32_t count) | 839 | uint32_t count) |
790 | { | 840 | { |
791 | uint16_t partition = bloc.partitionReferenceNum; | 841 | uint16_t partition = bloc.partitionReferenceNum; |
842 | struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; | ||
792 | 843 | ||
793 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { | 844 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { |
794 | return udf_bitmap_free_blocks(sb, inode, | 845 | return udf_bitmap_free_blocks(sb, inode, |
795 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap, | 846 | map->s_uspace.s_bitmap, |
796 | bloc, offset, count); | 847 | bloc, offset, count); |
797 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) { | 848 | } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { |
798 | return udf_table_free_blocks(sb, inode, | 849 | return udf_table_free_blocks(sb, inode, |
799 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table, | 850 | map->s_uspace.s_table, |
800 | bloc, offset, count); | 851 | bloc, offset, count); |
801 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { | 852 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { |
802 | return udf_bitmap_free_blocks(sb, inode, | 853 | return udf_bitmap_free_blocks(sb, inode, |
803 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap, | 854 | map->s_fspace.s_bitmap, |
804 | bloc, offset, count); | 855 | bloc, offset, count); |
805 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { | 856 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { |
806 | return udf_table_free_blocks(sb, inode, | 857 | return udf_table_free_blocks(sb, inode, |
807 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table, | 858 | map->s_fspace.s_table, |
808 | bloc, offset, count); | 859 | bloc, offset, count); |
809 | } else { | 860 | } else { |
810 | return; | 861 | return; |
@@ -816,51 +867,55 @@ inline int udf_prealloc_blocks(struct super_block *sb, | |||
816 | uint16_t partition, uint32_t first_block, | 867 | uint16_t partition, uint32_t first_block, |
817 | uint32_t block_count) | 868 | uint32_t block_count) |
818 | { | 869 | { |
819 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { | 870 | struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; |
871 | |||
872 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) | ||
820 | return udf_bitmap_prealloc_blocks(sb, inode, | 873 | return udf_bitmap_prealloc_blocks(sb, inode, |
821 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap, | 874 | map->s_uspace.s_bitmap, |
822 | partition, first_block, block_count); | 875 | partition, first_block, |
823 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) { | 876 | block_count); |
877 | else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) | ||
824 | return udf_table_prealloc_blocks(sb, inode, | 878 | return udf_table_prealloc_blocks(sb, inode, |
825 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table, | 879 | map->s_uspace.s_table, |
826 | partition, first_block, block_count); | 880 | partition, first_block, |
827 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { | 881 | block_count); |
882 | else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) | ||
828 | return udf_bitmap_prealloc_blocks(sb, inode, | 883 | return udf_bitmap_prealloc_blocks(sb, inode, |
829 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap, | 884 | map->s_fspace.s_bitmap, |
830 | partition, first_block, block_count); | 885 | partition, first_block, |
831 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { | 886 | block_count); |
887 | else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) | ||
832 | return udf_table_prealloc_blocks(sb, inode, | 888 | return udf_table_prealloc_blocks(sb, inode, |
833 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table, | 889 | map->s_fspace.s_table, |
834 | partition, first_block, block_count); | 890 | partition, first_block, |
835 | } else { | 891 | block_count); |
892 | else | ||
836 | return 0; | 893 | return 0; |
837 | } | ||
838 | } | 894 | } |
839 | 895 | ||
840 | inline int udf_new_block(struct super_block *sb, | 896 | inline int udf_new_block(struct super_block *sb, |
841 | struct inode *inode, | 897 | struct inode *inode, |
842 | uint16_t partition, uint32_t goal, int *err) | 898 | uint16_t partition, uint32_t goal, int *err) |
843 | { | 899 | { |
844 | int ret; | 900 | struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; |
845 | 901 | ||
846 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { | 902 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) |
847 | ret = udf_bitmap_new_block(sb, inode, | 903 | return udf_bitmap_new_block(sb, inode, |
848 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap, | 904 | map->s_uspace.s_bitmap, |
849 | partition, goal, err); | 905 | partition, goal, err); |
850 | return ret; | 906 | else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) |
851 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) { | ||
852 | return udf_table_new_block(sb, inode, | 907 | return udf_table_new_block(sb, inode, |
853 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table, | 908 | map->s_uspace.s_table, |
854 | partition, goal, err); | 909 | partition, goal, err); |
855 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { | 910 | else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) |
856 | return udf_bitmap_new_block(sb, inode, | 911 | return udf_bitmap_new_block(sb, inode, |
857 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap, | 912 | map->s_fspace.s_bitmap, |
858 | partition, goal, err); | 913 | partition, goal, err); |
859 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { | 914 | else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) |
860 | return udf_table_new_block(sb, inode, | 915 | return udf_table_new_block(sb, inode, |
861 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table, | 916 | map->s_fspace.s_table, |
862 | partition, goal, err); | 917 | partition, goal, err); |
863 | } else { | 918 | else { |
864 | *err = -EIO; | 919 | *err = -EIO; |
865 | return 0; | 920 | return 0; |
866 | } | 921 | } |
diff --git a/fs/udf/crc.c b/fs/udf/crc.c index 85aaee5fab26..b1661296e786 100644 --- a/fs/udf/crc.c +++ b/fs/udf/crc.c | |||
@@ -79,7 +79,7 @@ static uint16_t crc_table[256] = { | |||
79 | * July 21, 1997 - Andrew E. Mileski | 79 | * July 21, 1997 - Andrew E. Mileski |
80 | * Adapted from OSTA-UDF(tm) 1.50 standard. | 80 | * Adapted from OSTA-UDF(tm) 1.50 standard. |
81 | */ | 81 | */ |
82 | uint16_t udf_crc(uint8_t * data, uint32_t size, uint16_t crc) | 82 | uint16_t udf_crc(uint8_t *data, uint32_t size, uint16_t crc) |
83 | { | 83 | { |
84 | while (size--) | 84 | while (size--) |
85 | crc = crc_table[(crc >> 8 ^ *(data++)) & 0xffU] ^ (crc << 8); | 85 | crc = crc_table[(crc >> 8 ^ *(data++)) & 0xffU] ^ (crc << 8); |
diff --git a/fs/udf/dir.c b/fs/udf/dir.c index 9e3b9f97ddbc..4b44e23caa12 100644 --- a/fs/udf/dir.c +++ b/fs/udf/dir.c | |||
@@ -36,68 +36,8 @@ | |||
36 | #include "udf_i.h" | 36 | #include "udf_i.h" |
37 | #include "udf_sb.h" | 37 | #include "udf_sb.h" |
38 | 38 | ||
39 | /* Prototypes for file operations */ | 39 | static int do_udf_readdir(struct inode *dir, struct file *filp, |
40 | static int udf_readdir(struct file *, void *, filldir_t); | 40 | filldir_t filldir, void *dirent) |
41 | static int do_udf_readdir(struct inode *, struct file *, filldir_t, void *); | ||
42 | |||
43 | /* readdir and lookup functions */ | ||
44 | |||
45 | const struct file_operations udf_dir_operations = { | ||
46 | .read = generic_read_dir, | ||
47 | .readdir = udf_readdir, | ||
48 | .ioctl = udf_ioctl, | ||
49 | .fsync = udf_fsync_file, | ||
50 | }; | ||
51 | |||
52 | /* | ||
53 | * udf_readdir | ||
54 | * | ||
55 | * PURPOSE | ||
56 | * Read a directory entry. | ||
57 | * | ||
58 | * DESCRIPTION | ||
59 | * Optional - sys_getdents() will return -ENOTDIR if this routine is not | ||
60 | * available. | ||
61 | * | ||
62 | * Refer to sys_getdents() in fs/readdir.c | ||
63 | * sys_getdents() -> . | ||
64 | * | ||
65 | * PRE-CONDITIONS | ||
66 | * filp Pointer to directory file. | ||
67 | * buf Pointer to directory entry buffer. | ||
68 | * filldir Pointer to filldir function. | ||
69 | * | ||
70 | * POST-CONDITIONS | ||
71 | * <return> >=0 on success. | ||
72 | * | ||
73 | * HISTORY | ||
74 | * July 1, 1997 - Andrew E. Mileski | ||
75 | * Written, tested, and released. | ||
76 | */ | ||
77 | |||
78 | int udf_readdir(struct file *filp, void *dirent, filldir_t filldir) | ||
79 | { | ||
80 | struct inode *dir = filp->f_path.dentry->d_inode; | ||
81 | int result; | ||
82 | |||
83 | lock_kernel(); | ||
84 | |||
85 | if (filp->f_pos == 0) { | ||
86 | if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) { | ||
87 | unlock_kernel(); | ||
88 | return 0; | ||
89 | } | ||
90 | filp->f_pos++; | ||
91 | } | ||
92 | |||
93 | result = do_udf_readdir(dir, filp, filldir, dirent); | ||
94 | unlock_kernel(); | ||
95 | return result; | ||
96 | } | ||
97 | |||
98 | static int | ||
99 | do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, | ||
100 | void *dirent) | ||
101 | { | 41 | { |
102 | struct udf_fileident_bh fibh; | 42 | struct udf_fileident_bh fibh; |
103 | struct fileIdentDesc *fi = NULL; | 43 | struct fileIdentDesc *fi = NULL; |
@@ -117,6 +57,7 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, | |||
117 | int i, num; | 57 | int i, num; |
118 | unsigned int dt_type; | 58 | unsigned int dt_type; |
119 | struct extent_position epos = { NULL, 0, {0, 0} }; | 59 | struct extent_position epos = { NULL, 0, {0, 0} }; |
60 | struct udf_inode_info *iinfo; | ||
120 | 61 | ||
121 | if (nf_pos >= size) | 62 | if (nf_pos >= size) |
122 | return 0; | 63 | return 0; |
@@ -125,15 +66,17 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, | |||
125 | nf_pos = (udf_ext0_offset(dir) >> 2); | 66 | nf_pos = (udf_ext0_offset(dir) >> 2); |
126 | 67 | ||
127 | fibh.soffset = fibh.eoffset = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | 68 | fibh.soffset = fibh.eoffset = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; |
128 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 69 | iinfo = UDF_I(dir); |
70 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { | ||
129 | fibh.sbh = fibh.ebh = NULL; | 71 | fibh.sbh = fibh.ebh = NULL; |
130 | } else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2), | 72 | } else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2), |
131 | &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { | 73 | &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { |
132 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); | 74 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
133 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { | 75 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
134 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) | 76 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
135 | epos.offset -= sizeof(short_ad); | 77 | epos.offset -= sizeof(short_ad); |
136 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) | 78 | else if (iinfo->i_alloc_type == |
79 | ICBTAG_FLAG_AD_LONG) | ||
137 | epos.offset -= sizeof(long_ad); | 80 | epos.offset -= sizeof(long_ad); |
138 | } else { | 81 | } else { |
139 | offset = 0; | 82 | offset = 0; |
@@ -244,3 +187,57 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, | |||
244 | 187 | ||
245 | return 0; | 188 | return 0; |
246 | } | 189 | } |
190 | |||
191 | /* | ||
192 | * udf_readdir | ||
193 | * | ||
194 | * PURPOSE | ||
195 | * Read a directory entry. | ||
196 | * | ||
197 | * DESCRIPTION | ||
198 | * Optional - sys_getdents() will return -ENOTDIR if this routine is not | ||
199 | * available. | ||
200 | * | ||
201 | * Refer to sys_getdents() in fs/readdir.c | ||
202 | * sys_getdents() -> . | ||
203 | * | ||
204 | * PRE-CONDITIONS | ||
205 | * filp Pointer to directory file. | ||
206 | * buf Pointer to directory entry buffer. | ||
207 | * filldir Pointer to filldir function. | ||
208 | * | ||
209 | * POST-CONDITIONS | ||
210 | * <return> >=0 on success. | ||
211 | * | ||
212 | * HISTORY | ||
213 | * July 1, 1997 - Andrew E. Mileski | ||
214 | * Written, tested, and released. | ||
215 | */ | ||
216 | |||
217 | static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir) | ||
218 | { | ||
219 | struct inode *dir = filp->f_path.dentry->d_inode; | ||
220 | int result; | ||
221 | |||
222 | lock_kernel(); | ||
223 | |||
224 | if (filp->f_pos == 0) { | ||
225 | if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) { | ||
226 | unlock_kernel(); | ||
227 | return 0; | ||
228 | } | ||
229 | filp->f_pos++; | ||
230 | } | ||
231 | |||
232 | result = do_udf_readdir(dir, filp, filldir, dirent); | ||
233 | unlock_kernel(); | ||
234 | return result; | ||
235 | } | ||
236 | |||
237 | /* readdir and lookup functions */ | ||
238 | const struct file_operations udf_dir_operations = { | ||
239 | .read = generic_read_dir, | ||
240 | .readdir = udf_readdir, | ||
241 | .ioctl = udf_ioctl, | ||
242 | .fsync = udf_fsync_file, | ||
243 | }; | ||
diff --git a/fs/udf/directory.c b/fs/udf/directory.c index ff8c08fd7bf5..2820f8fcf4cc 100644 --- a/fs/udf/directory.c +++ b/fs/udf/directory.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/buffer_head.h> | 19 | #include <linux/buffer_head.h> |
20 | 20 | ||
21 | #if 0 | 21 | #if 0 |
22 | static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad, | 22 | static uint8_t *udf_filead_read(struct inode *dir, uint8_t *tmpad, |
23 | uint8_t ad_size, kernel_lb_addr fe_loc, | 23 | uint8_t ad_size, kernel_lb_addr fe_loc, |
24 | int *pos, int *offset, struct buffer_head **bh, | 24 | int *pos, int *offset, struct buffer_head **bh, |
25 | int *error) | 25 | int *error) |
@@ -45,7 +45,8 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad, | |||
45 | block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos); | 45 | block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos); |
46 | if (!block) | 46 | if (!block) |
47 | return NULL; | 47 | return NULL; |
48 | if (!(*bh = udf_tread(dir->i_sb, block))) | 48 | *bh = udf_tread(dir->i_sb, block); |
49 | if (!*bh) | ||
49 | return NULL; | 50 | return NULL; |
50 | } else if (*offset > dir->i_sb->s_blocksize) { | 51 | } else if (*offset > dir->i_sb->s_blocksize) { |
51 | ad = tmpad; | 52 | ad = tmpad; |
@@ -57,10 +58,12 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad, | |||
57 | block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos); | 58 | block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos); |
58 | if (!block) | 59 | if (!block) |
59 | return NULL; | 60 | return NULL; |
60 | if (!((*bh) = udf_tread(dir->i_sb, block))) | 61 | (*bh) = udf_tread(dir->i_sb, block); |
62 | if (!*bh) | ||
61 | return NULL; | 63 | return NULL; |
62 | 64 | ||
63 | memcpy((uint8_t *)ad + remainder, (*bh)->b_data, ad_size - remainder); | 65 | memcpy((uint8_t *)ad + remainder, (*bh)->b_data, |
66 | ad_size - remainder); | ||
64 | *offset = ad_size - remainder; | 67 | *offset = ad_size - remainder; |
65 | } | 68 | } |
66 | 69 | ||
@@ -68,29 +71,31 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad, | |||
68 | } | 71 | } |
69 | #endif | 72 | #endif |
70 | 73 | ||
71 | struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos, | 74 | struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, |
72 | struct udf_fileident_bh *fibh, | 75 | struct udf_fileident_bh *fibh, |
73 | struct fileIdentDesc *cfi, | 76 | struct fileIdentDesc *cfi, |
74 | struct extent_position *epos, | 77 | struct extent_position *epos, |
75 | kernel_lb_addr * eloc, uint32_t * elen, | 78 | kernel_lb_addr *eloc, uint32_t *elen, |
76 | sector_t * offset) | 79 | sector_t *offset) |
77 | { | 80 | { |
78 | struct fileIdentDesc *fi; | 81 | struct fileIdentDesc *fi; |
79 | int i, num, block; | 82 | int i, num, block; |
80 | struct buffer_head *tmp, *bha[16]; | 83 | struct buffer_head *tmp, *bha[16]; |
84 | struct udf_inode_info *iinfo = UDF_I(dir); | ||
81 | 85 | ||
82 | fibh->soffset = fibh->eoffset; | 86 | fibh->soffset = fibh->eoffset; |
83 | 87 | ||
84 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 88 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
85 | fi = udf_get_fileident(UDF_I_DATA(dir) - | 89 | fi = udf_get_fileident(iinfo->i_ext.i_data - |
86 | (UDF_I_EFE(dir) ? | 90 | (iinfo->i_efe ? |
87 | sizeof(struct extendedFileEntry) : | 91 | sizeof(struct extendedFileEntry) : |
88 | sizeof(struct fileEntry)), | 92 | sizeof(struct fileEntry)), |
89 | dir->i_sb->s_blocksize, &(fibh->eoffset)); | 93 | dir->i_sb->s_blocksize, |
94 | &(fibh->eoffset)); | ||
90 | if (!fi) | 95 | if (!fi) |
91 | return NULL; | 96 | return NULL; |
92 | 97 | ||
93 | *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2); | 98 | *nf_pos += fibh->eoffset - fibh->soffset; |
94 | 99 | ||
95 | memcpy((uint8_t *)cfi, (uint8_t *)fi, | 100 | memcpy((uint8_t *)cfi, (uint8_t *)fi, |
96 | sizeof(struct fileIdentDesc)); | 101 | sizeof(struct fileIdentDesc)); |
@@ -100,6 +105,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos, | |||
100 | 105 | ||
101 | if (fibh->eoffset == dir->i_sb->s_blocksize) { | 106 | if (fibh->eoffset == dir->i_sb->s_blocksize) { |
102 | int lextoffset = epos->offset; | 107 | int lextoffset = epos->offset; |
108 | unsigned char blocksize_bits = dir->i_sb->s_blocksize_bits; | ||
103 | 109 | ||
104 | if (udf_next_aext(dir, epos, eloc, elen, 1) != | 110 | if (udf_next_aext(dir, epos, eloc, elen, 1) != |
105 | (EXT_RECORDED_ALLOCATED >> 30)) | 111 | (EXT_RECORDED_ALLOCATED >> 30)) |
@@ -109,24 +115,27 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos, | |||
109 | 115 | ||
110 | (*offset)++; | 116 | (*offset)++; |
111 | 117 | ||
112 | if ((*offset << dir->i_sb->s_blocksize_bits) >= *elen) | 118 | if ((*offset << blocksize_bits) >= *elen) |
113 | *offset = 0; | 119 | *offset = 0; |
114 | else | 120 | else |
115 | epos->offset = lextoffset; | 121 | epos->offset = lextoffset; |
116 | 122 | ||
117 | brelse(fibh->sbh); | 123 | brelse(fibh->sbh); |
118 | if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) | 124 | fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block); |
125 | if (!fibh->sbh) | ||
119 | return NULL; | 126 | return NULL; |
120 | fibh->soffset = fibh->eoffset = 0; | 127 | fibh->soffset = fibh->eoffset = 0; |
121 | 128 | ||
122 | if (!(*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) { | 129 | if (!(*offset & ((16 >> (blocksize_bits - 9)) - 1))) { |
123 | i = 16 >> (dir->i_sb->s_blocksize_bits - 9); | 130 | i = 16 >> (blocksize_bits - 9); |
124 | if (i + *offset > (*elen >> dir->i_sb->s_blocksize_bits)) | 131 | if (i + *offset > (*elen >> blocksize_bits)) |
125 | i = (*elen >> dir->i_sb->s_blocksize_bits)-*offset; | 132 | i = (*elen >> blocksize_bits)-*offset; |
126 | for (num = 0; i > 0; i--) { | 133 | for (num = 0; i > 0; i--) { |
127 | block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset + i); | 134 | block = udf_get_lb_pblock(dir->i_sb, *eloc, |
135 | *offset + i); | ||
128 | tmp = udf_tgetblk(dir->i_sb, block); | 136 | tmp = udf_tgetblk(dir->i_sb, block); |
129 | if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp)) | 137 | if (tmp && !buffer_uptodate(tmp) && |
138 | !buffer_locked(tmp)) | ||
130 | bha[num++] = tmp; | 139 | bha[num++] = tmp; |
131 | else | 140 | else |
132 | brelse(tmp); | 141 | brelse(tmp); |
@@ -148,7 +157,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos, | |||
148 | if (!fi) | 157 | if (!fi) |
149 | return NULL; | 158 | return NULL; |
150 | 159 | ||
151 | *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2); | 160 | *nf_pos += fibh->eoffset - fibh->soffset; |
152 | 161 | ||
153 | if (fibh->eoffset <= dir->i_sb->s_blocksize) { | 162 | if (fibh->eoffset <= dir->i_sb->s_blocksize) { |
154 | memcpy((uint8_t *)cfi, (uint8_t *)fi, | 163 | memcpy((uint8_t *)cfi, (uint8_t *)fi, |
@@ -172,20 +181,23 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos, | |||
172 | fibh->soffset -= dir->i_sb->s_blocksize; | 181 | fibh->soffset -= dir->i_sb->s_blocksize; |
173 | fibh->eoffset -= dir->i_sb->s_blocksize; | 182 | fibh->eoffset -= dir->i_sb->s_blocksize; |
174 | 183 | ||
175 | if (!(fibh->ebh = udf_tread(dir->i_sb, block))) | 184 | fibh->ebh = udf_tread(dir->i_sb, block); |
185 | if (!fibh->ebh) | ||
176 | return NULL; | 186 | return NULL; |
177 | 187 | ||
178 | if (sizeof(struct fileIdentDesc) > -fibh->soffset) { | 188 | if (sizeof(struct fileIdentDesc) > -fibh->soffset) { |
179 | int fi_len; | 189 | int fi_len; |
180 | 190 | ||
181 | memcpy((uint8_t *)cfi, (uint8_t *)fi, -fibh->soffset); | 191 | memcpy((uint8_t *)cfi, (uint8_t *)fi, -fibh->soffset); |
182 | memcpy((uint8_t *)cfi - fibh->soffset, fibh->ebh->b_data, | 192 | memcpy((uint8_t *)cfi - fibh->soffset, |
193 | fibh->ebh->b_data, | ||
183 | sizeof(struct fileIdentDesc) + fibh->soffset); | 194 | sizeof(struct fileIdentDesc) + fibh->soffset); |
184 | 195 | ||
185 | fi_len = (sizeof(struct fileIdentDesc) + cfi->lengthFileIdent + | 196 | fi_len = (sizeof(struct fileIdentDesc) + |
197 | cfi->lengthFileIdent + | ||
186 | le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3; | 198 | le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3; |
187 | 199 | ||
188 | *nf_pos += ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2); | 200 | *nf_pos += fi_len - (fibh->eoffset - fibh->soffset); |
189 | fibh->eoffset = fibh->soffset + fi_len; | 201 | fibh->eoffset = fibh->soffset + fi_len; |
190 | } else { | 202 | } else { |
191 | memcpy((uint8_t *)cfi, (uint8_t *)fi, | 203 | memcpy((uint8_t *)cfi, (uint8_t *)fi, |
@@ -210,11 +222,10 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset) | |||
210 | 222 | ||
211 | ptr = buffer; | 223 | ptr = buffer; |
212 | 224 | ||
213 | if ((*offset > 0) && (*offset < bufsize)) { | 225 | if ((*offset > 0) && (*offset < bufsize)) |
214 | ptr += *offset; | 226 | ptr += *offset; |
215 | } | ||
216 | fi = (struct fileIdentDesc *)ptr; | 227 | fi = (struct fileIdentDesc *)ptr; |
217 | if (le16_to_cpu(fi->descTag.tagIdent) != TAG_IDENT_FID) { | 228 | if (fi->descTag.tagIdent != cpu_to_le16(TAG_IDENT_FID)) { |
218 | udf_debug("0x%x != TAG_IDENT_FID\n", | 229 | udf_debug("0x%x != TAG_IDENT_FID\n", |
219 | le16_to_cpu(fi->descTag.tagIdent)); | 230 | le16_to_cpu(fi->descTag.tagIdent)); |
220 | udf_debug("offset: %u sizeof: %lu bufsize: %u\n", | 231 | udf_debug("offset: %u sizeof: %lu bufsize: %u\n", |
@@ -222,12 +233,11 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset) | |||
222 | bufsize); | 233 | bufsize); |
223 | return NULL; | 234 | return NULL; |
224 | } | 235 | } |
225 | if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) { | 236 | if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) |
226 | lengthThisIdent = sizeof(struct fileIdentDesc); | 237 | lengthThisIdent = sizeof(struct fileIdentDesc); |
227 | } else { | 238 | else |
228 | lengthThisIdent = sizeof(struct fileIdentDesc) + | 239 | lengthThisIdent = sizeof(struct fileIdentDesc) + |
229 | fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse); | 240 | fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse); |
230 | } | ||
231 | 241 | ||
232 | /* we need to figure padding, too! */ | 242 | /* we need to figure padding, too! */ |
233 | padlen = lengthThisIdent % UDF_NAME_PAD; | 243 | padlen = lengthThisIdent % UDF_NAME_PAD; |
@@ -252,17 +262,17 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset) | |||
252 | 262 | ||
253 | fe = (struct fileEntry *)buffer; | 263 | fe = (struct fileEntry *)buffer; |
254 | 264 | ||
255 | if (le16_to_cpu(fe->descTag.tagIdent) != TAG_IDENT_FE) { | 265 | if (fe->descTag.tagIdent != cpu_to_le16(TAG_IDENT_FE)) { |
256 | udf_debug("0x%x != TAG_IDENT_FE\n", | 266 | udf_debug("0x%x != TAG_IDENT_FE\n", |
257 | le16_to_cpu(fe->descTag.tagIdent)); | 267 | le16_to_cpu(fe->descTag.tagIdent)); |
258 | return NULL; | 268 | return NULL; |
259 | } | 269 | } |
260 | 270 | ||
261 | ptr = (uint8_t *)(fe->extendedAttr) + le32_to_cpu(fe->lengthExtendedAttr); | 271 | ptr = (uint8_t *)(fe->extendedAttr) + |
272 | le32_to_cpu(fe->lengthExtendedAttr); | ||
262 | 273 | ||
263 | if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs))) { | 274 | if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs))) |
264 | ptr += *offset; | 275 | ptr += *offset; |
265 | } | ||
266 | 276 | ||
267 | ext = (extent_ad *)ptr; | 277 | ext = (extent_ad *)ptr; |
268 | 278 | ||
@@ -271,7 +281,7 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset) | |||
271 | } | 281 | } |
272 | #endif | 282 | #endif |
273 | 283 | ||
274 | short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset, | 284 | short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset, |
275 | int inc) | 285 | int inc) |
276 | { | 286 | { |
277 | short_ad *sa; | 287 | short_ad *sa; |
@@ -281,17 +291,20 @@ short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset, | |||
281 | return NULL; | 291 | return NULL; |
282 | } | 292 | } |
283 | 293 | ||
284 | if ((*offset < 0) || ((*offset + sizeof(short_ad)) > maxoffset)) | 294 | if ((*offset + sizeof(short_ad)) > maxoffset) |
285 | return NULL; | ||
286 | else if ((sa = (short_ad *)ptr)->extLength == 0) | ||
287 | return NULL; | 295 | return NULL; |
296 | else { | ||
297 | sa = (short_ad *)ptr; | ||
298 | if (sa->extLength == 0) | ||
299 | return NULL; | ||
300 | } | ||
288 | 301 | ||
289 | if (inc) | 302 | if (inc) |
290 | *offset += sizeof(short_ad); | 303 | *offset += sizeof(short_ad); |
291 | return sa; | 304 | return sa; |
292 | } | 305 | } |
293 | 306 | ||
294 | long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, int *offset, int inc) | 307 | long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset, int inc) |
295 | { | 308 | { |
296 | long_ad *la; | 309 | long_ad *la; |
297 | 310 | ||
@@ -300,10 +313,13 @@ long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, int *offset, int inc) | |||
300 | return NULL; | 313 | return NULL; |
301 | } | 314 | } |
302 | 315 | ||
303 | if ((*offset < 0) || ((*offset + sizeof(long_ad)) > maxoffset)) | 316 | if ((*offset + sizeof(long_ad)) > maxoffset) |
304 | return NULL; | ||
305 | else if ((la = (long_ad *)ptr)->extLength == 0) | ||
306 | return NULL; | 317 | return NULL; |
318 | else { | ||
319 | la = (long_ad *)ptr; | ||
320 | if (la->extLength == 0) | ||
321 | return NULL; | ||
322 | } | ||
307 | 323 | ||
308 | if (inc) | 324 | if (inc) |
309 | *offset += sizeof(long_ad); | 325 | *offset += sizeof(long_ad); |
diff --git a/fs/udf/file.c b/fs/udf/file.c index 7c7a1b39d56c..97c71ae7c689 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c | |||
@@ -45,12 +45,13 @@ static int udf_adinicb_readpage(struct file *file, struct page *page) | |||
45 | { | 45 | { |
46 | struct inode *inode = page->mapping->host; | 46 | struct inode *inode = page->mapping->host; |
47 | char *kaddr; | 47 | char *kaddr; |
48 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
48 | 49 | ||
49 | BUG_ON(!PageLocked(page)); | 50 | BUG_ON(!PageLocked(page)); |
50 | 51 | ||
51 | kaddr = kmap(page); | 52 | kaddr = kmap(page); |
52 | memset(kaddr, 0, PAGE_CACHE_SIZE); | 53 | memset(kaddr, 0, PAGE_CACHE_SIZE); |
53 | memcpy(kaddr, UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), inode->i_size); | 54 | memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, inode->i_size); |
54 | flush_dcache_page(page); | 55 | flush_dcache_page(page); |
55 | SetPageUptodate(page); | 56 | SetPageUptodate(page); |
56 | kunmap(page); | 57 | kunmap(page); |
@@ -59,15 +60,17 @@ static int udf_adinicb_readpage(struct file *file, struct page *page) | |||
59 | return 0; | 60 | return 0; |
60 | } | 61 | } |
61 | 62 | ||
62 | static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc) | 63 | static int udf_adinicb_writepage(struct page *page, |
64 | struct writeback_control *wbc) | ||
63 | { | 65 | { |
64 | struct inode *inode = page->mapping->host; | 66 | struct inode *inode = page->mapping->host; |
65 | char *kaddr; | 67 | char *kaddr; |
68 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
66 | 69 | ||
67 | BUG_ON(!PageLocked(page)); | 70 | BUG_ON(!PageLocked(page)); |
68 | 71 | ||
69 | kaddr = kmap(page); | 72 | kaddr = kmap(page); |
70 | memcpy(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), kaddr, inode->i_size); | 73 | memcpy(iinfo->i_ext.i_data + iinfo->i_lenEAttr, kaddr, inode->i_size); |
71 | mark_inode_dirty(inode); | 74 | mark_inode_dirty(inode); |
72 | SetPageUptodate(page); | 75 | SetPageUptodate(page); |
73 | kunmap(page); | 76 | kunmap(page); |
@@ -84,9 +87,10 @@ static int udf_adinicb_write_end(struct file *file, | |||
84 | struct inode *inode = mapping->host; | 87 | struct inode *inode = mapping->host; |
85 | unsigned offset = pos & (PAGE_CACHE_SIZE - 1); | 88 | unsigned offset = pos & (PAGE_CACHE_SIZE - 1); |
86 | char *kaddr; | 89 | char *kaddr; |
90 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
87 | 91 | ||
88 | kaddr = kmap_atomic(page, KM_USER0); | 92 | kaddr = kmap_atomic(page, KM_USER0); |
89 | memcpy(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + offset, | 93 | memcpy(iinfo->i_ext.i_data + iinfo->i_lenEAttr + offset, |
90 | kaddr + offset, copied); | 94 | kaddr + offset, copied); |
91 | kunmap_atomic(kaddr, KM_USER0); | 95 | kunmap_atomic(kaddr, KM_USER0); |
92 | 96 | ||
@@ -109,25 +113,27 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
109 | struct inode *inode = file->f_path.dentry->d_inode; | 113 | struct inode *inode = file->f_path.dentry->d_inode; |
110 | int err, pos; | 114 | int err, pos; |
111 | size_t count = iocb->ki_left; | 115 | size_t count = iocb->ki_left; |
116 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
112 | 117 | ||
113 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 118 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
114 | if (file->f_flags & O_APPEND) | 119 | if (file->f_flags & O_APPEND) |
115 | pos = inode->i_size; | 120 | pos = inode->i_size; |
116 | else | 121 | else |
117 | pos = ppos; | 122 | pos = ppos; |
118 | 123 | ||
119 | if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) + | 124 | if (inode->i_sb->s_blocksize < |
125 | (udf_file_entry_alloc_offset(inode) + | ||
120 | pos + count)) { | 126 | pos + count)) { |
121 | udf_expand_file_adinicb(inode, pos + count, &err); | 127 | udf_expand_file_adinicb(inode, pos + count, &err); |
122 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 128 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
123 | udf_debug("udf_expand_adinicb: err=%d\n", err); | 129 | udf_debug("udf_expand_adinicb: err=%d\n", err); |
124 | return err; | 130 | return err; |
125 | } | 131 | } |
126 | } else { | 132 | } else { |
127 | if (pos + count > inode->i_size) | 133 | if (pos + count > inode->i_size) |
128 | UDF_I_LENALLOC(inode) = pos + count; | 134 | iinfo->i_lenAlloc = pos + count; |
129 | else | 135 | else |
130 | UDF_I_LENALLOC(inode) = inode->i_size; | 136 | iinfo->i_lenAlloc = inode->i_size; |
131 | } | 137 | } |
132 | } | 138 | } |
133 | 139 | ||
@@ -191,23 +197,28 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | |||
191 | 197 | ||
192 | switch (cmd) { | 198 | switch (cmd) { |
193 | case UDF_GETVOLIDENT: | 199 | case UDF_GETVOLIDENT: |
194 | return copy_to_user((char __user *)arg, | 200 | if (copy_to_user((char __user *)arg, |
195 | UDF_SB_VOLIDENT(inode->i_sb), 32) ? -EFAULT : 0; | 201 | UDF_SB(inode->i_sb)->s_volume_ident, 32)) |
202 | return -EFAULT; | ||
203 | else | ||
204 | return 0; | ||
196 | case UDF_RELOCATE_BLOCKS: | 205 | case UDF_RELOCATE_BLOCKS: |
197 | if (!capable(CAP_SYS_ADMIN)) | 206 | if (!capable(CAP_SYS_ADMIN)) |
198 | return -EACCES; | 207 | return -EACCES; |
199 | if (get_user(old_block, (long __user *)arg)) | 208 | if (get_user(old_block, (long __user *)arg)) |
200 | return -EFAULT; | 209 | return -EFAULT; |
201 | if ((result = udf_relocate_blocks(inode->i_sb, | 210 | result = udf_relocate_blocks(inode->i_sb, |
202 | old_block, &new_block)) == 0) | 211 | old_block, &new_block); |
212 | if (result == 0) | ||
203 | result = put_user(new_block, (long __user *)arg); | 213 | result = put_user(new_block, (long __user *)arg); |
204 | return result; | 214 | return result; |
205 | case UDF_GETEASIZE: | 215 | case UDF_GETEASIZE: |
206 | result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg); | 216 | result = put_user(UDF_I(inode)->i_lenEAttr, (int __user *)arg); |
207 | break; | 217 | break; |
208 | case UDF_GETEABLOCK: | 218 | case UDF_GETEABLOCK: |
209 | result = copy_to_user((char __user *)arg, UDF_I_DATA(inode), | 219 | result = copy_to_user((char __user *)arg, |
210 | UDF_I_LENEATTR(inode)) ? -EFAULT : 0; | 220 | UDF_I(inode)->i_ext.i_data, |
221 | UDF_I(inode)->i_lenEAttr) ? -EFAULT : 0; | ||
211 | break; | 222 | break; |
212 | } | 223 | } |
213 | 224 | ||
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c index 636d8f613929..84360315aca2 100644 --- a/fs/udf/ialloc.c +++ b/fs/udf/ialloc.c | |||
@@ -43,19 +43,21 @@ void udf_free_inode(struct inode *inode) | |||
43 | clear_inode(inode); | 43 | clear_inode(inode); |
44 | 44 | ||
45 | mutex_lock(&sbi->s_alloc_mutex); | 45 | mutex_lock(&sbi->s_alloc_mutex); |
46 | if (sbi->s_lvidbh) { | 46 | if (sbi->s_lvid_bh) { |
47 | struct logicalVolIntegrityDescImpUse *lvidiu = | ||
48 | udf_sb_lvidiu(sbi); | ||
47 | if (S_ISDIR(inode->i_mode)) | 49 | if (S_ISDIR(inode->i_mode)) |
48 | UDF_SB_LVIDIU(sb)->numDirs = | 50 | lvidiu->numDirs = |
49 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1); | 51 | cpu_to_le32(le32_to_cpu(lvidiu->numDirs) - 1); |
50 | else | 52 | else |
51 | UDF_SB_LVIDIU(sb)->numFiles = | 53 | lvidiu->numFiles = |
52 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1); | 54 | cpu_to_le32(le32_to_cpu(lvidiu->numFiles) - 1); |
53 | 55 | ||
54 | mark_buffer_dirty(sbi->s_lvidbh); | 56 | mark_buffer_dirty(sbi->s_lvid_bh); |
55 | } | 57 | } |
56 | mutex_unlock(&sbi->s_alloc_mutex); | 58 | mutex_unlock(&sbi->s_alloc_mutex); |
57 | 59 | ||
58 | udf_free_blocks(sb, NULL, UDF_I_LOCATION(inode), 0, 1); | 60 | udf_free_blocks(sb, NULL, UDF_I(inode)->i_location, 0, 1); |
59 | } | 61 | } |
60 | 62 | ||
61 | struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | 63 | struct inode *udf_new_inode(struct inode *dir, int mode, int *err) |
@@ -64,7 +66,9 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
64 | struct udf_sb_info *sbi = UDF_SB(sb); | 66 | struct udf_sb_info *sbi = UDF_SB(sb); |
65 | struct inode *inode; | 67 | struct inode *inode; |
66 | int block; | 68 | int block; |
67 | uint32_t start = UDF_I_LOCATION(dir).logicalBlockNum; | 69 | uint32_t start = UDF_I(dir)->i_location.logicalBlockNum; |
70 | struct udf_inode_info *iinfo; | ||
71 | struct udf_inode_info *dinfo = UDF_I(dir); | ||
68 | 72 | ||
69 | inode = new_inode(sb); | 73 | inode = new_inode(sb); |
70 | 74 | ||
@@ -74,13 +78,15 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
74 | } | 78 | } |
75 | *err = -ENOSPC; | 79 | *err = -ENOSPC; |
76 | 80 | ||
77 | UDF_I_UNIQUE(inode) = 0; | 81 | iinfo = UDF_I(inode); |
78 | UDF_I_LENEXTENTS(inode) = 0; | 82 | iinfo->i_unique = 0; |
79 | UDF_I_NEXT_ALLOC_BLOCK(inode) = 0; | 83 | iinfo->i_lenExtents = 0; |
80 | UDF_I_NEXT_ALLOC_GOAL(inode) = 0; | 84 | iinfo->i_next_alloc_block = 0; |
81 | UDF_I_STRAT4096(inode) = 0; | 85 | iinfo->i_next_alloc_goal = 0; |
86 | iinfo->i_strat4096 = 0; | ||
82 | 87 | ||
83 | block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum, | 88 | block = udf_new_block(dir->i_sb, NULL, |
89 | dinfo->i_location.partitionReferenceNum, | ||
84 | start, err); | 90 | start, err); |
85 | if (*err) { | 91 | if (*err) { |
86 | iput(inode); | 92 | iput(inode); |
@@ -88,21 +94,27 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
88 | } | 94 | } |
89 | 95 | ||
90 | mutex_lock(&sbi->s_alloc_mutex); | 96 | mutex_lock(&sbi->s_alloc_mutex); |
91 | if (UDF_SB_LVIDBH(sb)) { | 97 | if (sbi->s_lvid_bh) { |
98 | struct logicalVolIntegrityDesc *lvid = | ||
99 | (struct logicalVolIntegrityDesc *) | ||
100 | sbi->s_lvid_bh->b_data; | ||
101 | struct logicalVolIntegrityDescImpUse *lvidiu = | ||
102 | udf_sb_lvidiu(sbi); | ||
92 | struct logicalVolHeaderDesc *lvhd; | 103 | struct logicalVolHeaderDesc *lvhd; |
93 | uint64_t uniqueID; | 104 | uint64_t uniqueID; |
94 | lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse); | 105 | lvhd = (struct logicalVolHeaderDesc *) |
106 | (lvid->logicalVolContentsUse); | ||
95 | if (S_ISDIR(mode)) | 107 | if (S_ISDIR(mode)) |
96 | UDF_SB_LVIDIU(sb)->numDirs = | 108 | lvidiu->numDirs = |
97 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1); | 109 | cpu_to_le32(le32_to_cpu(lvidiu->numDirs) + 1); |
98 | else | 110 | else |
99 | UDF_SB_LVIDIU(sb)->numFiles = | 111 | lvidiu->numFiles = |
100 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1); | 112 | cpu_to_le32(le32_to_cpu(lvidiu->numFiles) + 1); |
101 | UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID); | 113 | iinfo->i_unique = uniqueID = le64_to_cpu(lvhd->uniqueID); |
102 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) | 114 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) |
103 | uniqueID += 16; | 115 | uniqueID += 16; |
104 | lvhd->uniqueID = cpu_to_le64(uniqueID); | 116 | lvhd->uniqueID = cpu_to_le64(uniqueID); |
105 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 117 | mark_buffer_dirty(sbi->s_lvid_bh); |
106 | } | 118 | } |
107 | inode->i_mode = mode; | 119 | inode->i_mode = mode; |
108 | inode->i_uid = current->fsuid; | 120 | inode->i_uid = current->fsuid; |
@@ -114,35 +126,41 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
114 | inode->i_gid = current->fsgid; | 126 | inode->i_gid = current->fsgid; |
115 | } | 127 | } |
116 | 128 | ||
117 | UDF_I_LOCATION(inode).logicalBlockNum = block; | 129 | iinfo->i_location.logicalBlockNum = block; |
118 | UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum; | 130 | iinfo->i_location.partitionReferenceNum = |
119 | inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0); | 131 | dinfo->i_location.partitionReferenceNum; |
132 | inode->i_ino = udf_get_lb_pblock(sb, iinfo->i_location, 0); | ||
120 | inode->i_blocks = 0; | 133 | inode->i_blocks = 0; |
121 | UDF_I_LENEATTR(inode) = 0; | 134 | iinfo->i_lenEAttr = 0; |
122 | UDF_I_LENALLOC(inode) = 0; | 135 | iinfo->i_lenAlloc = 0; |
123 | UDF_I_USE(inode) = 0; | 136 | iinfo->i_use = 0; |
124 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) { | 137 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) { |
125 | UDF_I_EFE(inode) = 1; | 138 | iinfo->i_efe = 1; |
126 | UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE); | 139 | if (UDF_VERS_USE_EXTENDED_FE > sbi->s_udfrev) |
127 | UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL); | 140 | sbi->s_udfrev = UDF_VERS_USE_EXTENDED_FE; |
141 | iinfo->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize - | ||
142 | sizeof(struct extendedFileEntry), | ||
143 | GFP_KERNEL); | ||
128 | } else { | 144 | } else { |
129 | UDF_I_EFE(inode) = 0; | 145 | iinfo->i_efe = 0; |
130 | UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL); | 146 | iinfo->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize - |
147 | sizeof(struct fileEntry), | ||
148 | GFP_KERNEL); | ||
131 | } | 149 | } |
132 | if (!UDF_I_DATA(inode)) { | 150 | if (!iinfo->i_ext.i_data) { |
133 | iput(inode); | 151 | iput(inode); |
134 | *err = -ENOMEM; | 152 | *err = -ENOMEM; |
135 | mutex_unlock(&sbi->s_alloc_mutex); | 153 | mutex_unlock(&sbi->s_alloc_mutex); |
136 | return NULL; | 154 | return NULL; |
137 | } | 155 | } |
138 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB)) | 156 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB)) |
139 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; | 157 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; |
140 | else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) | 158 | else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) |
141 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_SHORT; | 159 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT; |
142 | else | 160 | else |
143 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG; | 161 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG; |
144 | inode->i_mtime = inode->i_atime = inode->i_ctime = | 162 | inode->i_mtime = inode->i_atime = inode->i_ctime = |
145 | UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb); | 163 | iinfo->i_crtime = current_fs_time(inode->i_sb); |
146 | insert_inode_hash(inode); | 164 | insert_inode_hash(inode); |
147 | mark_inode_dirty(inode); | 165 | mark_inode_dirty(inode); |
148 | mutex_unlock(&sbi->s_alloc_mutex); | 166 | mutex_unlock(&sbi->s_alloc_mutex); |
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 6ff8151984cf..24cfa55d0fdc 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -19,7 +19,8 @@ | |||
19 | * 10/04/98 dgb Added rudimentary directory functions | 19 | * 10/04/98 dgb Added rudimentary directory functions |
20 | * 10/07/98 Fully working udf_block_map! It works! | 20 | * 10/07/98 Fully working udf_block_map! It works! |
21 | * 11/25/98 bmap altered to better support extents | 21 | * 11/25/98 bmap altered to better support extents |
22 | * 12/06/98 blf partition support in udf_iget, udf_block_map and udf_read_inode | 22 | * 12/06/98 blf partition support in udf_iget, udf_block_map |
23 | * and udf_read_inode | ||
23 | * 12/12/98 rewrote udf_block_map to handle next extents and descs across | 24 | * 12/12/98 rewrote udf_block_map to handle next extents and descs across |
24 | * block boundaries (which is not actually allowed) | 25 | * block boundaries (which is not actually allowed) |
25 | * 12/20/98 added support for strategy 4096 | 26 | * 12/20/98 added support for strategy 4096 |
@@ -51,7 +52,7 @@ static int udf_update_inode(struct inode *, int); | |||
51 | static void udf_fill_inode(struct inode *, struct buffer_head *); | 52 | static void udf_fill_inode(struct inode *, struct buffer_head *); |
52 | static int udf_alloc_i_data(struct inode *inode, size_t size); | 53 | static int udf_alloc_i_data(struct inode *inode, size_t size); |
53 | static struct buffer_head *inode_getblk(struct inode *, sector_t, int *, | 54 | static struct buffer_head *inode_getblk(struct inode *, sector_t, int *, |
54 | long *, int *); | 55 | sector_t *, int *); |
55 | static int8_t udf_insert_aext(struct inode *, struct extent_position, | 56 | static int8_t udf_insert_aext(struct inode *, struct extent_position, |
56 | kernel_lb_addr, uint32_t); | 57 | kernel_lb_addr, uint32_t); |
57 | static void udf_split_extents(struct inode *, int *, int, int, | 58 | static void udf_split_extents(struct inode *, int *, int, int, |
@@ -111,16 +112,18 @@ no_delete: | |||
111 | */ | 112 | */ |
112 | void udf_clear_inode(struct inode *inode) | 113 | void udf_clear_inode(struct inode *inode) |
113 | { | 114 | { |
115 | struct udf_inode_info *iinfo; | ||
114 | if (!(inode->i_sb->s_flags & MS_RDONLY)) { | 116 | if (!(inode->i_sb->s_flags & MS_RDONLY)) { |
115 | lock_kernel(); | 117 | lock_kernel(); |
116 | /* Discard preallocation for directories, symlinks, etc. */ | 118 | /* Discard preallocation for directories, symlinks, etc. */ |
117 | udf_discard_prealloc(inode); | 119 | udf_discard_prealloc(inode); |
118 | udf_truncate_tail_extent(inode); | 120 | udf_truncate_tail_extent(inode); |
119 | unlock_kernel(); | 121 | unlock_kernel(); |
120 | write_inode_now(inode, 1); | 122 | write_inode_now(inode, 0); |
121 | } | 123 | } |
122 | kfree(UDF_I_DATA(inode)); | 124 | iinfo = UDF_I(inode); |
123 | UDF_I_DATA(inode) = NULL; | 125 | kfree(iinfo->i_ext.i_data); |
126 | iinfo->i_ext.i_data = NULL; | ||
124 | } | 127 | } |
125 | 128 | ||
126 | static int udf_writepage(struct page *page, struct writeback_control *wbc) | 129 | static int udf_writepage(struct page *page, struct writeback_control *wbc) |
@@ -160,6 +163,7 @@ void udf_expand_file_adinicb(struct inode *inode, int newsize, int *err) | |||
160 | { | 163 | { |
161 | struct page *page; | 164 | struct page *page; |
162 | char *kaddr; | 165 | char *kaddr; |
166 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
163 | struct writeback_control udf_wbc = { | 167 | struct writeback_control udf_wbc = { |
164 | .sync_mode = WB_SYNC_NONE, | 168 | .sync_mode = WB_SYNC_NONE, |
165 | .nr_to_write = 1, | 169 | .nr_to_write = 1, |
@@ -168,11 +172,11 @@ void udf_expand_file_adinicb(struct inode *inode, int newsize, int *err) | |||
168 | /* from now on we have normal address_space methods */ | 172 | /* from now on we have normal address_space methods */ |
169 | inode->i_data.a_ops = &udf_aops; | 173 | inode->i_data.a_ops = &udf_aops; |
170 | 174 | ||
171 | if (!UDF_I_LENALLOC(inode)) { | 175 | if (!iinfo->i_lenAlloc) { |
172 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) | 176 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) |
173 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_SHORT; | 177 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT; |
174 | else | 178 | else |
175 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG; | 179 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG; |
176 | mark_inode_dirty(inode); | 180 | mark_inode_dirty(inode); |
177 | return; | 181 | return; |
178 | } | 182 | } |
@@ -182,21 +186,21 @@ void udf_expand_file_adinicb(struct inode *inode, int newsize, int *err) | |||
182 | 186 | ||
183 | if (!PageUptodate(page)) { | 187 | if (!PageUptodate(page)) { |
184 | kaddr = kmap(page); | 188 | kaddr = kmap(page); |
185 | memset(kaddr + UDF_I_LENALLOC(inode), 0x00, | 189 | memset(kaddr + iinfo->i_lenAlloc, 0x00, |
186 | PAGE_CACHE_SIZE - UDF_I_LENALLOC(inode)); | 190 | PAGE_CACHE_SIZE - iinfo->i_lenAlloc); |
187 | memcpy(kaddr, UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), | 191 | memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, |
188 | UDF_I_LENALLOC(inode)); | 192 | iinfo->i_lenAlloc); |
189 | flush_dcache_page(page); | 193 | flush_dcache_page(page); |
190 | SetPageUptodate(page); | 194 | SetPageUptodate(page); |
191 | kunmap(page); | 195 | kunmap(page); |
192 | } | 196 | } |
193 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0x00, | 197 | memset(iinfo->i_ext.i_data + iinfo->i_lenEAttr, 0x00, |
194 | UDF_I_LENALLOC(inode)); | 198 | iinfo->i_lenAlloc); |
195 | UDF_I_LENALLOC(inode) = 0; | 199 | iinfo->i_lenAlloc = 0; |
196 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) | 200 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) |
197 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_SHORT; | 201 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT; |
198 | else | 202 | else |
199 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG; | 203 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG; |
200 | 204 | ||
201 | inode->i_data.a_ops->writepage(page, &udf_wbc); | 205 | inode->i_data.a_ops->writepage(page, &udf_wbc); |
202 | page_cache_release(page); | 206 | page_cache_release(page); |
@@ -215,9 +219,10 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
215 | struct extent_position epos; | 219 | struct extent_position epos; |
216 | 220 | ||
217 | struct udf_fileident_bh sfibh, dfibh; | 221 | struct udf_fileident_bh sfibh, dfibh; |
218 | loff_t f_pos = udf_ext0_offset(inode) >> 2; | 222 | loff_t f_pos = udf_ext0_offset(inode); |
219 | int size = (udf_ext0_offset(inode) + inode->i_size) >> 2; | 223 | int size = udf_ext0_offset(inode) + inode->i_size; |
220 | struct fileIdentDesc cfi, *sfi, *dfi; | 224 | struct fileIdentDesc cfi, *sfi, *dfi; |
225 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
221 | 226 | ||
222 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) | 227 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) |
223 | alloctype = ICBTAG_FLAG_AD_SHORT; | 228 | alloctype = ICBTAG_FLAG_AD_SHORT; |
@@ -225,19 +230,20 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
225 | alloctype = ICBTAG_FLAG_AD_LONG; | 230 | alloctype = ICBTAG_FLAG_AD_LONG; |
226 | 231 | ||
227 | if (!inode->i_size) { | 232 | if (!inode->i_size) { |
228 | UDF_I_ALLOCTYPE(inode) = alloctype; | 233 | iinfo->i_alloc_type = alloctype; |
229 | mark_inode_dirty(inode); | 234 | mark_inode_dirty(inode); |
230 | return NULL; | 235 | return NULL; |
231 | } | 236 | } |
232 | 237 | ||
233 | /* alloc block, and copy data to it */ | 238 | /* alloc block, and copy data to it */ |
234 | *block = udf_new_block(inode->i_sb, inode, | 239 | *block = udf_new_block(inode->i_sb, inode, |
235 | UDF_I_LOCATION(inode).partitionReferenceNum, | 240 | iinfo->i_location.partitionReferenceNum, |
236 | UDF_I_LOCATION(inode).logicalBlockNum, err); | 241 | iinfo->i_location.logicalBlockNum, err); |
237 | if (!(*block)) | 242 | if (!(*block)) |
238 | return NULL; | 243 | return NULL; |
239 | newblock = udf_get_pblock(inode->i_sb, *block, | 244 | newblock = udf_get_pblock(inode->i_sb, *block, |
240 | UDF_I_LOCATION(inode).partitionReferenceNum, 0); | 245 | iinfo->i_location.partitionReferenceNum, |
246 | 0); | ||
241 | if (!newblock) | 247 | if (!newblock) |
242 | return NULL; | 248 | return NULL; |
243 | dbh = udf_tgetblk(inode->i_sb, newblock); | 249 | dbh = udf_tgetblk(inode->i_sb, newblock); |
@@ -249,39 +255,44 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
249 | unlock_buffer(dbh); | 255 | unlock_buffer(dbh); |
250 | mark_buffer_dirty_inode(dbh, inode); | 256 | mark_buffer_dirty_inode(dbh, inode); |
251 | 257 | ||
252 | sfibh.soffset = sfibh.eoffset = (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2; | 258 | sfibh.soffset = sfibh.eoffset = |
259 | f_pos & (inode->i_sb->s_blocksize - 1); | ||
253 | sfibh.sbh = sfibh.ebh = NULL; | 260 | sfibh.sbh = sfibh.ebh = NULL; |
254 | dfibh.soffset = dfibh.eoffset = 0; | 261 | dfibh.soffset = dfibh.eoffset = 0; |
255 | dfibh.sbh = dfibh.ebh = dbh; | 262 | dfibh.sbh = dfibh.ebh = dbh; |
256 | while ((f_pos < size)) { | 263 | while (f_pos < size) { |
257 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; | 264 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; |
258 | sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, NULL, NULL, NULL); | 265 | sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, |
266 | NULL, NULL, NULL); | ||
259 | if (!sfi) { | 267 | if (!sfi) { |
260 | brelse(dbh); | 268 | brelse(dbh); |
261 | return NULL; | 269 | return NULL; |
262 | } | 270 | } |
263 | UDF_I_ALLOCTYPE(inode) = alloctype; | 271 | iinfo->i_alloc_type = alloctype; |
264 | sfi->descTag.tagLocation = cpu_to_le32(*block); | 272 | sfi->descTag.tagLocation = cpu_to_le32(*block); |
265 | dfibh.soffset = dfibh.eoffset; | 273 | dfibh.soffset = dfibh.eoffset; |
266 | dfibh.eoffset += (sfibh.eoffset - sfibh.soffset); | 274 | dfibh.eoffset += (sfibh.eoffset - sfibh.soffset); |
267 | dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset); | 275 | dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset); |
268 | if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse, | 276 | if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse, |
269 | sfi->fileIdent + le16_to_cpu(sfi->lengthOfImpUse))) { | 277 | sfi->fileIdent + |
270 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; | 278 | le16_to_cpu(sfi->lengthOfImpUse))) { |
279 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; | ||
271 | brelse(dbh); | 280 | brelse(dbh); |
272 | return NULL; | 281 | return NULL; |
273 | } | 282 | } |
274 | } | 283 | } |
275 | mark_buffer_dirty_inode(dbh, inode); | 284 | mark_buffer_dirty_inode(dbh, inode); |
276 | 285 | ||
277 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0, UDF_I_LENALLOC(inode)); | 286 | memset(iinfo->i_ext.i_data + iinfo->i_lenEAttr, 0, |
278 | UDF_I_LENALLOC(inode) = 0; | 287 | iinfo->i_lenAlloc); |
288 | iinfo->i_lenAlloc = 0; | ||
279 | eloc.logicalBlockNum = *block; | 289 | eloc.logicalBlockNum = *block; |
280 | eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; | 290 | eloc.partitionReferenceNum = |
281 | elen = inode->i_size; | 291 | iinfo->i_location.partitionReferenceNum; |
282 | UDF_I_LENEXTENTS(inode) = elen; | 292 | elen = inode->i_sb->s_blocksize; |
293 | iinfo->i_lenExtents = elen; | ||
283 | epos.bh = NULL; | 294 | epos.bh = NULL; |
284 | epos.block = UDF_I_LOCATION(inode); | 295 | epos.block = iinfo->i_location; |
285 | epos.offset = udf_file_entry_alloc_offset(inode); | 296 | epos.offset = udf_file_entry_alloc_offset(inode); |
286 | udf_add_aext(inode, &epos, eloc, elen, 0); | 297 | udf_add_aext(inode, &epos, eloc, elen, 0); |
287 | /* UniqueID stuff */ | 298 | /* UniqueID stuff */ |
@@ -296,7 +307,8 @@ static int udf_get_block(struct inode *inode, sector_t block, | |||
296 | { | 307 | { |
297 | int err, new; | 308 | int err, new; |
298 | struct buffer_head *bh; | 309 | struct buffer_head *bh; |
299 | unsigned long phys; | 310 | sector_t phys = 0; |
311 | struct udf_inode_info *iinfo; | ||
300 | 312 | ||
301 | if (!create) { | 313 | if (!create) { |
302 | phys = udf_block_map(inode, block); | 314 | phys = udf_block_map(inode, block); |
@@ -314,9 +326,10 @@ static int udf_get_block(struct inode *inode, sector_t block, | |||
314 | if (block < 0) | 326 | if (block < 0) |
315 | goto abort_negative; | 327 | goto abort_negative; |
316 | 328 | ||
317 | if (block == UDF_I_NEXT_ALLOC_BLOCK(inode) + 1) { | 329 | iinfo = UDF_I(inode); |
318 | UDF_I_NEXT_ALLOC_BLOCK(inode)++; | 330 | if (block == iinfo->i_next_alloc_block + 1) { |
319 | UDF_I_NEXT_ALLOC_GOAL(inode)++; | 331 | iinfo->i_next_alloc_block++; |
332 | iinfo->i_next_alloc_goal++; | ||
320 | } | 333 | } |
321 | 334 | ||
322 | err = 0; | 335 | err = 0; |
@@ -366,32 +379,35 @@ static struct buffer_head *udf_getblk(struct inode *inode, long block, | |||
366 | 379 | ||
367 | /* Extend the file by 'blocks' blocks, return the number of extents added */ | 380 | /* Extend the file by 'blocks' blocks, return the number of extents added */ |
368 | int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | 381 | int udf_extend_file(struct inode *inode, struct extent_position *last_pos, |
369 | kernel_long_ad * last_ext, sector_t blocks) | 382 | kernel_long_ad *last_ext, sector_t blocks) |
370 | { | 383 | { |
371 | sector_t add; | 384 | sector_t add; |
372 | int count = 0, fake = !(last_ext->extLength & UDF_EXTENT_LENGTH_MASK); | 385 | int count = 0, fake = !(last_ext->extLength & UDF_EXTENT_LENGTH_MASK); |
373 | struct super_block *sb = inode->i_sb; | 386 | struct super_block *sb = inode->i_sb; |
374 | kernel_lb_addr prealloc_loc = {}; | 387 | kernel_lb_addr prealloc_loc = {}; |
375 | int prealloc_len = 0; | 388 | int prealloc_len = 0; |
389 | struct udf_inode_info *iinfo; | ||
376 | 390 | ||
377 | /* The previous extent is fake and we should not extend by anything | 391 | /* The previous extent is fake and we should not extend by anything |
378 | * - there's nothing to do... */ | 392 | * - there's nothing to do... */ |
379 | if (!blocks && fake) | 393 | if (!blocks && fake) |
380 | return 0; | 394 | return 0; |
381 | 395 | ||
396 | iinfo = UDF_I(inode); | ||
382 | /* Round the last extent up to a multiple of block size */ | 397 | /* Round the last extent up to a multiple of block size */ |
383 | if (last_ext->extLength & (sb->s_blocksize - 1)) { | 398 | if (last_ext->extLength & (sb->s_blocksize - 1)) { |
384 | last_ext->extLength = | 399 | last_ext->extLength = |
385 | (last_ext->extLength & UDF_EXTENT_FLAG_MASK) | | 400 | (last_ext->extLength & UDF_EXTENT_FLAG_MASK) | |
386 | (((last_ext->extLength & UDF_EXTENT_LENGTH_MASK) + | 401 | (((last_ext->extLength & UDF_EXTENT_LENGTH_MASK) + |
387 | sb->s_blocksize - 1) & ~(sb->s_blocksize - 1)); | 402 | sb->s_blocksize - 1) & ~(sb->s_blocksize - 1)); |
388 | UDF_I_LENEXTENTS(inode) = | 403 | iinfo->i_lenExtents = |
389 | (UDF_I_LENEXTENTS(inode) + sb->s_blocksize - 1) & | 404 | (iinfo->i_lenExtents + sb->s_blocksize - 1) & |
390 | ~(sb->s_blocksize - 1); | 405 | ~(sb->s_blocksize - 1); |
391 | } | 406 | } |
392 | 407 | ||
393 | /* Last extent are just preallocated blocks? */ | 408 | /* Last extent are just preallocated blocks? */ |
394 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == EXT_NOT_RECORDED_ALLOCATED) { | 409 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == |
410 | EXT_NOT_RECORDED_ALLOCATED) { | ||
395 | /* Save the extent so that we can reattach it to the end */ | 411 | /* Save the extent so that we can reattach it to the end */ |
396 | prealloc_loc = last_ext->extLocation; | 412 | prealloc_loc = last_ext->extLocation; |
397 | prealloc_len = last_ext->extLength; | 413 | prealloc_len = last_ext->extLength; |
@@ -399,13 +415,15 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
399 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 415 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
400 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK); | 416 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK); |
401 | last_ext->extLocation.logicalBlockNum = 0; | 417 | last_ext->extLocation.logicalBlockNum = 0; |
402 | last_ext->extLocation.partitionReferenceNum = 0; | 418 | last_ext->extLocation.partitionReferenceNum = 0; |
403 | } | 419 | } |
404 | 420 | ||
405 | /* Can we merge with the previous extent? */ | 421 | /* Can we merge with the previous extent? */ |
406 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == EXT_NOT_RECORDED_NOT_ALLOCATED) { | 422 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == |
407 | add = ((1 << 30) - sb->s_blocksize - (last_ext->extLength & | 423 | EXT_NOT_RECORDED_NOT_ALLOCATED) { |
408 | UDF_EXTENT_LENGTH_MASK)) >> sb->s_blocksize_bits; | 424 | add = ((1 << 30) - sb->s_blocksize - |
425 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK)) >> | ||
426 | sb->s_blocksize_bits; | ||
409 | if (add > blocks) | 427 | if (add > blocks) |
410 | add = blocks; | 428 | add = blocks; |
411 | blocks -= add; | 429 | blocks -= add; |
@@ -416,9 +434,9 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
416 | udf_add_aext(inode, last_pos, last_ext->extLocation, | 434 | udf_add_aext(inode, last_pos, last_ext->extLocation, |
417 | last_ext->extLength, 1); | 435 | last_ext->extLength, 1); |
418 | count++; | 436 | count++; |
419 | } else { | 437 | } else |
420 | udf_write_aext(inode, last_pos, last_ext->extLocation, last_ext->extLength, 1); | 438 | udf_write_aext(inode, last_pos, last_ext->extLocation, |
421 | } | 439 | last_ext->extLength, 1); |
422 | 440 | ||
423 | /* Managed to do everything necessary? */ | 441 | /* Managed to do everything necessary? */ |
424 | if (!blocks) | 442 | if (!blocks) |
@@ -426,9 +444,10 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
426 | 444 | ||
427 | /* All further extents will be NOT_RECORDED_NOT_ALLOCATED */ | 445 | /* All further extents will be NOT_RECORDED_NOT_ALLOCATED */ |
428 | last_ext->extLocation.logicalBlockNum = 0; | 446 | last_ext->extLocation.logicalBlockNum = 0; |
429 | last_ext->extLocation.partitionReferenceNum = 0; | 447 | last_ext->extLocation.partitionReferenceNum = 0; |
430 | add = (1 << (30-sb->s_blocksize_bits)) - 1; | 448 | add = (1 << (30-sb->s_blocksize_bits)) - 1; |
431 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | (add << sb->s_blocksize_bits); | 449 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
450 | (add << sb->s_blocksize_bits); | ||
432 | 451 | ||
433 | /* Create enough extents to cover the whole hole */ | 452 | /* Create enough extents to cover the whole hole */ |
434 | while (blocks > add) { | 453 | while (blocks > add) { |
@@ -450,7 +469,8 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
450 | out: | 469 | out: |
451 | /* Do we have some preallocated blocks saved? */ | 470 | /* Do we have some preallocated blocks saved? */ |
452 | if (prealloc_len) { | 471 | if (prealloc_len) { |
453 | if (udf_add_aext(inode, last_pos, prealloc_loc, prealloc_len, 1) == -1) | 472 | if (udf_add_aext(inode, last_pos, prealloc_loc, |
473 | prealloc_len, 1) == -1) | ||
454 | return -1; | 474 | return -1; |
455 | last_ext->extLocation = prealloc_loc; | 475 | last_ext->extLocation = prealloc_loc; |
456 | last_ext->extLength = prealloc_len; | 476 | last_ext->extLength = prealloc_len; |
@@ -458,9 +478,9 @@ out: | |||
458 | } | 478 | } |
459 | 479 | ||
460 | /* last_pos should point to the last written extent... */ | 480 | /* last_pos should point to the last written extent... */ |
461 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) | 481 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
462 | last_pos->offset -= sizeof(short_ad); | 482 | last_pos->offset -= sizeof(short_ad); |
463 | else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG) | 483 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
464 | last_pos->offset -= sizeof(long_ad); | 484 | last_pos->offset -= sizeof(long_ad); |
465 | else | 485 | else |
466 | return -1; | 486 | return -1; |
@@ -469,7 +489,7 @@ out: | |||
469 | } | 489 | } |
470 | 490 | ||
471 | static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | 491 | static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, |
472 | int *err, long *phys, int *new) | 492 | int *err, sector_t *phys, int *new) |
473 | { | 493 | { |
474 | static sector_t last_block; | 494 | static sector_t last_block; |
475 | struct buffer_head *result = NULL; | 495 | struct buffer_head *result = NULL; |
@@ -483,11 +503,12 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
483 | uint32_t newblocknum, newblock; | 503 | uint32_t newblocknum, newblock; |
484 | sector_t offset = 0; | 504 | sector_t offset = 0; |
485 | int8_t etype; | 505 | int8_t etype; |
486 | int goal = 0, pgoal = UDF_I_LOCATION(inode).logicalBlockNum; | 506 | struct udf_inode_info *iinfo = UDF_I(inode); |
507 | int goal = 0, pgoal = iinfo->i_location.logicalBlockNum; | ||
487 | int lastblock = 0; | 508 | int lastblock = 0; |
488 | 509 | ||
489 | prev_epos.offset = udf_file_entry_alloc_offset(inode); | 510 | prev_epos.offset = udf_file_entry_alloc_offset(inode); |
490 | prev_epos.block = UDF_I_LOCATION(inode); | 511 | prev_epos.block = iinfo->i_location; |
491 | prev_epos.bh = NULL; | 512 | prev_epos.bh = NULL; |
492 | cur_epos = next_epos = prev_epos; | 513 | cur_epos = next_epos = prev_epos; |
493 | b_off = (loff_t)block << inode->i_sb->s_blocksize_bits; | 514 | b_off = (loff_t)block << inode->i_sb->s_blocksize_bits; |
@@ -515,7 +536,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
515 | prev_epos.offset = cur_epos.offset; | 536 | prev_epos.offset = cur_epos.offset; |
516 | cur_epos.offset = next_epos.offset; | 537 | cur_epos.offset = next_epos.offset; |
517 | 538 | ||
518 | if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 1)) == -1) | 539 | etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 1); |
540 | if (etype == -1) | ||
519 | break; | 541 | break; |
520 | 542 | ||
521 | c = !c; | 543 | c = !c; |
@@ -569,9 +591,11 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
569 | startnum = 1; | 591 | startnum = 1; |
570 | } else { | 592 | } else { |
571 | /* Create a fake extent when there's not one */ | 593 | /* Create a fake extent when there's not one */ |
572 | memset(&laarr[0].extLocation, 0x00, sizeof(kernel_lb_addr)); | 594 | memset(&laarr[0].extLocation, 0x00, |
595 | sizeof(kernel_lb_addr)); | ||
573 | laarr[0].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; | 596 | laarr[0].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; |
574 | /* Will udf_extend_file() create real extent from a fake one? */ | 597 | /* Will udf_extend_file() create real extent from |
598 | a fake one? */ | ||
575 | startnum = (offset > 0); | 599 | startnum = (offset > 0); |
576 | } | 600 | } |
577 | /* Create extents for the hole between EOF and offset */ | 601 | /* Create extents for the hole between EOF and offset */ |
@@ -589,14 +613,16 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
589 | offset = 0; | 613 | offset = 0; |
590 | count += ret; | 614 | count += ret; |
591 | /* We are not covered by a preallocated extent? */ | 615 | /* We are not covered by a preallocated extent? */ |
592 | if ((laarr[0].extLength & UDF_EXTENT_FLAG_MASK) != EXT_NOT_RECORDED_ALLOCATED) { | 616 | if ((laarr[0].extLength & UDF_EXTENT_FLAG_MASK) != |
617 | EXT_NOT_RECORDED_ALLOCATED) { | ||
593 | /* Is there any real extent? - otherwise we overwrite | 618 | /* Is there any real extent? - otherwise we overwrite |
594 | * the fake one... */ | 619 | * the fake one... */ |
595 | if (count) | 620 | if (count) |
596 | c = !c; | 621 | c = !c; |
597 | laarr[c].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 622 | laarr[c].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
598 | inode->i_sb->s_blocksize; | 623 | inode->i_sb->s_blocksize; |
599 | memset(&laarr[c].extLocation, 0x00, sizeof(kernel_lb_addr)); | 624 | memset(&laarr[c].extLocation, 0x00, |
625 | sizeof(kernel_lb_addr)); | ||
600 | count++; | 626 | count++; |
601 | endnum++; | 627 | endnum++; |
602 | } | 628 | } |
@@ -605,7 +631,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
605 | } else { | 631 | } else { |
606 | endnum = startnum = ((count > 2) ? 2 : count); | 632 | endnum = startnum = ((count > 2) ? 2 : count); |
607 | 633 | ||
608 | /* if the current extent is in position 0, swap it with the previous */ | 634 | /* if the current extent is in position 0, |
635 | swap it with the previous */ | ||
609 | if (!c && count != 1) { | 636 | if (!c && count != 1) { |
610 | laarr[2] = laarr[0]; | 637 | laarr[2] = laarr[0]; |
611 | laarr[0] = laarr[1]; | 638 | laarr[0] = laarr[1]; |
@@ -613,44 +640,47 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
613 | c = 1; | 640 | c = 1; |
614 | } | 641 | } |
615 | 642 | ||
616 | /* if the current block is located in an extent, read the next extent */ | 643 | /* if the current block is located in an extent, |
617 | if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 0)) != -1) { | 644 | read the next extent */ |
645 | etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 0); | ||
646 | if (etype != -1) { | ||
618 | laarr[c + 1].extLength = (etype << 30) | elen; | 647 | laarr[c + 1].extLength = (etype << 30) | elen; |
619 | laarr[c + 1].extLocation = eloc; | 648 | laarr[c + 1].extLocation = eloc; |
620 | count++; | 649 | count++; |
621 | startnum++; | 650 | startnum++; |
622 | endnum++; | 651 | endnum++; |
623 | } else { | 652 | } else |
624 | lastblock = 1; | 653 | lastblock = 1; |
625 | } | ||
626 | } | 654 | } |
627 | 655 | ||
628 | /* if the current extent is not recorded but allocated, get the | 656 | /* if the current extent is not recorded but allocated, get the |
629 | * block in the extent corresponding to the requested block */ | 657 | * block in the extent corresponding to the requested block */ |
630 | if ((laarr[c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 658 | if ((laarr[c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) |
631 | newblocknum = laarr[c].extLocation.logicalBlockNum + offset; | 659 | newblocknum = laarr[c].extLocation.logicalBlockNum + offset; |
632 | } else { /* otherwise, allocate a new block */ | 660 | else { /* otherwise, allocate a new block */ |
633 | if (UDF_I_NEXT_ALLOC_BLOCK(inode) == block) | 661 | if (iinfo->i_next_alloc_block == block) |
634 | goal = UDF_I_NEXT_ALLOC_GOAL(inode); | 662 | goal = iinfo->i_next_alloc_goal; |
635 | 663 | ||
636 | if (!goal) { | 664 | if (!goal) { |
637 | if (!(goal = pgoal)) | 665 | if (!(goal = pgoal)) /* XXX: what was intended here? */ |
638 | goal = UDF_I_LOCATION(inode).logicalBlockNum + 1; | 666 | goal = iinfo->i_location.logicalBlockNum + 1; |
639 | } | 667 | } |
640 | 668 | ||
641 | if (!(newblocknum = udf_new_block(inode->i_sb, inode, | 669 | newblocknum = udf_new_block(inode->i_sb, inode, |
642 | UDF_I_LOCATION(inode).partitionReferenceNum, | 670 | iinfo->i_location.partitionReferenceNum, |
643 | goal, err))) { | 671 | goal, err); |
672 | if (!newblocknum) { | ||
644 | brelse(prev_epos.bh); | 673 | brelse(prev_epos.bh); |
645 | *err = -ENOSPC; | 674 | *err = -ENOSPC; |
646 | return NULL; | 675 | return NULL; |
647 | } | 676 | } |
648 | UDF_I_LENEXTENTS(inode) += inode->i_sb->s_blocksize; | 677 | iinfo->i_lenExtents += inode->i_sb->s_blocksize; |
649 | } | 678 | } |
650 | 679 | ||
651 | /* if the extent the requsted block is located in contains multiple blocks, | 680 | /* if the extent the requsted block is located in contains multiple |
652 | * split the extent into at most three extents. blocks prior to requested | 681 | * blocks, split the extent into at most three extents. blocks prior |
653 | * block, requested block, and blocks after requested block */ | 682 | * to requested block, requested block, and blocks after requested |
683 | * block */ | ||
654 | udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum); | 684 | udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum); |
655 | 685 | ||
656 | #ifdef UDF_PREALLOCATE | 686 | #ifdef UDF_PREALLOCATE |
@@ -668,15 +698,15 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
668 | 698 | ||
669 | brelse(prev_epos.bh); | 699 | brelse(prev_epos.bh); |
670 | 700 | ||
671 | if (!(newblock = udf_get_pblock(inode->i_sb, newblocknum, | 701 | newblock = udf_get_pblock(inode->i_sb, newblocknum, |
672 | UDF_I_LOCATION(inode).partitionReferenceNum, 0))) { | 702 | iinfo->i_location.partitionReferenceNum, 0); |
703 | if (!newblock) | ||
673 | return NULL; | 704 | return NULL; |
674 | } | ||
675 | *phys = newblock; | 705 | *phys = newblock; |
676 | *err = 0; | 706 | *err = 0; |
677 | *new = 1; | 707 | *new = 1; |
678 | UDF_I_NEXT_ALLOC_BLOCK(inode) = block; | 708 | iinfo->i_next_alloc_block = block; |
679 | UDF_I_NEXT_ALLOC_GOAL(inode) = newblocknum; | 709 | iinfo->i_next_alloc_goal = newblocknum; |
680 | inode->i_ctime = current_fs_time(inode->i_sb); | 710 | inode->i_ctime = current_fs_time(inode->i_sb); |
681 | 711 | ||
682 | if (IS_SYNC(inode)) | 712 | if (IS_SYNC(inode)) |
@@ -692,16 +722,20 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
692 | kernel_long_ad laarr[EXTENT_MERGE_SIZE], | 722 | kernel_long_ad laarr[EXTENT_MERGE_SIZE], |
693 | int *endnum) | 723 | int *endnum) |
694 | { | 724 | { |
725 | unsigned long blocksize = inode->i_sb->s_blocksize; | ||
726 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
727 | |||
695 | if ((laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30) || | 728 | if ((laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30) || |
696 | (laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { | 729 | (laarr[*c].extLength >> 30) == |
730 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { | ||
697 | int curr = *c; | 731 | int curr = *c; |
698 | int blen = ((laarr[curr].extLength & UDF_EXTENT_LENGTH_MASK) + | 732 | int blen = ((laarr[curr].extLength & UDF_EXTENT_LENGTH_MASK) + |
699 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; | 733 | blocksize - 1) >> blocksize_bits; |
700 | int8_t etype = (laarr[curr].extLength >> 30); | 734 | int8_t etype = (laarr[curr].extLength >> 30); |
701 | 735 | ||
702 | if (blen == 1) { | 736 | if (blen == 1) |
703 | ; | 737 | ; |
704 | } else if (!offset || blen == offset + 1) { | 738 | else if (!offset || blen == offset + 1) { |
705 | laarr[curr + 2] = laarr[curr + 1]; | 739 | laarr[curr + 2] = laarr[curr + 1]; |
706 | laarr[curr + 1] = laarr[curr]; | 740 | laarr[curr + 1] = laarr[curr]; |
707 | } else { | 741 | } else { |
@@ -711,15 +745,18 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
711 | 745 | ||
712 | if (offset) { | 746 | if (offset) { |
713 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 747 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
714 | udf_free_blocks(inode->i_sb, inode, laarr[curr].extLocation, 0, offset); | 748 | udf_free_blocks(inode->i_sb, inode, |
715 | laarr[curr].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 749 | laarr[curr].extLocation, |
716 | (offset << inode->i_sb->s_blocksize_bits); | 750 | 0, offset); |
751 | laarr[curr].extLength = | ||
752 | EXT_NOT_RECORDED_NOT_ALLOCATED | | ||
753 | (offset << blocksize_bits); | ||
717 | laarr[curr].extLocation.logicalBlockNum = 0; | 754 | laarr[curr].extLocation.logicalBlockNum = 0; |
718 | laarr[curr].extLocation.partitionReferenceNum = 0; | 755 | laarr[curr].extLocation. |
719 | } else { | 756 | partitionReferenceNum = 0; |
757 | } else | ||
720 | laarr[curr].extLength = (etype << 30) | | 758 | laarr[curr].extLength = (etype << 30) | |
721 | (offset << inode->i_sb->s_blocksize_bits); | 759 | (offset << blocksize_bits); |
722 | } | ||
723 | curr++; | 760 | curr++; |
724 | (*c)++; | 761 | (*c)++; |
725 | (*endnum)++; | 762 | (*endnum)++; |
@@ -728,16 +765,17 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
728 | laarr[curr].extLocation.logicalBlockNum = newblocknum; | 765 | laarr[curr].extLocation.logicalBlockNum = newblocknum; |
729 | if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) | 766 | if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) |
730 | laarr[curr].extLocation.partitionReferenceNum = | 767 | laarr[curr].extLocation.partitionReferenceNum = |
731 | UDF_I_LOCATION(inode).partitionReferenceNum; | 768 | UDF_I(inode)->i_location.partitionReferenceNum; |
732 | laarr[curr].extLength = EXT_RECORDED_ALLOCATED | | 769 | laarr[curr].extLength = EXT_RECORDED_ALLOCATED | |
733 | inode->i_sb->s_blocksize; | 770 | blocksize; |
734 | curr++; | 771 | curr++; |
735 | 772 | ||
736 | if (blen != offset + 1) { | 773 | if (blen != offset + 1) { |
737 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) | 774 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) |
738 | laarr[curr].extLocation.logicalBlockNum += (offset + 1); | 775 | laarr[curr].extLocation.logicalBlockNum += |
776 | offset + 1; | ||
739 | laarr[curr].extLength = (etype << 30) | | 777 | laarr[curr].extLength = (etype << 30) | |
740 | ((blen - (offset + 1)) << inode->i_sb->s_blocksize_bits); | 778 | ((blen - (offset + 1)) << blocksize_bits); |
741 | curr++; | 779 | curr++; |
742 | (*endnum)++; | 780 | (*endnum)++; |
743 | } | 781 | } |
@@ -756,69 +794,86 @@ static void udf_prealloc_extents(struct inode *inode, int c, int lastblock, | |||
756 | else | 794 | else |
757 | start = c; | 795 | start = c; |
758 | } else { | 796 | } else { |
759 | if ((laarr[c + 1].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 797 | if ((laarr[c + 1].extLength >> 30) == |
798 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | ||
760 | start = c + 1; | 799 | start = c + 1; |
761 | length = currlength = (((laarr[c + 1].extLength & UDF_EXTENT_LENGTH_MASK) + | 800 | length = currlength = |
762 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 801 | (((laarr[c + 1].extLength & |
763 | } else { | 802 | UDF_EXTENT_LENGTH_MASK) + |
803 | inode->i_sb->s_blocksize - 1) >> | ||
804 | inode->i_sb->s_blocksize_bits); | ||
805 | } else | ||
764 | start = c; | 806 | start = c; |
765 | } | ||
766 | } | 807 | } |
767 | 808 | ||
768 | for (i = start + 1; i <= *endnum; i++) { | 809 | for (i = start + 1; i <= *endnum; i++) { |
769 | if (i == *endnum) { | 810 | if (i == *endnum) { |
770 | if (lastblock) | 811 | if (lastblock) |
771 | length += UDF_DEFAULT_PREALLOC_BLOCKS; | 812 | length += UDF_DEFAULT_PREALLOC_BLOCKS; |
772 | } else if ((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { | 813 | } else if ((laarr[i].extLength >> 30) == |
773 | length += (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 814 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { |
774 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 815 | length += (((laarr[i].extLength & |
775 | } else { | 816 | UDF_EXTENT_LENGTH_MASK) + |
817 | inode->i_sb->s_blocksize - 1) >> | ||
818 | inode->i_sb->s_blocksize_bits); | ||
819 | } else | ||
776 | break; | 820 | break; |
777 | } | ||
778 | } | 821 | } |
779 | 822 | ||
780 | if (length) { | 823 | if (length) { |
781 | int next = laarr[start].extLocation.logicalBlockNum + | 824 | int next = laarr[start].extLocation.logicalBlockNum + |
782 | (((laarr[start].extLength & UDF_EXTENT_LENGTH_MASK) + | 825 | (((laarr[start].extLength & UDF_EXTENT_LENGTH_MASK) + |
783 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 826 | inode->i_sb->s_blocksize - 1) >> |
827 | inode->i_sb->s_blocksize_bits); | ||
784 | int numalloc = udf_prealloc_blocks(inode->i_sb, inode, | 828 | int numalloc = udf_prealloc_blocks(inode->i_sb, inode, |
785 | laarr[start].extLocation.partitionReferenceNum, | 829 | laarr[start].extLocation.partitionReferenceNum, |
786 | next, (UDF_DEFAULT_PREALLOC_BLOCKS > length ? length : | 830 | next, (UDF_DEFAULT_PREALLOC_BLOCKS > length ? |
787 | UDF_DEFAULT_PREALLOC_BLOCKS) - currlength); | 831 | length : UDF_DEFAULT_PREALLOC_BLOCKS) - |
832 | currlength); | ||
788 | if (numalloc) { | 833 | if (numalloc) { |
789 | if (start == (c + 1)) { | 834 | if (start == (c + 1)) |
790 | laarr[start].extLength += | 835 | laarr[start].extLength += |
791 | (numalloc << inode->i_sb->s_blocksize_bits); | 836 | (numalloc << |
792 | } else { | 837 | inode->i_sb->s_blocksize_bits); |
838 | else { | ||
793 | memmove(&laarr[c + 2], &laarr[c + 1], | 839 | memmove(&laarr[c + 2], &laarr[c + 1], |
794 | sizeof(long_ad) * (*endnum - (c + 1))); | 840 | sizeof(long_ad) * (*endnum - (c + 1))); |
795 | (*endnum)++; | 841 | (*endnum)++; |
796 | laarr[c + 1].extLocation.logicalBlockNum = next; | 842 | laarr[c + 1].extLocation.logicalBlockNum = next; |
797 | laarr[c + 1].extLocation.partitionReferenceNum = | 843 | laarr[c + 1].extLocation.partitionReferenceNum = |
798 | laarr[c].extLocation.partitionReferenceNum; | 844 | laarr[c].extLocation. |
799 | laarr[c + 1].extLength = EXT_NOT_RECORDED_ALLOCATED | | 845 | partitionReferenceNum; |
800 | (numalloc << inode->i_sb->s_blocksize_bits); | 846 | laarr[c + 1].extLength = |
847 | EXT_NOT_RECORDED_ALLOCATED | | ||
848 | (numalloc << | ||
849 | inode->i_sb->s_blocksize_bits); | ||
801 | start = c + 1; | 850 | start = c + 1; |
802 | } | 851 | } |
803 | 852 | ||
804 | for (i = start + 1; numalloc && i < *endnum; i++) { | 853 | for (i = start + 1; numalloc && i < *endnum; i++) { |
805 | int elen = ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 854 | int elen = ((laarr[i].extLength & |
806 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; | 855 | UDF_EXTENT_LENGTH_MASK) + |
856 | inode->i_sb->s_blocksize - 1) >> | ||
857 | inode->i_sb->s_blocksize_bits; | ||
807 | 858 | ||
808 | if (elen > numalloc) { | 859 | if (elen > numalloc) { |
809 | laarr[i].extLength -= | 860 | laarr[i].extLength -= |
810 | (numalloc << inode->i_sb->s_blocksize_bits); | 861 | (numalloc << |
862 | inode->i_sb->s_blocksize_bits); | ||
811 | numalloc = 0; | 863 | numalloc = 0; |
812 | } else { | 864 | } else { |
813 | numalloc -= elen; | 865 | numalloc -= elen; |
814 | if (*endnum > (i + 1)) | 866 | if (*endnum > (i + 1)) |
815 | memmove(&laarr[i], &laarr[i + 1], | 867 | memmove(&laarr[i], |
816 | sizeof(long_ad) * (*endnum - (i + 1))); | 868 | &laarr[i + 1], |
869 | sizeof(long_ad) * | ||
870 | (*endnum - (i + 1))); | ||
817 | i--; | 871 | i--; |
818 | (*endnum)--; | 872 | (*endnum)--; |
819 | } | 873 | } |
820 | } | 874 | } |
821 | UDF_I_LENEXTENTS(inode) += numalloc << inode->i_sb->s_blocksize_bits; | 875 | UDF_I(inode)->i_lenExtents += |
876 | numalloc << inode->i_sb->s_blocksize_bits; | ||
822 | } | 877 | } |
823 | } | 878 | } |
824 | } | 879 | } |
@@ -828,70 +883,97 @@ static void udf_merge_extents(struct inode *inode, | |||
828 | int *endnum) | 883 | int *endnum) |
829 | { | 884 | { |
830 | int i; | 885 | int i; |
886 | unsigned long blocksize = inode->i_sb->s_blocksize; | ||
887 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
831 | 888 | ||
832 | for (i = 0; i < (*endnum - 1); i++) { | 889 | for (i = 0; i < (*endnum - 1); i++) { |
833 | if ((laarr[i].extLength >> 30) == (laarr[i + 1].extLength >> 30)) { | 890 | kernel_long_ad *li /*l[i]*/ = &laarr[i]; |
834 | if (((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) || | 891 | kernel_long_ad *lip1 /*l[i plus 1]*/ = &laarr[i + 1]; |
835 | ((laarr[i + 1].extLocation.logicalBlockNum - laarr[i].extLocation.logicalBlockNum) == | 892 | |
836 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 893 | if (((li->extLength >> 30) == (lip1->extLength >> 30)) && |
837 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits))) { | 894 | (((li->extLength >> 30) == |
838 | if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 895 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) || |
839 | (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) + | 896 | ((lip1->extLocation.logicalBlockNum - |
840 | inode->i_sb->s_blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { | 897 | li->extLocation.logicalBlockNum) == |
841 | laarr[i + 1].extLength = (laarr[i + 1].extLength - | 898 | (((li->extLength & UDF_EXTENT_LENGTH_MASK) + |
842 | (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 899 | blocksize - 1) >> blocksize_bits)))) { |
843 | UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb->s_blocksize - 1); | 900 | |
844 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_FLAG_MASK) + | 901 | if (((li->extLength & UDF_EXTENT_LENGTH_MASK) + |
845 | (UDF_EXTENT_LENGTH_MASK + 1) - inode->i_sb->s_blocksize; | 902 | (lip1->extLength & UDF_EXTENT_LENGTH_MASK) + |
846 | laarr[i + 1].extLocation.logicalBlockNum = | 903 | blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { |
847 | laarr[i].extLocation.logicalBlockNum + | 904 | lip1->extLength = (lip1->extLength - |
848 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) >> | 905 | (li->extLength & |
849 | inode->i_sb->s_blocksize_bits); | 906 | UDF_EXTENT_LENGTH_MASK) + |
850 | } else { | 907 | UDF_EXTENT_LENGTH_MASK) & |
851 | laarr[i].extLength = laarr[i + 1].extLength + | 908 | ~(blocksize - 1); |
852 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 909 | li->extLength = (li->extLength & |
853 | inode->i_sb->s_blocksize - 1) & ~(inode->i_sb->s_blocksize - 1)); | 910 | UDF_EXTENT_FLAG_MASK) + |
854 | if (*endnum > (i + 2)) | 911 | (UDF_EXTENT_LENGTH_MASK + 1) - |
855 | memmove(&laarr[i + 1], &laarr[i + 2], | 912 | blocksize; |
856 | sizeof(long_ad) * (*endnum - (i + 2))); | 913 | lip1->extLocation.logicalBlockNum = |
857 | i--; | 914 | li->extLocation.logicalBlockNum + |
858 | (*endnum)--; | 915 | ((li->extLength & |
859 | } | 916 | UDF_EXTENT_LENGTH_MASK) >> |
917 | blocksize_bits); | ||
918 | } else { | ||
919 | li->extLength = lip1->extLength + | ||
920 | (((li->extLength & | ||
921 | UDF_EXTENT_LENGTH_MASK) + | ||
922 | blocksize - 1) & ~(blocksize - 1)); | ||
923 | if (*endnum > (i + 2)) | ||
924 | memmove(&laarr[i + 1], &laarr[i + 2], | ||
925 | sizeof(long_ad) * | ||
926 | (*endnum - (i + 2))); | ||
927 | i--; | ||
928 | (*endnum)--; | ||
860 | } | 929 | } |
861 | } else if (((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) && | 930 | } else if (((li->extLength >> 30) == |
862 | ((laarr[i + 1].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) { | 931 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) && |
863 | udf_free_blocks(inode->i_sb, inode, laarr[i].extLocation, 0, | 932 | ((lip1->extLength >> 30) == |
864 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 933 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) { |
865 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 934 | udf_free_blocks(inode->i_sb, inode, li->extLocation, 0, |
866 | laarr[i].extLocation.logicalBlockNum = 0; | 935 | ((li->extLength & |
867 | laarr[i].extLocation.partitionReferenceNum = 0; | 936 | UDF_EXTENT_LENGTH_MASK) + |
868 | 937 | blocksize - 1) >> blocksize_bits); | |
869 | if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 938 | li->extLocation.logicalBlockNum = 0; |
870 | (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) + | 939 | li->extLocation.partitionReferenceNum = 0; |
871 | inode->i_sb->s_blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { | 940 | |
872 | laarr[i + 1].extLength = (laarr[i + 1].extLength - | 941 | if (((li->extLength & UDF_EXTENT_LENGTH_MASK) + |
873 | (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 942 | (lip1->extLength & UDF_EXTENT_LENGTH_MASK) + |
874 | UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb->s_blocksize - 1); | 943 | blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { |
875 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_FLAG_MASK) + | 944 | lip1->extLength = (lip1->extLength - |
876 | (UDF_EXTENT_LENGTH_MASK + 1) - inode->i_sb->s_blocksize; | 945 | (li->extLength & |
946 | UDF_EXTENT_LENGTH_MASK) + | ||
947 | UDF_EXTENT_LENGTH_MASK) & | ||
948 | ~(blocksize - 1); | ||
949 | li->extLength = (li->extLength & | ||
950 | UDF_EXTENT_FLAG_MASK) + | ||
951 | (UDF_EXTENT_LENGTH_MASK + 1) - | ||
952 | blocksize; | ||
877 | } else { | 953 | } else { |
878 | laarr[i].extLength = laarr[i + 1].extLength + | 954 | li->extLength = lip1->extLength + |
879 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 955 | (((li->extLength & |
880 | inode->i_sb->s_blocksize - 1) & ~(inode->i_sb->s_blocksize - 1)); | 956 | UDF_EXTENT_LENGTH_MASK) + |
957 | blocksize - 1) & ~(blocksize - 1)); | ||
881 | if (*endnum > (i + 2)) | 958 | if (*endnum > (i + 2)) |
882 | memmove(&laarr[i + 1], &laarr[i + 2], | 959 | memmove(&laarr[i + 1], &laarr[i + 2], |
883 | sizeof(long_ad) * (*endnum - (i + 2))); | 960 | sizeof(long_ad) * |
961 | (*endnum - (i + 2))); | ||
884 | i--; | 962 | i--; |
885 | (*endnum)--; | 963 | (*endnum)--; |
886 | } | 964 | } |
887 | } else if ((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 965 | } else if ((li->extLength >> 30) == |
888 | udf_free_blocks(inode->i_sb, inode, laarr[i].extLocation, 0, | 966 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
889 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 967 | udf_free_blocks(inode->i_sb, inode, |
890 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 968 | li->extLocation, 0, |
891 | laarr[i].extLocation.logicalBlockNum = 0; | 969 | ((li->extLength & |
892 | laarr[i].extLocation.partitionReferenceNum = 0; | 970 | UDF_EXTENT_LENGTH_MASK) + |
893 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) | | 971 | blocksize - 1) >> blocksize_bits); |
894 | EXT_NOT_RECORDED_NOT_ALLOCATED; | 972 | li->extLocation.logicalBlockNum = 0; |
973 | li->extLocation.partitionReferenceNum = 0; | ||
974 | li->extLength = (li->extLength & | ||
975 | UDF_EXTENT_LENGTH_MASK) | | ||
976 | EXT_NOT_RECORDED_NOT_ALLOCATED; | ||
895 | } | 977 | } |
896 | } | 978 | } |
897 | } | 979 | } |
@@ -953,6 +1035,7 @@ void udf_truncate(struct inode *inode) | |||
953 | { | 1035 | { |
954 | int offset; | 1036 | int offset; |
955 | int err; | 1037 | int err; |
1038 | struct udf_inode_info *iinfo; | ||
956 | 1039 | ||
957 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || | 1040 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || |
958 | S_ISLNK(inode->i_mode))) | 1041 | S_ISLNK(inode->i_mode))) |
@@ -961,25 +1044,28 @@ void udf_truncate(struct inode *inode) | |||
961 | return; | 1044 | return; |
962 | 1045 | ||
963 | lock_kernel(); | 1046 | lock_kernel(); |
964 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 1047 | iinfo = UDF_I(inode); |
965 | if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) + | 1048 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
966 | inode->i_size)) { | 1049 | if (inode->i_sb->s_blocksize < |
1050 | (udf_file_entry_alloc_offset(inode) + | ||
1051 | inode->i_size)) { | ||
967 | udf_expand_file_adinicb(inode, inode->i_size, &err); | 1052 | udf_expand_file_adinicb(inode, inode->i_size, &err); |
968 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 1053 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
969 | inode->i_size = UDF_I_LENALLOC(inode); | 1054 | inode->i_size = iinfo->i_lenAlloc; |
970 | unlock_kernel(); | 1055 | unlock_kernel(); |
971 | return; | 1056 | return; |
972 | } else { | 1057 | } else |
973 | udf_truncate_extents(inode); | 1058 | udf_truncate_extents(inode); |
974 | } | ||
975 | } else { | 1059 | } else { |
976 | offset = inode->i_size & (inode->i_sb->s_blocksize - 1); | 1060 | offset = inode->i_size & (inode->i_sb->s_blocksize - 1); |
977 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + offset, 0x00, | 1061 | memset(iinfo->i_ext.i_data + iinfo->i_lenEAttr + offset, |
978 | inode->i_sb->s_blocksize - offset - udf_file_entry_alloc_offset(inode)); | 1062 | 0x00, inode->i_sb->s_blocksize - |
979 | UDF_I_LENALLOC(inode) = inode->i_size; | 1063 | offset - udf_file_entry_alloc_offset(inode)); |
1064 | iinfo->i_lenAlloc = inode->i_size; | ||
980 | } | 1065 | } |
981 | } else { | 1066 | } else { |
982 | block_truncate_page(inode->i_mapping, inode->i_size, udf_get_block); | 1067 | block_truncate_page(inode->i_mapping, inode->i_size, |
1068 | udf_get_block); | ||
983 | udf_truncate_extents(inode); | 1069 | udf_truncate_extents(inode); |
984 | } | 1070 | } |
985 | 1071 | ||
@@ -996,6 +1082,7 @@ static void __udf_read_inode(struct inode *inode) | |||
996 | struct buffer_head *bh = NULL; | 1082 | struct buffer_head *bh = NULL; |
997 | struct fileEntry *fe; | 1083 | struct fileEntry *fe; |
998 | uint16_t ident; | 1084 | uint16_t ident; |
1085 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
999 | 1086 | ||
1000 | /* | 1087 | /* |
1001 | * Set defaults, but the inode is still incomplete! | 1088 | * Set defaults, but the inode is still incomplete! |
@@ -1009,7 +1096,7 @@ static void __udf_read_inode(struct inode *inode) | |||
1009 | * i_nlink = 1 | 1096 | * i_nlink = 1 |
1010 | * i_op = NULL; | 1097 | * i_op = NULL; |
1011 | */ | 1098 | */ |
1012 | bh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 0, &ident); | 1099 | bh = udf_read_ptagged(inode->i_sb, iinfo->i_location, 0, &ident); |
1013 | if (!bh) { | 1100 | if (!bh) { |
1014 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n", | 1101 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n", |
1015 | inode->i_ino); | 1102 | inode->i_ino); |
@@ -1019,8 +1106,8 @@ static void __udf_read_inode(struct inode *inode) | |||
1019 | 1106 | ||
1020 | if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && | 1107 | if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && |
1021 | ident != TAG_IDENT_USE) { | 1108 | ident != TAG_IDENT_USE) { |
1022 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed ident=%d\n", | 1109 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) " |
1023 | inode->i_ino, ident); | 1110 | "failed ident=%d\n", inode->i_ino, ident); |
1024 | brelse(bh); | 1111 | brelse(bh); |
1025 | make_bad_inode(inode); | 1112 | make_bad_inode(inode); |
1026 | return; | 1113 | return; |
@@ -1028,11 +1115,12 @@ static void __udf_read_inode(struct inode *inode) | |||
1028 | 1115 | ||
1029 | fe = (struct fileEntry *)bh->b_data; | 1116 | fe = (struct fileEntry *)bh->b_data; |
1030 | 1117 | ||
1031 | if (le16_to_cpu(fe->icbTag.strategyType) == 4096) { | 1118 | if (fe->icbTag.strategyType == cpu_to_le16(4096)) { |
1032 | struct buffer_head *ibh = NULL, *nbh = NULL; | 1119 | struct buffer_head *ibh = NULL, *nbh = NULL; |
1033 | struct indirectEntry *ie; | 1120 | struct indirectEntry *ie; |
1034 | 1121 | ||
1035 | ibh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 1, &ident); | 1122 | ibh = udf_read_ptagged(inode->i_sb, iinfo->i_location, 1, |
1123 | &ident); | ||
1036 | if (ident == TAG_IDENT_IE) { | 1124 | if (ident == TAG_IDENT_IE) { |
1037 | if (ibh) { | 1125 | if (ibh) { |
1038 | kernel_lb_addr loc; | 1126 | kernel_lb_addr loc; |
@@ -1041,10 +1129,12 @@ static void __udf_read_inode(struct inode *inode) | |||
1041 | loc = lelb_to_cpu(ie->indirectICB.extLocation); | 1129 | loc = lelb_to_cpu(ie->indirectICB.extLocation); |
1042 | 1130 | ||
1043 | if (ie->indirectICB.extLength && | 1131 | if (ie->indirectICB.extLength && |
1044 | (nbh = udf_read_ptagged(inode->i_sb, loc, 0, &ident))) { | 1132 | (nbh = udf_read_ptagged(inode->i_sb, loc, 0, |
1133 | &ident))) { | ||
1045 | if (ident == TAG_IDENT_FE || | 1134 | if (ident == TAG_IDENT_FE || |
1046 | ident == TAG_IDENT_EFE) { | 1135 | ident == TAG_IDENT_EFE) { |
1047 | memcpy(&UDF_I_LOCATION(inode), &loc, | 1136 | memcpy(&iinfo->i_location, |
1137 | &loc, | ||
1048 | sizeof(kernel_lb_addr)); | 1138 | sizeof(kernel_lb_addr)); |
1049 | brelse(bh); | 1139 | brelse(bh); |
1050 | brelse(ibh); | 1140 | brelse(ibh); |
@@ -1062,7 +1152,7 @@ static void __udf_read_inode(struct inode *inode) | |||
1062 | } else { | 1152 | } else { |
1063 | brelse(ibh); | 1153 | brelse(ibh); |
1064 | } | 1154 | } |
1065 | } else if (le16_to_cpu(fe->icbTag.strategyType) != 4) { | 1155 | } else if (fe->icbTag.strategyType != cpu_to_le16(4)) { |
1066 | printk(KERN_ERR "udf: unsupported strategy type: %d\n", | 1156 | printk(KERN_ERR "udf: unsupported strategy type: %d\n", |
1067 | le16_to_cpu(fe->icbTag.strategyType)); | 1157 | le16_to_cpu(fe->icbTag.strategyType)); |
1068 | brelse(bh); | 1158 | brelse(bh); |
@@ -1081,51 +1171,63 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1081 | time_t convtime; | 1171 | time_t convtime; |
1082 | long convtime_usec; | 1172 | long convtime_usec; |
1083 | int offset; | 1173 | int offset; |
1174 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); | ||
1175 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
1084 | 1176 | ||
1085 | fe = (struct fileEntry *)bh->b_data; | 1177 | fe = (struct fileEntry *)bh->b_data; |
1086 | efe = (struct extendedFileEntry *)bh->b_data; | 1178 | efe = (struct extendedFileEntry *)bh->b_data; |
1087 | 1179 | ||
1088 | if (le16_to_cpu(fe->icbTag.strategyType) == 4) | 1180 | if (fe->icbTag.strategyType == cpu_to_le16(4)) |
1089 | UDF_I_STRAT4096(inode) = 0; | 1181 | iinfo->i_strat4096 = 0; |
1090 | else /* if (le16_to_cpu(fe->icbTag.strategyType) == 4096) */ | 1182 | else /* if (fe->icbTag.strategyType == cpu_to_le16(4096)) */ |
1091 | UDF_I_STRAT4096(inode) = 1; | 1183 | iinfo->i_strat4096 = 1; |
1092 | 1184 | ||
1093 | UDF_I_ALLOCTYPE(inode) = le16_to_cpu(fe->icbTag.flags) & ICBTAG_FLAG_AD_MASK; | 1185 | iinfo->i_alloc_type = le16_to_cpu(fe->icbTag.flags) & |
1094 | UDF_I_UNIQUE(inode) = 0; | 1186 | ICBTAG_FLAG_AD_MASK; |
1095 | UDF_I_LENEATTR(inode) = 0; | 1187 | iinfo->i_unique = 0; |
1096 | UDF_I_LENEXTENTS(inode) = 0; | 1188 | iinfo->i_lenEAttr = 0; |
1097 | UDF_I_LENALLOC(inode) = 0; | 1189 | iinfo->i_lenExtents = 0; |
1098 | UDF_I_NEXT_ALLOC_BLOCK(inode) = 0; | 1190 | iinfo->i_lenAlloc = 0; |
1099 | UDF_I_NEXT_ALLOC_GOAL(inode) = 0; | 1191 | iinfo->i_next_alloc_block = 0; |
1100 | if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_EFE) { | 1192 | iinfo->i_next_alloc_goal = 0; |
1101 | UDF_I_EFE(inode) = 1; | 1193 | if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_EFE)) { |
1102 | UDF_I_USE(inode) = 0; | 1194 | iinfo->i_efe = 1; |
1103 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry))) { | 1195 | iinfo->i_use = 0; |
1196 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - | ||
1197 | sizeof(struct extendedFileEntry))) { | ||
1104 | make_bad_inode(inode); | 1198 | make_bad_inode(inode); |
1105 | return; | 1199 | return; |
1106 | } | 1200 | } |
1107 | memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct extendedFileEntry), | 1201 | memcpy(iinfo->i_ext.i_data, |
1108 | inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry)); | 1202 | bh->b_data + sizeof(struct extendedFileEntry), |
1109 | } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_FE) { | 1203 | inode->i_sb->s_blocksize - |
1110 | UDF_I_EFE(inode) = 0; | 1204 | sizeof(struct extendedFileEntry)); |
1111 | UDF_I_USE(inode) = 0; | 1205 | } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_FE)) { |
1112 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct fileEntry))) { | 1206 | iinfo->i_efe = 0; |
1207 | iinfo->i_use = 0; | ||
1208 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - | ||
1209 | sizeof(struct fileEntry))) { | ||
1113 | make_bad_inode(inode); | 1210 | make_bad_inode(inode); |
1114 | return; | 1211 | return; |
1115 | } | 1212 | } |
1116 | memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct fileEntry), | 1213 | memcpy(iinfo->i_ext.i_data, |
1214 | bh->b_data + sizeof(struct fileEntry), | ||
1117 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); | 1215 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); |
1118 | } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_USE) { | 1216 | } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_USE)) { |
1119 | UDF_I_EFE(inode) = 0; | 1217 | iinfo->i_efe = 0; |
1120 | UDF_I_USE(inode) = 1; | 1218 | iinfo->i_use = 1; |
1121 | UDF_I_LENALLOC(inode) = | 1219 | iinfo->i_lenAlloc = le32_to_cpu( |
1122 | le32_to_cpu(((struct unallocSpaceEntry *)bh->b_data)->lengthAllocDescs); | 1220 | ((struct unallocSpaceEntry *)bh->b_data)-> |
1123 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry))) { | 1221 | lengthAllocDescs); |
1222 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - | ||
1223 | sizeof(struct unallocSpaceEntry))) { | ||
1124 | make_bad_inode(inode); | 1224 | make_bad_inode(inode); |
1125 | return; | 1225 | return; |
1126 | } | 1226 | } |
1127 | memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct unallocSpaceEntry), | 1227 | memcpy(iinfo->i_ext.i_data, |
1128 | inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry)); | 1228 | bh->b_data + sizeof(struct unallocSpaceEntry), |
1229 | inode->i_sb->s_blocksize - | ||
1230 | sizeof(struct unallocSpaceEntry)); | ||
1129 | return; | 1231 | return; |
1130 | } | 1232 | } |
1131 | 1233 | ||
@@ -1146,12 +1248,12 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1146 | inode->i_nlink = 1; | 1248 | inode->i_nlink = 1; |
1147 | 1249 | ||
1148 | inode->i_size = le64_to_cpu(fe->informationLength); | 1250 | inode->i_size = le64_to_cpu(fe->informationLength); |
1149 | UDF_I_LENEXTENTS(inode) = inode->i_size; | 1251 | iinfo->i_lenExtents = inode->i_size; |
1150 | 1252 | ||
1151 | inode->i_mode = udf_convert_permissions(fe); | 1253 | inode->i_mode = udf_convert_permissions(fe); |
1152 | inode->i_mode &= ~UDF_SB(inode->i_sb)->s_umask; | 1254 | inode->i_mode &= ~UDF_SB(inode->i_sb)->s_umask; |
1153 | 1255 | ||
1154 | if (UDF_I_EFE(inode) == 0) { | 1256 | if (iinfo->i_efe == 0) { |
1155 | inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) << | 1257 | inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) << |
1156 | (inode->i_sb->s_blocksize_bits - 9); | 1258 | (inode->i_sb->s_blocksize_bits - 9); |
1157 | 1259 | ||
@@ -1160,7 +1262,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1160 | inode->i_atime.tv_sec = convtime; | 1262 | inode->i_atime.tv_sec = convtime; |
1161 | inode->i_atime.tv_nsec = convtime_usec * 1000; | 1263 | inode->i_atime.tv_nsec = convtime_usec * 1000; |
1162 | } else { | 1264 | } else { |
1163 | inode->i_atime = UDF_SB_RECORDTIME(inode->i_sb); | 1265 | inode->i_atime = sbi->s_record_time; |
1164 | } | 1266 | } |
1165 | 1267 | ||
1166 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1268 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1168,7 +1270,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1168 | inode->i_mtime.tv_sec = convtime; | 1270 | inode->i_mtime.tv_sec = convtime; |
1169 | inode->i_mtime.tv_nsec = convtime_usec * 1000; | 1271 | inode->i_mtime.tv_nsec = convtime_usec * 1000; |
1170 | } else { | 1272 | } else { |
1171 | inode->i_mtime = UDF_SB_RECORDTIME(inode->i_sb); | 1273 | inode->i_mtime = sbi->s_record_time; |
1172 | } | 1274 | } |
1173 | 1275 | ||
1174 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1276 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1176,13 +1278,13 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1176 | inode->i_ctime.tv_sec = convtime; | 1278 | inode->i_ctime.tv_sec = convtime; |
1177 | inode->i_ctime.tv_nsec = convtime_usec * 1000; | 1279 | inode->i_ctime.tv_nsec = convtime_usec * 1000; |
1178 | } else { | 1280 | } else { |
1179 | inode->i_ctime = UDF_SB_RECORDTIME(inode->i_sb); | 1281 | inode->i_ctime = sbi->s_record_time; |
1180 | } | 1282 | } |
1181 | 1283 | ||
1182 | UDF_I_UNIQUE(inode) = le64_to_cpu(fe->uniqueID); | 1284 | iinfo->i_unique = le64_to_cpu(fe->uniqueID); |
1183 | UDF_I_LENEATTR(inode) = le32_to_cpu(fe->lengthExtendedAttr); | 1285 | iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr); |
1184 | UDF_I_LENALLOC(inode) = le32_to_cpu(fe->lengthAllocDescs); | 1286 | iinfo->i_lenAlloc = le32_to_cpu(fe->lengthAllocDescs); |
1185 | offset = sizeof(struct fileEntry) + UDF_I_LENEATTR(inode); | 1287 | offset = sizeof(struct fileEntry) + iinfo->i_lenEAttr; |
1186 | } else { | 1288 | } else { |
1187 | inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << | 1289 | inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << |
1188 | (inode->i_sb->s_blocksize_bits - 9); | 1290 | (inode->i_sb->s_blocksize_bits - 9); |
@@ -1192,7 +1294,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1192 | inode->i_atime.tv_sec = convtime; | 1294 | inode->i_atime.tv_sec = convtime; |
1193 | inode->i_atime.tv_nsec = convtime_usec * 1000; | 1295 | inode->i_atime.tv_nsec = convtime_usec * 1000; |
1194 | } else { | 1296 | } else { |
1195 | inode->i_atime = UDF_SB_RECORDTIME(inode->i_sb); | 1297 | inode->i_atime = sbi->s_record_time; |
1196 | } | 1298 | } |
1197 | 1299 | ||
1198 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1300 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1200,15 +1302,15 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1200 | inode->i_mtime.tv_sec = convtime; | 1302 | inode->i_mtime.tv_sec = convtime; |
1201 | inode->i_mtime.tv_nsec = convtime_usec * 1000; | 1303 | inode->i_mtime.tv_nsec = convtime_usec * 1000; |
1202 | } else { | 1304 | } else { |
1203 | inode->i_mtime = UDF_SB_RECORDTIME(inode->i_sb); | 1305 | inode->i_mtime = sbi->s_record_time; |
1204 | } | 1306 | } |
1205 | 1307 | ||
1206 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1308 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
1207 | lets_to_cpu(efe->createTime))) { | 1309 | lets_to_cpu(efe->createTime))) { |
1208 | UDF_I_CRTIME(inode).tv_sec = convtime; | 1310 | iinfo->i_crtime.tv_sec = convtime; |
1209 | UDF_I_CRTIME(inode).tv_nsec = convtime_usec * 1000; | 1311 | iinfo->i_crtime.tv_nsec = convtime_usec * 1000; |
1210 | } else { | 1312 | } else { |
1211 | UDF_I_CRTIME(inode) = UDF_SB_RECORDTIME(inode->i_sb); | 1313 | iinfo->i_crtime = sbi->s_record_time; |
1212 | } | 1314 | } |
1213 | 1315 | ||
1214 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1316 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1216,13 +1318,14 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1216 | inode->i_ctime.tv_sec = convtime; | 1318 | inode->i_ctime.tv_sec = convtime; |
1217 | inode->i_ctime.tv_nsec = convtime_usec * 1000; | 1319 | inode->i_ctime.tv_nsec = convtime_usec * 1000; |
1218 | } else { | 1320 | } else { |
1219 | inode->i_ctime = UDF_SB_RECORDTIME(inode->i_sb); | 1321 | inode->i_ctime = sbi->s_record_time; |
1220 | } | 1322 | } |
1221 | 1323 | ||
1222 | UDF_I_UNIQUE(inode) = le64_to_cpu(efe->uniqueID); | 1324 | iinfo->i_unique = le64_to_cpu(efe->uniqueID); |
1223 | UDF_I_LENEATTR(inode) = le32_to_cpu(efe->lengthExtendedAttr); | 1325 | iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr); |
1224 | UDF_I_LENALLOC(inode) = le32_to_cpu(efe->lengthAllocDescs); | 1326 | iinfo->i_lenAlloc = le32_to_cpu(efe->lengthAllocDescs); |
1225 | offset = sizeof(struct extendedFileEntry) + UDF_I_LENEATTR(inode); | 1327 | offset = sizeof(struct extendedFileEntry) + |
1328 | iinfo->i_lenEAttr; | ||
1226 | } | 1329 | } |
1227 | 1330 | ||
1228 | switch (fe->icbTag.fileType) { | 1331 | switch (fe->icbTag.fileType) { |
@@ -1235,7 +1338,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1235 | case ICBTAG_FILE_TYPE_REALTIME: | 1338 | case ICBTAG_FILE_TYPE_REALTIME: |
1236 | case ICBTAG_FILE_TYPE_REGULAR: | 1339 | case ICBTAG_FILE_TYPE_REGULAR: |
1237 | case ICBTAG_FILE_TYPE_UNDEF: | 1340 | case ICBTAG_FILE_TYPE_UNDEF: |
1238 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) | 1341 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
1239 | inode->i_data.a_ops = &udf_adinicb_aops; | 1342 | inode->i_data.a_ops = &udf_adinicb_aops; |
1240 | else | 1343 | else |
1241 | inode->i_data.a_ops = &udf_aops; | 1344 | inode->i_data.a_ops = &udf_aops; |
@@ -1261,31 +1364,33 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1261 | inode->i_mode = S_IFLNK | S_IRWXUGO; | 1364 | inode->i_mode = S_IFLNK | S_IRWXUGO; |
1262 | break; | 1365 | break; |
1263 | default: | 1366 | default: |
1264 | printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown file type=%d\n", | 1367 | printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown " |
1265 | inode->i_ino, fe->icbTag.fileType); | 1368 | "file type=%d\n", inode->i_ino, |
1369 | fe->icbTag.fileType); | ||
1266 | make_bad_inode(inode); | 1370 | make_bad_inode(inode); |
1267 | return; | 1371 | return; |
1268 | } | 1372 | } |
1269 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { | 1373 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { |
1270 | struct deviceSpec *dsea = (struct deviceSpec *)udf_get_extendedattr(inode, 12, 1); | 1374 | struct deviceSpec *dsea = |
1375 | (struct deviceSpec *)udf_get_extendedattr(inode, 12, 1); | ||
1271 | if (dsea) { | 1376 | if (dsea) { |
1272 | init_special_inode(inode, inode->i_mode, | 1377 | init_special_inode(inode, inode->i_mode, |
1273 | MKDEV(le32_to_cpu(dsea->majorDeviceIdent), | 1378 | MKDEV(le32_to_cpu(dsea->majorDeviceIdent), |
1274 | le32_to_cpu(dsea->minorDeviceIdent))); | 1379 | le32_to_cpu(dsea->minorDeviceIdent))); |
1275 | /* Developer ID ??? */ | 1380 | /* Developer ID ??? */ |
1276 | } else { | 1381 | } else |
1277 | make_bad_inode(inode); | 1382 | make_bad_inode(inode); |
1278 | } | ||
1279 | } | 1383 | } |
1280 | } | 1384 | } |
1281 | 1385 | ||
1282 | static int udf_alloc_i_data(struct inode *inode, size_t size) | 1386 | static int udf_alloc_i_data(struct inode *inode, size_t size) |
1283 | { | 1387 | { |
1284 | UDF_I_DATA(inode) = kmalloc(size, GFP_KERNEL); | 1388 | struct udf_inode_info *iinfo = UDF_I(inode); |
1389 | iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL); | ||
1285 | 1390 | ||
1286 | if (!UDF_I_DATA(inode)) { | 1391 | if (!iinfo->i_ext.i_data) { |
1287 | printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) no free memory\n", | 1392 | printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) " |
1288 | inode->i_ino); | 1393 | "no free memory\n", inode->i_ino); |
1289 | return -ENOMEM; | 1394 | return -ENOMEM; |
1290 | } | 1395 | } |
1291 | 1396 | ||
@@ -1301,12 +1406,12 @@ static mode_t udf_convert_permissions(struct fileEntry *fe) | |||
1301 | permissions = le32_to_cpu(fe->permissions); | 1406 | permissions = le32_to_cpu(fe->permissions); |
1302 | flags = le16_to_cpu(fe->icbTag.flags); | 1407 | flags = le16_to_cpu(fe->icbTag.flags); |
1303 | 1408 | ||
1304 | mode = (( permissions ) & S_IRWXO) | | 1409 | mode = ((permissions) & S_IRWXO) | |
1305 | (( permissions >> 2 ) & S_IRWXG) | | 1410 | ((permissions >> 2) & S_IRWXG) | |
1306 | (( permissions >> 4 ) & S_IRWXU) | | 1411 | ((permissions >> 4) & S_IRWXU) | |
1307 | (( flags & ICBTAG_FLAG_SETUID) ? S_ISUID : 0) | | 1412 | ((flags & ICBTAG_FLAG_SETUID) ? S_ISUID : 0) | |
1308 | (( flags & ICBTAG_FLAG_SETGID) ? S_ISGID : 0) | | 1413 | ((flags & ICBTAG_FLAG_SETGID) ? S_ISGID : 0) | |
1309 | (( flags & ICBTAG_FLAG_STICKY) ? S_ISVTX : 0); | 1414 | ((flags & ICBTAG_FLAG_STICKY) ? S_ISVTX : 0); |
1310 | 1415 | ||
1311 | return mode; | 1416 | return mode; |
1312 | } | 1417 | } |
@@ -1350,11 +1455,15 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1350 | uint32_t udfperms; | 1455 | uint32_t udfperms; |
1351 | uint16_t icbflags; | 1456 | uint16_t icbflags; |
1352 | uint16_t crclen; | 1457 | uint16_t crclen; |
1353 | int i; | ||
1354 | kernel_timestamp cpu_time; | 1458 | kernel_timestamp cpu_time; |
1355 | int err = 0; | 1459 | int err = 0; |
1460 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); | ||
1461 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
1462 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
1356 | 1463 | ||
1357 | bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0)); | 1464 | bh = udf_tread(inode->i_sb, |
1465 | udf_get_lb_pblock(inode->i_sb, | ||
1466 | iinfo->i_location, 0)); | ||
1358 | if (!bh) { | 1467 | if (!bh) { |
1359 | udf_debug("bread failure\n"); | 1468 | udf_debug("bread failure\n"); |
1360 | return -EIO; | 1469 | return -EIO; |
@@ -1365,23 +1474,24 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1365 | fe = (struct fileEntry *)bh->b_data; | 1474 | fe = (struct fileEntry *)bh->b_data; |
1366 | efe = (struct extendedFileEntry *)bh->b_data; | 1475 | efe = (struct extendedFileEntry *)bh->b_data; |
1367 | 1476 | ||
1368 | if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_USE) { | 1477 | if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_USE)) { |
1369 | struct unallocSpaceEntry *use = | 1478 | struct unallocSpaceEntry *use = |
1370 | (struct unallocSpaceEntry *)bh->b_data; | 1479 | (struct unallocSpaceEntry *)bh->b_data; |
1371 | 1480 | ||
1372 | use->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode)); | 1481 | use->lengthAllocDescs = cpu_to_le32(iinfo->i_lenAlloc); |
1373 | memcpy(bh->b_data + sizeof(struct unallocSpaceEntry), UDF_I_DATA(inode), | 1482 | memcpy(bh->b_data + sizeof(struct unallocSpaceEntry), |
1374 | inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry)); | 1483 | iinfo->i_ext.i_data, inode->i_sb->s_blocksize - |
1375 | crclen = sizeof(struct unallocSpaceEntry) + UDF_I_LENALLOC(inode) - sizeof(tag); | 1484 | sizeof(struct unallocSpaceEntry)); |
1376 | use->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | 1485 | crclen = sizeof(struct unallocSpaceEntry) + |
1486 | iinfo->i_lenAlloc - sizeof(tag); | ||
1487 | use->descTag.tagLocation = cpu_to_le32( | ||
1488 | iinfo->i_location. | ||
1489 | logicalBlockNum); | ||
1377 | use->descTag.descCRCLength = cpu_to_le16(crclen); | 1490 | use->descTag.descCRCLength = cpu_to_le16(crclen); |
1378 | use->descTag.descCRC = cpu_to_le16(udf_crc((char *)use + sizeof(tag), crclen, 0)); | 1491 | use->descTag.descCRC = cpu_to_le16(udf_crc((char *)use + |
1379 | 1492 | sizeof(tag), crclen, | |
1380 | use->descTag.tagChecksum = 0; | 1493 | 0)); |
1381 | for (i = 0; i < 16; i++) { | 1494 | use->descTag.tagChecksum = udf_tag_checksum(&use->descTag); |
1382 | if (i != 4) | ||
1383 | use->descTag.tagChecksum += ((uint8_t *)&(use->descTag))[i]; | ||
1384 | } | ||
1385 | 1495 | ||
1386 | mark_buffer_dirty(bh); | 1496 | mark_buffer_dirty(bh); |
1387 | brelse(bh); | 1497 | brelse(bh); |
@@ -1398,14 +1508,14 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1398 | else | 1508 | else |
1399 | fe->gid = cpu_to_le32(inode->i_gid); | 1509 | fe->gid = cpu_to_le32(inode->i_gid); |
1400 | 1510 | ||
1401 | udfperms = ((inode->i_mode & S_IRWXO) ) | | 1511 | udfperms = ((inode->i_mode & S_IRWXO)) | |
1402 | ((inode->i_mode & S_IRWXG) << 2) | | 1512 | ((inode->i_mode & S_IRWXG) << 2) | |
1403 | ((inode->i_mode & S_IRWXU) << 4); | 1513 | ((inode->i_mode & S_IRWXU) << 4); |
1404 | 1514 | ||
1405 | udfperms |= (le32_to_cpu(fe->permissions) & | 1515 | udfperms |= (le32_to_cpu(fe->permissions) & |
1406 | (FE_PERM_O_DELETE | FE_PERM_O_CHATTR | | 1516 | (FE_PERM_O_DELETE | FE_PERM_O_CHATTR | |
1407 | FE_PERM_G_DELETE | FE_PERM_G_CHATTR | | 1517 | FE_PERM_G_DELETE | FE_PERM_G_CHATTR | |
1408 | FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); | 1518 | FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); |
1409 | fe->permissions = cpu_to_le32(udfperms); | 1519 | fe->permissions = cpu_to_le32(udfperms); |
1410 | 1520 | ||
1411 | if (S_ISDIR(inode->i_mode)) | 1521 | if (S_ISDIR(inode->i_mode)) |
@@ -1426,8 +1536,9 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1426 | sizeof(regid), 12, 0x3); | 1536 | sizeof(regid), 12, 0x3); |
1427 | dsea->attrType = cpu_to_le32(12); | 1537 | dsea->attrType = cpu_to_le32(12); |
1428 | dsea->attrSubtype = 1; | 1538 | dsea->attrSubtype = 1; |
1429 | dsea->attrLength = cpu_to_le32(sizeof(struct deviceSpec) + | 1539 | dsea->attrLength = cpu_to_le32( |
1430 | sizeof(regid)); | 1540 | sizeof(struct deviceSpec) + |
1541 | sizeof(regid)); | ||
1431 | dsea->impUseLength = cpu_to_le32(sizeof(regid)); | 1542 | dsea->impUseLength = cpu_to_le32(sizeof(regid)); |
1432 | } | 1543 | } |
1433 | eid = (regid *)dsea->impUse; | 1544 | eid = (regid *)dsea->impUse; |
@@ -1439,12 +1550,13 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1439 | dsea->minorDeviceIdent = cpu_to_le32(iminor(inode)); | 1550 | dsea->minorDeviceIdent = cpu_to_le32(iminor(inode)); |
1440 | } | 1551 | } |
1441 | 1552 | ||
1442 | if (UDF_I_EFE(inode) == 0) { | 1553 | if (iinfo->i_efe == 0) { |
1443 | memcpy(bh->b_data + sizeof(struct fileEntry), UDF_I_DATA(inode), | 1554 | memcpy(bh->b_data + sizeof(struct fileEntry), |
1555 | iinfo->i_ext.i_data, | ||
1444 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); | 1556 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); |
1445 | fe->logicalBlocksRecorded = cpu_to_le64( | 1557 | fe->logicalBlocksRecorded = cpu_to_le64( |
1446 | (inode->i_blocks + (1 << (inode->i_sb->s_blocksize_bits - 9)) - 1) >> | 1558 | (inode->i_blocks + (1 << (blocksize_bits - 9)) - 1) >> |
1447 | (inode->i_sb->s_blocksize_bits - 9)); | 1559 | (blocksize_bits - 9)); |
1448 | 1560 | ||
1449 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) | 1561 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) |
1450 | fe->accessTime = cpu_to_lets(cpu_time); | 1562 | fe->accessTime = cpu_to_lets(cpu_time); |
@@ -1456,40 +1568,41 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1456 | strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER); | 1568 | strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER); |
1457 | fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1569 | fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1458 | fe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1570 | fe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1459 | fe->uniqueID = cpu_to_le64(UDF_I_UNIQUE(inode)); | 1571 | fe->uniqueID = cpu_to_le64(iinfo->i_unique); |
1460 | fe->lengthExtendedAttr = cpu_to_le32(UDF_I_LENEATTR(inode)); | 1572 | fe->lengthExtendedAttr = cpu_to_le32(iinfo->i_lenEAttr); |
1461 | fe->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode)); | 1573 | fe->lengthAllocDescs = cpu_to_le32(iinfo->i_lenAlloc); |
1462 | fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE); | 1574 | fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE); |
1463 | crclen = sizeof(struct fileEntry); | 1575 | crclen = sizeof(struct fileEntry); |
1464 | } else { | 1576 | } else { |
1465 | memcpy(bh->b_data + sizeof(struct extendedFileEntry), UDF_I_DATA(inode), | 1577 | memcpy(bh->b_data + sizeof(struct extendedFileEntry), |
1466 | inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry)); | 1578 | iinfo->i_ext.i_data, |
1579 | inode->i_sb->s_blocksize - | ||
1580 | sizeof(struct extendedFileEntry)); | ||
1467 | efe->objectSize = cpu_to_le64(inode->i_size); | 1581 | efe->objectSize = cpu_to_le64(inode->i_size); |
1468 | efe->logicalBlocksRecorded = cpu_to_le64( | 1582 | efe->logicalBlocksRecorded = cpu_to_le64( |
1469 | (inode->i_blocks + (1 << (inode->i_sb->s_blocksize_bits - 9)) - 1) >> | 1583 | (inode->i_blocks + (1 << (blocksize_bits - 9)) - 1) >> |
1470 | (inode->i_sb->s_blocksize_bits - 9)); | 1584 | (blocksize_bits - 9)); |
1471 | 1585 | ||
1472 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_atime.tv_sec || | 1586 | if (iinfo->i_crtime.tv_sec > inode->i_atime.tv_sec || |
1473 | (UDF_I_CRTIME(inode).tv_sec == inode->i_atime.tv_sec && | 1587 | (iinfo->i_crtime.tv_sec == inode->i_atime.tv_sec && |
1474 | UDF_I_CRTIME(inode).tv_nsec > inode->i_atime.tv_nsec)) { | 1588 | iinfo->i_crtime.tv_nsec > inode->i_atime.tv_nsec)) |
1475 | UDF_I_CRTIME(inode) = inode->i_atime; | 1589 | iinfo->i_crtime = inode->i_atime; |
1476 | } | 1590 | |
1477 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_mtime.tv_sec || | 1591 | if (iinfo->i_crtime.tv_sec > inode->i_mtime.tv_sec || |
1478 | (UDF_I_CRTIME(inode).tv_sec == inode->i_mtime.tv_sec && | 1592 | (iinfo->i_crtime.tv_sec == inode->i_mtime.tv_sec && |
1479 | UDF_I_CRTIME(inode).tv_nsec > inode->i_mtime.tv_nsec)) { | 1593 | iinfo->i_crtime.tv_nsec > inode->i_mtime.tv_nsec)) |
1480 | UDF_I_CRTIME(inode) = inode->i_mtime; | 1594 | iinfo->i_crtime = inode->i_mtime; |
1481 | } | 1595 | |
1482 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_ctime.tv_sec || | 1596 | if (iinfo->i_crtime.tv_sec > inode->i_ctime.tv_sec || |
1483 | (UDF_I_CRTIME(inode).tv_sec == inode->i_ctime.tv_sec && | 1597 | (iinfo->i_crtime.tv_sec == inode->i_ctime.tv_sec && |
1484 | UDF_I_CRTIME(inode).tv_nsec > inode->i_ctime.tv_nsec)) { | 1598 | iinfo->i_crtime.tv_nsec > inode->i_ctime.tv_nsec)) |
1485 | UDF_I_CRTIME(inode) = inode->i_ctime; | 1599 | iinfo->i_crtime = inode->i_ctime; |
1486 | } | ||
1487 | 1600 | ||
1488 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) | 1601 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) |
1489 | efe->accessTime = cpu_to_lets(cpu_time); | 1602 | efe->accessTime = cpu_to_lets(cpu_time); |
1490 | if (udf_time_to_stamp(&cpu_time, inode->i_mtime)) | 1603 | if (udf_time_to_stamp(&cpu_time, inode->i_mtime)) |
1491 | efe->modificationTime = cpu_to_lets(cpu_time); | 1604 | efe->modificationTime = cpu_to_lets(cpu_time); |
1492 | if (udf_time_to_stamp(&cpu_time, UDF_I_CRTIME(inode))) | 1605 | if (udf_time_to_stamp(&cpu_time, iinfo->i_crtime)) |
1493 | efe->createTime = cpu_to_lets(cpu_time); | 1606 | efe->createTime = cpu_to_lets(cpu_time); |
1494 | if (udf_time_to_stamp(&cpu_time, inode->i_ctime)) | 1607 | if (udf_time_to_stamp(&cpu_time, inode->i_ctime)) |
1495 | efe->attrTime = cpu_to_lets(cpu_time); | 1608 | efe->attrTime = cpu_to_lets(cpu_time); |
@@ -1498,13 +1611,13 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1498 | strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER); | 1611 | strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER); |
1499 | efe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1612 | efe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1500 | efe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1613 | efe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1501 | efe->uniqueID = cpu_to_le64(UDF_I_UNIQUE(inode)); | 1614 | efe->uniqueID = cpu_to_le64(iinfo->i_unique); |
1502 | efe->lengthExtendedAttr = cpu_to_le32(UDF_I_LENEATTR(inode)); | 1615 | efe->lengthExtendedAttr = cpu_to_le32(iinfo->i_lenEAttr); |
1503 | efe->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode)); | 1616 | efe->lengthAllocDescs = cpu_to_le32(iinfo->i_lenAlloc); |
1504 | efe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EFE); | 1617 | efe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EFE); |
1505 | crclen = sizeof(struct extendedFileEntry); | 1618 | crclen = sizeof(struct extendedFileEntry); |
1506 | } | 1619 | } |
1507 | if (UDF_I_STRAT4096(inode)) { | 1620 | if (iinfo->i_strat4096) { |
1508 | fe->icbTag.strategyType = cpu_to_le16(4096); | 1621 | fe->icbTag.strategyType = cpu_to_le16(4096); |
1509 | fe->icbTag.strategyParameter = cpu_to_le16(1); | 1622 | fe->icbTag.strategyParameter = cpu_to_le16(1); |
1510 | fe->icbTag.numEntries = cpu_to_le16(2); | 1623 | fe->icbTag.numEntries = cpu_to_le16(2); |
@@ -1528,7 +1641,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1528 | else if (S_ISSOCK(inode->i_mode)) | 1641 | else if (S_ISSOCK(inode->i_mode)) |
1529 | fe->icbTag.fileType = ICBTAG_FILE_TYPE_SOCKET; | 1642 | fe->icbTag.fileType = ICBTAG_FILE_TYPE_SOCKET; |
1530 | 1643 | ||
1531 | icbflags = UDF_I_ALLOCTYPE(inode) | | 1644 | icbflags = iinfo->i_alloc_type | |
1532 | ((inode->i_mode & S_ISUID) ? ICBTAG_FLAG_SETUID : 0) | | 1645 | ((inode->i_mode & S_ISUID) ? ICBTAG_FLAG_SETUID : 0) | |
1533 | ((inode->i_mode & S_ISGID) ? ICBTAG_FLAG_SETGID : 0) | | 1646 | ((inode->i_mode & S_ISGID) ? ICBTAG_FLAG_SETGID : 0) | |
1534 | ((inode->i_mode & S_ISVTX) ? ICBTAG_FLAG_STICKY : 0) | | 1647 | ((inode->i_mode & S_ISVTX) ? ICBTAG_FLAG_STICKY : 0) | |
@@ -1537,29 +1650,28 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1537 | ICBTAG_FLAG_SETGID | ICBTAG_FLAG_STICKY)); | 1650 | ICBTAG_FLAG_SETGID | ICBTAG_FLAG_STICKY)); |
1538 | 1651 | ||
1539 | fe->icbTag.flags = cpu_to_le16(icbflags); | 1652 | fe->icbTag.flags = cpu_to_le16(icbflags); |
1540 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) | 1653 | if (sbi->s_udfrev >= 0x0200) |
1541 | fe->descTag.descVersion = cpu_to_le16(3); | 1654 | fe->descTag.descVersion = cpu_to_le16(3); |
1542 | else | 1655 | else |
1543 | fe->descTag.descVersion = cpu_to_le16(2); | 1656 | fe->descTag.descVersion = cpu_to_le16(2); |
1544 | fe->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); | 1657 | fe->descTag.tagSerialNum = cpu_to_le16(sbi->s_serial_number); |
1545 | fe->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | 1658 | fe->descTag.tagLocation = cpu_to_le32( |
1546 | crclen += UDF_I_LENEATTR(inode) + UDF_I_LENALLOC(inode) - sizeof(tag); | 1659 | iinfo->i_location.logicalBlockNum); |
1660 | crclen += iinfo->i_lenEAttr + iinfo->i_lenAlloc - | ||
1661 | sizeof(tag); | ||
1547 | fe->descTag.descCRCLength = cpu_to_le16(crclen); | 1662 | fe->descTag.descCRCLength = cpu_to_le16(crclen); |
1548 | fe->descTag.descCRC = cpu_to_le16(udf_crc((char *)fe + sizeof(tag), crclen, 0)); | 1663 | fe->descTag.descCRC = cpu_to_le16(udf_crc((char *)fe + sizeof(tag), |
1549 | 1664 | crclen, 0)); | |
1550 | fe->descTag.tagChecksum = 0; | 1665 | fe->descTag.tagChecksum = udf_tag_checksum(&fe->descTag); |
1551 | for (i = 0; i < 16; i++) { | ||
1552 | if (i != 4) | ||
1553 | fe->descTag.tagChecksum += ((uint8_t *)&(fe->descTag))[i]; | ||
1554 | } | ||
1555 | 1666 | ||
1556 | /* write the data blocks */ | 1667 | /* write the data blocks */ |
1557 | mark_buffer_dirty(bh); | 1668 | mark_buffer_dirty(bh); |
1558 | if (do_sync) { | 1669 | if (do_sync) { |
1559 | sync_dirty_buffer(bh); | 1670 | sync_dirty_buffer(bh); |
1560 | if (buffer_req(bh) && !buffer_uptodate(bh)) { | 1671 | if (buffer_req(bh) && !buffer_uptodate(bh)) { |
1561 | printk("IO error syncing udf inode [%s:%08lx]\n", | 1672 | printk(KERN_WARNING "IO error syncing udf inode " |
1562 | inode->i_sb->s_id, inode->i_ino); | 1673 | "[%s:%08lx]\n", inode->i_sb->s_id, |
1674 | inode->i_ino); | ||
1563 | err = -EIO; | 1675 | err = -EIO; |
1564 | } | 1676 | } |
1565 | } | 1677 | } |
@@ -1577,7 +1689,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino) | |||
1577 | return NULL; | 1689 | return NULL; |
1578 | 1690 | ||
1579 | if (inode->i_state & I_NEW) { | 1691 | if (inode->i_state & I_NEW) { |
1580 | memcpy(&UDF_I_LOCATION(inode), &ino, sizeof(kernel_lb_addr)); | 1692 | memcpy(&UDF_I(inode)->i_location, &ino, sizeof(kernel_lb_addr)); |
1581 | __udf_read_inode(inode); | 1693 | __udf_read_inode(inode); |
1582 | unlock_new_inode(inode); | 1694 | unlock_new_inode(inode); |
1583 | } | 1695 | } |
@@ -1585,7 +1697,8 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino) | |||
1585 | if (is_bad_inode(inode)) | 1697 | if (is_bad_inode(inode)) |
1586 | goto out_iput; | 1698 | goto out_iput; |
1587 | 1699 | ||
1588 | if (ino.logicalBlockNum >= UDF_SB_PARTLEN(sb, ino.partitionReferenceNum)) { | 1700 | if (ino.logicalBlockNum >= UDF_SB(sb)-> |
1701 | s_partmaps[ino.partitionReferenceNum].s_partition_len) { | ||
1589 | udf_debug("block=%d, partition=%d out of range\n", | 1702 | udf_debug("block=%d, partition=%d out of range\n", |
1590 | ino.logicalBlockNum, ino.partitionReferenceNum); | 1703 | ino.logicalBlockNum, ino.partitionReferenceNum); |
1591 | make_bad_inode(inode); | 1704 | make_bad_inode(inode); |
@@ -1599,7 +1712,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino) | |||
1599 | return NULL; | 1712 | return NULL; |
1600 | } | 1713 | } |
1601 | 1714 | ||
1602 | int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | 1715 | int8_t udf_add_aext(struct inode *inode, struct extent_position *epos, |
1603 | kernel_lb_addr eloc, uint32_t elen, int inc) | 1716 | kernel_lb_addr eloc, uint32_t elen, int inc) |
1604 | { | 1717 | { |
1605 | int adsize; | 1718 | int adsize; |
@@ -1608,15 +1721,18 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1608 | struct allocExtDesc *aed; | 1721 | struct allocExtDesc *aed; |
1609 | int8_t etype; | 1722 | int8_t etype; |
1610 | uint8_t *ptr; | 1723 | uint8_t *ptr; |
1724 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
1611 | 1725 | ||
1612 | if (!epos->bh) | 1726 | if (!epos->bh) |
1613 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | 1727 | ptr = iinfo->i_ext.i_data + epos->offset - |
1728 | udf_file_entry_alloc_offset(inode) + | ||
1729 | iinfo->i_lenEAttr; | ||
1614 | else | 1730 | else |
1615 | ptr = epos->bh->b_data + epos->offset; | 1731 | ptr = epos->bh->b_data + epos->offset; |
1616 | 1732 | ||
1617 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) | 1733 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
1618 | adsize = sizeof(short_ad); | 1734 | adsize = sizeof(short_ad); |
1619 | else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG) | 1735 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
1620 | adsize = sizeof(long_ad); | 1736 | adsize = sizeof(long_ad); |
1621 | else | 1737 | else |
1622 | return -1; | 1738 | return -1; |
@@ -1627,15 +1743,16 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1627 | int err, loffset; | 1743 | int err, loffset; |
1628 | kernel_lb_addr obloc = epos->block; | 1744 | kernel_lb_addr obloc = epos->block; |
1629 | 1745 | ||
1630 | if (!(epos->block.logicalBlockNum = udf_new_block(inode->i_sb, NULL, | 1746 | epos->block.logicalBlockNum = udf_new_block(inode->i_sb, NULL, |
1631 | obloc.partitionReferenceNum, | 1747 | obloc.partitionReferenceNum, |
1632 | obloc.logicalBlockNum, &err))) { | 1748 | obloc.logicalBlockNum, &err); |
1749 | if (!epos->block.logicalBlockNum) | ||
1633 | return -1; | 1750 | return -1; |
1634 | } | 1751 | nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb, |
1635 | if (!(nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb, | 1752 | epos->block, |
1636 | epos->block, 0)))) { | 1753 | 0)); |
1754 | if (!nbh) | ||
1637 | return -1; | 1755 | return -1; |
1638 | } | ||
1639 | lock_buffer(nbh); | 1756 | lock_buffer(nbh); |
1640 | memset(nbh->b_data, 0x00, inode->i_sb->s_blocksize); | 1757 | memset(nbh->b_data, 0x00, inode->i_sb->s_blocksize); |
1641 | set_buffer_uptodate(nbh); | 1758 | set_buffer_uptodate(nbh); |
@@ -1644,7 +1761,8 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1644 | 1761 | ||
1645 | aed = (struct allocExtDesc *)(nbh->b_data); | 1762 | aed = (struct allocExtDesc *)(nbh->b_data); |
1646 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) | 1763 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) |
1647 | aed->previousAllocExtLocation = cpu_to_le32(obloc.logicalBlockNum); | 1764 | aed->previousAllocExtLocation = |
1765 | cpu_to_le32(obloc.logicalBlockNum); | ||
1648 | if (epos->offset + adsize > inode->i_sb->s_blocksize) { | 1766 | if (epos->offset + adsize > inode->i_sb->s_blocksize) { |
1649 | loffset = epos->offset; | 1767 | loffset = epos->offset; |
1650 | aed->lengthAllocDescs = cpu_to_le32(adsize); | 1768 | aed->lengthAllocDescs = cpu_to_le32(adsize); |
@@ -1661,24 +1779,26 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1661 | if (epos->bh) { | 1779 | if (epos->bh) { |
1662 | aed = (struct allocExtDesc *)epos->bh->b_data; | 1780 | aed = (struct allocExtDesc *)epos->bh->b_data; |
1663 | aed->lengthAllocDescs = | 1781 | aed->lengthAllocDescs = |
1664 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); | 1782 | cpu_to_le32(le32_to_cpu( |
1783 | aed->lengthAllocDescs) + adsize); | ||
1665 | } else { | 1784 | } else { |
1666 | UDF_I_LENALLOC(inode) += adsize; | 1785 | iinfo->i_lenAlloc += adsize; |
1667 | mark_inode_dirty(inode); | 1786 | mark_inode_dirty(inode); |
1668 | } | 1787 | } |
1669 | } | 1788 | } |
1670 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) | 1789 | if (UDF_SB(inode->i_sb)->s_udfrev >= 0x0200) |
1671 | udf_new_tag(nbh->b_data, TAG_IDENT_AED, 3, 1, | 1790 | udf_new_tag(nbh->b_data, TAG_IDENT_AED, 3, 1, |
1672 | epos->block.logicalBlockNum, sizeof(tag)); | 1791 | epos->block.logicalBlockNum, sizeof(tag)); |
1673 | else | 1792 | else |
1674 | udf_new_tag(nbh->b_data, TAG_IDENT_AED, 2, 1, | 1793 | udf_new_tag(nbh->b_data, TAG_IDENT_AED, 2, 1, |
1675 | epos->block.logicalBlockNum, sizeof(tag)); | 1794 | epos->block.logicalBlockNum, sizeof(tag)); |
1676 | switch (UDF_I_ALLOCTYPE(inode)) { | 1795 | switch (iinfo->i_alloc_type) { |
1677 | case ICBTAG_FLAG_AD_SHORT: | 1796 | case ICBTAG_FLAG_AD_SHORT: |
1678 | sad = (short_ad *)sptr; | 1797 | sad = (short_ad *)sptr; |
1679 | sad->extLength = cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | | 1798 | sad->extLength = cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | |
1680 | inode->i_sb->s_blocksize); | 1799 | inode->i_sb->s_blocksize); |
1681 | sad->extPosition = cpu_to_le32(epos->block.logicalBlockNum); | 1800 | sad->extPosition = |
1801 | cpu_to_le32(epos->block.logicalBlockNum); | ||
1682 | break; | 1802 | break; |
1683 | case ICBTAG_FLAG_AD_LONG: | 1803 | case ICBTAG_FLAG_AD_LONG: |
1684 | lad = (long_ad *)sptr; | 1804 | lad = (long_ad *)sptr; |
@@ -1690,10 +1810,11 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1690 | } | 1810 | } |
1691 | if (epos->bh) { | 1811 | if (epos->bh) { |
1692 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 1812 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1693 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1813 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1694 | udf_update_tag(epos->bh->b_data, loffset); | 1814 | udf_update_tag(epos->bh->b_data, loffset); |
1695 | else | 1815 | else |
1696 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); | 1816 | udf_update_tag(epos->bh->b_data, |
1817 | sizeof(struct allocExtDesc)); | ||
1697 | mark_buffer_dirty_inode(epos->bh, inode); | 1818 | mark_buffer_dirty_inode(epos->bh, inode); |
1698 | brelse(epos->bh); | 1819 | brelse(epos->bh); |
1699 | } else { | 1820 | } else { |
@@ -1705,36 +1826,43 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1705 | etype = udf_write_aext(inode, epos, eloc, elen, inc); | 1826 | etype = udf_write_aext(inode, epos, eloc, elen, inc); |
1706 | 1827 | ||
1707 | if (!epos->bh) { | 1828 | if (!epos->bh) { |
1708 | UDF_I_LENALLOC(inode) += adsize; | 1829 | iinfo->i_lenAlloc += adsize; |
1709 | mark_inode_dirty(inode); | 1830 | mark_inode_dirty(inode); |
1710 | } else { | 1831 | } else { |
1711 | aed = (struct allocExtDesc *)epos->bh->b_data; | 1832 | aed = (struct allocExtDesc *)epos->bh->b_data; |
1712 | aed->lengthAllocDescs = | 1833 | aed->lengthAllocDescs = |
1713 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); | 1834 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + |
1714 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1835 | adsize); |
1715 | udf_update_tag(epos->bh->b_data, epos->offset + (inc ? 0 : adsize)); | 1836 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1837 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) | ||
1838 | udf_update_tag(epos->bh->b_data, | ||
1839 | epos->offset + (inc ? 0 : adsize)); | ||
1716 | else | 1840 | else |
1717 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); | 1841 | udf_update_tag(epos->bh->b_data, |
1842 | sizeof(struct allocExtDesc)); | ||
1718 | mark_buffer_dirty_inode(epos->bh, inode); | 1843 | mark_buffer_dirty_inode(epos->bh, inode); |
1719 | } | 1844 | } |
1720 | 1845 | ||
1721 | return etype; | 1846 | return etype; |
1722 | } | 1847 | } |
1723 | 1848 | ||
1724 | int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | 1849 | int8_t udf_write_aext(struct inode *inode, struct extent_position *epos, |
1725 | kernel_lb_addr eloc, uint32_t elen, int inc) | 1850 | kernel_lb_addr eloc, uint32_t elen, int inc) |
1726 | { | 1851 | { |
1727 | int adsize; | 1852 | int adsize; |
1728 | uint8_t *ptr; | 1853 | uint8_t *ptr; |
1729 | short_ad *sad; | 1854 | short_ad *sad; |
1730 | long_ad *lad; | 1855 | long_ad *lad; |
1856 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
1731 | 1857 | ||
1732 | if (!epos->bh) | 1858 | if (!epos->bh) |
1733 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | 1859 | ptr = iinfo->i_ext.i_data + epos->offset - |
1860 | udf_file_entry_alloc_offset(inode) + | ||
1861 | iinfo->i_lenEAttr; | ||
1734 | else | 1862 | else |
1735 | ptr = epos->bh->b_data + epos->offset; | 1863 | ptr = epos->bh->b_data + epos->offset; |
1736 | 1864 | ||
1737 | switch (UDF_I_ALLOCTYPE(inode)) { | 1865 | switch (iinfo->i_alloc_type) { |
1738 | case ICBTAG_FLAG_AD_SHORT: | 1866 | case ICBTAG_FLAG_AD_SHORT: |
1739 | sad = (short_ad *)ptr; | 1867 | sad = (short_ad *)ptr; |
1740 | sad->extLength = cpu_to_le32(elen); | 1868 | sad->extLength = cpu_to_le32(elen); |
@@ -1754,10 +1882,12 @@ int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | |||
1754 | 1882 | ||
1755 | if (epos->bh) { | 1883 | if (epos->bh) { |
1756 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 1884 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1757 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) { | 1885 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) { |
1758 | struct allocExtDesc *aed = (struct allocExtDesc *)epos->bh->b_data; | 1886 | struct allocExtDesc *aed = |
1887 | (struct allocExtDesc *)epos->bh->b_data; | ||
1759 | udf_update_tag(epos->bh->b_data, | 1888 | udf_update_tag(epos->bh->b_data, |
1760 | le32_to_cpu(aed->lengthAllocDescs) + sizeof(struct allocExtDesc)); | 1889 | le32_to_cpu(aed->lengthAllocDescs) + |
1890 | sizeof(struct allocExtDesc)); | ||
1761 | } | 1891 | } |
1762 | mark_buffer_dirty_inode(epos->bh, inode); | 1892 | mark_buffer_dirty_inode(epos->bh, inode); |
1763 | } else { | 1893 | } else { |
@@ -1770,19 +1900,21 @@ int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | |||
1770 | return (elen >> 30); | 1900 | return (elen >> 30); |
1771 | } | 1901 | } |
1772 | 1902 | ||
1773 | int8_t udf_next_aext(struct inode * inode, struct extent_position * epos, | 1903 | int8_t udf_next_aext(struct inode *inode, struct extent_position *epos, |
1774 | kernel_lb_addr * eloc, uint32_t * elen, int inc) | 1904 | kernel_lb_addr *eloc, uint32_t *elen, int inc) |
1775 | { | 1905 | { |
1776 | int8_t etype; | 1906 | int8_t etype; |
1777 | 1907 | ||
1778 | while ((etype = udf_current_aext(inode, epos, eloc, elen, inc)) == | 1908 | while ((etype = udf_current_aext(inode, epos, eloc, elen, inc)) == |
1779 | (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { | 1909 | (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { |
1910 | int block; | ||
1780 | epos->block = *eloc; | 1911 | epos->block = *eloc; |
1781 | epos->offset = sizeof(struct allocExtDesc); | 1912 | epos->offset = sizeof(struct allocExtDesc); |
1782 | brelse(epos->bh); | 1913 | brelse(epos->bh); |
1783 | if (!(epos->bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, epos->block, 0)))) { | 1914 | block = udf_get_lb_pblock(inode->i_sb, epos->block, 0); |
1784 | udf_debug("reading block %d failed!\n", | 1915 | epos->bh = udf_tread(inode->i_sb, block); |
1785 | udf_get_lb_pblock(inode->i_sb, epos->block, 0)); | 1916 | if (!epos->bh) { |
1917 | udf_debug("reading block %d failed!\n", block); | ||
1786 | return -1; | 1918 | return -1; |
1787 | } | 1919 | } |
1788 | } | 1920 | } |
@@ -1790,47 +1922,55 @@ int8_t udf_next_aext(struct inode * inode, struct extent_position * epos, | |||
1790 | return etype; | 1922 | return etype; |
1791 | } | 1923 | } |
1792 | 1924 | ||
1793 | int8_t udf_current_aext(struct inode * inode, struct extent_position * epos, | 1925 | int8_t udf_current_aext(struct inode *inode, struct extent_position *epos, |
1794 | kernel_lb_addr * eloc, uint32_t * elen, int inc) | 1926 | kernel_lb_addr *eloc, uint32_t *elen, int inc) |
1795 | { | 1927 | { |
1796 | int alen; | 1928 | int alen; |
1797 | int8_t etype; | 1929 | int8_t etype; |
1798 | uint8_t *ptr; | 1930 | uint8_t *ptr; |
1799 | short_ad *sad; | 1931 | short_ad *sad; |
1800 | long_ad *lad; | 1932 | long_ad *lad; |
1801 | 1933 | struct udf_inode_info *iinfo = UDF_I(inode); | |
1802 | 1934 | ||
1803 | if (!epos->bh) { | 1935 | if (!epos->bh) { |
1804 | if (!epos->offset) | 1936 | if (!epos->offset) |
1805 | epos->offset = udf_file_entry_alloc_offset(inode); | 1937 | epos->offset = udf_file_entry_alloc_offset(inode); |
1806 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | 1938 | ptr = iinfo->i_ext.i_data + epos->offset - |
1807 | alen = udf_file_entry_alloc_offset(inode) + UDF_I_LENALLOC(inode); | 1939 | udf_file_entry_alloc_offset(inode) + |
1940 | iinfo->i_lenEAttr; | ||
1941 | alen = udf_file_entry_alloc_offset(inode) + | ||
1942 | iinfo->i_lenAlloc; | ||
1808 | } else { | 1943 | } else { |
1809 | if (!epos->offset) | 1944 | if (!epos->offset) |
1810 | epos->offset = sizeof(struct allocExtDesc); | 1945 | epos->offset = sizeof(struct allocExtDesc); |
1811 | ptr = epos->bh->b_data + epos->offset; | 1946 | ptr = epos->bh->b_data + epos->offset; |
1812 | alen = sizeof(struct allocExtDesc) + | 1947 | alen = sizeof(struct allocExtDesc) + |
1813 | le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)->lengthAllocDescs); | 1948 | le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)-> |
1949 | lengthAllocDescs); | ||
1814 | } | 1950 | } |
1815 | 1951 | ||
1816 | switch (UDF_I_ALLOCTYPE(inode)) { | 1952 | switch (iinfo->i_alloc_type) { |
1817 | case ICBTAG_FLAG_AD_SHORT: | 1953 | case ICBTAG_FLAG_AD_SHORT: |
1818 | if (!(sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc))) | 1954 | sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc); |
1955 | if (!sad) | ||
1819 | return -1; | 1956 | return -1; |
1820 | etype = le32_to_cpu(sad->extLength) >> 30; | 1957 | etype = le32_to_cpu(sad->extLength) >> 30; |
1821 | eloc->logicalBlockNum = le32_to_cpu(sad->extPosition); | 1958 | eloc->logicalBlockNum = le32_to_cpu(sad->extPosition); |
1822 | eloc->partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; | 1959 | eloc->partitionReferenceNum = |
1960 | iinfo->i_location.partitionReferenceNum; | ||
1823 | *elen = le32_to_cpu(sad->extLength) & UDF_EXTENT_LENGTH_MASK; | 1961 | *elen = le32_to_cpu(sad->extLength) & UDF_EXTENT_LENGTH_MASK; |
1824 | break; | 1962 | break; |
1825 | case ICBTAG_FLAG_AD_LONG: | 1963 | case ICBTAG_FLAG_AD_LONG: |
1826 | if (!(lad = udf_get_filelongad(ptr, alen, &epos->offset, inc))) | 1964 | lad = udf_get_filelongad(ptr, alen, &epos->offset, inc); |
1965 | if (!lad) | ||
1827 | return -1; | 1966 | return -1; |
1828 | etype = le32_to_cpu(lad->extLength) >> 30; | 1967 | etype = le32_to_cpu(lad->extLength) >> 30; |
1829 | *eloc = lelb_to_cpu(lad->extLocation); | 1968 | *eloc = lelb_to_cpu(lad->extLocation); |
1830 | *elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK; | 1969 | *elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK; |
1831 | break; | 1970 | break; |
1832 | default: | 1971 | default: |
1833 | udf_debug("alloc_type = %d unsupported\n", UDF_I_ALLOCTYPE(inode)); | 1972 | udf_debug("alloc_type = %d unsupported\n", |
1973 | iinfo->i_alloc_type); | ||
1834 | return -1; | 1974 | return -1; |
1835 | } | 1975 | } |
1836 | 1976 | ||
@@ -1858,22 +1998,24 @@ static int8_t udf_insert_aext(struct inode *inode, struct extent_position epos, | |||
1858 | return (nelen >> 30); | 1998 | return (nelen >> 30); |
1859 | } | 1999 | } |
1860 | 2000 | ||
1861 | int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | 2001 | int8_t udf_delete_aext(struct inode *inode, struct extent_position epos, |
1862 | kernel_lb_addr eloc, uint32_t elen) | 2002 | kernel_lb_addr eloc, uint32_t elen) |
1863 | { | 2003 | { |
1864 | struct extent_position oepos; | 2004 | struct extent_position oepos; |
1865 | int adsize; | 2005 | int adsize; |
1866 | int8_t etype; | 2006 | int8_t etype; |
1867 | struct allocExtDesc *aed; | 2007 | struct allocExtDesc *aed; |
2008 | struct udf_inode_info *iinfo; | ||
1868 | 2009 | ||
1869 | if (epos.bh) { | 2010 | if (epos.bh) { |
1870 | get_bh(epos.bh); | 2011 | get_bh(epos.bh); |
1871 | get_bh(epos.bh); | 2012 | get_bh(epos.bh); |
1872 | } | 2013 | } |
1873 | 2014 | ||
1874 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) | 2015 | iinfo = UDF_I(inode); |
2016 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | ||
1875 | adsize = sizeof(short_ad); | 2017 | adsize = sizeof(short_ad); |
1876 | else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG) | 2018 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
1877 | adsize = sizeof(long_ad); | 2019 | adsize = sizeof(long_ad); |
1878 | else | 2020 | else |
1879 | adsize = 0; | 2021 | adsize = 0; |
@@ -1900,33 +2042,39 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | |||
1900 | udf_write_aext(inode, &oepos, eloc, elen, 1); | 2042 | udf_write_aext(inode, &oepos, eloc, elen, 1); |
1901 | udf_write_aext(inode, &oepos, eloc, elen, 1); | 2043 | udf_write_aext(inode, &oepos, eloc, elen, 1); |
1902 | if (!oepos.bh) { | 2044 | if (!oepos.bh) { |
1903 | UDF_I_LENALLOC(inode) -= (adsize * 2); | 2045 | iinfo->i_lenAlloc -= (adsize * 2); |
1904 | mark_inode_dirty(inode); | 2046 | mark_inode_dirty(inode); |
1905 | } else { | 2047 | } else { |
1906 | aed = (struct allocExtDesc *)oepos.bh->b_data; | 2048 | aed = (struct allocExtDesc *)oepos.bh->b_data; |
1907 | aed->lengthAllocDescs = | 2049 | aed->lengthAllocDescs = |
1908 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - (2 * adsize)); | 2050 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - |
2051 | (2 * adsize)); | ||
1909 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 2052 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1910 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 2053 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1911 | udf_update_tag(oepos.bh->b_data, oepos.offset - (2 * adsize)); | 2054 | udf_update_tag(oepos.bh->b_data, |
2055 | oepos.offset - (2 * adsize)); | ||
1912 | else | 2056 | else |
1913 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); | 2057 | udf_update_tag(oepos.bh->b_data, |
2058 | sizeof(struct allocExtDesc)); | ||
1914 | mark_buffer_dirty_inode(oepos.bh, inode); | 2059 | mark_buffer_dirty_inode(oepos.bh, inode); |
1915 | } | 2060 | } |
1916 | } else { | 2061 | } else { |
1917 | udf_write_aext(inode, &oepos, eloc, elen, 1); | 2062 | udf_write_aext(inode, &oepos, eloc, elen, 1); |
1918 | if (!oepos.bh) { | 2063 | if (!oepos.bh) { |
1919 | UDF_I_LENALLOC(inode) -= adsize; | 2064 | iinfo->i_lenAlloc -= adsize; |
1920 | mark_inode_dirty(inode); | 2065 | mark_inode_dirty(inode); |
1921 | } else { | 2066 | } else { |
1922 | aed = (struct allocExtDesc *)oepos.bh->b_data; | 2067 | aed = (struct allocExtDesc *)oepos.bh->b_data; |
1923 | aed->lengthAllocDescs = | 2068 | aed->lengthAllocDescs = |
1924 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - adsize); | 2069 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - |
2070 | adsize); | ||
1925 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 2071 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1926 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 2072 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1927 | udf_update_tag(oepos.bh->b_data, epos.offset - adsize); | 2073 | udf_update_tag(oepos.bh->b_data, |
2074 | epos.offset - adsize); | ||
1928 | else | 2075 | else |
1929 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); | 2076 | udf_update_tag(oepos.bh->b_data, |
2077 | sizeof(struct allocExtDesc)); | ||
1930 | mark_buffer_dirty_inode(oepos.bh, inode); | 2078 | mark_buffer_dirty_inode(oepos.bh, inode); |
1931 | } | 2079 | } |
1932 | } | 2080 | } |
@@ -1937,34 +2085,38 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | |||
1937 | return (elen >> 30); | 2085 | return (elen >> 30); |
1938 | } | 2086 | } |
1939 | 2087 | ||
1940 | int8_t inode_bmap(struct inode * inode, sector_t block, | 2088 | int8_t inode_bmap(struct inode *inode, sector_t block, |
1941 | struct extent_position * pos, kernel_lb_addr * eloc, | 2089 | struct extent_position *pos, kernel_lb_addr *eloc, |
1942 | uint32_t * elen, sector_t * offset) | 2090 | uint32_t *elen, sector_t *offset) |
1943 | { | 2091 | { |
2092 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
1944 | loff_t lbcount = 0, bcount = | 2093 | loff_t lbcount = 0, bcount = |
1945 | (loff_t) block << inode->i_sb->s_blocksize_bits; | 2094 | (loff_t) block << blocksize_bits; |
1946 | int8_t etype; | 2095 | int8_t etype; |
2096 | struct udf_inode_info *iinfo; | ||
1947 | 2097 | ||
1948 | if (block < 0) { | 2098 | if (block < 0) { |
1949 | printk(KERN_ERR "udf: inode_bmap: block < 0\n"); | 2099 | printk(KERN_ERR "udf: inode_bmap: block < 0\n"); |
1950 | return -1; | 2100 | return -1; |
1951 | } | 2101 | } |
1952 | 2102 | ||
2103 | iinfo = UDF_I(inode); | ||
1953 | pos->offset = 0; | 2104 | pos->offset = 0; |
1954 | pos->block = UDF_I_LOCATION(inode); | 2105 | pos->block = iinfo->i_location; |
1955 | pos->bh = NULL; | 2106 | pos->bh = NULL; |
1956 | *elen = 0; | 2107 | *elen = 0; |
1957 | 2108 | ||
1958 | do { | 2109 | do { |
1959 | if ((etype = udf_next_aext(inode, pos, eloc, elen, 1)) == -1) { | 2110 | etype = udf_next_aext(inode, pos, eloc, elen, 1); |
1960 | *offset = (bcount - lbcount) >> inode->i_sb->s_blocksize_bits; | 2111 | if (etype == -1) { |
1961 | UDF_I_LENEXTENTS(inode) = lbcount; | 2112 | *offset = (bcount - lbcount) >> blocksize_bits; |
2113 | iinfo->i_lenExtents = lbcount; | ||
1962 | return -1; | 2114 | return -1; |
1963 | } | 2115 | } |
1964 | lbcount += *elen; | 2116 | lbcount += *elen; |
1965 | } while (lbcount <= bcount); | 2117 | } while (lbcount <= bcount); |
1966 | 2118 | ||
1967 | *offset = (bcount + *elen - lbcount) >> inode->i_sb->s_blocksize_bits; | 2119 | *offset = (bcount + *elen - lbcount) >> blocksize_bits; |
1968 | 2120 | ||
1969 | return etype; | 2121 | return etype; |
1970 | } | 2122 | } |
@@ -1979,7 +2131,8 @@ long udf_block_map(struct inode *inode, sector_t block) | |||
1979 | 2131 | ||
1980 | lock_kernel(); | 2132 | lock_kernel(); |
1981 | 2133 | ||
1982 | if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) | 2134 | if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == |
2135 | (EXT_RECORDED_ALLOCATED >> 30)) | ||
1983 | ret = udf_get_lb_pblock(inode->i_sb, eloc, offset); | 2136 | ret = udf_get_lb_pblock(inode->i_sb, eloc, offset); |
1984 | else | 2137 | else |
1985 | ret = 0; | 2138 | ret = 0; |
diff --git a/fs/udf/misc.c b/fs/udf/misc.c index 15297deb5051..a1d6da0caf71 100644 --- a/fs/udf/misc.c +++ b/fs/udf/misc.c | |||
@@ -51,18 +51,18 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
51 | uint8_t *ea = NULL, *ad = NULL; | 51 | uint8_t *ea = NULL, *ad = NULL; |
52 | int offset; | 52 | int offset; |
53 | uint16_t crclen; | 53 | uint16_t crclen; |
54 | int i; | 54 | struct udf_inode_info *iinfo = UDF_I(inode); |
55 | 55 | ||
56 | ea = UDF_I_DATA(inode); | 56 | ea = iinfo->i_ext.i_data; |
57 | if (UDF_I_LENEATTR(inode)) { | 57 | if (iinfo->i_lenEAttr) { |
58 | ad = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); | 58 | ad = iinfo->i_ext.i_data + iinfo->i_lenEAttr; |
59 | } else { | 59 | } else { |
60 | ad = ea; | 60 | ad = ea; |
61 | size += sizeof(struct extendedAttrHeaderDesc); | 61 | size += sizeof(struct extendedAttrHeaderDesc); |
62 | } | 62 | } |
63 | 63 | ||
64 | offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) - | 64 | offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) - |
65 | UDF_I_LENALLOC(inode); | 65 | iinfo->i_lenAlloc; |
66 | 66 | ||
67 | /* TODO - Check for FreeEASpace */ | 67 | /* TODO - Check for FreeEASpace */ |
68 | 68 | ||
@@ -70,69 +70,80 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
70 | struct extendedAttrHeaderDesc *eahd; | 70 | struct extendedAttrHeaderDesc *eahd; |
71 | eahd = (struct extendedAttrHeaderDesc *)ea; | 71 | eahd = (struct extendedAttrHeaderDesc *)ea; |
72 | 72 | ||
73 | if (UDF_I_LENALLOC(inode)) { | 73 | if (iinfo->i_lenAlloc) |
74 | memmove(&ad[size], ad, UDF_I_LENALLOC(inode)); | 74 | memmove(&ad[size], ad, iinfo->i_lenAlloc); |
75 | } | ||
76 | 75 | ||
77 | if (UDF_I_LENEATTR(inode)) { | 76 | if (iinfo->i_lenEAttr) { |
78 | /* check checksum/crc */ | 77 | /* check checksum/crc */ |
79 | if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD || | 78 | if (eahd->descTag.tagIdent != |
80 | le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) { | 79 | cpu_to_le16(TAG_IDENT_EAHD) || |
80 | le32_to_cpu(eahd->descTag.tagLocation) != | ||
81 | iinfo->i_location.logicalBlockNum) | ||
81 | return NULL; | 82 | return NULL; |
82 | } | ||
83 | } else { | 83 | } else { |
84 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); | ||
85 | |||
84 | size -= sizeof(struct extendedAttrHeaderDesc); | 86 | size -= sizeof(struct extendedAttrHeaderDesc); |
85 | UDF_I_LENEATTR(inode) += sizeof(struct extendedAttrHeaderDesc); | 87 | iinfo->i_lenEAttr += |
88 | sizeof(struct extendedAttrHeaderDesc); | ||
86 | eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD); | 89 | eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD); |
87 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) | 90 | if (sbi->s_udfrev >= 0x0200) |
88 | eahd->descTag.descVersion = cpu_to_le16(3); | 91 | eahd->descTag.descVersion = cpu_to_le16(3); |
89 | else | 92 | else |
90 | eahd->descTag.descVersion = cpu_to_le16(2); | 93 | eahd->descTag.descVersion = cpu_to_le16(2); |
91 | eahd->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); | 94 | eahd->descTag.tagSerialNum = |
92 | eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | 95 | cpu_to_le16(sbi->s_serial_number); |
96 | eahd->descTag.tagLocation = cpu_to_le32( | ||
97 | iinfo->i_location.logicalBlockNum); | ||
93 | eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF); | 98 | eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF); |
94 | eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF); | 99 | eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF); |
95 | } | 100 | } |
96 | 101 | ||
97 | offset = UDF_I_LENEATTR(inode); | 102 | offset = iinfo->i_lenEAttr; |
98 | if (type < 2048) { | 103 | if (type < 2048) { |
99 | if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) { | 104 | if (le32_to_cpu(eahd->appAttrLocation) < |
100 | uint32_t aal = le32_to_cpu(eahd->appAttrLocation); | 105 | iinfo->i_lenEAttr) { |
106 | uint32_t aal = | ||
107 | le32_to_cpu(eahd->appAttrLocation); | ||
101 | memmove(&ea[offset - aal + size], | 108 | memmove(&ea[offset - aal + size], |
102 | &ea[aal], offset - aal); | 109 | &ea[aal], offset - aal); |
103 | offset -= aal; | 110 | offset -= aal; |
104 | eahd->appAttrLocation = cpu_to_le32(aal + size); | 111 | eahd->appAttrLocation = |
112 | cpu_to_le32(aal + size); | ||
105 | } | 113 | } |
106 | if (le32_to_cpu(eahd->impAttrLocation) < UDF_I_LENEATTR(inode)) { | 114 | if (le32_to_cpu(eahd->impAttrLocation) < |
107 | uint32_t ial = le32_to_cpu(eahd->impAttrLocation); | 115 | iinfo->i_lenEAttr) { |
116 | uint32_t ial = | ||
117 | le32_to_cpu(eahd->impAttrLocation); | ||
108 | memmove(&ea[offset - ial + size], | 118 | memmove(&ea[offset - ial + size], |
109 | &ea[ial], offset - ial); | 119 | &ea[ial], offset - ial); |
110 | offset -= ial; | 120 | offset -= ial; |
111 | eahd->impAttrLocation = cpu_to_le32(ial + size); | 121 | eahd->impAttrLocation = |
122 | cpu_to_le32(ial + size); | ||
112 | } | 123 | } |
113 | } else if (type < 65536) { | 124 | } else if (type < 65536) { |
114 | if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) { | 125 | if (le32_to_cpu(eahd->appAttrLocation) < |
115 | uint32_t aal = le32_to_cpu(eahd->appAttrLocation); | 126 | iinfo->i_lenEAttr) { |
127 | uint32_t aal = | ||
128 | le32_to_cpu(eahd->appAttrLocation); | ||
116 | memmove(&ea[offset - aal + size], | 129 | memmove(&ea[offset - aal + size], |
117 | &ea[aal], offset - aal); | 130 | &ea[aal], offset - aal); |
118 | offset -= aal; | 131 | offset -= aal; |
119 | eahd->appAttrLocation = cpu_to_le32(aal + size); | 132 | eahd->appAttrLocation = |
133 | cpu_to_le32(aal + size); | ||
120 | } | 134 | } |
121 | } | 135 | } |
122 | /* rewrite CRC + checksum of eahd */ | 136 | /* rewrite CRC + checksum of eahd */ |
123 | crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag); | 137 | crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag); |
124 | eahd->descTag.descCRCLength = cpu_to_le16(crclen); | 138 | eahd->descTag.descCRCLength = cpu_to_le16(crclen); |
125 | eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd + | 139 | eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd + |
126 | sizeof(tag), crclen, 0)); | 140 | sizeof(tag), crclen, 0)); |
127 | eahd->descTag.tagChecksum = 0; | 141 | eahd->descTag.tagChecksum = udf_tag_checksum(&eahd->descTag); |
128 | for (i = 0; i < 16; i++) | 142 | iinfo->i_lenEAttr += size; |
129 | if (i != 4) | ||
130 | eahd->descTag.tagChecksum += ((uint8_t *)&(eahd->descTag))[i]; | ||
131 | UDF_I_LENEATTR(inode) += size; | ||
132 | return (struct genericFormat *)&ea[offset]; | 143 | return (struct genericFormat *)&ea[offset]; |
133 | } | 144 | } |
134 | if (loc & 0x02) { | 145 | if (loc & 0x02) |
135 | } | 146 | ; |
136 | 147 | ||
137 | return NULL; | 148 | return NULL; |
138 | } | 149 | } |
@@ -143,18 +154,20 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, | |||
143 | struct genericFormat *gaf; | 154 | struct genericFormat *gaf; |
144 | uint8_t *ea = NULL; | 155 | uint8_t *ea = NULL; |
145 | uint32_t offset; | 156 | uint32_t offset; |
157 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
146 | 158 | ||
147 | ea = UDF_I_DATA(inode); | 159 | ea = iinfo->i_ext.i_data; |
148 | 160 | ||
149 | if (UDF_I_LENEATTR(inode)) { | 161 | if (iinfo->i_lenEAttr) { |
150 | struct extendedAttrHeaderDesc *eahd; | 162 | struct extendedAttrHeaderDesc *eahd; |
151 | eahd = (struct extendedAttrHeaderDesc *)ea; | 163 | eahd = (struct extendedAttrHeaderDesc *)ea; |
152 | 164 | ||
153 | /* check checksum/crc */ | 165 | /* check checksum/crc */ |
154 | if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD || | 166 | if (eahd->descTag.tagIdent != |
155 | le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) { | 167 | cpu_to_le16(TAG_IDENT_EAHD) || |
168 | le32_to_cpu(eahd->descTag.tagLocation) != | ||
169 | iinfo->i_location.logicalBlockNum) | ||
156 | return NULL; | 170 | return NULL; |
157 | } | ||
158 | 171 | ||
159 | if (type < 2048) | 172 | if (type < 2048) |
160 | offset = sizeof(struct extendedAttrHeaderDesc); | 173 | offset = sizeof(struct extendedAttrHeaderDesc); |
@@ -163,9 +176,10 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, | |||
163 | else | 176 | else |
164 | offset = le32_to_cpu(eahd->appAttrLocation); | 177 | offset = le32_to_cpu(eahd->appAttrLocation); |
165 | 178 | ||
166 | while (offset < UDF_I_LENEATTR(inode)) { | 179 | while (offset < iinfo->i_lenEAttr) { |
167 | gaf = (struct genericFormat *)&ea[offset]; | 180 | gaf = (struct genericFormat *)&ea[offset]; |
168 | if (le32_to_cpu(gaf->attrType) == type && gaf->attrSubtype == subtype) | 181 | if (le32_to_cpu(gaf->attrType) == type && |
182 | gaf->attrSubtype == subtype) | ||
169 | return gaf; | 183 | return gaf; |
170 | else | 184 | else |
171 | offset += le32_to_cpu(gaf->attrLength); | 185 | offset += le32_to_cpu(gaf->attrLength); |
@@ -186,21 +200,20 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, | |||
186 | * Written, tested, and released. | 200 | * Written, tested, and released. |
187 | */ | 201 | */ |
188 | struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, | 202 | struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, |
189 | uint32_t location, uint16_t * ident) | 203 | uint32_t location, uint16_t *ident) |
190 | { | 204 | { |
191 | tag *tag_p; | 205 | tag *tag_p; |
192 | struct buffer_head *bh = NULL; | 206 | struct buffer_head *bh = NULL; |
193 | register uint8_t checksum; | 207 | struct udf_sb_info *sbi = UDF_SB(sb); |
194 | register int i; | ||
195 | 208 | ||
196 | /* Read the block */ | 209 | /* Read the block */ |
197 | if (block == 0xFFFFFFFF) | 210 | if (block == 0xFFFFFFFF) |
198 | return NULL; | 211 | return NULL; |
199 | 212 | ||
200 | bh = udf_tread(sb, block + UDF_SB_SESSION(sb)); | 213 | bh = udf_tread(sb, block + sbi->s_session); |
201 | if (!bh) { | 214 | if (!bh) { |
202 | udf_debug("block=%d, location=%d: read failed\n", | 215 | udf_debug("block=%d, location=%d: read failed\n", |
203 | block + UDF_SB_SESSION(sb), location); | 216 | block + sbi->s_session, location); |
204 | return NULL; | 217 | return NULL; |
205 | } | 218 | } |
206 | 219 | ||
@@ -210,24 +223,20 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, | |||
210 | 223 | ||
211 | if (location != le32_to_cpu(tag_p->tagLocation)) { | 224 | if (location != le32_to_cpu(tag_p->tagLocation)) { |
212 | udf_debug("location mismatch block %u, tag %u != %u\n", | 225 | udf_debug("location mismatch block %u, tag %u != %u\n", |
213 | block + UDF_SB_SESSION(sb), le32_to_cpu(tag_p->tagLocation), location); | 226 | block + sbi->s_session, |
227 | le32_to_cpu(tag_p->tagLocation), location); | ||
214 | goto error_out; | 228 | goto error_out; |
215 | } | 229 | } |
216 | 230 | ||
217 | /* Verify the tag checksum */ | 231 | /* Verify the tag checksum */ |
218 | checksum = 0U; | 232 | if (udf_tag_checksum(tag_p) != tag_p->tagChecksum) { |
219 | for (i = 0; i < 4; i++) | ||
220 | checksum += (uint8_t)(bh->b_data[i]); | ||
221 | for (i = 5; i < 16; i++) | ||
222 | checksum += (uint8_t)(bh->b_data[i]); | ||
223 | if (checksum != tag_p->tagChecksum) { | ||
224 | printk(KERN_ERR "udf: tag checksum failed block %d\n", block); | 233 | printk(KERN_ERR "udf: tag checksum failed block %d\n", block); |
225 | goto error_out; | 234 | goto error_out; |
226 | } | 235 | } |
227 | 236 | ||
228 | /* Verify the tag version */ | 237 | /* Verify the tag version */ |
229 | if (le16_to_cpu(tag_p->descVersion) != 0x0002U && | 238 | if (tag_p->descVersion != cpu_to_le16(0x0002U) && |
230 | le16_to_cpu(tag_p->descVersion) != 0x0003U) { | 239 | tag_p->descVersion != cpu_to_le16(0x0003U)) { |
231 | udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n", | 240 | udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n", |
232 | le16_to_cpu(tag_p->descVersion), block); | 241 | le16_to_cpu(tag_p->descVersion), block); |
233 | goto error_out; | 242 | goto error_out; |
@@ -236,11 +245,11 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, | |||
236 | /* Verify the descriptor CRC */ | 245 | /* Verify the descriptor CRC */ |
237 | if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize || | 246 | if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize || |
238 | le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag), | 247 | le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag), |
239 | le16_to_cpu(tag_p->descCRCLength), 0)) { | 248 | le16_to_cpu(tag_p->descCRCLength), 0)) |
240 | return bh; | 249 | return bh; |
241 | } | 250 | |
242 | udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", | 251 | udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", |
243 | block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC), | 252 | block + sbi->s_session, le16_to_cpu(tag_p->descCRC), |
244 | le16_to_cpu(tag_p->descCRCLength)); | 253 | le16_to_cpu(tag_p->descCRCLength)); |
245 | 254 | ||
246 | error_out: | 255 | error_out: |
@@ -249,7 +258,7 @@ error_out: | |||
249 | } | 258 | } |
250 | 259 | ||
251 | struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc, | 260 | struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc, |
252 | uint32_t offset, uint16_t * ident) | 261 | uint32_t offset, uint16_t *ident) |
253 | { | 262 | { |
254 | return udf_read_tagged(sb, udf_get_lb_pblock(sb, loc, offset), | 263 | return udf_read_tagged(sb, udf_get_lb_pblock(sb, loc, offset), |
255 | loc.logicalBlockNum + offset, ident); | 264 | loc.logicalBlockNum + offset, ident); |
@@ -258,17 +267,11 @@ struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc, | |||
258 | void udf_update_tag(char *data, int length) | 267 | void udf_update_tag(char *data, int length) |
259 | { | 268 | { |
260 | tag *tptr = (tag *)data; | 269 | tag *tptr = (tag *)data; |
261 | int i; | ||
262 | |||
263 | length -= sizeof(tag); | 270 | length -= sizeof(tag); |
264 | 271 | ||
265 | tptr->tagChecksum = 0; | ||
266 | tptr->descCRCLength = cpu_to_le16(length); | 272 | tptr->descCRCLength = cpu_to_le16(length); |
267 | tptr->descCRC = cpu_to_le16(udf_crc(data + sizeof(tag), length, 0)); | 273 | tptr->descCRC = cpu_to_le16(udf_crc(data + sizeof(tag), length, 0)); |
268 | 274 | tptr->tagChecksum = udf_tag_checksum(tptr); | |
269 | for (i = 0; i < 16; i++) | ||
270 | if (i != 4) | ||
271 | tptr->tagChecksum += (uint8_t)(data[i]); | ||
272 | } | 275 | } |
273 | 276 | ||
274 | void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum, | 277 | void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum, |
@@ -281,3 +284,14 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum, | |||
281 | tptr->tagLocation = cpu_to_le32(loc); | 284 | tptr->tagLocation = cpu_to_le32(loc); |
282 | udf_update_tag(data, length); | 285 | udf_update_tag(data, length); |
283 | } | 286 | } |
287 | |||
288 | u8 udf_tag_checksum(const tag *t) | ||
289 | { | ||
290 | u8 *data = (u8 *)t; | ||
291 | u8 checksum = 0; | ||
292 | int i; | ||
293 | for (i = 0; i < sizeof(tag); ++i) | ||
294 | if (i != 4) /* position of checksum */ | ||
295 | checksum += data[i]; | ||
296 | return checksum; | ||
297 | } | ||
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index bec96a6b3343..112a5fb0b27b 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -43,12 +43,10 @@ static inline int udf_match(int len1, const char *name1, int len2, | |||
43 | 43 | ||
44 | int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, | 44 | int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, |
45 | struct fileIdentDesc *sfi, struct udf_fileident_bh *fibh, | 45 | struct fileIdentDesc *sfi, struct udf_fileident_bh *fibh, |
46 | uint8_t * impuse, uint8_t * fileident) | 46 | uint8_t *impuse, uint8_t *fileident) |
47 | { | 47 | { |
48 | uint16_t crclen = fibh->eoffset - fibh->soffset - sizeof(tag); | 48 | uint16_t crclen = fibh->eoffset - fibh->soffset - sizeof(tag); |
49 | uint16_t crc; | 49 | uint16_t crc; |
50 | uint8_t checksum = 0; | ||
51 | int i; | ||
52 | int offset; | 50 | int offset; |
53 | uint16_t liu = le16_to_cpu(cfi->lengthOfImpUse); | 51 | uint16_t liu = le16_to_cpu(cfi->lengthOfImpUse); |
54 | uint8_t lfi = cfi->lengthFileIdent; | 52 | uint8_t lfi = cfi->lengthFileIdent; |
@@ -56,7 +54,7 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, | |||
56 | sizeof(struct fileIdentDesc); | 54 | sizeof(struct fileIdentDesc); |
57 | int adinicb = 0; | 55 | int adinicb = 0; |
58 | 56 | ||
59 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) | 57 | if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
60 | adinicb = 1; | 58 | adinicb = 1; |
61 | 59 | ||
62 | offset = fibh->soffset + sizeof(struct fileIdentDesc); | 60 | offset = fibh->soffset + sizeof(struct fileIdentDesc); |
@@ -68,7 +66,8 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, | |||
68 | memcpy(fibh->ebh->b_data + offset, impuse, liu); | 66 | memcpy(fibh->ebh->b_data + offset, impuse, liu); |
69 | } else { | 67 | } else { |
70 | memcpy((uint8_t *)sfi->impUse, impuse, -offset); | 68 | memcpy((uint8_t *)sfi->impUse, impuse, -offset); |
71 | memcpy(fibh->ebh->b_data, impuse - offset, liu + offset); | 69 | memcpy(fibh->ebh->b_data, impuse - offset, |
70 | liu + offset); | ||
72 | } | 71 | } |
73 | } | 72 | } |
74 | 73 | ||
@@ -80,8 +79,10 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, | |||
80 | } else if (offset >= 0) { | 79 | } else if (offset >= 0) { |
81 | memcpy(fibh->ebh->b_data + offset, fileident, lfi); | 80 | memcpy(fibh->ebh->b_data + offset, fileident, lfi); |
82 | } else { | 81 | } else { |
83 | memcpy((uint8_t *)sfi->fileIdent + liu, fileident, -offset); | 82 | memcpy((uint8_t *)sfi->fileIdent + liu, fileident, |
84 | memcpy(fibh->ebh->b_data, fileident - offset, lfi + offset); | 83 | -offset); |
84 | memcpy(fibh->ebh->b_data, fileident - offset, | ||
85 | lfi + offset); | ||
85 | } | 86 | } |
86 | } | 87 | } |
87 | 88 | ||
@@ -101,27 +102,29 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, | |||
101 | 102 | ||
102 | if (fibh->sbh == fibh->ebh) { | 103 | if (fibh->sbh == fibh->ebh) { |
103 | crc = udf_crc((uint8_t *)sfi->impUse, | 104 | crc = udf_crc((uint8_t *)sfi->impUse, |
104 | crclen + sizeof(tag) - sizeof(struct fileIdentDesc), crc); | 105 | crclen + sizeof(tag) - |
106 | sizeof(struct fileIdentDesc), crc); | ||
105 | } else if (sizeof(struct fileIdentDesc) >= -fibh->soffset) { | 107 | } else if (sizeof(struct fileIdentDesc) >= -fibh->soffset) { |
106 | crc = udf_crc(fibh->ebh->b_data + sizeof(struct fileIdentDesc) + fibh->soffset, | 108 | crc = udf_crc(fibh->ebh->b_data + |
107 | crclen + sizeof(tag) - sizeof(struct fileIdentDesc), crc); | 109 | sizeof(struct fileIdentDesc) + |
110 | fibh->soffset, | ||
111 | crclen + sizeof(tag) - | ||
112 | sizeof(struct fileIdentDesc), | ||
113 | crc); | ||
108 | } else { | 114 | } else { |
109 | crc = udf_crc((uint8_t *)sfi->impUse, | 115 | crc = udf_crc((uint8_t *)sfi->impUse, |
110 | -fibh->soffset - sizeof(struct fileIdentDesc), crc); | 116 | -fibh->soffset - sizeof(struct fileIdentDesc), |
117 | crc); | ||
111 | crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc); | 118 | crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc); |
112 | } | 119 | } |
113 | 120 | ||
114 | cfi->descTag.descCRC = cpu_to_le16(crc); | 121 | cfi->descTag.descCRC = cpu_to_le16(crc); |
115 | cfi->descTag.descCRCLength = cpu_to_le16(crclen); | 122 | cfi->descTag.descCRCLength = cpu_to_le16(crclen); |
123 | cfi->descTag.tagChecksum = udf_tag_checksum(&cfi->descTag); | ||
116 | 124 | ||
117 | for (i = 0; i < 16; i++) { | ||
118 | if (i != 4) | ||
119 | checksum += ((uint8_t *)&cfi->descTag)[i]; | ||
120 | } | ||
121 | |||
122 | cfi->descTag.tagChecksum = checksum; | ||
123 | if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) { | 125 | if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) { |
124 | memcpy((uint8_t *)sfi, (uint8_t *)cfi, sizeof(struct fileIdentDesc)); | 126 | memcpy((uint8_t *)sfi, (uint8_t *)cfi, |
127 | sizeof(struct fileIdentDesc)); | ||
125 | } else { | 128 | } else { |
126 | memcpy((uint8_t *)sfi, (uint8_t *)cfi, -fibh->soffset); | 129 | memcpy((uint8_t *)sfi, (uint8_t *)cfi, -fibh->soffset); |
127 | memcpy(fibh->ebh->b_data, (uint8_t *)cfi - fibh->soffset, | 130 | memcpy(fibh->ebh->b_data, (uint8_t *)cfi - fibh->soffset, |
@@ -155,26 +158,28 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, | |||
155 | uint32_t elen; | 158 | uint32_t elen; |
156 | sector_t offset; | 159 | sector_t offset; |
157 | struct extent_position epos = {}; | 160 | struct extent_position epos = {}; |
161 | struct udf_inode_info *dinfo = UDF_I(dir); | ||
158 | 162 | ||
159 | size = (udf_ext0_offset(dir) + dir->i_size) >> 2; | 163 | size = udf_ext0_offset(dir) + dir->i_size; |
160 | f_pos = (udf_ext0_offset(dir) >> 2); | 164 | f_pos = udf_ext0_offset(dir); |
161 | 165 | ||
162 | fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | 166 | fibh->soffset = fibh->eoffset = f_pos & (dir->i_sb->s_blocksize - 1); |
163 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 167 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
164 | fibh->sbh = fibh->ebh = NULL; | 168 | fibh->sbh = fibh->ebh = NULL; |
165 | } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), | 169 | else if (inode_bmap(dir, f_pos >> dir->i_sb->s_blocksize_bits, |
166 | &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { | 170 | &epos, &eloc, &elen, &offset) == |
171 | (EXT_RECORDED_ALLOCATED >> 30)) { | ||
167 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); | 172 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
168 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { | 173 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
169 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) | 174 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
170 | epos.offset -= sizeof(short_ad); | 175 | epos.offset -= sizeof(short_ad); |
171 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) | 176 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
172 | epos.offset -= sizeof(long_ad); | 177 | epos.offset -= sizeof(long_ad); |
173 | } else { | 178 | } else |
174 | offset = 0; | 179 | offset = 0; |
175 | } | ||
176 | 180 | ||
177 | if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { | 181 | fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block); |
182 | if (!fibh->sbh) { | ||
178 | brelse(epos.bh); | 183 | brelse(epos.bh); |
179 | return NULL; | 184 | return NULL; |
180 | } | 185 | } |
@@ -183,7 +188,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, | |||
183 | return NULL; | 188 | return NULL; |
184 | } | 189 | } |
185 | 190 | ||
186 | while ((f_pos < size)) { | 191 | while (f_pos < size) { |
187 | fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc, | 192 | fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc, |
188 | &elen, &offset); | 193 | &elen, &offset); |
189 | if (!fi) { | 194 | if (!fi) { |
@@ -202,14 +207,18 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, | |||
202 | } else { | 207 | } else { |
203 | int poffset; /* Unpaded ending offset */ | 208 | int poffset; /* Unpaded ending offset */ |
204 | 209 | ||
205 | poffset = fibh->soffset + sizeof(struct fileIdentDesc) + liu + lfi; | 210 | poffset = fibh->soffset + sizeof(struct fileIdentDesc) + |
211 | liu + lfi; | ||
206 | 212 | ||
207 | if (poffset >= lfi) { | 213 | if (poffset >= lfi) |
208 | nameptr = (uint8_t *)(fibh->ebh->b_data + poffset - lfi); | 214 | nameptr = (uint8_t *)(fibh->ebh->b_data + |
209 | } else { | 215 | poffset - lfi); |
216 | else { | ||
210 | nameptr = fname; | 217 | nameptr = fname; |
211 | memcpy(nameptr, fi->fileIdent + liu, lfi - poffset); | 218 | memcpy(nameptr, fi->fileIdent + liu, |
212 | memcpy(nameptr + lfi - poffset, fibh->ebh->b_data, poffset); | 219 | lfi - poffset); |
220 | memcpy(nameptr + lfi - poffset, | ||
221 | fibh->ebh->b_data, poffset); | ||
213 | } | 222 | } |
214 | } | 223 | } |
215 | 224 | ||
@@ -226,11 +235,11 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, | |||
226 | if (!lfi) | 235 | if (!lfi) |
227 | continue; | 236 | continue; |
228 | 237 | ||
229 | if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi))) { | 238 | flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi); |
230 | if (udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) { | 239 | if (flen && udf_match(flen, fname, dentry->d_name.len, |
231 | brelse(epos.bh); | 240 | dentry->d_name.name)) { |
232 | return fi; | 241 | brelse(epos.bh); |
233 | } | 242 | return fi; |
234 | } | 243 | } |
235 | } | 244 | } |
236 | 245 | ||
@@ -291,16 +300,16 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, | |||
291 | if (!strncmp(dentry->d_name.name, ".B=", 3)) { | 300 | if (!strncmp(dentry->d_name.name, ".B=", 3)) { |
292 | kernel_lb_addr lb = { | 301 | kernel_lb_addr lb = { |
293 | .logicalBlockNum = 0, | 302 | .logicalBlockNum = 0, |
294 | .partitionReferenceNum = simple_strtoul(dentry->d_name.name + 3, | 303 | .partitionReferenceNum = |
295 | NULL, 0), | 304 | simple_strtoul(dentry->d_name.name + 3, |
305 | NULL, 0), | ||
296 | }; | 306 | }; |
297 | inode = udf_iget(dir->i_sb, lb); | 307 | inode = udf_iget(dir->i_sb, lb); |
298 | if (!inode) { | 308 | if (!inode) { |
299 | unlock_kernel(); | 309 | unlock_kernel(); |
300 | return ERR_PTR(-EACCES); | 310 | return ERR_PTR(-EACCES); |
301 | } | 311 | } |
302 | } | 312 | } else |
303 | else | ||
304 | #endif /* UDF_RECOVERY */ | 313 | #endif /* UDF_RECOVERY */ |
305 | 314 | ||
306 | if (udf_find_entry(dir, dentry, &fibh, &cfi)) { | 315 | if (udf_find_entry(dir, dentry, &fibh, &cfi)) { |
@@ -325,14 +334,14 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
325 | struct udf_fileident_bh *fibh, | 334 | struct udf_fileident_bh *fibh, |
326 | struct fileIdentDesc *cfi, int *err) | 335 | struct fileIdentDesc *cfi, int *err) |
327 | { | 336 | { |
328 | struct super_block *sb; | 337 | struct super_block *sb = dir->i_sb; |
329 | struct fileIdentDesc *fi = NULL; | 338 | struct fileIdentDesc *fi = NULL; |
330 | char name[UDF_NAME_LEN], fname[UDF_NAME_LEN]; | 339 | char name[UDF_NAME_LEN], fname[UDF_NAME_LEN]; |
331 | int namelen; | 340 | int namelen; |
332 | loff_t f_pos; | 341 | loff_t f_pos; |
333 | int flen; | 342 | int flen; |
334 | char *nameptr; | 343 | char *nameptr; |
335 | loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2; | 344 | loff_t size = udf_ext0_offset(dir) + dir->i_size; |
336 | int nfidlen; | 345 | int nfidlen; |
337 | uint8_t lfi; | 346 | uint8_t lfi; |
338 | uint16_t liu; | 347 | uint16_t liu; |
@@ -341,16 +350,16 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
341 | uint32_t elen; | 350 | uint32_t elen; |
342 | sector_t offset; | 351 | sector_t offset; |
343 | struct extent_position epos = {}; | 352 | struct extent_position epos = {}; |
344 | 353 | struct udf_inode_info *dinfo; | |
345 | sb = dir->i_sb; | ||
346 | 354 | ||
347 | if (dentry) { | 355 | if (dentry) { |
348 | if (!dentry->d_name.len) { | 356 | if (!dentry->d_name.len) { |
349 | *err = -EINVAL; | 357 | *err = -EINVAL; |
350 | return NULL; | 358 | return NULL; |
351 | } | 359 | } |
352 | if (!(namelen = udf_put_filename(sb, dentry->d_name.name, name, | 360 | namelen = udf_put_filename(sb, dentry->d_name.name, name, |
353 | dentry->d_name.len))) { | 361 | dentry->d_name.len); |
362 | if (!namelen) { | ||
354 | *err = -ENAMETOOLONG; | 363 | *err = -ENAMETOOLONG; |
355 | return NULL; | 364 | return NULL; |
356 | } | 365 | } |
@@ -360,39 +369,40 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
360 | 369 | ||
361 | nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3; | 370 | nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3; |
362 | 371 | ||
363 | f_pos = (udf_ext0_offset(dir) >> 2); | 372 | f_pos = udf_ext0_offset(dir); |
364 | 373 | ||
365 | fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | 374 | fibh->soffset = fibh->eoffset = f_pos & (dir->i_sb->s_blocksize - 1); |
366 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 375 | dinfo = UDF_I(dir); |
376 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | ||
367 | fibh->sbh = fibh->ebh = NULL; | 377 | fibh->sbh = fibh->ebh = NULL; |
368 | } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), | 378 | else if (inode_bmap(dir, f_pos >> dir->i_sb->s_blocksize_bits, |
369 | &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { | 379 | &epos, &eloc, &elen, &offset) == |
380 | (EXT_RECORDED_ALLOCATED >> 30)) { | ||
370 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); | 381 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
371 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { | 382 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
372 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) | 383 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
373 | epos.offset -= sizeof(short_ad); | 384 | epos.offset -= sizeof(short_ad); |
374 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) | 385 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
375 | epos.offset -= sizeof(long_ad); | 386 | epos.offset -= sizeof(long_ad); |
376 | } else { | 387 | } else |
377 | offset = 0; | 388 | offset = 0; |
378 | } | ||
379 | 389 | ||
380 | if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { | 390 | fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block); |
391 | if (!fibh->sbh) { | ||
381 | brelse(epos.bh); | 392 | brelse(epos.bh); |
382 | *err = -EIO; | 393 | *err = -EIO; |
383 | return NULL; | 394 | return NULL; |
384 | } | 395 | } |
385 | 396 | ||
386 | block = UDF_I_LOCATION(dir).logicalBlockNum; | 397 | block = dinfo->i_location.logicalBlockNum; |
387 | |||
388 | } else { | 398 | } else { |
389 | block = udf_get_lb_pblock(dir->i_sb, UDF_I_LOCATION(dir), 0); | 399 | block = udf_get_lb_pblock(dir->i_sb, dinfo->i_location, 0); |
390 | fibh->sbh = fibh->ebh = NULL; | 400 | fibh->sbh = fibh->ebh = NULL; |
391 | fibh->soffset = fibh->eoffset = sb->s_blocksize; | 401 | fibh->soffset = fibh->eoffset = sb->s_blocksize; |
392 | goto add; | 402 | goto add; |
393 | } | 403 | } |
394 | 404 | ||
395 | while ((f_pos < size)) { | 405 | while (f_pos < size) { |
396 | fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc, | 406 | fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc, |
397 | &elen, &offset); | 407 | &elen, &offset); |
398 | 408 | ||
@@ -408,33 +418,39 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
408 | liu = le16_to_cpu(cfi->lengthOfImpUse); | 418 | liu = le16_to_cpu(cfi->lengthOfImpUse); |
409 | lfi = cfi->lengthFileIdent; | 419 | lfi = cfi->lengthFileIdent; |
410 | 420 | ||
411 | if (fibh->sbh == fibh->ebh) { | 421 | if (fibh->sbh == fibh->ebh) |
412 | nameptr = fi->fileIdent + liu; | 422 | nameptr = fi->fileIdent + liu; |
413 | } else { | 423 | else { |
414 | int poffset; /* Unpaded ending offset */ | 424 | int poffset; /* Unpaded ending offset */ |
415 | 425 | ||
416 | poffset = fibh->soffset + sizeof(struct fileIdentDesc) + liu + lfi; | 426 | poffset = fibh->soffset + sizeof(struct fileIdentDesc) + |
427 | liu + lfi; | ||
417 | 428 | ||
418 | if (poffset >= lfi) { | 429 | if (poffset >= lfi) |
419 | nameptr = (char *)(fibh->ebh->b_data + poffset - lfi); | 430 | nameptr = (char *)(fibh->ebh->b_data + |
420 | } else { | 431 | poffset - lfi); |
432 | else { | ||
421 | nameptr = fname; | 433 | nameptr = fname; |
422 | memcpy(nameptr, fi->fileIdent + liu, lfi - poffset); | 434 | memcpy(nameptr, fi->fileIdent + liu, |
423 | memcpy(nameptr + lfi - poffset, fibh->ebh->b_data, poffset); | 435 | lfi - poffset); |
436 | memcpy(nameptr + lfi - poffset, | ||
437 | fibh->ebh->b_data, poffset); | ||
424 | } | 438 | } |
425 | } | 439 | } |
426 | 440 | ||
427 | if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { | 441 | if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { |
428 | if (((sizeof(struct fileIdentDesc) + liu + lfi + 3) & ~3) == nfidlen) { | 442 | if (((sizeof(struct fileIdentDesc) + |
443 | liu + lfi + 3) & ~3) == nfidlen) { | ||
429 | brelse(epos.bh); | 444 | brelse(epos.bh); |
430 | cfi->descTag.tagSerialNum = cpu_to_le16(1); | 445 | cfi->descTag.tagSerialNum = cpu_to_le16(1); |
431 | cfi->fileVersionNum = cpu_to_le16(1); | 446 | cfi->fileVersionNum = cpu_to_le16(1); |
432 | cfi->fileCharacteristics = 0; | 447 | cfi->fileCharacteristics = 0; |
433 | cfi->lengthFileIdent = namelen; | 448 | cfi->lengthFileIdent = namelen; |
434 | cfi->lengthOfImpUse = cpu_to_le16(0); | 449 | cfi->lengthOfImpUse = cpu_to_le16(0); |
435 | if (!udf_write_fi(dir, cfi, fi, fibh, NULL, name)) { | 450 | if (!udf_write_fi(dir, cfi, fi, fibh, NULL, |
451 | name)) | ||
436 | return fi; | 452 | return fi; |
437 | } else { | 453 | else { |
438 | *err = -EIO; | 454 | *err = -EIO; |
439 | return NULL; | 455 | return NULL; |
440 | } | 456 | } |
@@ -444,8 +460,9 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
444 | if (!lfi || !dentry) | 460 | if (!lfi || !dentry) |
445 | continue; | 461 | continue; |
446 | 462 | ||
447 | if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi)) && | 463 | flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi); |
448 | udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) { | 464 | if (flen && udf_match(flen, fname, dentry->d_name.len, |
465 | dentry->d_name.name)) { | ||
449 | if (fibh->sbh != fibh->ebh) | 466 | if (fibh->sbh != fibh->ebh) |
450 | brelse(fibh->ebh); | 467 | brelse(fibh->ebh); |
451 | brelse(fibh->sbh); | 468 | brelse(fibh->sbh); |
@@ -456,29 +473,34 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
456 | } | 473 | } |
457 | 474 | ||
458 | add: | 475 | add: |
476 | if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { | ||
477 | elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1); | ||
478 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | ||
479 | epos.offset -= sizeof(short_ad); | ||
480 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) | ||
481 | epos.offset -= sizeof(long_ad); | ||
482 | udf_write_aext(dir, &epos, eloc, elen, 1); | ||
483 | } | ||
459 | f_pos += nfidlen; | 484 | f_pos += nfidlen; |
460 | 485 | ||
461 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB && | 486 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB && |
462 | sb->s_blocksize - fibh->eoffset < nfidlen) { | 487 | sb->s_blocksize - fibh->eoffset < nfidlen) { |
463 | brelse(epos.bh); | 488 | brelse(epos.bh); |
464 | epos.bh = NULL; | 489 | epos.bh = NULL; |
465 | fibh->soffset -= udf_ext0_offset(dir); | 490 | fibh->soffset -= udf_ext0_offset(dir); |
466 | fibh->eoffset -= udf_ext0_offset(dir); | 491 | fibh->eoffset -= udf_ext0_offset(dir); |
467 | f_pos -= (udf_ext0_offset(dir) >> 2); | 492 | f_pos -= udf_ext0_offset(dir); |
468 | if (fibh->sbh != fibh->ebh) | 493 | if (fibh->sbh != fibh->ebh) |
469 | brelse(fibh->ebh); | 494 | brelse(fibh->ebh); |
470 | brelse(fibh->sbh); | 495 | brelse(fibh->sbh); |
471 | if (!(fibh->sbh = fibh->ebh = udf_expand_dir_adinicb(dir, &block, err))) | 496 | fibh->sbh = fibh->ebh = |
497 | udf_expand_dir_adinicb(dir, &block, err); | ||
498 | if (!fibh->sbh) | ||
472 | return NULL; | 499 | return NULL; |
473 | epos.block = UDF_I_LOCATION(dir); | 500 | epos.block = dinfo->i_location; |
474 | eloc.logicalBlockNum = block; | ||
475 | eloc.partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum; | ||
476 | elen = dir->i_sb->s_blocksize; | ||
477 | epos.offset = udf_file_entry_alloc_offset(dir); | 501 | epos.offset = udf_file_entry_alloc_offset(dir); |
478 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) | 502 | /* Load extent udf_expand_dir_adinicb() has created */ |
479 | epos.offset += sizeof(short_ad); | 503 | udf_current_aext(dir, &epos, &eloc, &elen, 1); |
480 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) | ||
481 | epos.offset += sizeof(long_ad); | ||
482 | } | 504 | } |
483 | 505 | ||
484 | if (sb->s_blocksize - fibh->eoffset >= nfidlen) { | 506 | if (sb->s_blocksize - fibh->eoffset >= nfidlen) { |
@@ -489,15 +511,19 @@ add: | |||
489 | fibh->sbh = fibh->ebh; | 511 | fibh->sbh = fibh->ebh; |
490 | } | 512 | } |
491 | 513 | ||
492 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 514 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
493 | block = UDF_I_LOCATION(dir).logicalBlockNum; | 515 | block = dinfo->i_location.logicalBlockNum; |
494 | fi = (struct fileIdentDesc *)(UDF_I_DATA(dir) + fibh->soffset - | 516 | fi = (struct fileIdentDesc *) |
495 | udf_ext0_offset(dir) + | 517 | (dinfo->i_ext.i_data + |
496 | UDF_I_LENEATTR(dir)); | 518 | fibh->soffset - |
519 | udf_ext0_offset(dir) + | ||
520 | dinfo->i_lenEAttr); | ||
497 | } else { | 521 | } else { |
498 | block = eloc.logicalBlockNum + ((elen - 1) >> | 522 | block = eloc.logicalBlockNum + |
499 | dir->i_sb->s_blocksize_bits); | 523 | ((elen - 1) >> |
500 | fi = (struct fileIdentDesc *)(fibh->sbh->b_data + fibh->soffset); | 524 | dir->i_sb->s_blocksize_bits); |
525 | fi = (struct fileIdentDesc *) | ||
526 | (fibh->sbh->b_data + fibh->soffset); | ||
501 | } | 527 | } |
502 | } else { | 528 | } else { |
503 | fibh->soffset = fibh->eoffset - sb->s_blocksize; | 529 | fibh->soffset = fibh->eoffset - sb->s_blocksize; |
@@ -509,7 +535,8 @@ add: | |||
509 | 535 | ||
510 | block = eloc.logicalBlockNum + ((elen - 1) >> | 536 | block = eloc.logicalBlockNum + ((elen - 1) >> |
511 | dir->i_sb->s_blocksize_bits); | 537 | dir->i_sb->s_blocksize_bits); |
512 | fibh->ebh = udf_bread(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 1, err); | 538 | fibh->ebh = udf_bread(dir, |
539 | f_pos >> dir->i_sb->s_blocksize_bits, 1, err); | ||
513 | if (!fibh->ebh) { | 540 | if (!fibh->ebh) { |
514 | brelse(epos.bh); | 541 | brelse(epos.bh); |
515 | brelse(fibh->sbh); | 542 | brelse(fibh->sbh); |
@@ -521,32 +548,34 @@ add: | |||
521 | (EXT_RECORDED_ALLOCATED >> 30)) { | 548 | (EXT_RECORDED_ALLOCATED >> 30)) { |
522 | block = eloc.logicalBlockNum + ((elen - 1) >> | 549 | block = eloc.logicalBlockNum + ((elen - 1) >> |
523 | dir->i_sb->s_blocksize_bits); | 550 | dir->i_sb->s_blocksize_bits); |
524 | } else { | 551 | } else |
525 | block++; | 552 | block++; |
526 | } | ||
527 | 553 | ||
528 | brelse(fibh->sbh); | 554 | brelse(fibh->sbh); |
529 | fibh->sbh = fibh->ebh; | 555 | fibh->sbh = fibh->ebh; |
530 | fi = (struct fileIdentDesc *)(fibh->sbh->b_data); | 556 | fi = (struct fileIdentDesc *)(fibh->sbh->b_data); |
531 | } else { | 557 | } else { |
532 | fi = (struct fileIdentDesc *) | 558 | fi = (struct fileIdentDesc *) |
533 | (fibh->sbh->b_data + sb->s_blocksize + fibh->soffset); | 559 | (fibh->sbh->b_data + sb->s_blocksize + |
560 | fibh->soffset); | ||
534 | } | 561 | } |
535 | } | 562 | } |
536 | 563 | ||
537 | memset(cfi, 0, sizeof(struct fileIdentDesc)); | 564 | memset(cfi, 0, sizeof(struct fileIdentDesc)); |
538 | if (UDF_SB_UDFREV(sb) >= 0x0200) | 565 | if (UDF_SB(sb)->s_udfrev >= 0x0200) |
539 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, sizeof(tag)); | 566 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, |
567 | sizeof(tag)); | ||
540 | else | 568 | else |
541 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, sizeof(tag)); | 569 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, |
570 | sizeof(tag)); | ||
542 | cfi->fileVersionNum = cpu_to_le16(1); | 571 | cfi->fileVersionNum = cpu_to_le16(1); |
543 | cfi->lengthFileIdent = namelen; | 572 | cfi->lengthFileIdent = namelen; |
544 | cfi->lengthOfImpUse = cpu_to_le16(0); | 573 | cfi->lengthOfImpUse = cpu_to_le16(0); |
545 | if (!udf_write_fi(dir, cfi, fi, fibh, NULL, name)) { | 574 | if (!udf_write_fi(dir, cfi, fi, fibh, NULL, name)) { |
546 | brelse(epos.bh); | 575 | brelse(epos.bh); |
547 | dir->i_size += nfidlen; | 576 | dir->i_size += nfidlen; |
548 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) | 577 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
549 | UDF_I_LENALLOC(dir) += nfidlen; | 578 | dinfo->i_lenAlloc += nfidlen; |
550 | mark_inode_dirty(dir); | 579 | mark_inode_dirty(dir); |
551 | return fi; | 580 | return fi; |
552 | } else { | 581 | } else { |
@@ -578,6 +607,7 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, | |||
578 | struct inode *inode; | 607 | struct inode *inode; |
579 | struct fileIdentDesc cfi, *fi; | 608 | struct fileIdentDesc cfi, *fi; |
580 | int err; | 609 | int err; |
610 | struct udf_inode_info *iinfo; | ||
581 | 611 | ||
582 | lock_kernel(); | 612 | lock_kernel(); |
583 | inode = udf_new_inode(dir, mode, &err); | 613 | inode = udf_new_inode(dir, mode, &err); |
@@ -586,7 +616,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, | |||
586 | return err; | 616 | return err; |
587 | } | 617 | } |
588 | 618 | ||
589 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) | 619 | iinfo = UDF_I(inode); |
620 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | ||
590 | inode->i_data.a_ops = &udf_adinicb_aops; | 621 | inode->i_data.a_ops = &udf_adinicb_aops; |
591 | else | 622 | else |
592 | inode->i_data.a_ops = &udf_aops; | 623 | inode->i_data.a_ops = &udf_aops; |
@@ -595,7 +626,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, | |||
595 | inode->i_mode = mode; | 626 | inode->i_mode = mode; |
596 | mark_inode_dirty(inode); | 627 | mark_inode_dirty(inode); |
597 | 628 | ||
598 | if (!(fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err))) { | 629 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
630 | if (!fi) { | ||
599 | inode->i_nlink--; | 631 | inode->i_nlink--; |
600 | mark_inode_dirty(inode); | 632 | mark_inode_dirty(inode); |
601 | iput(inode); | 633 | iput(inode); |
@@ -603,13 +635,12 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, | |||
603 | return err; | 635 | return err; |
604 | } | 636 | } |
605 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 637 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
606 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); | 638 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
607 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 639 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
608 | cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); | 640 | cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL); |
609 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 641 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
610 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 642 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
611 | mark_inode_dirty(dir); | 643 | mark_inode_dirty(dir); |
612 | } | ||
613 | if (fibh.sbh != fibh.ebh) | 644 | if (fibh.sbh != fibh.ebh) |
614 | brelse(fibh.ebh); | 645 | brelse(fibh.ebh); |
615 | brelse(fibh.sbh); | 646 | brelse(fibh.sbh); |
@@ -626,6 +657,7 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, | |||
626 | struct udf_fileident_bh fibh; | 657 | struct udf_fileident_bh fibh; |
627 | struct fileIdentDesc cfi, *fi; | 658 | struct fileIdentDesc cfi, *fi; |
628 | int err; | 659 | int err; |
660 | struct udf_inode_info *iinfo; | ||
629 | 661 | ||
630 | if (!old_valid_dev(rdev)) | 662 | if (!old_valid_dev(rdev)) |
631 | return -EINVAL; | 663 | return -EINVAL; |
@@ -636,9 +668,11 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, | |||
636 | if (!inode) | 668 | if (!inode) |
637 | goto out; | 669 | goto out; |
638 | 670 | ||
671 | iinfo = UDF_I(inode); | ||
639 | inode->i_uid = current->fsuid; | 672 | inode->i_uid = current->fsuid; |
640 | init_special_inode(inode, mode, rdev); | 673 | init_special_inode(inode, mode, rdev); |
641 | if (!(fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err))) { | 674 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
675 | if (!fi) { | ||
642 | inode->i_nlink--; | 676 | inode->i_nlink--; |
643 | mark_inode_dirty(inode); | 677 | mark_inode_dirty(inode); |
644 | iput(inode); | 678 | iput(inode); |
@@ -646,13 +680,12 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, | |||
646 | return err; | 680 | return err; |
647 | } | 681 | } |
648 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 682 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
649 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); | 683 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
650 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 684 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
651 | cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); | 685 | cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL); |
652 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 686 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
653 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 687 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
654 | mark_inode_dirty(dir); | 688 | mark_inode_dirty(dir); |
655 | } | ||
656 | mark_inode_dirty(inode); | 689 | mark_inode_dirty(inode); |
657 | 690 | ||
658 | if (fibh.sbh != fibh.ebh) | 691 | if (fibh.sbh != fibh.ebh) |
@@ -672,6 +705,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
672 | struct udf_fileident_bh fibh; | 705 | struct udf_fileident_bh fibh; |
673 | struct fileIdentDesc cfi, *fi; | 706 | struct fileIdentDesc cfi, *fi; |
674 | int err; | 707 | int err; |
708 | struct udf_inode_info *dinfo = UDF_I(dir); | ||
709 | struct udf_inode_info *iinfo; | ||
675 | 710 | ||
676 | lock_kernel(); | 711 | lock_kernel(); |
677 | err = -EMLINK; | 712 | err = -EMLINK; |
@@ -683,9 +718,11 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
683 | if (!inode) | 718 | if (!inode) |
684 | goto out; | 719 | goto out; |
685 | 720 | ||
721 | iinfo = UDF_I(inode); | ||
686 | inode->i_op = &udf_dir_inode_operations; | 722 | inode->i_op = &udf_dir_inode_operations; |
687 | inode->i_fop = &udf_dir_operations; | 723 | inode->i_fop = &udf_dir_operations; |
688 | if (!(fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err))) { | 724 | fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err); |
725 | if (!fi) { | ||
689 | inode->i_nlink--; | 726 | inode->i_nlink--; |
690 | mark_inode_dirty(inode); | 727 | mark_inode_dirty(inode); |
691 | iput(inode); | 728 | iput(inode); |
@@ -693,10 +730,11 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
693 | } | 730 | } |
694 | inode->i_nlink = 2; | 731 | inode->i_nlink = 2; |
695 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 732 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
696 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(dir)); | 733 | cfi.icb.extLocation = cpu_to_lelb(dinfo->i_location); |
697 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 734 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
698 | cpu_to_le32(UDF_I_UNIQUE(dir) & 0x00000000FFFFFFFFUL); | 735 | cpu_to_le32(dinfo->i_unique & 0x00000000FFFFFFFFUL); |
699 | cfi.fileCharacteristics = FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT; | 736 | cfi.fileCharacteristics = |
737 | FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT; | ||
700 | udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); | 738 | udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); |
701 | brelse(fibh.sbh); | 739 | brelse(fibh.sbh); |
702 | inode->i_mode = S_IFDIR | mode; | 740 | inode->i_mode = S_IFDIR | mode; |
@@ -704,16 +742,17 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
704 | inode->i_mode |= S_ISGID; | 742 | inode->i_mode |= S_ISGID; |
705 | mark_inode_dirty(inode); | 743 | mark_inode_dirty(inode); |
706 | 744 | ||
707 | if (!(fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err))) { | 745 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
746 | if (!fi) { | ||
708 | inode->i_nlink = 0; | 747 | inode->i_nlink = 0; |
709 | mark_inode_dirty(inode); | 748 | mark_inode_dirty(inode); |
710 | iput(inode); | 749 | iput(inode); |
711 | goto out; | 750 | goto out; |
712 | } | 751 | } |
713 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 752 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
714 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); | 753 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
715 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 754 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
716 | cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); | 755 | cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL); |
717 | cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY; | 756 | cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY; |
718 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 757 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
719 | inc_nlink(dir); | 758 | inc_nlink(dir); |
@@ -734,32 +773,33 @@ static int empty_dir(struct inode *dir) | |||
734 | struct fileIdentDesc *fi, cfi; | 773 | struct fileIdentDesc *fi, cfi; |
735 | struct udf_fileident_bh fibh; | 774 | struct udf_fileident_bh fibh; |
736 | loff_t f_pos; | 775 | loff_t f_pos; |
737 | loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2; | 776 | loff_t size = udf_ext0_offset(dir) + dir->i_size; |
738 | int block; | 777 | int block; |
739 | kernel_lb_addr eloc; | 778 | kernel_lb_addr eloc; |
740 | uint32_t elen; | 779 | uint32_t elen; |
741 | sector_t offset; | 780 | sector_t offset; |
742 | struct extent_position epos = {}; | 781 | struct extent_position epos = {}; |
782 | struct udf_inode_info *dinfo = UDF_I(dir); | ||
743 | 783 | ||
744 | f_pos = (udf_ext0_offset(dir) >> 2); | 784 | f_pos = udf_ext0_offset(dir); |
785 | fibh.soffset = fibh.eoffset = f_pos & (dir->i_sb->s_blocksize - 1); | ||
745 | 786 | ||
746 | fibh.soffset = fibh.eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | 787 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
747 | |||
748 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | ||
749 | fibh.sbh = fibh.ebh = NULL; | 788 | fibh.sbh = fibh.ebh = NULL; |
750 | } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), | 789 | else if (inode_bmap(dir, f_pos >> dir->i_sb->s_blocksize_bits, |
751 | &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { | 790 | &epos, &eloc, &elen, &offset) == |
791 | (EXT_RECORDED_ALLOCATED >> 30)) { | ||
752 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); | 792 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
753 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { | 793 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
754 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) | 794 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
755 | epos.offset -= sizeof(short_ad); | 795 | epos.offset -= sizeof(short_ad); |
756 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) | 796 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
757 | epos.offset -= sizeof(long_ad); | 797 | epos.offset -= sizeof(long_ad); |
758 | } else { | 798 | } else |
759 | offset = 0; | 799 | offset = 0; |
760 | } | ||
761 | 800 | ||
762 | if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) { | 801 | fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block); |
802 | if (!fibh.sbh) { | ||
763 | brelse(epos.bh); | 803 | brelse(epos.bh); |
764 | return 0; | 804 | return 0; |
765 | } | 805 | } |
@@ -768,7 +808,7 @@ static int empty_dir(struct inode *dir) | |||
768 | return 0; | 808 | return 0; |
769 | } | 809 | } |
770 | 810 | ||
771 | while ((f_pos < size)) { | 811 | while (f_pos < size) { |
772 | fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc, | 812 | fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc, |
773 | &elen, &offset); | 813 | &elen, &offset); |
774 | if (!fi) { | 814 | if (!fi) { |
@@ -828,7 +868,8 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry) | |||
828 | clear_nlink(inode); | 868 | clear_nlink(inode); |
829 | inode->i_size = 0; | 869 | inode->i_size = 0; |
830 | inode_dec_link_count(dir); | 870 | inode_dec_link_count(dir); |
831 | inode->i_ctime = dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb); | 871 | inode->i_ctime = dir->i_ctime = dir->i_mtime = |
872 | current_fs_time(dir->i_sb); | ||
832 | mark_inode_dirty(dir); | 873 | mark_inode_dirty(dir); |
833 | 874 | ||
834 | end_rmdir: | 875 | end_rmdir: |
@@ -901,36 +942,42 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
901 | int block; | 942 | int block; |
902 | char name[UDF_NAME_LEN]; | 943 | char name[UDF_NAME_LEN]; |
903 | int namelen; | 944 | int namelen; |
945 | struct buffer_head *bh; | ||
946 | struct udf_inode_info *iinfo; | ||
904 | 947 | ||
905 | lock_kernel(); | 948 | lock_kernel(); |
906 | if (!(inode = udf_new_inode(dir, S_IFLNK, &err))) | 949 | inode = udf_new_inode(dir, S_IFLNK, &err); |
950 | if (!inode) | ||
907 | goto out; | 951 | goto out; |
908 | 952 | ||
953 | iinfo = UDF_I(inode); | ||
909 | inode->i_mode = S_IFLNK | S_IRWXUGO; | 954 | inode->i_mode = S_IFLNK | S_IRWXUGO; |
910 | inode->i_data.a_ops = &udf_symlink_aops; | 955 | inode->i_data.a_ops = &udf_symlink_aops; |
911 | inode->i_op = &page_symlink_inode_operations; | 956 | inode->i_op = &page_symlink_inode_operations; |
912 | 957 | ||
913 | if (UDF_I_ALLOCTYPE(inode) != ICBTAG_FLAG_AD_IN_ICB) { | 958 | if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { |
914 | kernel_lb_addr eloc; | 959 | kernel_lb_addr eloc; |
915 | uint32_t elen; | 960 | uint32_t elen; |
916 | 961 | ||
917 | block = udf_new_block(inode->i_sb, inode, | 962 | block = udf_new_block(inode->i_sb, inode, |
918 | UDF_I_LOCATION(inode).partitionReferenceNum, | 963 | iinfo->i_location.partitionReferenceNum, |
919 | UDF_I_LOCATION(inode).logicalBlockNum, &err); | 964 | iinfo->i_location.logicalBlockNum, &err); |
920 | if (!block) | 965 | if (!block) |
921 | goto out_no_entry; | 966 | goto out_no_entry; |
922 | epos.block = UDF_I_LOCATION(inode); | 967 | epos.block = iinfo->i_location; |
923 | epos.offset = udf_file_entry_alloc_offset(inode); | 968 | epos.offset = udf_file_entry_alloc_offset(inode); |
924 | epos.bh = NULL; | 969 | epos.bh = NULL; |
925 | eloc.logicalBlockNum = block; | 970 | eloc.logicalBlockNum = block; |
926 | eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; | 971 | eloc.partitionReferenceNum = |
972 | iinfo->i_location.partitionReferenceNum; | ||
927 | elen = inode->i_sb->s_blocksize; | 973 | elen = inode->i_sb->s_blocksize; |
928 | UDF_I_LENEXTENTS(inode) = elen; | 974 | iinfo->i_lenExtents = elen; |
929 | udf_add_aext(inode, &epos, eloc, elen, 0); | 975 | udf_add_aext(inode, &epos, eloc, elen, 0); |
930 | brelse(epos.bh); | 976 | brelse(epos.bh); |
931 | 977 | ||
932 | block = udf_get_pblock(inode->i_sb, block, | 978 | block = udf_get_pblock(inode->i_sb, block, |
933 | UDF_I_LOCATION(inode).partitionReferenceNum, 0); | 979 | iinfo->i_location.partitionReferenceNum, |
980 | 0); | ||
934 | epos.bh = udf_tread(inode->i_sb, block); | 981 | epos.bh = udf_tread(inode->i_sb, block); |
935 | lock_buffer(epos.bh); | 982 | lock_buffer(epos.bh); |
936 | memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize); | 983 | memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize); |
@@ -938,9 +985,8 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
938 | unlock_buffer(epos.bh); | 985 | unlock_buffer(epos.bh); |
939 | mark_buffer_dirty_inode(epos.bh, inode); | 986 | mark_buffer_dirty_inode(epos.bh, inode); |
940 | ea = epos.bh->b_data + udf_ext0_offset(inode); | 987 | ea = epos.bh->b_data + udf_ext0_offset(inode); |
941 | } else { | 988 | } else |
942 | ea = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); | 989 | ea = iinfo->i_ext.i_data + iinfo->i_lenEAttr; |
943 | } | ||
944 | 990 | ||
945 | eoffset = inode->i_sb->s_blocksize - udf_ext0_offset(inode); | 991 | eoffset = inode->i_sb->s_blocksize - udf_ext0_offset(inode); |
946 | pc = (struct pathComponent *)ea; | 992 | pc = (struct pathComponent *)ea; |
@@ -977,7 +1023,8 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
977 | if (compstart[0] == '.') { | 1023 | if (compstart[0] == '.') { |
978 | if ((symname - compstart) == 1) | 1024 | if ((symname - compstart) == 1) |
979 | pc->componentType = 4; | 1025 | pc->componentType = 4; |
980 | else if ((symname - compstart) == 2 && compstart[1] == '.') | 1026 | else if ((symname - compstart) == 2 && |
1027 | compstart[1] == '.') | ||
981 | pc->componentType = 3; | 1028 | pc->componentType = 3; |
982 | } | 1029 | } |
983 | 1030 | ||
@@ -987,7 +1034,8 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
987 | if (!namelen) | 1034 | if (!namelen) |
988 | goto out_no_entry; | 1035 | goto out_no_entry; |
989 | 1036 | ||
990 | if (elen + sizeof(struct pathComponent) + namelen > eoffset) | 1037 | if (elen + sizeof(struct pathComponent) + namelen > |
1038 | eoffset) | ||
991 | goto out_no_entry; | 1039 | goto out_no_entry; |
992 | else | 1040 | else |
993 | pc->lengthComponentIdent = namelen; | 1041 | pc->lengthComponentIdent = namelen; |
@@ -1006,30 +1054,34 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
1006 | 1054 | ||
1007 | brelse(epos.bh); | 1055 | brelse(epos.bh); |
1008 | inode->i_size = elen; | 1056 | inode->i_size = elen; |
1009 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) | 1057 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
1010 | UDF_I_LENALLOC(inode) = inode->i_size; | 1058 | iinfo->i_lenAlloc = inode->i_size; |
1011 | mark_inode_dirty(inode); | 1059 | mark_inode_dirty(inode); |
1012 | 1060 | ||
1013 | if (!(fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err))) | 1061 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
1062 | if (!fi) | ||
1014 | goto out_no_entry; | 1063 | goto out_no_entry; |
1015 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 1064 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
1016 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); | 1065 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
1017 | if (UDF_SB_LVIDBH(inode->i_sb)) { | 1066 | bh = UDF_SB(inode->i_sb)->s_lvid_bh; |
1067 | if (bh) { | ||
1068 | struct logicalVolIntegrityDesc *lvid = | ||
1069 | (struct logicalVolIntegrityDesc *)bh->b_data; | ||
1018 | struct logicalVolHeaderDesc *lvhd; | 1070 | struct logicalVolHeaderDesc *lvhd; |
1019 | uint64_t uniqueID; | 1071 | uint64_t uniqueID; |
1020 | lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse); | 1072 | lvhd = (struct logicalVolHeaderDesc *) |
1073 | lvid->logicalVolContentsUse; | ||
1021 | uniqueID = le64_to_cpu(lvhd->uniqueID); | 1074 | uniqueID = le64_to_cpu(lvhd->uniqueID); |
1022 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 1075 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
1023 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); | 1076 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); |
1024 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) | 1077 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) |
1025 | uniqueID += 16; | 1078 | uniqueID += 16; |
1026 | lvhd->uniqueID = cpu_to_le64(uniqueID); | 1079 | lvhd->uniqueID = cpu_to_le64(uniqueID); |
1027 | mark_buffer_dirty(UDF_SB_LVIDBH(inode->i_sb)); | 1080 | mark_buffer_dirty(bh); |
1028 | } | 1081 | } |
1029 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 1082 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
1030 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 1083 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
1031 | mark_inode_dirty(dir); | 1084 | mark_inode_dirty(dir); |
1032 | } | ||
1033 | if (fibh.sbh != fibh.ebh) | 1085 | if (fibh.sbh != fibh.ebh) |
1034 | brelse(fibh.ebh); | 1086 | brelse(fibh.ebh); |
1035 | brelse(fibh.sbh); | 1087 | brelse(fibh.sbh); |
@@ -1053,6 +1105,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir, | |||
1053 | struct udf_fileident_bh fibh; | 1105 | struct udf_fileident_bh fibh; |
1054 | struct fileIdentDesc cfi, *fi; | 1106 | struct fileIdentDesc cfi, *fi; |
1055 | int err; | 1107 | int err; |
1108 | struct buffer_head *bh; | ||
1056 | 1109 | ||
1057 | lock_kernel(); | 1110 | lock_kernel(); |
1058 | if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) { | 1111 | if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) { |
@@ -1060,28 +1113,32 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir, | |||
1060 | return -EMLINK; | 1113 | return -EMLINK; |
1061 | } | 1114 | } |
1062 | 1115 | ||
1063 | if (!(fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err))) { | 1116 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
1117 | if (!fi) { | ||
1064 | unlock_kernel(); | 1118 | unlock_kernel(); |
1065 | return err; | 1119 | return err; |
1066 | } | 1120 | } |
1067 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 1121 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
1068 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); | 1122 | cfi.icb.extLocation = cpu_to_lelb(UDF_I(inode)->i_location); |
1069 | if (UDF_SB_LVIDBH(inode->i_sb)) { | 1123 | bh = UDF_SB(inode->i_sb)->s_lvid_bh; |
1124 | if (bh) { | ||
1125 | struct logicalVolIntegrityDesc *lvid = | ||
1126 | (struct logicalVolIntegrityDesc *)bh->b_data; | ||
1070 | struct logicalVolHeaderDesc *lvhd; | 1127 | struct logicalVolHeaderDesc *lvhd; |
1071 | uint64_t uniqueID; | 1128 | uint64_t uniqueID; |
1072 | lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse); | 1129 | lvhd = (struct logicalVolHeaderDesc *) |
1130 | (lvid->logicalVolContentsUse); | ||
1073 | uniqueID = le64_to_cpu(lvhd->uniqueID); | 1131 | uniqueID = le64_to_cpu(lvhd->uniqueID); |
1074 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 1132 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
1075 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); | 1133 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); |
1076 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) | 1134 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) |
1077 | uniqueID += 16; | 1135 | uniqueID += 16; |
1078 | lvhd->uniqueID = cpu_to_le64(uniqueID); | 1136 | lvhd->uniqueID = cpu_to_le64(uniqueID); |
1079 | mark_buffer_dirty(UDF_SB_LVIDBH(inode->i_sb)); | 1137 | mark_buffer_dirty(bh); |
1080 | } | 1138 | } |
1081 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 1139 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
1082 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 1140 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
1083 | mark_inode_dirty(dir); | 1141 | mark_inode_dirty(dir); |
1084 | } | ||
1085 | 1142 | ||
1086 | if (fibh.sbh != fibh.ebh) | 1143 | if (fibh.sbh != fibh.ebh) |
1087 | brelse(fibh.ebh); | 1144 | brelse(fibh.ebh); |
@@ -1105,13 +1162,16 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1105 | struct inode *old_inode = old_dentry->d_inode; | 1162 | struct inode *old_inode = old_dentry->d_inode; |
1106 | struct inode *new_inode = new_dentry->d_inode; | 1163 | struct inode *new_inode = new_dentry->d_inode; |
1107 | struct udf_fileident_bh ofibh, nfibh; | 1164 | struct udf_fileident_bh ofibh, nfibh; |
1108 | struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi = NULL, ocfi, ncfi; | 1165 | struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi = NULL; |
1166 | struct fileIdentDesc ocfi, ncfi; | ||
1109 | struct buffer_head *dir_bh = NULL; | 1167 | struct buffer_head *dir_bh = NULL; |
1110 | int retval = -ENOENT; | 1168 | int retval = -ENOENT; |
1111 | kernel_lb_addr tloc; | 1169 | kernel_lb_addr tloc; |
1170 | struct udf_inode_info *old_iinfo = UDF_I(old_inode); | ||
1112 | 1171 | ||
1113 | lock_kernel(); | 1172 | lock_kernel(); |
1114 | if ((ofi = udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi))) { | 1173 | ofi = udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi); |
1174 | if (ofi) { | ||
1115 | if (ofibh.sbh != ofibh.ebh) | 1175 | if (ofibh.sbh != ofibh.ebh) |
1116 | brelse(ofibh.ebh); | 1176 | brelse(ofibh.ebh); |
1117 | brelse(ofibh.sbh); | 1177 | brelse(ofibh.sbh); |
@@ -1131,7 +1191,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1131 | } | 1191 | } |
1132 | } | 1192 | } |
1133 | if (S_ISDIR(old_inode->i_mode)) { | 1193 | if (S_ISDIR(old_inode->i_mode)) { |
1134 | uint32_t offset = udf_ext0_offset(old_inode); | 1194 | int offset = udf_ext0_offset(old_inode); |
1135 | 1195 | ||
1136 | if (new_inode) { | 1196 | if (new_inode) { |
1137 | retval = -ENOTEMPTY; | 1197 | retval = -ENOTEMPTY; |
@@ -1139,30 +1199,36 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1139 | goto end_rename; | 1199 | goto end_rename; |
1140 | } | 1200 | } |
1141 | retval = -EIO; | 1201 | retval = -EIO; |
1142 | if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) { | 1202 | if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
1143 | dir_fi = udf_get_fileident(UDF_I_DATA(old_inode) - | 1203 | dir_fi = udf_get_fileident( |
1144 | (UDF_I_EFE(old_inode) ? | 1204 | old_iinfo->i_ext.i_data - |
1145 | sizeof(struct extendedFileEntry) : | 1205 | (old_iinfo->i_efe ? |
1146 | sizeof(struct fileEntry)), | 1206 | sizeof(struct extendedFileEntry) : |
1147 | old_inode->i_sb->s_blocksize, &offset); | 1207 | sizeof(struct fileEntry)), |
1208 | old_inode->i_sb->s_blocksize, &offset); | ||
1148 | } else { | 1209 | } else { |
1149 | dir_bh = udf_bread(old_inode, 0, 0, &retval); | 1210 | dir_bh = udf_bread(old_inode, 0, 0, &retval); |
1150 | if (!dir_bh) | 1211 | if (!dir_bh) |
1151 | goto end_rename; | 1212 | goto end_rename; |
1152 | dir_fi = udf_get_fileident(dir_bh->b_data, old_inode->i_sb->s_blocksize, &offset); | 1213 | dir_fi = udf_get_fileident(dir_bh->b_data, |
1214 | old_inode->i_sb->s_blocksize, &offset); | ||
1153 | } | 1215 | } |
1154 | if (!dir_fi) | 1216 | if (!dir_fi) |
1155 | goto end_rename; | 1217 | goto end_rename; |
1156 | tloc = lelb_to_cpu(dir_fi->icb.extLocation); | 1218 | tloc = lelb_to_cpu(dir_fi->icb.extLocation); |
1157 | if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0) != old_dir->i_ino) | 1219 | if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0) != |
1220 | old_dir->i_ino) | ||
1158 | goto end_rename; | 1221 | goto end_rename; |
1159 | 1222 | ||
1160 | retval = -EMLINK; | 1223 | retval = -EMLINK; |
1161 | if (!new_inode && new_dir->i_nlink >= (256 << sizeof(new_dir->i_nlink)) - 1) | 1224 | if (!new_inode && |
1225 | new_dir->i_nlink >= | ||
1226 | (256 << sizeof(new_dir->i_nlink)) - 1) | ||
1162 | goto end_rename; | 1227 | goto end_rename; |
1163 | } | 1228 | } |
1164 | if (!nfi) { | 1229 | if (!nfi) { |
1165 | nfi = udf_add_entry(new_dir, new_dentry, &nfibh, &ncfi, &retval); | 1230 | nfi = udf_add_entry(new_dir, new_dentry, &nfibh, &ncfi, |
1231 | &retval); | ||
1166 | if (!nfi) | 1232 | if (!nfi) |
1167 | goto end_rename; | 1233 | goto end_rename; |
1168 | } | 1234 | } |
@@ -1194,18 +1260,19 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1194 | mark_inode_dirty(old_dir); | 1260 | mark_inode_dirty(old_dir); |
1195 | 1261 | ||
1196 | if (dir_fi) { | 1262 | if (dir_fi) { |
1197 | dir_fi->icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(new_dir)); | 1263 | dir_fi->icb.extLocation = cpu_to_lelb(UDF_I(new_dir)->i_location); |
1198 | udf_update_tag((char *)dir_fi, (sizeof(struct fileIdentDesc) + | 1264 | udf_update_tag((char *)dir_fi, |
1199 | le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3); | 1265 | (sizeof(struct fileIdentDesc) + |
1200 | if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) { | 1266 | le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3); |
1267 | if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | ||
1201 | mark_inode_dirty(old_inode); | 1268 | mark_inode_dirty(old_inode); |
1202 | } else { | 1269 | else |
1203 | mark_buffer_dirty_inode(dir_bh, old_inode); | 1270 | mark_buffer_dirty_inode(dir_bh, old_inode); |
1204 | } | 1271 | |
1205 | inode_dec_link_count(old_dir); | 1272 | inode_dec_link_count(old_dir); |
1206 | if (new_inode) { | 1273 | if (new_inode) |
1207 | inode_dec_link_count(new_inode); | 1274 | inode_dec_link_count(new_inode); |
1208 | } else { | 1275 | else { |
1209 | inc_nlink(new_dir); | 1276 | inc_nlink(new_dir); |
1210 | mark_inode_dirty(new_dir); | 1277 | mark_inode_dirty(new_dir); |
1211 | } | 1278 | } |
diff --git a/fs/udf/partition.c b/fs/udf/partition.c index aaab24c8c498..fc533345ab89 100644 --- a/fs/udf/partition.c +++ b/fs/udf/partition.c | |||
@@ -31,15 +31,18 @@ | |||
31 | inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, | 31 | inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, |
32 | uint16_t partition, uint32_t offset) | 32 | uint16_t partition, uint32_t offset) |
33 | { | 33 | { |
34 | if (partition >= UDF_SB_NUMPARTS(sb)) { | 34 | struct udf_sb_info *sbi = UDF_SB(sb); |
35 | udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n", | 35 | struct udf_part_map *map; |
36 | block, partition, offset); | 36 | if (partition >= sbi->s_partitions) { |
37 | udf_debug("block=%d, partition=%d, offset=%d: " | ||
38 | "invalid partition\n", block, partition, offset); | ||
37 | return 0xFFFFFFFF; | 39 | return 0xFFFFFFFF; |
38 | } | 40 | } |
39 | if (UDF_SB_PARTFUNC(sb, partition)) | 41 | map = &sbi->s_partmaps[partition]; |
40 | return UDF_SB_PARTFUNC(sb, partition)(sb, block, partition, offset); | 42 | if (map->s_partition_func) |
43 | return map->s_partition_func(sb, block, partition, offset); | ||
41 | else | 44 | else |
42 | return UDF_SB_PARTROOT(sb, partition) + block + offset; | 45 | return map->s_partition_root + block + offset; |
43 | } | 46 | } |
44 | 47 | ||
45 | uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, | 48 | uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, |
@@ -49,12 +52,18 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, | |||
49 | uint32_t newblock; | 52 | uint32_t newblock; |
50 | uint32_t index; | 53 | uint32_t index; |
51 | uint32_t loc; | 54 | uint32_t loc; |
55 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
56 | struct udf_part_map *map; | ||
57 | struct udf_virtual_data *vdata; | ||
58 | struct udf_inode_info *iinfo; | ||
52 | 59 | ||
53 | index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(uint32_t); | 60 | map = &sbi->s_partmaps[partition]; |
61 | vdata = &map->s_type_specific.s_virtual; | ||
62 | index = (sb->s_blocksize - vdata->s_start_offset) / sizeof(uint32_t); | ||
54 | 63 | ||
55 | if (block > UDF_SB_TYPEVIRT(sb,partition).s_num_entries) { | 64 | if (block > vdata->s_num_entries) { |
56 | udf_debug("Trying to access block beyond end of VAT (%d max %d)\n", | 65 | udf_debug("Trying to access block beyond end of VAT " |
57 | block, UDF_SB_TYPEVIRT(sb,partition).s_num_entries); | 66 | "(%d max %d)\n", block, vdata->s_num_entries); |
58 | return 0xFFFFFFFF; | 67 | return 0xFFFFFFFF; |
59 | } | 68 | } |
60 | 69 | ||
@@ -64,12 +73,13 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, | |||
64 | index = block % (sb->s_blocksize / sizeof(uint32_t)); | 73 | index = block % (sb->s_blocksize / sizeof(uint32_t)); |
65 | } else { | 74 | } else { |
66 | newblock = 0; | 75 | newblock = 0; |
67 | index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(uint32_t) + block; | 76 | index = vdata->s_start_offset / sizeof(uint32_t) + block; |
68 | } | 77 | } |
69 | 78 | ||
70 | loc = udf_block_map(UDF_SB_VAT(sb), newblock); | 79 | loc = udf_block_map(sbi->s_vat_inode, newblock); |
71 | 80 | ||
72 | if (!(bh = sb_bread(sb, loc))) { | 81 | bh = sb_bread(sb, loc); |
82 | if (!bh) { | ||
73 | udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n", | 83 | udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n", |
74 | sb, block, partition, loc, index); | 84 | sb, block, partition, loc, index); |
75 | return 0xFFFFFFFF; | 85 | return 0xFFFFFFFF; |
@@ -79,50 +89,61 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, | |||
79 | 89 | ||
80 | brelse(bh); | 90 | brelse(bh); |
81 | 91 | ||
82 | if (UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum == partition) { | 92 | iinfo = UDF_I(sbi->s_vat_inode); |
93 | if (iinfo->i_location.partitionReferenceNum == partition) { | ||
83 | udf_debug("recursive call to udf_get_pblock!\n"); | 94 | udf_debug("recursive call to udf_get_pblock!\n"); |
84 | return 0xFFFFFFFF; | 95 | return 0xFFFFFFFF; |
85 | } | 96 | } |
86 | 97 | ||
87 | return udf_get_pblock(sb, loc, | 98 | return udf_get_pblock(sb, loc, |
88 | UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum, | 99 | iinfo->i_location.partitionReferenceNum, |
89 | offset); | 100 | offset); |
90 | } | 101 | } |
91 | 102 | ||
92 | inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block, | 103 | inline uint32_t udf_get_pblock_virt20(struct super_block *sb, uint32_t block, |
93 | uint16_t partition, uint32_t offset) | 104 | uint16_t partition, uint32_t offset) |
94 | { | 105 | { |
95 | return udf_get_pblock_virt15(sb, block, partition, offset); | 106 | return udf_get_pblock_virt15(sb, block, partition, offset); |
96 | } | 107 | } |
97 | 108 | ||
98 | uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block, | 109 | uint32_t udf_get_pblock_spar15(struct super_block *sb, uint32_t block, |
99 | uint16_t partition, uint32_t offset) | 110 | uint16_t partition, uint32_t offset) |
100 | { | 111 | { |
101 | int i; | 112 | int i; |
102 | struct sparingTable *st = NULL; | 113 | struct sparingTable *st = NULL; |
103 | uint32_t packet = (block + offset) & ~(UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1); | 114 | struct udf_sb_info *sbi = UDF_SB(sb); |
115 | struct udf_part_map *map; | ||
116 | uint32_t packet; | ||
117 | struct udf_sparing_data *sdata; | ||
118 | |||
119 | map = &sbi->s_partmaps[partition]; | ||
120 | sdata = &map->s_type_specific.s_sparing; | ||
121 | packet = (block + offset) & ~(sdata->s_packet_len - 1); | ||
104 | 122 | ||
105 | for (i = 0; i < 4; i++) { | 123 | for (i = 0; i < 4; i++) { |
106 | if (UDF_SB_TYPESPAR(sb,partition).s_spar_map[i] != NULL) { | 124 | if (sdata->s_spar_map[i] != NULL) { |
107 | st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,partition).s_spar_map[i]->b_data; | 125 | st = (struct sparingTable *) |
126 | sdata->s_spar_map[i]->b_data; | ||
108 | break; | 127 | break; |
109 | } | 128 | } |
110 | } | 129 | } |
111 | 130 | ||
112 | if (st) { | 131 | if (st) { |
113 | for (i = 0; i < le16_to_cpu(st->reallocationTableLen); i++) { | 132 | for (i = 0; i < le16_to_cpu(st->reallocationTableLen); i++) { |
114 | if (le32_to_cpu(st->mapEntry[i].origLocation) >= 0xFFFFFFF0) { | 133 | struct sparingEntry *entry = &st->mapEntry[i]; |
134 | u32 origLoc = le32_to_cpu(entry->origLocation); | ||
135 | if (origLoc >= 0xFFFFFFF0) | ||
115 | break; | 136 | break; |
116 | } else if (le32_to_cpu(st->mapEntry[i].origLocation) == packet) { | 137 | else if (origLoc == packet) |
117 | return le32_to_cpu(st->mapEntry[i].mappedLocation) + | 138 | return le32_to_cpu(entry->mappedLocation) + |
118 | ((block + offset) & (UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1)); | 139 | ((block + offset) & |
119 | } else if (le32_to_cpu(st->mapEntry[i].origLocation) > packet) { | 140 | (sdata->s_packet_len - 1)); |
141 | else if (origLoc > packet) | ||
120 | break; | 142 | break; |
121 | } | ||
122 | } | 143 | } |
123 | } | 144 | } |
124 | 145 | ||
125 | return UDF_SB_PARTROOT(sb,partition) + block + offset; | 146 | return map->s_partition_root + block + offset; |
126 | } | 147 | } |
127 | 148 | ||
128 | int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) | 149 | int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) |
@@ -132,69 +153,109 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) | |||
132 | struct sparingEntry mapEntry; | 153 | struct sparingEntry mapEntry; |
133 | uint32_t packet; | 154 | uint32_t packet; |
134 | int i, j, k, l; | 155 | int i, j, k, l; |
156 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
157 | u16 reallocationTableLen; | ||
158 | struct buffer_head *bh; | ||
135 | 159 | ||
136 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { | 160 | for (i = 0; i < sbi->s_partitions; i++) { |
137 | if (old_block > UDF_SB_PARTROOT(sb,i) && | 161 | struct udf_part_map *map = &sbi->s_partmaps[i]; |
138 | old_block < UDF_SB_PARTROOT(sb,i) + UDF_SB_PARTLEN(sb,i)) { | 162 | if (old_block > map->s_partition_root && |
139 | sdata = &UDF_SB_TYPESPAR(sb,i); | 163 | old_block < map->s_partition_root + map->s_partition_len) { |
140 | packet = (old_block - UDF_SB_PARTROOT(sb,i)) & ~(sdata->s_packet_len - 1); | 164 | sdata = &map->s_type_specific.s_sparing; |
165 | packet = (old_block - map->s_partition_root) & | ||
166 | ~(sdata->s_packet_len - 1); | ||
141 | 167 | ||
142 | for (j = 0; j < 4; j++) { | 168 | for (j = 0; j < 4; j++) |
143 | if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) { | 169 | if (sdata->s_spar_map[j] != NULL) { |
144 | st = (struct sparingTable *)sdata->s_spar_map[j]->b_data; | 170 | st = (struct sparingTable *) |
171 | sdata->s_spar_map[j]->b_data; | ||
145 | break; | 172 | break; |
146 | } | 173 | } |
147 | } | ||
148 | 174 | ||
149 | if (!st) | 175 | if (!st) |
150 | return 1; | 176 | return 1; |
151 | 177 | ||
152 | for (k = 0; k < le16_to_cpu(st->reallocationTableLen); k++) { | 178 | reallocationTableLen = |
153 | if (le32_to_cpu(st->mapEntry[k].origLocation) == 0xFFFFFFFF) { | 179 | le16_to_cpu(st->reallocationTableLen); |
180 | for (k = 0; k < reallocationTableLen; k++) { | ||
181 | struct sparingEntry *entry = &st->mapEntry[k]; | ||
182 | u32 origLoc = le32_to_cpu(entry->origLocation); | ||
183 | |||
184 | if (origLoc == 0xFFFFFFFF) { | ||
154 | for (; j < 4; j++) { | 185 | for (; j < 4; j++) { |
155 | if (sdata->s_spar_map[j]) { | 186 | int len; |
156 | st = (struct sparingTable *)sdata->s_spar_map[j]->b_data; | 187 | bh = sdata->s_spar_map[j]; |
157 | st->mapEntry[k].origLocation = cpu_to_le32(packet); | 188 | if (!bh) |
158 | udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry)); | 189 | continue; |
159 | mark_buffer_dirty(sdata->s_spar_map[j]); | 190 | |
160 | } | 191 | st = (struct sparingTable *) |
192 | bh->b_data; | ||
193 | entry->origLocation = | ||
194 | cpu_to_le32(packet); | ||
195 | len = | ||
196 | sizeof(struct sparingTable) + | ||
197 | reallocationTableLen * | ||
198 | sizeof(struct sparingEntry); | ||
199 | udf_update_tag((char *)st, len); | ||
200 | mark_buffer_dirty(bh); | ||
161 | } | 201 | } |
162 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + | 202 | *new_block = le32_to_cpu( |
163 | ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); | 203 | entry->mappedLocation) + |
204 | ((old_block - | ||
205 | map->s_partition_root) & | ||
206 | (sdata->s_packet_len - 1)); | ||
164 | return 0; | 207 | return 0; |
165 | } else if (le32_to_cpu(st->mapEntry[k].origLocation) == packet) { | 208 | } else if (origLoc == packet) { |
166 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + | 209 | *new_block = le32_to_cpu( |
167 | ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); | 210 | entry->mappedLocation) + |
211 | ((old_block - | ||
212 | map->s_partition_root) & | ||
213 | (sdata->s_packet_len - 1)); | ||
168 | return 0; | 214 | return 0; |
169 | } else if (le32_to_cpu(st->mapEntry[k].origLocation) > packet) { | 215 | } else if (origLoc > packet) |
170 | break; | 216 | break; |
171 | } | ||
172 | } | 217 | } |
173 | 218 | ||
174 | for (l = k; l < le16_to_cpu(st->reallocationTableLen); l++) { | 219 | for (l = k; l < reallocationTableLen; l++) { |
175 | if (le32_to_cpu(st->mapEntry[l].origLocation) == 0xFFFFFFFF) { | 220 | struct sparingEntry *entry = &st->mapEntry[l]; |
176 | for (; j < 4; j++) { | 221 | u32 origLoc = le32_to_cpu(entry->origLocation); |
177 | if (sdata->s_spar_map[j]) { | 222 | |
178 | st = (struct sparingTable *)sdata->s_spar_map[j]->b_data; | 223 | if (origLoc != 0xFFFFFFFF) |
179 | mapEntry = st->mapEntry[l]; | 224 | continue; |
180 | mapEntry.origLocation = cpu_to_le32(packet); | 225 | |
181 | memmove(&st->mapEntry[k + 1], &st->mapEntry[k], (l - k) * sizeof(struct sparingEntry)); | 226 | for (; j < 4; j++) { |
182 | st->mapEntry[k] = mapEntry; | 227 | bh = sdata->s_spar_map[j]; |
183 | udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry)); | 228 | if (!bh) |
184 | mark_buffer_dirty(sdata->s_spar_map[j]); | 229 | continue; |
185 | } | 230 | |
186 | } | 231 | st = (struct sparingTable *)bh->b_data; |
187 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + | 232 | mapEntry = st->mapEntry[l]; |
188 | ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); | 233 | mapEntry.origLocation = |
189 | return 0; | 234 | cpu_to_le32(packet); |
235 | memmove(&st->mapEntry[k + 1], | ||
236 | &st->mapEntry[k], | ||
237 | (l - k) * | ||
238 | sizeof(struct sparingEntry)); | ||
239 | st->mapEntry[k] = mapEntry; | ||
240 | udf_update_tag((char *)st, | ||
241 | sizeof(struct sparingTable) + | ||
242 | reallocationTableLen * | ||
243 | sizeof(struct sparingEntry)); | ||
244 | mark_buffer_dirty(bh); | ||
190 | } | 245 | } |
246 | *new_block = | ||
247 | le32_to_cpu( | ||
248 | st->mapEntry[k].mappedLocation) + | ||
249 | ((old_block - map->s_partition_root) & | ||
250 | (sdata->s_packet_len - 1)); | ||
251 | return 0; | ||
191 | } | 252 | } |
192 | 253 | ||
193 | return 1; | 254 | return 1; |
194 | } /* if old_block */ | 255 | } /* if old_block */ |
195 | } | 256 | } |
196 | 257 | ||
197 | if (i == UDF_SB_NUMPARTS(sb)) { | 258 | if (i == sbi->s_partitions) { |
198 | /* outside of partitions */ | 259 | /* outside of partitions */ |
199 | /* for now, fail =) */ | 260 | /* for now, fail =) */ |
200 | return 1; | 261 | return 1; |
diff --git a/fs/udf/super.c b/fs/udf/super.c index 4360c7a05743..f3ac4abfc946 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -33,8 +33,8 @@ | |||
33 | * 10/17/98 added freespace count for "df" | 33 | * 10/17/98 added freespace count for "df" |
34 | * 11/11/98 gr added novrs option | 34 | * 11/11/98 gr added novrs option |
35 | * 11/26/98 dgb added fileset,anchor mount options | 35 | * 11/26/98 dgb added fileset,anchor mount options |
36 | * 12/06/98 blf really hosed things royally. vat/sparing support. sequenced vol descs | 36 | * 12/06/98 blf really hosed things royally. vat/sparing support. sequenced |
37 | * rewrote option handling based on isofs | 37 | * vol descs. rewrote option handling based on isofs |
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 | ||
@@ -52,6 +52,9 @@ | |||
52 | #include <linux/buffer_head.h> | 52 | #include <linux/buffer_head.h> |
53 | #include <linux/vfs.h> | 53 | #include <linux/vfs.h> |
54 | #include <linux/vmalloc.h> | 54 | #include <linux/vmalloc.h> |
55 | #include <linux/errno.h> | ||
56 | #include <linux/mount.h> | ||
57 | #include <linux/seq_file.h> | ||
55 | #include <asm/byteorder.h> | 58 | #include <asm/byteorder.h> |
56 | 59 | ||
57 | #include <linux/udf_fs.h> | 60 | #include <linux/udf_fs.h> |
@@ -70,6 +73,8 @@ | |||
70 | #define VDS_POS_TERMINATING_DESC 6 | 73 | #define VDS_POS_TERMINATING_DESC 6 |
71 | #define VDS_POS_LENGTH 7 | 74 | #define VDS_POS_LENGTH 7 |
72 | 75 | ||
76 | #define UDF_DEFAULT_BLOCKSIZE 2048 | ||
77 | |||
73 | static char error_buf[1024]; | 78 | static char error_buf[1024]; |
74 | 79 | ||
75 | /* These are the "meat" - everything else is stuffing */ | 80 | /* These are the "meat" - everything else is stuffing */ |
@@ -94,6 +99,17 @@ static void udf_open_lvid(struct super_block *); | |||
94 | static void udf_close_lvid(struct super_block *); | 99 | static void udf_close_lvid(struct super_block *); |
95 | static unsigned int udf_count_free(struct super_block *); | 100 | static unsigned int udf_count_free(struct super_block *); |
96 | static int udf_statfs(struct dentry *, struct kstatfs *); | 101 | static int udf_statfs(struct dentry *, struct kstatfs *); |
102 | static int udf_show_options(struct seq_file *, struct vfsmount *); | ||
103 | |||
104 | struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi) | ||
105 | { | ||
106 | struct logicalVolIntegrityDesc *lvid = | ||
107 | (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; | ||
108 | __u32 number_of_partitions = le32_to_cpu(lvid->numOfPartitions); | ||
109 | __u32 offset = number_of_partitions * 2 * | ||
110 | sizeof(uint32_t)/sizeof(uint8_t); | ||
111 | return (struct logicalVolIntegrityDescImpUse *)&(lvid->impUse[offset]); | ||
112 | } | ||
97 | 113 | ||
98 | /* UDF filesystem type */ | 114 | /* UDF filesystem type */ |
99 | static int udf_get_sb(struct file_system_type *fs_type, | 115 | static int udf_get_sb(struct file_system_type *fs_type, |
@@ -116,7 +132,7 @@ static struct kmem_cache *udf_inode_cachep; | |||
116 | static struct inode *udf_alloc_inode(struct super_block *sb) | 132 | static struct inode *udf_alloc_inode(struct super_block *sb) |
117 | { | 133 | { |
118 | struct udf_inode_info *ei; | 134 | struct udf_inode_info *ei; |
119 | ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL); | 135 | ei = kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL); |
120 | if (!ei) | 136 | if (!ei) |
121 | return NULL; | 137 | return NULL; |
122 | 138 | ||
@@ -170,6 +186,7 @@ static const struct super_operations udf_sb_ops = { | |||
170 | .write_super = udf_write_super, | 186 | .write_super = udf_write_super, |
171 | .statfs = udf_statfs, | 187 | .statfs = udf_statfs, |
172 | .remount_fs = udf_remount_fs, | 188 | .remount_fs = udf_remount_fs, |
189 | .show_options = udf_show_options, | ||
173 | }; | 190 | }; |
174 | 191 | ||
175 | struct udf_options { | 192 | struct udf_options { |
@@ -218,6 +235,79 @@ static void __exit exit_udf_fs(void) | |||
218 | module_init(init_udf_fs) | 235 | module_init(init_udf_fs) |
219 | module_exit(exit_udf_fs) | 236 | module_exit(exit_udf_fs) |
220 | 237 | ||
238 | static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count) | ||
239 | { | ||
240 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
241 | |||
242 | sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map), | ||
243 | GFP_KERNEL); | ||
244 | if (!sbi->s_partmaps) { | ||
245 | udf_error(sb, __FUNCTION__, | ||
246 | "Unable to allocate space for %d partition maps", | ||
247 | count); | ||
248 | sbi->s_partitions = 0; | ||
249 | return -ENOMEM; | ||
250 | } | ||
251 | |||
252 | sbi->s_partitions = count; | ||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | static int udf_show_options(struct seq_file *seq, struct vfsmount *mnt) | ||
257 | { | ||
258 | struct super_block *sb = mnt->mnt_sb; | ||
259 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
260 | |||
261 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT)) | ||
262 | seq_puts(seq, ",nostrict"); | ||
263 | if (sb->s_blocksize != UDF_DEFAULT_BLOCKSIZE) | ||
264 | seq_printf(seq, ",bs=%lu", sb->s_blocksize); | ||
265 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UNHIDE)) | ||
266 | seq_puts(seq, ",unhide"); | ||
267 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UNDELETE)) | ||
268 | seq_puts(seq, ",undelete"); | ||
269 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_USE_AD_IN_ICB)) | ||
270 | seq_puts(seq, ",noadinicb"); | ||
271 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_USE_SHORT_AD)) | ||
272 | seq_puts(seq, ",shortad"); | ||
273 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_FORGET)) | ||
274 | seq_puts(seq, ",uid=forget"); | ||
275 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_IGNORE)) | ||
276 | seq_puts(seq, ",uid=ignore"); | ||
277 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_FORGET)) | ||
278 | seq_puts(seq, ",gid=forget"); | ||
279 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_IGNORE)) | ||
280 | seq_puts(seq, ",gid=ignore"); | ||
281 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET)) | ||
282 | seq_printf(seq, ",uid=%u", sbi->s_uid); | ||
283 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET)) | ||
284 | seq_printf(seq, ",gid=%u", sbi->s_gid); | ||
285 | if (sbi->s_umask != 0) | ||
286 | seq_printf(seq, ",umask=%o", sbi->s_umask); | ||
287 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_SESSION_SET)) | ||
288 | seq_printf(seq, ",session=%u", sbi->s_session); | ||
289 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_LASTBLOCK_SET)) | ||
290 | seq_printf(seq, ",lastblock=%u", sbi->s_last_block); | ||
291 | /* | ||
292 | * s_anchor[2] could be zeroed out in case there is no anchor | ||
293 | * in the specified block, but then the "anchor=N" option | ||
294 | * originally given by the user wasn't effective, so it's OK | ||
295 | * if we don't show it. | ||
296 | */ | ||
297 | if (sbi->s_anchor[2] != 0) | ||
298 | seq_printf(seq, ",anchor=%u", sbi->s_anchor[2]); | ||
299 | /* | ||
300 | * volume, partition, fileset and rootdir seem to be ignored | ||
301 | * currently | ||
302 | */ | ||
303 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) | ||
304 | seq_puts(seq, ",utf8"); | ||
305 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP) && sbi->s_nls_map) | ||
306 | seq_printf(seq, ",iocharset=%s", sbi->s_nls_map->charset); | ||
307 | |||
308 | return 0; | ||
309 | } | ||
310 | |||
221 | /* | 311 | /* |
222 | * udf_parse_options | 312 | * udf_parse_options |
223 | * | 313 | * |
@@ -310,13 +400,14 @@ static match_table_t tokens = { | |||
310 | {Opt_err, NULL} | 400 | {Opt_err, NULL} |
311 | }; | 401 | }; |
312 | 402 | ||
313 | static int udf_parse_options(char *options, struct udf_options *uopt) | 403 | static int udf_parse_options(char *options, struct udf_options *uopt, |
404 | bool remount) | ||
314 | { | 405 | { |
315 | char *p; | 406 | char *p; |
316 | int option; | 407 | int option; |
317 | 408 | ||
318 | uopt->novrs = 0; | 409 | uopt->novrs = 0; |
319 | uopt->blocksize = 2048; | 410 | uopt->blocksize = UDF_DEFAULT_BLOCKSIZE; |
320 | uopt->partition = 0xFFFF; | 411 | uopt->partition = 0xFFFF; |
321 | uopt->session = 0xFFFFFFFF; | 412 | uopt->session = 0xFFFFFFFF; |
322 | uopt->lastblock = 0; | 413 | uopt->lastblock = 0; |
@@ -386,11 +477,15 @@ static int udf_parse_options(char *options, struct udf_options *uopt) | |||
386 | if (match_int(args, &option)) | 477 | if (match_int(args, &option)) |
387 | return 0; | 478 | return 0; |
388 | uopt->session = option; | 479 | uopt->session = option; |
480 | if (!remount) | ||
481 | uopt->flags |= (1 << UDF_FLAG_SESSION_SET); | ||
389 | break; | 482 | break; |
390 | case Opt_lastblock: | 483 | case Opt_lastblock: |
391 | if (match_int(args, &option)) | 484 | if (match_int(args, &option)) |
392 | return 0; | 485 | return 0; |
393 | uopt->lastblock = option; | 486 | uopt->lastblock = option; |
487 | if (!remount) | ||
488 | uopt->flags |= (1 << UDF_FLAG_LASTBLOCK_SET); | ||
394 | break; | 489 | break; |
395 | case Opt_anchor: | 490 | case Opt_anchor: |
396 | if (match_int(args, &option)) | 491 | if (match_int(args, &option)) |
@@ -447,7 +542,7 @@ static int udf_parse_options(char *options, struct udf_options *uopt) | |||
447 | return 1; | 542 | return 1; |
448 | } | 543 | } |
449 | 544 | ||
450 | void udf_write_super(struct super_block *sb) | 545 | static void udf_write_super(struct super_block *sb) |
451 | { | 546 | { |
452 | lock_kernel(); | 547 | lock_kernel(); |
453 | 548 | ||
@@ -461,22 +556,23 @@ void udf_write_super(struct super_block *sb) | |||
461 | static int udf_remount_fs(struct super_block *sb, int *flags, char *options) | 556 | static int udf_remount_fs(struct super_block *sb, int *flags, char *options) |
462 | { | 557 | { |
463 | struct udf_options uopt; | 558 | struct udf_options uopt; |
559 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
464 | 560 | ||
465 | uopt.flags = UDF_SB(sb)->s_flags; | 561 | uopt.flags = sbi->s_flags; |
466 | uopt.uid = UDF_SB(sb)->s_uid; | 562 | uopt.uid = sbi->s_uid; |
467 | uopt.gid = UDF_SB(sb)->s_gid; | 563 | uopt.gid = sbi->s_gid; |
468 | uopt.umask = UDF_SB(sb)->s_umask; | 564 | uopt.umask = sbi->s_umask; |
469 | 565 | ||
470 | if (!udf_parse_options(options, &uopt)) | 566 | if (!udf_parse_options(options, &uopt, true)) |
471 | return -EINVAL; | 567 | return -EINVAL; |
472 | 568 | ||
473 | UDF_SB(sb)->s_flags = uopt.flags; | 569 | sbi->s_flags = uopt.flags; |
474 | UDF_SB(sb)->s_uid = uopt.uid; | 570 | sbi->s_uid = uopt.uid; |
475 | UDF_SB(sb)->s_gid = uopt.gid; | 571 | sbi->s_gid = uopt.gid; |
476 | UDF_SB(sb)->s_umask = uopt.umask; | 572 | sbi->s_umask = uopt.umask; |
477 | 573 | ||
478 | if (UDF_SB_LVIDBH(sb)) { | 574 | if (sbi->s_lvid_bh) { |
479 | int write_rev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev); | 575 | int write_rev = le16_to_cpu(udf_sb_lvidiu(sbi)->minUDFWriteRev); |
480 | if (write_rev > UDF_MAX_WRITE_VERSION) | 576 | if (write_rev > UDF_MAX_WRITE_VERSION) |
481 | *flags |= MS_RDONLY; | 577 | *flags |= MS_RDONLY; |
482 | } | 578 | } |
@@ -538,17 +634,19 @@ static int udf_vrs(struct super_block *sb, int silent) | |||
538 | int iso9660 = 0; | 634 | int iso9660 = 0; |
539 | int nsr02 = 0; | 635 | int nsr02 = 0; |
540 | int nsr03 = 0; | 636 | int nsr03 = 0; |
637 | struct udf_sb_info *sbi; | ||
541 | 638 | ||
542 | /* Block size must be a multiple of 512 */ | 639 | /* Block size must be a multiple of 512 */ |
543 | if (sb->s_blocksize & 511) | 640 | if (sb->s_blocksize & 511) |
544 | return 0; | 641 | return 0; |
642 | sbi = UDF_SB(sb); | ||
545 | 643 | ||
546 | if (sb->s_blocksize < sizeof(struct volStructDesc)) | 644 | if (sb->s_blocksize < sizeof(struct volStructDesc)) |
547 | sectorsize = sizeof(struct volStructDesc); | 645 | sectorsize = sizeof(struct volStructDesc); |
548 | else | 646 | else |
549 | sectorsize = sb->s_blocksize; | 647 | sectorsize = sb->s_blocksize; |
550 | 648 | ||
551 | sector += (UDF_SB_SESSION(sb) << sb->s_blocksize_bits); | 649 | sector += (sbi->s_session << sb->s_blocksize_bits); |
552 | 650 | ||
553 | udf_debug("Starting at sector %u (%ld byte sectors)\n", | 651 | udf_debug("Starting at sector %u (%ld byte sectors)\n", |
554 | (sector >> sb->s_blocksize_bits), sb->s_blocksize); | 652 | (sector >> sb->s_blocksize_bits), sb->s_blocksize); |
@@ -561,47 +659,52 @@ static int udf_vrs(struct super_block *sb, int silent) | |||
561 | 659 | ||
562 | /* Look for ISO descriptors */ | 660 | /* Look for ISO descriptors */ |
563 | vsd = (struct volStructDesc *)(bh->b_data + | 661 | vsd = (struct volStructDesc *)(bh->b_data + |
564 | (sector & (sb->s_blocksize - 1))); | 662 | (sector & (sb->s_blocksize - 1))); |
565 | 663 | ||
566 | if (vsd->stdIdent[0] == 0) { | 664 | if (vsd->stdIdent[0] == 0) { |
567 | brelse(bh); | 665 | brelse(bh); |
568 | break; | 666 | break; |
569 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) { | 667 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, |
668 | VSD_STD_ID_LEN)) { | ||
570 | iso9660 = sector; | 669 | iso9660 = sector; |
571 | switch (vsd->structType) { | 670 | switch (vsd->structType) { |
572 | case 0: | 671 | case 0: |
573 | udf_debug("ISO9660 Boot Record found\n"); | 672 | udf_debug("ISO9660 Boot Record found\n"); |
574 | break; | 673 | break; |
575 | case 1: | 674 | case 1: |
576 | udf_debug | 675 | udf_debug("ISO9660 Primary Volume Descriptor " |
577 | ("ISO9660 Primary Volume Descriptor found\n"); | 676 | "found\n"); |
578 | break; | 677 | break; |
579 | case 2: | 678 | case 2: |
580 | udf_debug | 679 | udf_debug("ISO9660 Supplementary Volume " |
581 | ("ISO9660 Supplementary Volume Descriptor found\n"); | 680 | "Descriptor found\n"); |
582 | break; | 681 | break; |
583 | case 3: | 682 | case 3: |
584 | udf_debug | 683 | udf_debug("ISO9660 Volume Partition Descriptor " |
585 | ("ISO9660 Volume Partition Descriptor found\n"); | 684 | "found\n"); |
586 | break; | 685 | break; |
587 | case 255: | 686 | case 255: |
588 | udf_debug | 687 | udf_debug("ISO9660 Volume Descriptor Set " |
589 | ("ISO9660 Volume Descriptor Set Terminator found\n"); | 688 | "Terminator found\n"); |
590 | break; | 689 | break; |
591 | default: | 690 | default: |
592 | udf_debug("ISO9660 VRS (%u) found\n", | 691 | udf_debug("ISO9660 VRS (%u) found\n", |
593 | vsd->structType); | 692 | vsd->structType); |
594 | break; | 693 | break; |
595 | } | 694 | } |
596 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) { | 695 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, |
597 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN)) { | 696 | VSD_STD_ID_LEN)) |
697 | ; /* nothing */ | ||
698 | else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, | ||
699 | VSD_STD_ID_LEN)) { | ||
598 | brelse(bh); | 700 | brelse(bh); |
599 | break; | 701 | break; |
600 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) { | 702 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, |
703 | VSD_STD_ID_LEN)) | ||
601 | nsr02 = sector; | 704 | nsr02 = sector; |
602 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) { | 705 | else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, |
706 | VSD_STD_ID_LEN)) | ||
603 | nsr03 = sector; | 707 | nsr03 = sector; |
604 | } | ||
605 | brelse(bh); | 708 | brelse(bh); |
606 | } | 709 | } |
607 | 710 | ||
@@ -609,7 +712,7 @@ static int udf_vrs(struct super_block *sb, int silent) | |||
609 | return nsr03; | 712 | return nsr03; |
610 | else if (nsr02) | 713 | else if (nsr02) |
611 | return nsr02; | 714 | return nsr02; |
612 | else if (sector - (UDF_SB_SESSION(sb) << sb->s_blocksize_bits) == 32768) | 715 | else if (sector - (sbi->s_session << sb->s_blocksize_bits) == 32768) |
613 | return -1; | 716 | return -1; |
614 | else | 717 | else |
615 | return 0; | 718 | return 0; |
@@ -634,11 +737,15 @@ static int udf_vrs(struct super_block *sb, int silent) | |||
634 | */ | 737 | */ |
635 | static void udf_find_anchor(struct super_block *sb) | 738 | static void udf_find_anchor(struct super_block *sb) |
636 | { | 739 | { |
637 | int lastblock = UDF_SB_LASTBLOCK(sb); | 740 | int lastblock; |
638 | struct buffer_head *bh = NULL; | 741 | struct buffer_head *bh = NULL; |
639 | uint16_t ident; | 742 | uint16_t ident; |
640 | uint32_t location; | 743 | uint32_t location; |
641 | int i; | 744 | int i; |
745 | struct udf_sb_info *sbi; | ||
746 | |||
747 | sbi = UDF_SB(sb); | ||
748 | lastblock = sbi->s_last_block; | ||
642 | 749 | ||
643 | if (lastblock) { | 750 | if (lastblock) { |
644 | int varlastblock = udf_variable_to_fixed(lastblock); | 751 | int varlastblock = udf_variable_to_fixed(lastblock); |
@@ -658,57 +765,83 @@ static void udf_find_anchor(struct super_block *sb) | |||
658 | * however, if the disc isn't closed, it could be 512 */ | 765 | * however, if the disc isn't closed, it could be 512 */ |
659 | 766 | ||
660 | for (i = 0; !lastblock && i < ARRAY_SIZE(last); i++) { | 767 | for (i = 0; !lastblock && i < ARRAY_SIZE(last); i++) { |
661 | if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) { | 768 | ident = location = 0; |
662 | ident = location = 0; | 769 | if (last[i] >= 0) { |
663 | } else { | 770 | bh = sb_bread(sb, last[i]); |
664 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); | 771 | if (bh) { |
665 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); | 772 | tag *t = (tag *)bh->b_data; |
666 | brelse(bh); | 773 | ident = le16_to_cpu(t->tagIdent); |
774 | location = le32_to_cpu(t->tagLocation); | ||
775 | brelse(bh); | ||
776 | } | ||
667 | } | 777 | } |
668 | 778 | ||
669 | if (ident == TAG_IDENT_AVDP) { | 779 | if (ident == TAG_IDENT_AVDP) { |
670 | if (location == last[i] - UDF_SB_SESSION(sb)) { | 780 | if (location == last[i] - sbi->s_session) { |
671 | lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] - UDF_SB_SESSION(sb); | 781 | lastblock = last[i] - sbi->s_session; |
672 | UDF_SB_ANCHOR(sb)[1] = last[i] - 256 - UDF_SB_SESSION(sb); | 782 | sbi->s_anchor[0] = lastblock; |
673 | } else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb)) { | 783 | sbi->s_anchor[1] = lastblock - 256; |
784 | } else if (location == | ||
785 | udf_variable_to_fixed(last[i]) - | ||
786 | sbi->s_session) { | ||
674 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); | 787 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); |
675 | lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb); | 788 | lastblock = |
676 | UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb); | 789 | udf_variable_to_fixed(last[i]) - |
790 | sbi->s_session; | ||
791 | sbi->s_anchor[0] = lastblock; | ||
792 | sbi->s_anchor[1] = lastblock - 256 - | ||
793 | sbi->s_session; | ||
677 | } else { | 794 | } else { |
678 | udf_debug("Anchor found at block %d, location mismatch %d.\n", | 795 | udf_debug("Anchor found at block %d, " |
796 | "location mismatch %d.\n", | ||
679 | last[i], location); | 797 | last[i], location); |
680 | } | 798 | } |
681 | } else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE) { | 799 | } else if (ident == TAG_IDENT_FE || |
800 | ident == TAG_IDENT_EFE) { | ||
682 | lastblock = last[i]; | 801 | lastblock = last[i]; |
683 | UDF_SB_ANCHOR(sb)[3] = 512; | 802 | sbi->s_anchor[3] = 512; |
684 | } else { | 803 | } else { |
685 | if (last[i] < 256 || !(bh = sb_bread(sb, last[i] - 256))) { | 804 | ident = location = 0; |
686 | ident = location = 0; | 805 | if (last[i] >= 256) { |
687 | } else { | 806 | bh = sb_bread(sb, last[i] - 256); |
688 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); | 807 | if (bh) { |
689 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); | 808 | tag *t = (tag *)bh->b_data; |
690 | brelse(bh); | 809 | ident = le16_to_cpu( |
810 | t->tagIdent); | ||
811 | location = le32_to_cpu( | ||
812 | t->tagLocation); | ||
813 | brelse(bh); | ||
814 | } | ||
691 | } | 815 | } |
692 | 816 | ||
693 | if (ident == TAG_IDENT_AVDP && | 817 | if (ident == TAG_IDENT_AVDP && |
694 | location == last[i] - 256 - UDF_SB_SESSION(sb)) { | 818 | location == last[i] - 256 - |
819 | sbi->s_session) { | ||
695 | lastblock = last[i]; | 820 | lastblock = last[i]; |
696 | UDF_SB_ANCHOR(sb)[1] = last[i] - 256; | 821 | sbi->s_anchor[1] = last[i] - 256; |
697 | } else { | 822 | } else { |
698 | if (last[i] < 312 + UDF_SB_SESSION(sb) || | 823 | ident = location = 0; |
699 | !(bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb)))) { | 824 | if (last[i] >= 312 + sbi->s_session) { |
700 | ident = location = 0; | 825 | bh = sb_bread(sb, |
701 | } else { | 826 | last[i] - 312 - |
702 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); | 827 | sbi->s_session); |
703 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); | 828 | if (bh) { |
704 | brelse(bh); | 829 | tag *t = (tag *) |
830 | bh->b_data; | ||
831 | ident = le16_to_cpu( | ||
832 | t->tagIdent); | ||
833 | location = le32_to_cpu( | ||
834 | t->tagLocation); | ||
835 | brelse(bh); | ||
836 | } | ||
705 | } | 837 | } |
706 | 838 | ||
707 | if (ident == TAG_IDENT_AVDP && | 839 | if (ident == TAG_IDENT_AVDP && |
708 | location == udf_variable_to_fixed(last[i]) - 256) { | 840 | location == udf_variable_to_fixed(last[i]) - 256) { |
709 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); | 841 | UDF_SET_FLAG(sb, |
842 | UDF_FLAG_VARCONV); | ||
710 | lastblock = udf_variable_to_fixed(last[i]); | 843 | lastblock = udf_variable_to_fixed(last[i]); |
711 | UDF_SB_ANCHOR(sb)[1] = lastblock - 256; | 844 | sbi->s_anchor[1] = lastblock - 256; |
712 | } | 845 | } |
713 | } | 846 | } |
714 | } | 847 | } |
@@ -716,10 +849,12 @@ static void udf_find_anchor(struct super_block *sb) | |||
716 | } | 849 | } |
717 | 850 | ||
718 | if (!lastblock) { | 851 | if (!lastblock) { |
719 | /* We havn't found the lastblock. check 312 */ | 852 | /* We haven't found the lastblock. check 312 */ |
720 | if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) { | 853 | bh = sb_bread(sb, 312 + sbi->s_session); |
721 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); | 854 | if (bh) { |
722 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); | 855 | tag *t = (tag *)bh->b_data; |
856 | ident = le16_to_cpu(t->tagIdent); | ||
857 | location = le32_to_cpu(t->tagLocation); | ||
723 | brelse(bh); | 858 | brelse(bh); |
724 | 859 | ||
725 | if (ident == TAG_IDENT_AVDP && location == 256) | 860 | if (ident == TAG_IDENT_AVDP && location == 256) |
@@ -727,29 +862,33 @@ static void udf_find_anchor(struct super_block *sb) | |||
727 | } | 862 | } |
728 | } | 863 | } |
729 | 864 | ||
730 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { | 865 | for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { |
731 | if (UDF_SB_ANCHOR(sb)[i]) { | 866 | if (sbi->s_anchor[i]) { |
732 | if (!(bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i], | 867 | bh = udf_read_tagged(sb, sbi->s_anchor[i], |
733 | UDF_SB_ANCHOR(sb)[i], &ident))) { | 868 | sbi->s_anchor[i], &ident); |
734 | UDF_SB_ANCHOR(sb)[i] = 0; | 869 | if (!bh) |
735 | } else { | 870 | sbi->s_anchor[i] = 0; |
871 | else { | ||
736 | brelse(bh); | 872 | brelse(bh); |
737 | if ((ident != TAG_IDENT_AVDP) && | 873 | if ((ident != TAG_IDENT_AVDP) && |
738 | (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE))) { | 874 | (i || (ident != TAG_IDENT_FE && |
739 | UDF_SB_ANCHOR(sb)[i] = 0; | 875 | ident != TAG_IDENT_EFE))) |
740 | } | 876 | sbi->s_anchor[i] = 0; |
741 | } | 877 | } |
742 | } | 878 | } |
743 | } | 879 | } |
744 | 880 | ||
745 | UDF_SB_LASTBLOCK(sb) = lastblock; | 881 | sbi->s_last_block = lastblock; |
746 | } | 882 | } |
747 | 883 | ||
748 | static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr *root) | 884 | static int udf_find_fileset(struct super_block *sb, |
885 | kernel_lb_addr *fileset, | ||
886 | kernel_lb_addr *root) | ||
749 | { | 887 | { |
750 | struct buffer_head *bh = NULL; | 888 | struct buffer_head *bh = NULL; |
751 | long lastblock; | 889 | long lastblock; |
752 | uint16_t ident; | 890 | uint16_t ident; |
891 | struct udf_sb_info *sbi; | ||
753 | 892 | ||
754 | if (fileset->logicalBlockNum != 0xFFFFFFFF || | 893 | if (fileset->logicalBlockNum != 0xFFFFFFFF || |
755 | fileset->partitionReferenceNum != 0xFFFF) { | 894 | fileset->partitionReferenceNum != 0xFFFF) { |
@@ -764,22 +903,27 @@ static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, ker | |||
764 | 903 | ||
765 | } | 904 | } |
766 | 905 | ||
767 | if (!bh) { /* Search backwards through the partitions */ | 906 | sbi = UDF_SB(sb); |
907 | if (!bh) { | ||
908 | /* Search backwards through the partitions */ | ||
768 | kernel_lb_addr newfileset; | 909 | kernel_lb_addr newfileset; |
769 | 910 | ||
770 | /* --> cvg: FIXME - is it reasonable? */ | 911 | /* --> cvg: FIXME - is it reasonable? */ |
771 | return 1; | 912 | return 1; |
772 | 913 | ||
773 | for (newfileset.partitionReferenceNum = UDF_SB_NUMPARTS(sb) - 1; | 914 | for (newfileset.partitionReferenceNum = sbi->s_partitions - 1; |
774 | (newfileset.partitionReferenceNum != 0xFFFF && | 915 | (newfileset.partitionReferenceNum != 0xFFFF && |
775 | fileset->logicalBlockNum == 0xFFFFFFFF && | 916 | fileset->logicalBlockNum == 0xFFFFFFFF && |
776 | fileset->partitionReferenceNum == 0xFFFF); | 917 | fileset->partitionReferenceNum == 0xFFFF); |
777 | newfileset.partitionReferenceNum--) { | 918 | newfileset.partitionReferenceNum--) { |
778 | lastblock = UDF_SB_PARTLEN(sb, newfileset.partitionReferenceNum); | 919 | lastblock = sbi->s_partmaps |
920 | [newfileset.partitionReferenceNum] | ||
921 | .s_partition_len; | ||
779 | newfileset.logicalBlockNum = 0; | 922 | newfileset.logicalBlockNum = 0; |
780 | 923 | ||
781 | do { | 924 | do { |
782 | bh = udf_read_ptagged(sb, newfileset, 0, &ident); | 925 | bh = udf_read_ptagged(sb, newfileset, 0, |
926 | &ident); | ||
783 | if (!bh) { | 927 | if (!bh) { |
784 | newfileset.logicalBlockNum++; | 928 | newfileset.logicalBlockNum++; |
785 | continue; | 929 | continue; |
@@ -789,11 +933,12 @@ static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, ker | |||
789 | case TAG_IDENT_SBD: | 933 | case TAG_IDENT_SBD: |
790 | { | 934 | { |
791 | struct spaceBitmapDesc *sp; | 935 | struct spaceBitmapDesc *sp; |
792 | sp = (struct spaceBitmapDesc *)bh->b_data; | 936 | sp = (struct spaceBitmapDesc *) |
937 | bh->b_data; | ||
793 | newfileset.logicalBlockNum += 1 + | 938 | newfileset.logicalBlockNum += 1 + |
794 | ((le32_to_cpu(sp->numOfBytes) + | 939 | ((le32_to_cpu(sp->numOfBytes) + |
795 | sizeof(struct spaceBitmapDesc) - 1) | 940 | sizeof(struct spaceBitmapDesc) |
796 | >> sb->s_blocksize_bits); | 941 | - 1) >> sb->s_blocksize_bits); |
797 | brelse(bh); | 942 | brelse(bh); |
798 | break; | 943 | break; |
799 | } | 944 | } |
@@ -818,7 +963,7 @@ static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, ker | |||
818 | fileset->logicalBlockNum, | 963 | fileset->logicalBlockNum, |
819 | fileset->partitionReferenceNum); | 964 | fileset->partitionReferenceNum); |
820 | 965 | ||
821 | UDF_SB_PARTITION(sb) = fileset->partitionReferenceNum; | 966 | sbi->s_partition = fileset->partitionReferenceNum; |
822 | udf_load_fileset(sb, bh, root); | 967 | udf_load_fileset(sb, bh, root); |
823 | brelse(bh); | 968 | brelse(bh); |
824 | return 0; | 969 | return 0; |
@@ -840,26 +985,26 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh) | |||
840 | lets_to_cpu(pvoldesc->recordingDateAndTime))) { | 985 | lets_to_cpu(pvoldesc->recordingDateAndTime))) { |
841 | kernel_timestamp ts; | 986 | kernel_timestamp ts; |
842 | ts = lets_to_cpu(pvoldesc->recordingDateAndTime); | 987 | ts = lets_to_cpu(pvoldesc->recordingDateAndTime); |
843 | udf_debug("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n", | 988 | udf_debug("recording time %ld/%ld, %04u/%02u/%02u" |
989 | " %02u:%02u (%x)\n", | ||
844 | recording, recording_usec, | 990 | recording, recording_usec, |
845 | ts.year, ts.month, ts.day, ts.hour, | 991 | ts.year, ts.month, ts.day, ts.hour, |
846 | ts.minute, ts.typeAndTimezone); | 992 | ts.minute, ts.typeAndTimezone); |
847 | UDF_SB_RECORDTIME(sb).tv_sec = recording; | 993 | UDF_SB(sb)->s_record_time.tv_sec = recording; |
848 | UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000; | 994 | UDF_SB(sb)->s_record_time.tv_nsec = recording_usec * 1000; |
849 | } | 995 | } |
850 | 996 | ||
851 | if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32)) { | 997 | if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32)) |
852 | if (udf_CS0toUTF8(&outstr, &instr)) { | 998 | if (udf_CS0toUTF8(&outstr, &instr)) { |
853 | strncpy(UDF_SB_VOLIDENT(sb), outstr.u_name, | 999 | strncpy(UDF_SB(sb)->s_volume_ident, outstr.u_name, |
854 | outstr.u_len > 31 ? 31 : outstr.u_len); | 1000 | outstr.u_len > 31 ? 31 : outstr.u_len); |
855 | udf_debug("volIdent[] = '%s'\n", UDF_SB_VOLIDENT(sb)); | 1001 | udf_debug("volIdent[] = '%s'\n", |
1002 | UDF_SB(sb)->s_volume_ident); | ||
856 | } | 1003 | } |
857 | } | ||
858 | 1004 | ||
859 | if (!udf_build_ustr(&instr, pvoldesc->volSetIdent, 128)) { | 1005 | if (!udf_build_ustr(&instr, pvoldesc->volSetIdent, 128)) |
860 | if (udf_CS0toUTF8(&outstr, &instr)) | 1006 | if (udf_CS0toUTF8(&outstr, &instr)) |
861 | udf_debug("volSetIdent[] = '%s'\n", outstr.u_name); | 1007 | udf_debug("volSetIdent[] = '%s'\n", outstr.u_name); |
862 | } | ||
863 | } | 1008 | } |
864 | 1009 | ||
865 | static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, | 1010 | static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, |
@@ -871,65 +1016,124 @@ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, | |||
871 | 1016 | ||
872 | *root = lelb_to_cpu(fset->rootDirectoryICB.extLocation); | 1017 | *root = lelb_to_cpu(fset->rootDirectoryICB.extLocation); |
873 | 1018 | ||
874 | UDF_SB_SERIALNUM(sb) = le16_to_cpu(fset->descTag.tagSerialNum); | 1019 | UDF_SB(sb)->s_serial_number = le16_to_cpu(fset->descTag.tagSerialNum); |
875 | 1020 | ||
876 | udf_debug("Rootdir at block=%d, partition=%d\n", | 1021 | udf_debug("Rootdir at block=%d, partition=%d\n", |
877 | root->logicalBlockNum, root->partitionReferenceNum); | 1022 | root->logicalBlockNum, root->partitionReferenceNum); |
878 | } | 1023 | } |
879 | 1024 | ||
1025 | int udf_compute_nr_groups(struct super_block *sb, u32 partition) | ||
1026 | { | ||
1027 | struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; | ||
1028 | return (map->s_partition_len + | ||
1029 | (sizeof(struct spaceBitmapDesc) << 3) + | ||
1030 | (sb->s_blocksize * 8) - 1) / | ||
1031 | (sb->s_blocksize * 8); | ||
1032 | } | ||
1033 | |||
1034 | static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index) | ||
1035 | { | ||
1036 | struct udf_bitmap *bitmap; | ||
1037 | int nr_groups; | ||
1038 | int size; | ||
1039 | |||
1040 | nr_groups = udf_compute_nr_groups(sb, index); | ||
1041 | size = sizeof(struct udf_bitmap) + | ||
1042 | (sizeof(struct buffer_head *) * nr_groups); | ||
1043 | |||
1044 | if (size <= PAGE_SIZE) | ||
1045 | bitmap = kmalloc(size, GFP_KERNEL); | ||
1046 | else | ||
1047 | bitmap = vmalloc(size); /* TODO: get rid of vmalloc */ | ||
1048 | |||
1049 | if (bitmap == NULL) { | ||
1050 | udf_error(sb, __FUNCTION__, | ||
1051 | "Unable to allocate space for bitmap " | ||
1052 | "and %d buffer_head pointers", nr_groups); | ||
1053 | return NULL; | ||
1054 | } | ||
1055 | |||
1056 | memset(bitmap, 0x00, size); | ||
1057 | bitmap->s_block_bitmap = (struct buffer_head **)(bitmap + 1); | ||
1058 | bitmap->s_nr_groups = nr_groups; | ||
1059 | return bitmap; | ||
1060 | } | ||
1061 | |||
880 | static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) | 1062 | static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) |
881 | { | 1063 | { |
882 | struct partitionDesc *p; | 1064 | struct partitionDesc *p; |
883 | int i; | 1065 | int i; |
1066 | struct udf_part_map *map; | ||
1067 | struct udf_sb_info *sbi; | ||
884 | 1068 | ||
885 | p = (struct partitionDesc *)bh->b_data; | 1069 | p = (struct partitionDesc *)bh->b_data; |
1070 | sbi = UDF_SB(sb); | ||
886 | 1071 | ||
887 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { | 1072 | for (i = 0; i < sbi->s_partitions; i++) { |
1073 | map = &sbi->s_partmaps[i]; | ||
888 | udf_debug("Searching map: (%d == %d)\n", | 1074 | udf_debug("Searching map: (%d == %d)\n", |
889 | UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber)); | 1075 | map->s_partition_num, |
890 | if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) { | 1076 | le16_to_cpu(p->partitionNumber)); |
891 | UDF_SB_PARTLEN(sb,i) = le32_to_cpu(p->partitionLength); /* blocks */ | 1077 | if (map->s_partition_num == |
892 | UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation); | 1078 | le16_to_cpu(p->partitionNumber)) { |
893 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY) | 1079 | map->s_partition_len = |
894 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_READ_ONLY; | 1080 | le32_to_cpu(p->partitionLength); /* blocks */ |
895 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE) | 1081 | map->s_partition_root = |
896 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_WRITE_ONCE; | 1082 | le32_to_cpu(p->partitionStartingLocation); |
897 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE) | 1083 | if (p->accessType == |
898 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_REWRITABLE; | 1084 | cpu_to_le32(PD_ACCESS_TYPE_READ_ONLY)) |
899 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE) | 1085 | map->s_partition_flags |= |
900 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_OVERWRITABLE; | 1086 | UDF_PART_FLAG_READ_ONLY; |
901 | 1087 | if (p->accessType == | |
902 | if (!strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) || | 1088 | cpu_to_le32(PD_ACCESS_TYPE_WRITE_ONCE)) |
903 | !strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) { | 1089 | map->s_partition_flags |= |
1090 | UDF_PART_FLAG_WRITE_ONCE; | ||
1091 | if (p->accessType == | ||
1092 | cpu_to_le32(PD_ACCESS_TYPE_REWRITABLE)) | ||
1093 | map->s_partition_flags |= | ||
1094 | UDF_PART_FLAG_REWRITABLE; | ||
1095 | if (p->accessType == | ||
1096 | cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE)) | ||
1097 | map->s_partition_flags |= | ||
1098 | UDF_PART_FLAG_OVERWRITABLE; | ||
1099 | |||
1100 | if (!strcmp(p->partitionContents.ident, | ||
1101 | PD_PARTITION_CONTENTS_NSR02) || | ||
1102 | !strcmp(p->partitionContents.ident, | ||
1103 | PD_PARTITION_CONTENTS_NSR03)) { | ||
904 | struct partitionHeaderDesc *phd; | 1104 | struct partitionHeaderDesc *phd; |
905 | 1105 | ||
906 | phd = (struct partitionHeaderDesc *)(p->partitionContentsUse); | 1106 | phd = (struct partitionHeaderDesc *) |
1107 | (p->partitionContentsUse); | ||
907 | if (phd->unallocSpaceTable.extLength) { | 1108 | if (phd->unallocSpaceTable.extLength) { |
908 | kernel_lb_addr loc = { | 1109 | kernel_lb_addr loc = { |
909 | .logicalBlockNum = le32_to_cpu(phd->unallocSpaceTable.extPosition), | 1110 | .logicalBlockNum = le32_to_cpu(phd->unallocSpaceTable.extPosition), |
910 | .partitionReferenceNum = i, | 1111 | .partitionReferenceNum = i, |
911 | }; | 1112 | }; |
912 | 1113 | ||
913 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table = | 1114 | map->s_uspace.s_table = |
914 | udf_iget(sb, loc); | 1115 | udf_iget(sb, loc); |
915 | if (!UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table) { | 1116 | if (!map->s_uspace.s_table) { |
916 | udf_debug("cannot load unallocSpaceTable (part %d)\n", i); | 1117 | udf_debug("cannot load unallocSpaceTable (part %d)\n", i); |
917 | return 1; | 1118 | return 1; |
918 | } | 1119 | } |
919 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_TABLE; | 1120 | map->s_partition_flags |= |
1121 | UDF_PART_FLAG_UNALLOC_TABLE; | ||
920 | udf_debug("unallocSpaceTable (part %d) @ %ld\n", | 1122 | udf_debug("unallocSpaceTable (part %d) @ %ld\n", |
921 | i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino); | 1123 | i, map->s_uspace.s_table->i_ino); |
922 | } | 1124 | } |
923 | if (phd->unallocSpaceBitmap.extLength) { | 1125 | if (phd->unallocSpaceBitmap.extLength) { |
924 | UDF_SB_ALLOC_BITMAP(sb, i, s_uspace); | 1126 | struct udf_bitmap *bitmap = |
925 | if (UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap != NULL) { | 1127 | udf_sb_alloc_bitmap(sb, i); |
926 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extLength = | 1128 | map->s_uspace.s_bitmap = bitmap; |
1129 | if (bitmap != NULL) { | ||
1130 | bitmap->s_extLength = | ||
927 | le32_to_cpu(phd->unallocSpaceBitmap.extLength); | 1131 | le32_to_cpu(phd->unallocSpaceBitmap.extLength); |
928 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition = | 1132 | bitmap->s_extPosition = |
929 | le32_to_cpu(phd->unallocSpaceBitmap.extPosition); | 1133 | le32_to_cpu(phd->unallocSpaceBitmap.extPosition); |
930 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_BITMAP; | 1134 | map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP; |
931 | udf_debug("unallocSpaceBitmap (part %d) @ %d\n", | 1135 | udf_debug("unallocSpaceBitmap (part %d) @ %d\n", |
932 | i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition); | 1136 | i, bitmap->s_extPosition); |
933 | } | 1137 | } |
934 | } | 1138 | } |
935 | if (phd->partitionIntegrityTable.extLength) | 1139 | if (phd->partitionIntegrityTable.extLength) |
@@ -940,40 +1144,45 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) | |||
940 | .partitionReferenceNum = i, | 1144 | .partitionReferenceNum = i, |
941 | }; | 1145 | }; |
942 | 1146 | ||
943 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table = | 1147 | map->s_fspace.s_table = |
944 | udf_iget(sb, loc); | 1148 | udf_iget(sb, loc); |
945 | if (!UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table) { | 1149 | if (!map->s_fspace.s_table) { |
946 | udf_debug("cannot load freedSpaceTable (part %d)\n", i); | 1150 | udf_debug("cannot load freedSpaceTable (part %d)\n", i); |
947 | return 1; | 1151 | return 1; |
948 | } | 1152 | } |
949 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_TABLE; | 1153 | map->s_partition_flags |= |
1154 | UDF_PART_FLAG_FREED_TABLE; | ||
950 | udf_debug("freedSpaceTable (part %d) @ %ld\n", | 1155 | udf_debug("freedSpaceTable (part %d) @ %ld\n", |
951 | i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino); | 1156 | i, map->s_fspace.s_table->i_ino); |
952 | } | 1157 | } |
953 | if (phd->freedSpaceBitmap.extLength) { | 1158 | if (phd->freedSpaceBitmap.extLength) { |
954 | UDF_SB_ALLOC_BITMAP(sb, i, s_fspace); | 1159 | struct udf_bitmap *bitmap = |
955 | if (UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap != NULL) { | 1160 | udf_sb_alloc_bitmap(sb, i); |
956 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extLength = | 1161 | map->s_fspace.s_bitmap = bitmap; |
1162 | if (bitmap != NULL) { | ||
1163 | bitmap->s_extLength = | ||
957 | le32_to_cpu(phd->freedSpaceBitmap.extLength); | 1164 | le32_to_cpu(phd->freedSpaceBitmap.extLength); |
958 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition = | 1165 | bitmap->s_extPosition = |
959 | le32_to_cpu(phd->freedSpaceBitmap.extPosition); | 1166 | le32_to_cpu(phd->freedSpaceBitmap.extPosition); |
960 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_BITMAP; | 1167 | map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP; |
961 | udf_debug("freedSpaceBitmap (part %d) @ %d\n", | 1168 | udf_debug("freedSpaceBitmap (part %d) @ %d\n", |
962 | i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition); | 1169 | i, bitmap->s_extPosition); |
963 | } | 1170 | } |
964 | } | 1171 | } |
965 | } | 1172 | } |
966 | break; | 1173 | break; |
967 | } | 1174 | } |
968 | } | 1175 | } |
969 | if (i == UDF_SB_NUMPARTS(sb)) { | 1176 | if (i == sbi->s_partitions) |
970 | udf_debug("Partition (%d) not found in partition map\n", | 1177 | udf_debug("Partition (%d) not found in partition map\n", |
971 | le16_to_cpu(p->partitionNumber)); | 1178 | le16_to_cpu(p->partitionNumber)); |
972 | } else { | 1179 | else |
973 | udf_debug("Partition (%d:%d type %x) starts at physical %d, block length %d\n", | 1180 | udf_debug("Partition (%d:%d type %x) starts at physical %d, " |
974 | le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb,i), | 1181 | "block length %d\n", |
975 | UDF_SB_PARTROOT(sb,i), UDF_SB_PARTLEN(sb,i)); | 1182 | le16_to_cpu(p->partitionNumber), i, |
976 | } | 1183 | map->s_partition_type, |
1184 | map->s_partition_root, | ||
1185 | map->s_partition_len); | ||
977 | return 0; | 1186 | return 0; |
978 | } | 1187 | } |
979 | 1188 | ||
@@ -983,70 +1192,105 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh, | |||
983 | struct logicalVolDesc *lvd; | 1192 | struct logicalVolDesc *lvd; |
984 | int i, j, offset; | 1193 | int i, j, offset; |
985 | uint8_t type; | 1194 | uint8_t type; |
1195 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
1196 | struct genericPartitionMap *gpm; | ||
986 | 1197 | ||
987 | lvd = (struct logicalVolDesc *)bh->b_data; | 1198 | lvd = (struct logicalVolDesc *)bh->b_data; |
988 | 1199 | ||
989 | UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps)); | 1200 | i = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps)); |
1201 | if (i != 0) | ||
1202 | return i; | ||
990 | 1203 | ||
991 | for (i = 0, offset = 0; | 1204 | for (i = 0, offset = 0; |
992 | i < UDF_SB_NUMPARTS(sb) && offset < le32_to_cpu(lvd->mapTableLength); | 1205 | i < sbi->s_partitions && offset < le32_to_cpu(lvd->mapTableLength); |
993 | i++, offset += ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength) { | 1206 | i++, offset += gpm->partitionMapLength) { |
994 | type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType; | 1207 | struct udf_part_map *map = &sbi->s_partmaps[i]; |
1208 | gpm = (struct genericPartitionMap *) | ||
1209 | &(lvd->partitionMaps[offset]); | ||
1210 | type = gpm->partitionMapType; | ||
995 | if (type == 1) { | 1211 | if (type == 1) { |
996 | struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]); | 1212 | struct genericPartitionMap1 *gpm1 = |
997 | UDF_SB_PARTTYPE(sb,i) = UDF_TYPE1_MAP15; | 1213 | (struct genericPartitionMap1 *)gpm; |
998 | UDF_SB_PARTVSN(sb,i) = le16_to_cpu(gpm1->volSeqNum); | 1214 | map->s_partition_type = UDF_TYPE1_MAP15; |
999 | UDF_SB_PARTNUM(sb,i) = le16_to_cpu(gpm1->partitionNum); | 1215 | map->s_volumeseqnum = le16_to_cpu(gpm1->volSeqNum); |
1000 | UDF_SB_PARTFUNC(sb,i) = NULL; | 1216 | map->s_partition_num = le16_to_cpu(gpm1->partitionNum); |
1217 | map->s_partition_func = NULL; | ||
1001 | } else if (type == 2) { | 1218 | } else if (type == 2) { |
1002 | struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]); | 1219 | struct udfPartitionMap2 *upm2 = |
1003 | if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) { | 1220 | (struct udfPartitionMap2 *)gpm; |
1004 | if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) { | 1221 | if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, |
1005 | UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP15; | 1222 | strlen(UDF_ID_VIRTUAL))) { |
1006 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt15; | 1223 | u16 suf = |
1007 | } else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) { | 1224 | le16_to_cpu(((__le16 *)upm2->partIdent. |
1008 | UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP20; | 1225 | identSuffix)[0]); |
1009 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt20; | 1226 | if (suf == 0x0150) { |
1227 | map->s_partition_type = | ||
1228 | UDF_VIRTUAL_MAP15; | ||
1229 | map->s_partition_func = | ||
1230 | udf_get_pblock_virt15; | ||
1231 | } else if (suf == 0x0200) { | ||
1232 | map->s_partition_type = | ||
1233 | UDF_VIRTUAL_MAP20; | ||
1234 | map->s_partition_func = | ||
1235 | udf_get_pblock_virt20; | ||
1010 | } | 1236 | } |
1011 | } else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) { | 1237 | } else if (!strncmp(upm2->partIdent.ident, |
1238 | UDF_ID_SPARABLE, | ||
1239 | strlen(UDF_ID_SPARABLE))) { | ||
1012 | uint32_t loc; | 1240 | uint32_t loc; |
1013 | uint16_t ident; | 1241 | uint16_t ident; |
1014 | struct sparingTable *st; | 1242 | struct sparingTable *st; |
1015 | struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]); | 1243 | struct sparablePartitionMap *spm = |
1244 | (struct sparablePartitionMap *)gpm; | ||
1016 | 1245 | ||
1017 | UDF_SB_PARTTYPE(sb,i) = UDF_SPARABLE_MAP15; | 1246 | map->s_partition_type = UDF_SPARABLE_MAP15; |
1018 | UDF_SB_TYPESPAR(sb,i).s_packet_len = le16_to_cpu(spm->packetLength); | 1247 | map->s_type_specific.s_sparing.s_packet_len = |
1248 | le16_to_cpu(spm->packetLength); | ||
1019 | for (j = 0; j < spm->numSparingTables; j++) { | 1249 | for (j = 0; j < spm->numSparingTables; j++) { |
1020 | loc = le32_to_cpu(spm->locSparingTable[j]); | 1250 | struct buffer_head *bh2; |
1021 | UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = | 1251 | |
1022 | udf_read_tagged(sb, loc, loc, &ident); | 1252 | loc = le32_to_cpu( |
1023 | if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) { | 1253 | spm->locSparingTable[j]); |
1024 | st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,i).s_spar_map[j]->b_data; | 1254 | bh2 = udf_read_tagged(sb, loc, loc, |
1025 | if (ident != 0 || | 1255 | &ident); |
1026 | strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) { | 1256 | map->s_type_specific.s_sparing. |
1027 | brelse(UDF_SB_TYPESPAR(sb,i).s_spar_map[j]); | 1257 | s_spar_map[j] = bh2; |
1028 | UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = NULL; | 1258 | |
1259 | if (bh2 != NULL) { | ||
1260 | st = (struct sparingTable *) | ||
1261 | bh2->b_data; | ||
1262 | if (ident != 0 || strncmp( | ||
1263 | st->sparingIdent.ident, | ||
1264 | UDF_ID_SPARING, | ||
1265 | strlen(UDF_ID_SPARING))) { | ||
1266 | brelse(bh2); | ||
1267 | map->s_type_specific. | ||
1268 | s_sparing. | ||
1269 | s_spar_map[j] = | ||
1270 | NULL; | ||
1029 | } | 1271 | } |
1030 | } | 1272 | } |
1031 | } | 1273 | } |
1032 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_spar15; | 1274 | map->s_partition_func = udf_get_pblock_spar15; |
1033 | } else { | 1275 | } else { |
1034 | udf_debug("Unknown ident: %s\n", upm2->partIdent.ident); | 1276 | udf_debug("Unknown ident: %s\n", |
1277 | upm2->partIdent.ident); | ||
1035 | continue; | 1278 | continue; |
1036 | } | 1279 | } |
1037 | UDF_SB_PARTVSN(sb,i) = le16_to_cpu(upm2->volSeqNum); | 1280 | map->s_volumeseqnum = le16_to_cpu(upm2->volSeqNum); |
1038 | UDF_SB_PARTNUM(sb,i) = le16_to_cpu(upm2->partitionNum); | 1281 | map->s_partition_num = le16_to_cpu(upm2->partitionNum); |
1039 | } | 1282 | } |
1040 | udf_debug("Partition (%d:%d) type %d on volume %d\n", | 1283 | udf_debug("Partition (%d:%d) type %d on volume %d\n", |
1041 | i, UDF_SB_PARTNUM(sb,i), type, UDF_SB_PARTVSN(sb,i)); | 1284 | i, map->s_partition_num, type, |
1285 | map->s_volumeseqnum); | ||
1042 | } | 1286 | } |
1043 | 1287 | ||
1044 | if (fileset) { | 1288 | if (fileset) { |
1045 | long_ad *la = (long_ad *)&(lvd->logicalVolContentsUse[0]); | 1289 | long_ad *la = (long_ad *)&(lvd->logicalVolContentsUse[0]); |
1046 | 1290 | ||
1047 | *fileset = lelb_to_cpu(la->extLocation); | 1291 | *fileset = lelb_to_cpu(la->extLocation); |
1048 | udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n", | 1292 | udf_debug("FileSet found in LogicalVolDesc at block=%d, " |
1049 | fileset->logicalBlockNum, | 1293 | "partition=%d\n", fileset->logicalBlockNum, |
1050 | fileset->partitionReferenceNum); | 1294 | fileset->partitionReferenceNum); |
1051 | } | 1295 | } |
1052 | if (lvd->integritySeqExt.extLength) | 1296 | if (lvd->integritySeqExt.extLength) |
@@ -1063,22 +1307,26 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc) | |||
1063 | { | 1307 | { |
1064 | struct buffer_head *bh = NULL; | 1308 | struct buffer_head *bh = NULL; |
1065 | uint16_t ident; | 1309 | uint16_t ident; |
1310 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
1311 | struct logicalVolIntegrityDesc *lvid; | ||
1066 | 1312 | ||
1067 | while (loc.extLength > 0 && | 1313 | while (loc.extLength > 0 && |
1068 | (bh = udf_read_tagged(sb, loc.extLocation, | 1314 | (bh = udf_read_tagged(sb, loc.extLocation, |
1069 | loc.extLocation, &ident)) && | 1315 | loc.extLocation, &ident)) && |
1070 | ident == TAG_IDENT_LVID) { | 1316 | ident == TAG_IDENT_LVID) { |
1071 | UDF_SB_LVIDBH(sb) = bh; | 1317 | sbi->s_lvid_bh = bh; |
1318 | lvid = (struct logicalVolIntegrityDesc *)bh->b_data; | ||
1072 | 1319 | ||
1073 | if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength) | 1320 | if (lvid->nextIntegrityExt.extLength) |
1074 | udf_load_logicalvolint(sb, leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt)); | 1321 | udf_load_logicalvolint(sb, |
1322 | leea_to_cpu(lvid->nextIntegrityExt)); | ||
1075 | 1323 | ||
1076 | if (UDF_SB_LVIDBH(sb) != bh) | 1324 | if (sbi->s_lvid_bh != bh) |
1077 | brelse(bh); | 1325 | brelse(bh); |
1078 | loc.extLength -= sb->s_blocksize; | 1326 | loc.extLength -= sb->s_blocksize; |
1079 | loc.extLocation++; | 1327 | loc.extLocation++; |
1080 | } | 1328 | } |
1081 | if (UDF_SB_LVIDBH(sb) != bh) | 1329 | if (sbi->s_lvid_bh != bh) |
1082 | brelse(bh); | 1330 | brelse(bh); |
1083 | } | 1331 | } |
1084 | 1332 | ||
@@ -1097,11 +1345,12 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc) | |||
1097 | * July 1, 1997 - Andrew E. Mileski | 1345 | * July 1, 1997 - Andrew E. Mileski |
1098 | * Written, tested, and released. | 1346 | * Written, tested, and released. |
1099 | */ | 1347 | */ |
1100 | static int udf_process_sequence(struct super_block *sb, long block, long lastblock, | 1348 | static int udf_process_sequence(struct super_block *sb, long block, |
1101 | kernel_lb_addr *fileset) | 1349 | long lastblock, kernel_lb_addr *fileset) |
1102 | { | 1350 | { |
1103 | struct buffer_head *bh = NULL; | 1351 | struct buffer_head *bh = NULL; |
1104 | struct udf_vds_record vds[VDS_POS_LENGTH]; | 1352 | struct udf_vds_record vds[VDS_POS_LENGTH]; |
1353 | struct udf_vds_record *curr; | ||
1105 | struct generic_desc *gd; | 1354 | struct generic_desc *gd; |
1106 | struct volDescPtr *vdp; | 1355 | struct volDescPtr *vdp; |
1107 | int done = 0; | 1356 | int done = 0; |
@@ -1124,43 +1373,51 @@ static int udf_process_sequence(struct super_block *sb, long block, long lastblo | |||
1124 | vdsn = le32_to_cpu(gd->volDescSeqNum); | 1373 | vdsn = le32_to_cpu(gd->volDescSeqNum); |
1125 | switch (ident) { | 1374 | switch (ident) { |
1126 | case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */ | 1375 | case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */ |
1127 | if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum) { | 1376 | curr = &vds[VDS_POS_PRIMARY_VOL_DESC]; |
1128 | vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = vdsn; | 1377 | if (vdsn >= curr->volDescSeqNum) { |
1129 | vds[VDS_POS_PRIMARY_VOL_DESC].block = block; | 1378 | curr->volDescSeqNum = vdsn; |
1379 | curr->block = block; | ||
1130 | } | 1380 | } |
1131 | break; | 1381 | break; |
1132 | case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */ | 1382 | case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */ |
1133 | if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum) { | 1383 | curr = &vds[VDS_POS_VOL_DESC_PTR]; |
1134 | vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn; | 1384 | if (vdsn >= curr->volDescSeqNum) { |
1135 | vds[VDS_POS_VOL_DESC_PTR].block = block; | 1385 | curr->volDescSeqNum = vdsn; |
1386 | curr->block = block; | ||
1136 | 1387 | ||
1137 | vdp = (struct volDescPtr *)bh->b_data; | 1388 | vdp = (struct volDescPtr *)bh->b_data; |
1138 | next_s = le32_to_cpu(vdp->nextVolDescSeqExt.extLocation); | 1389 | next_s = le32_to_cpu( |
1139 | next_e = le32_to_cpu(vdp->nextVolDescSeqExt.extLength); | 1390 | vdp->nextVolDescSeqExt.extLocation); |
1391 | next_e = le32_to_cpu( | ||
1392 | vdp->nextVolDescSeqExt.extLength); | ||
1140 | next_e = next_e >> sb->s_blocksize_bits; | 1393 | next_e = next_e >> sb->s_blocksize_bits; |
1141 | next_e += next_s; | 1394 | next_e += next_s; |
1142 | } | 1395 | } |
1143 | break; | 1396 | break; |
1144 | case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */ | 1397 | case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */ |
1145 | if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum) { | 1398 | curr = &vds[VDS_POS_IMP_USE_VOL_DESC]; |
1146 | vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = vdsn; | 1399 | if (vdsn >= curr->volDescSeqNum) { |
1147 | vds[VDS_POS_IMP_USE_VOL_DESC].block = block; | 1400 | curr->volDescSeqNum = vdsn; |
1401 | curr->block = block; | ||
1148 | } | 1402 | } |
1149 | break; | 1403 | break; |
1150 | case TAG_IDENT_PD: /* ISO 13346 3/10.5 */ | 1404 | case TAG_IDENT_PD: /* ISO 13346 3/10.5 */ |
1151 | if (!vds[VDS_POS_PARTITION_DESC].block) | 1405 | curr = &vds[VDS_POS_PARTITION_DESC]; |
1152 | vds[VDS_POS_PARTITION_DESC].block = block; | 1406 | if (!curr->block) |
1407 | curr->block = block; | ||
1153 | break; | 1408 | break; |
1154 | case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ | 1409 | case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ |
1155 | if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum) { | 1410 | curr = &vds[VDS_POS_LOGICAL_VOL_DESC]; |
1156 | vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = vdsn; | 1411 | if (vdsn >= curr->volDescSeqNum) { |
1157 | vds[VDS_POS_LOGICAL_VOL_DESC].block = block; | 1412 | curr->volDescSeqNum = vdsn; |
1413 | curr->block = block; | ||
1158 | } | 1414 | } |
1159 | break; | 1415 | break; |
1160 | case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ | 1416 | case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ |
1161 | if (vdsn >= vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum) { | 1417 | curr = &vds[VDS_POS_UNALLOC_SPACE_DESC]; |
1162 | vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum = vdsn; | 1418 | if (vdsn >= curr->volDescSeqNum) { |
1163 | vds[VDS_POS_UNALLOC_SPACE_DESC].block = block; | 1419 | curr->volDescSeqNum = vdsn; |
1420 | curr->block = block; | ||
1164 | } | 1421 | } |
1165 | break; | 1422 | break; |
1166 | case TAG_IDENT_TD: /* ISO 13346 3/10.9 */ | 1423 | case TAG_IDENT_TD: /* ISO 13346 3/10.9 */ |
@@ -1169,32 +1426,38 @@ static int udf_process_sequence(struct super_block *sb, long block, long lastblo | |||
1169 | block = next_s; | 1426 | block = next_s; |
1170 | lastblock = next_e; | 1427 | lastblock = next_e; |
1171 | next_s = next_e = 0; | 1428 | next_s = next_e = 0; |
1172 | } else { | 1429 | } else |
1173 | done = 1; | 1430 | done = 1; |
1174 | } | ||
1175 | break; | 1431 | break; |
1176 | } | 1432 | } |
1177 | brelse(bh); | 1433 | brelse(bh); |
1178 | } | 1434 | } |
1179 | for (i = 0; i < VDS_POS_LENGTH; i++) { | 1435 | for (i = 0; i < VDS_POS_LENGTH; i++) { |
1180 | if (vds[i].block) { | 1436 | if (vds[i].block) { |
1181 | bh = udf_read_tagged(sb, vds[i].block, vds[i].block, &ident); | 1437 | bh = udf_read_tagged(sb, vds[i].block, vds[i].block, |
1438 | &ident); | ||
1182 | 1439 | ||
1183 | if (i == VDS_POS_PRIMARY_VOL_DESC) { | 1440 | if (i == VDS_POS_PRIMARY_VOL_DESC) { |
1184 | udf_load_pvoldesc(sb, bh); | 1441 | udf_load_pvoldesc(sb, bh); |
1185 | } else if (i == VDS_POS_LOGICAL_VOL_DESC) { | 1442 | } else if (i == VDS_POS_LOGICAL_VOL_DESC) { |
1186 | udf_load_logicalvol(sb, bh, fileset); | 1443 | if (udf_load_logicalvol(sb, bh, fileset)) { |
1444 | brelse(bh); | ||
1445 | return 1; | ||
1446 | } | ||
1187 | } else if (i == VDS_POS_PARTITION_DESC) { | 1447 | } else if (i == VDS_POS_PARTITION_DESC) { |
1188 | struct buffer_head *bh2 = NULL; | 1448 | struct buffer_head *bh2 = NULL; |
1189 | if (udf_load_partdesc(sb, bh)) { | 1449 | if (udf_load_partdesc(sb, bh)) { |
1190 | brelse(bh); | 1450 | brelse(bh); |
1191 | return 1; | 1451 | return 1; |
1192 | } | 1452 | } |
1193 | for (j = vds[i].block + 1; j < vds[VDS_POS_TERMINATING_DESC].block; j++) { | 1453 | for (j = vds[i].block + 1; |
1454 | j < vds[VDS_POS_TERMINATING_DESC].block; | ||
1455 | j++) { | ||
1194 | bh2 = udf_read_tagged(sb, j, j, &ident); | 1456 | bh2 = udf_read_tagged(sb, j, j, &ident); |
1195 | gd = (struct generic_desc *)bh2->b_data; | 1457 | gd = (struct generic_desc *)bh2->b_data; |
1196 | if (ident == TAG_IDENT_PD) | 1458 | if (ident == TAG_IDENT_PD) |
1197 | if (udf_load_partdesc(sb, bh2)) { | 1459 | if (udf_load_partdesc(sb, |
1460 | bh2)) { | ||
1198 | brelse(bh); | 1461 | brelse(bh); |
1199 | brelse(bh2); | 1462 | brelse(bh2); |
1200 | return 1; | 1463 | return 1; |
@@ -1222,14 +1485,17 @@ static int udf_check_valid(struct super_block *sb, int novrs, int silent) | |||
1222 | } | 1485 | } |
1223 | /* Check that it is NSR02 compliant */ | 1486 | /* Check that it is NSR02 compliant */ |
1224 | /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ | 1487 | /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ |
1225 | else if ((block = udf_vrs(sb, silent)) == -1) { | 1488 | else { |
1226 | udf_debug("Failed to read byte 32768. Assuming open disc. " | 1489 | block = udf_vrs(sb, silent); |
1227 | "Skipping validity check\n"); | 1490 | if (block == -1) { |
1228 | if (!UDF_SB_LASTBLOCK(sb)) | 1491 | struct udf_sb_info *sbi = UDF_SB(sb); |
1229 | UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); | 1492 | udf_debug("Failed to read byte 32768. Assuming open " |
1230 | return 0; | 1493 | "disc. Skipping validity check\n"); |
1231 | } else { | 1494 | if (!sbi->s_last_block) |
1232 | return !block; | 1495 | sbi->s_last_block = udf_get_last_block(sb); |
1496 | return 0; | ||
1497 | } else | ||
1498 | return !block; | ||
1233 | } | 1499 | } |
1234 | } | 1500 | } |
1235 | 1501 | ||
@@ -1240,100 +1506,121 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | |||
1240 | struct buffer_head *bh; | 1506 | struct buffer_head *bh; |
1241 | long main_s, main_e, reserve_s, reserve_e; | 1507 | long main_s, main_e, reserve_s, reserve_e; |
1242 | int i, j; | 1508 | int i, j; |
1509 | struct udf_sb_info *sbi; | ||
1243 | 1510 | ||
1244 | if (!sb) | 1511 | if (!sb) |
1245 | return 1; | 1512 | return 1; |
1513 | sbi = UDF_SB(sb); | ||
1246 | 1514 | ||
1247 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { | 1515 | for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { |
1248 | if (UDF_SB_ANCHOR(sb)[i] && | 1516 | if (!sbi->s_anchor[i]) |
1249 | (bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i], | 1517 | continue; |
1250 | UDF_SB_ANCHOR(sb)[i], &ident))) { | 1518 | bh = udf_read_tagged(sb, sbi->s_anchor[i], sbi->s_anchor[i], |
1251 | anchor = (struct anchorVolDescPtr *)bh->b_data; | 1519 | &ident); |
1520 | if (!bh) | ||
1521 | continue; | ||
1252 | 1522 | ||
1253 | /* Locate the main sequence */ | 1523 | anchor = (struct anchorVolDescPtr *)bh->b_data; |
1254 | main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation); | ||
1255 | main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength ); | ||
1256 | main_e = main_e >> sb->s_blocksize_bits; | ||
1257 | main_e += main_s; | ||
1258 | 1524 | ||
1259 | /* Locate the reserve sequence */ | 1525 | /* Locate the main sequence */ |
1260 | reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation); | 1526 | main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation); |
1261 | reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength); | 1527 | main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength); |
1262 | reserve_e = reserve_e >> sb->s_blocksize_bits; | 1528 | main_e = main_e >> sb->s_blocksize_bits; |
1263 | reserve_e += reserve_s; | 1529 | main_e += main_s; |
1264 | 1530 | ||
1265 | brelse(bh); | 1531 | /* Locate the reserve sequence */ |
1532 | reserve_s = le32_to_cpu( | ||
1533 | anchor->reserveVolDescSeqExt.extLocation); | ||
1534 | reserve_e = le32_to_cpu( | ||
1535 | anchor->reserveVolDescSeqExt.extLength); | ||
1536 | reserve_e = reserve_e >> sb->s_blocksize_bits; | ||
1537 | reserve_e += reserve_s; | ||
1266 | 1538 | ||
1267 | /* Process the main & reserve sequences */ | 1539 | brelse(bh); |
1268 | /* responsible for finding the PartitionDesc(s) */ | 1540 | |
1269 | if (!(udf_process_sequence(sb, main_s, main_e, fileset) && | 1541 | /* Process the main & reserve sequences */ |
1270 | udf_process_sequence(sb, reserve_s, reserve_e, fileset))) { | 1542 | /* responsible for finding the PartitionDesc(s) */ |
1271 | break; | 1543 | if (!(udf_process_sequence(sb, main_s, main_e, |
1272 | } | 1544 | fileset) && |
1273 | } | 1545 | udf_process_sequence(sb, reserve_s, reserve_e, |
1546 | fileset))) | ||
1547 | break; | ||
1274 | } | 1548 | } |
1275 | 1549 | ||
1276 | if (i == ARRAY_SIZE(UDF_SB_ANCHOR(sb))) { | 1550 | if (i == ARRAY_SIZE(sbi->s_anchor)) { |
1277 | udf_debug("No Anchor block found\n"); | 1551 | udf_debug("No Anchor block found\n"); |
1278 | return 1; | 1552 | return 1; |
1279 | } else | 1553 | } |
1280 | udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]); | 1554 | udf_debug("Using anchor in block %d\n", sbi->s_anchor[i]); |
1281 | 1555 | ||
1282 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { | 1556 | for (i = 0; i < sbi->s_partitions; i++) { |
1283 | kernel_lb_addr uninitialized_var(ino); | 1557 | kernel_lb_addr uninitialized_var(ino); |
1284 | switch (UDF_SB_PARTTYPE(sb, i)) { | 1558 | struct udf_part_map *map = &sbi->s_partmaps[i]; |
1559 | switch (map->s_partition_type) { | ||
1285 | case UDF_VIRTUAL_MAP15: | 1560 | case UDF_VIRTUAL_MAP15: |
1286 | case UDF_VIRTUAL_MAP20: | 1561 | case UDF_VIRTUAL_MAP20: |
1287 | if (!UDF_SB_LASTBLOCK(sb)) { | 1562 | if (!sbi->s_last_block) { |
1288 | UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); | 1563 | sbi->s_last_block = udf_get_last_block(sb); |
1289 | udf_find_anchor(sb); | 1564 | udf_find_anchor(sb); |
1290 | } | 1565 | } |
1291 | 1566 | ||
1292 | if (!UDF_SB_LASTBLOCK(sb)) { | 1567 | if (!sbi->s_last_block) { |
1293 | udf_debug("Unable to determine Lastblock (For " | 1568 | udf_debug("Unable to determine Lastblock (For " |
1294 | "Virtual Partition)\n"); | 1569 | "Virtual Partition)\n"); |
1295 | return 1; | 1570 | return 1; |
1296 | } | 1571 | } |
1297 | 1572 | ||
1298 | for (j = 0; j < UDF_SB_NUMPARTS(sb); j++) { | 1573 | for (j = 0; j < sbi->s_partitions; j++) { |
1574 | struct udf_part_map *map2 = &sbi->s_partmaps[j]; | ||
1299 | if (j != i && | 1575 | if (j != i && |
1300 | UDF_SB_PARTVSN(sb, i) == UDF_SB_PARTVSN(sb, j) && | 1576 | map->s_volumeseqnum == |
1301 | UDF_SB_PARTNUM(sb, i) == UDF_SB_PARTNUM(sb, j)) { | 1577 | map2->s_volumeseqnum && |
1578 | map->s_partition_num == | ||
1579 | map2->s_partition_num) { | ||
1302 | ino.partitionReferenceNum = j; | 1580 | ino.partitionReferenceNum = j; |
1303 | ino.logicalBlockNum = UDF_SB_LASTBLOCK(sb) - UDF_SB_PARTROOT(sb, j); | 1581 | ino.logicalBlockNum = |
1582 | sbi->s_last_block - | ||
1583 | map2->s_partition_root; | ||
1304 | break; | 1584 | break; |
1305 | } | 1585 | } |
1306 | } | 1586 | } |
1307 | 1587 | ||
1308 | if (j == UDF_SB_NUMPARTS(sb)) | 1588 | if (j == sbi->s_partitions) |
1309 | return 1; | 1589 | return 1; |
1310 | 1590 | ||
1311 | if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino))) | 1591 | sbi->s_vat_inode = udf_iget(sb, ino); |
1592 | if (!sbi->s_vat_inode) | ||
1312 | return 1; | 1593 | return 1; |
1313 | 1594 | ||
1314 | if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) { | 1595 | if (map->s_partition_type == UDF_VIRTUAL_MAP15) { |
1315 | UDF_SB_TYPEVIRT(sb, i).s_start_offset = | 1596 | map->s_type_specific.s_virtual.s_start_offset = |
1316 | udf_ext0_offset(UDF_SB_VAT(sb)); | 1597 | udf_ext0_offset(sbi->s_vat_inode); |
1317 | UDF_SB_TYPEVIRT(sb, i).s_num_entries = | 1598 | map->s_type_specific.s_virtual.s_num_entries = |
1318 | (UDF_SB_VAT(sb)->i_size - 36) >> 2; | 1599 | (sbi->s_vat_inode->i_size - 36) >> 2; |
1319 | } else if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP20) { | 1600 | } else if (map->s_partition_type == UDF_VIRTUAL_MAP20) { |
1320 | struct buffer_head *bh = NULL; | ||
1321 | uint32_t pos; | 1601 | uint32_t pos; |
1602 | struct virtualAllocationTable20 *vat20; | ||
1322 | 1603 | ||
1323 | pos = udf_block_map(UDF_SB_VAT(sb), 0); | 1604 | pos = udf_block_map(sbi->s_vat_inode, 0); |
1324 | bh = sb_bread(sb, pos); | 1605 | bh = sb_bread(sb, pos); |
1325 | if (!bh) | 1606 | if (!bh) |
1326 | return 1; | 1607 | return 1; |
1327 | UDF_SB_TYPEVIRT(sb, i).s_start_offset = | 1608 | vat20 = (struct virtualAllocationTable20 *) |
1328 | le16_to_cpu(((struct virtualAllocationTable20 *)bh->b_data + | 1609 | bh->b_data + |
1329 | udf_ext0_offset(UDF_SB_VAT(sb)))->lengthHeader) + | 1610 | udf_ext0_offset(sbi->s_vat_inode); |
1330 | udf_ext0_offset(UDF_SB_VAT(sb)); | 1611 | map->s_type_specific.s_virtual.s_start_offset = |
1331 | UDF_SB_TYPEVIRT(sb, i).s_num_entries = (UDF_SB_VAT(sb)->i_size - | 1612 | le16_to_cpu(vat20->lengthHeader) + |
1332 | UDF_SB_TYPEVIRT(sb, i).s_start_offset) >> 2; | 1613 | udf_ext0_offset(sbi->s_vat_inode); |
1614 | map->s_type_specific.s_virtual.s_num_entries = | ||
1615 | (sbi->s_vat_inode->i_size - | ||
1616 | map->s_type_specific.s_virtual. | ||
1617 | s_start_offset) >> 2; | ||
1333 | brelse(bh); | 1618 | brelse(bh); |
1334 | } | 1619 | } |
1335 | UDF_SB_PARTROOT(sb, i) = udf_get_pblock(sb, 0, i, 0); | 1620 | map->s_partition_root = udf_get_pblock(sb, 0, i, 0); |
1336 | UDF_SB_PARTLEN(sb, i) = UDF_SB_PARTLEN(sb, ino.partitionReferenceNum); | 1621 | map->s_partition_len = |
1622 | sbi->s_partmaps[ino.partitionReferenceNum]. | ||
1623 | s_partition_len; | ||
1337 | } | 1624 | } |
1338 | } | 1625 | } |
1339 | return 0; | 1626 | return 0; |
@@ -1341,62 +1628,86 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | |||
1341 | 1628 | ||
1342 | static void udf_open_lvid(struct super_block *sb) | 1629 | static void udf_open_lvid(struct super_block *sb) |
1343 | { | 1630 | { |
1344 | if (UDF_SB_LVIDBH(sb)) { | 1631 | struct udf_sb_info *sbi = UDF_SB(sb); |
1345 | int i; | 1632 | struct buffer_head *bh = sbi->s_lvid_bh; |
1633 | if (bh) { | ||
1346 | kernel_timestamp cpu_time; | 1634 | kernel_timestamp cpu_time; |
1635 | struct logicalVolIntegrityDesc *lvid = | ||
1636 | (struct logicalVolIntegrityDesc *)bh->b_data; | ||
1637 | struct logicalVolIntegrityDescImpUse *lvidiu = | ||
1638 | udf_sb_lvidiu(sbi); | ||
1347 | 1639 | ||
1348 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1640 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1349 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1641 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1350 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) | 1642 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) |
1351 | UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time); | 1643 | lvid->recordingDateAndTime = cpu_to_lets(cpu_time); |
1352 | UDF_SB_LVID(sb)->integrityType = LVID_INTEGRITY_TYPE_OPEN; | 1644 | lvid->integrityType = LVID_INTEGRITY_TYPE_OPEN; |
1353 | |||
1354 | UDF_SB_LVID(sb)->descTag.descCRC = cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), | ||
1355 | le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0)); | ||
1356 | 1645 | ||
1357 | UDF_SB_LVID(sb)->descTag.tagChecksum = 0; | 1646 | lvid->descTag.descCRC = cpu_to_le16( |
1358 | for (i = 0; i < 16; i++) | 1647 | udf_crc((char *)lvid + sizeof(tag), |
1359 | if (i != 4) | 1648 | le16_to_cpu(lvid->descTag.descCRCLength), |
1360 | UDF_SB_LVID(sb)->descTag.tagChecksum += | 1649 | 0)); |
1361 | ((uint8_t *) &(UDF_SB_LVID(sb)->descTag))[i]; | ||
1362 | 1650 | ||
1363 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 1651 | lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); |
1652 | mark_buffer_dirty(bh); | ||
1364 | } | 1653 | } |
1365 | } | 1654 | } |
1366 | 1655 | ||
1367 | static void udf_close_lvid(struct super_block *sb) | 1656 | static void udf_close_lvid(struct super_block *sb) |
1368 | { | 1657 | { |
1369 | kernel_timestamp cpu_time; | 1658 | kernel_timestamp cpu_time; |
1370 | int i; | 1659 | struct udf_sb_info *sbi = UDF_SB(sb); |
1660 | struct buffer_head *bh = sbi->s_lvid_bh; | ||
1661 | struct logicalVolIntegrityDesc *lvid; | ||
1662 | |||
1663 | if (!bh) | ||
1664 | return; | ||
1665 | |||
1666 | lvid = (struct logicalVolIntegrityDesc *)bh->b_data; | ||
1371 | 1667 | ||
1372 | if (UDF_SB_LVIDBH(sb) && | 1668 | if (lvid->integrityType == LVID_INTEGRITY_TYPE_OPEN) { |
1373 | UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) { | 1669 | struct logicalVolIntegrityDescImpUse *lvidiu = |
1374 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1670 | udf_sb_lvidiu(sbi); |
1375 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1671 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1672 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | ||
1376 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) | 1673 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) |
1377 | UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time); | 1674 | lvid->recordingDateAndTime = cpu_to_lets(cpu_time); |
1378 | if (UDF_MAX_WRITE_VERSION > le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev)) | 1675 | if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev)) |
1379 | UDF_SB_LVIDIU(sb)->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION); | 1676 | lvidiu->maxUDFWriteRev = |
1380 | if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev)) | 1677 | cpu_to_le16(UDF_MAX_WRITE_VERSION); |
1381 | UDF_SB_LVIDIU(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb)); | 1678 | if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev)) |
1382 | if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev)) | 1679 | lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev); |
1383 | UDF_SB_LVIDIU(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb)); | 1680 | if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev)) |
1384 | UDF_SB_LVID(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); | 1681 | lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev); |
1385 | 1682 | lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); | |
1386 | UDF_SB_LVID(sb)->descTag.descCRC = | 1683 | |
1387 | cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), | 1684 | lvid->descTag.descCRC = cpu_to_le16( |
1388 | le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0)); | 1685 | udf_crc((char *)lvid + sizeof(tag), |
1389 | 1686 | le16_to_cpu(lvid->descTag.descCRCLength), | |
1390 | UDF_SB_LVID(sb)->descTag.tagChecksum = 0; | 1687 | 0)); |
1391 | for (i = 0; i < 16; i++) | 1688 | |
1392 | if (i != 4) | 1689 | lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); |
1393 | UDF_SB_LVID(sb)->descTag.tagChecksum += | 1690 | mark_buffer_dirty(bh); |
1394 | ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i]; | ||
1395 | |||
1396 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | ||
1397 | } | 1691 | } |
1398 | } | 1692 | } |
1399 | 1693 | ||
1694 | static void udf_sb_free_bitmap(struct udf_bitmap *bitmap) | ||
1695 | { | ||
1696 | int i; | ||
1697 | int nr_groups = bitmap->s_nr_groups; | ||
1698 | int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * | ||
1699 | nr_groups); | ||
1700 | |||
1701 | for (i = 0; i < nr_groups; i++) | ||
1702 | if (bitmap->s_block_bitmap[i]) | ||
1703 | brelse(bitmap->s_block_bitmap[i]); | ||
1704 | |||
1705 | if (size <= PAGE_SIZE) | ||
1706 | kfree(bitmap); | ||
1707 | else | ||
1708 | vfree(bitmap); | ||
1709 | } | ||
1710 | |||
1400 | /* | 1711 | /* |
1401 | * udf_read_super | 1712 | * udf_read_super |
1402 | * | 1713 | * |
@@ -1426,16 +1737,15 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1426 | uopt.gid = -1; | 1737 | uopt.gid = -1; |
1427 | uopt.umask = 0; | 1738 | uopt.umask = 0; |
1428 | 1739 | ||
1429 | sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL); | 1740 | sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL); |
1430 | if (!sbi) | 1741 | if (!sbi) |
1431 | return -ENOMEM; | 1742 | return -ENOMEM; |
1432 | 1743 | ||
1433 | sb->s_fs_info = sbi; | 1744 | sb->s_fs_info = sbi; |
1434 | memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); | ||
1435 | 1745 | ||
1436 | mutex_init(&sbi->s_alloc_mutex); | 1746 | mutex_init(&sbi->s_alloc_mutex); |
1437 | 1747 | ||
1438 | if (!udf_parse_options((char *)options, &uopt)) | 1748 | if (!udf_parse_options((char *)options, &uopt, false)) |
1439 | goto error_out; | 1749 | goto error_out; |
1440 | 1750 | ||
1441 | if (uopt.flags & (1 << UDF_FLAG_UTF8) && | 1751 | if (uopt.flags & (1 << UDF_FLAG_UTF8) && |
@@ -1459,30 +1769,31 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1459 | fileset.logicalBlockNum = 0xFFFFFFFF; | 1769 | fileset.logicalBlockNum = 0xFFFFFFFF; |
1460 | fileset.partitionReferenceNum = 0xFFFF; | 1770 | fileset.partitionReferenceNum = 0xFFFF; |
1461 | 1771 | ||
1462 | UDF_SB(sb)->s_flags = uopt.flags; | 1772 | sbi->s_flags = uopt.flags; |
1463 | UDF_SB(sb)->s_uid = uopt.uid; | 1773 | sbi->s_uid = uopt.uid; |
1464 | UDF_SB(sb)->s_gid = uopt.gid; | 1774 | sbi->s_gid = uopt.gid; |
1465 | UDF_SB(sb)->s_umask = uopt.umask; | 1775 | sbi->s_umask = uopt.umask; |
1466 | UDF_SB(sb)->s_nls_map = uopt.nls_map; | 1776 | sbi->s_nls_map = uopt.nls_map; |
1467 | 1777 | ||
1468 | /* Set the block size for all transfers */ | 1778 | /* Set the block size for all transfers */ |
1469 | if (!udf_set_blocksize(sb, uopt.blocksize)) | 1779 | if (!udf_set_blocksize(sb, uopt.blocksize)) |
1470 | goto error_out; | 1780 | goto error_out; |
1471 | 1781 | ||
1472 | if (uopt.session == 0xFFFFFFFF) | 1782 | if (uopt.session == 0xFFFFFFFF) |
1473 | UDF_SB_SESSION(sb) = udf_get_last_session(sb); | 1783 | sbi->s_session = udf_get_last_session(sb); |
1474 | else | 1784 | else |
1475 | UDF_SB_SESSION(sb) = uopt.session; | 1785 | sbi->s_session = uopt.session; |
1476 | 1786 | ||
1477 | udf_debug("Multi-session=%d\n", UDF_SB_SESSION(sb)); | 1787 | udf_debug("Multi-session=%d\n", sbi->s_session); |
1478 | 1788 | ||
1479 | UDF_SB_LASTBLOCK(sb) = uopt.lastblock; | 1789 | sbi->s_last_block = uopt.lastblock; |
1480 | UDF_SB_ANCHOR(sb)[0] = UDF_SB_ANCHOR(sb)[1] = 0; | 1790 | sbi->s_anchor[0] = sbi->s_anchor[1] = 0; |
1481 | UDF_SB_ANCHOR(sb)[2] = uopt.anchor; | 1791 | sbi->s_anchor[2] = uopt.anchor; |
1482 | UDF_SB_ANCHOR(sb)[3] = 256; | 1792 | sbi->s_anchor[3] = 256; |
1483 | 1793 | ||
1484 | if (udf_check_valid(sb, uopt.novrs, silent)) { /* read volume recognition sequences */ | 1794 | if (udf_check_valid(sb, uopt.novrs, silent)) { |
1485 | printk("UDF-fs: No VRS found\n"); | 1795 | /* read volume recognition sequences */ |
1796 | printk(KERN_WARNING "UDF-fs: No VRS found\n"); | ||
1486 | goto error_out; | 1797 | goto error_out; |
1487 | } | 1798 | } |
1488 | 1799 | ||
@@ -1496,27 +1807,30 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1496 | sb->s_time_gran = 1000; | 1807 | sb->s_time_gran = 1000; |
1497 | 1808 | ||
1498 | if (udf_load_partition(sb, &fileset)) { | 1809 | if (udf_load_partition(sb, &fileset)) { |
1499 | printk("UDF-fs: No partition found (1)\n"); | 1810 | printk(KERN_WARNING "UDF-fs: No partition found (1)\n"); |
1500 | goto error_out; | 1811 | goto error_out; |
1501 | } | 1812 | } |
1502 | 1813 | ||
1503 | udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb)); | 1814 | udf_debug("Lastblock=%d\n", sbi->s_last_block); |
1504 | 1815 | ||
1505 | if (UDF_SB_LVIDBH(sb)) { | 1816 | if (sbi->s_lvid_bh) { |
1506 | uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev); | 1817 | struct logicalVolIntegrityDescImpUse *lvidiu = |
1507 | uint16_t minUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev); | 1818 | udf_sb_lvidiu(sbi); |
1508 | /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */ | 1819 | uint16_t minUDFReadRev = le16_to_cpu(lvidiu->minUDFReadRev); |
1820 | uint16_t minUDFWriteRev = le16_to_cpu(lvidiu->minUDFWriteRev); | ||
1821 | /* uint16_t maxUDFWriteRev = | ||
1822 | le16_to_cpu(lvidiu->maxUDFWriteRev); */ | ||
1509 | 1823 | ||
1510 | if (minUDFReadRev > UDF_MAX_READ_VERSION) { | 1824 | if (minUDFReadRev > UDF_MAX_READ_VERSION) { |
1511 | printk("UDF-fs: minUDFReadRev=%x (max is %x)\n", | 1825 | printk(KERN_ERR "UDF-fs: minUDFReadRev=%x " |
1512 | le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev), | 1826 | "(max is %x)\n", |
1827 | le16_to_cpu(lvidiu->minUDFReadRev), | ||
1513 | UDF_MAX_READ_VERSION); | 1828 | UDF_MAX_READ_VERSION); |
1514 | goto error_out; | 1829 | goto error_out; |
1515 | } else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION) { | 1830 | } else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION) |
1516 | sb->s_flags |= MS_RDONLY; | 1831 | sb->s_flags |= MS_RDONLY; |
1517 | } | ||
1518 | 1832 | ||
1519 | UDF_SB_UDFREV(sb) = minUDFWriteRev; | 1833 | sbi->s_udfrev = minUDFWriteRev; |
1520 | 1834 | ||
1521 | if (minUDFReadRev >= UDF_VERS_USE_EXTENDED_FE) | 1835 | if (minUDFReadRev >= UDF_VERS_USE_EXTENDED_FE) |
1522 | UDF_SET_FLAG(sb, UDF_FLAG_USE_EXTENDED_FE); | 1836 | UDF_SET_FLAG(sb, UDF_FLAG_USE_EXTENDED_FE); |
@@ -1524,29 +1838,30 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1524 | UDF_SET_FLAG(sb, UDF_FLAG_USE_STREAMS); | 1838 | UDF_SET_FLAG(sb, UDF_FLAG_USE_STREAMS); |
1525 | } | 1839 | } |
1526 | 1840 | ||
1527 | if (!UDF_SB_NUMPARTS(sb)) { | 1841 | if (!sbi->s_partitions) { |
1528 | printk("UDF-fs: No partition found (2)\n"); | 1842 | printk(KERN_WARNING "UDF-fs: No partition found (2)\n"); |
1529 | goto error_out; | 1843 | goto error_out; |
1530 | } | 1844 | } |
1531 | 1845 | ||
1532 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_READ_ONLY) { | 1846 | if (sbi->s_partmaps[sbi->s_partition].s_partition_flags & |
1533 | printk("UDF-fs: Partition marked readonly; forcing readonly mount\n"); | 1847 | UDF_PART_FLAG_READ_ONLY) { |
1848 | printk(KERN_NOTICE "UDF-fs: Partition marked readonly; " | ||
1849 | "forcing readonly mount\n"); | ||
1534 | sb->s_flags |= MS_RDONLY; | 1850 | sb->s_flags |= MS_RDONLY; |
1535 | } | 1851 | } |
1536 | 1852 | ||
1537 | if (udf_find_fileset(sb, &fileset, &rootdir)) { | 1853 | if (udf_find_fileset(sb, &fileset, &rootdir)) { |
1538 | printk("UDF-fs: No fileset found\n"); | 1854 | printk(KERN_WARNING "UDF-fs: No fileset found\n"); |
1539 | goto error_out; | 1855 | goto error_out; |
1540 | } | 1856 | } |
1541 | 1857 | ||
1542 | if (!silent) { | 1858 | if (!silent) { |
1543 | kernel_timestamp ts; | 1859 | kernel_timestamp ts; |
1544 | udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb)); | 1860 | udf_time_to_stamp(&ts, sbi->s_record_time); |
1545 | udf_info("UDF %s (%s) Mounting volume '%s', " | 1861 | udf_info("UDF: Mounting volume '%s', " |
1546 | "timestamp %04u/%02u/%02u %02u:%02u (%x)\n", | 1862 | "timestamp %04u/%02u/%02u %02u:%02u (%x)\n", |
1547 | UDFFS_VERSION, UDFFS_DATE, | 1863 | sbi->s_volume_ident, ts.year, ts.month, ts.day, |
1548 | UDF_SB_VOLIDENT(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute, | 1864 | ts.hour, ts.minute, ts.typeAndTimezone); |
1549 | ts.typeAndTimezone); | ||
1550 | } | 1865 | } |
1551 | if (!(sb->s_flags & MS_RDONLY)) | 1866 | if (!(sb->s_flags & MS_RDONLY)) |
1552 | udf_open_lvid(sb); | 1867 | udf_open_lvid(sb); |
@@ -1556,7 +1871,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1556 | /* perhaps it's not extensible enough, but for now ... */ | 1871 | /* perhaps it's not extensible enough, but for now ... */ |
1557 | inode = udf_iget(sb, rootdir); | 1872 | inode = udf_iget(sb, rootdir); |
1558 | if (!inode) { | 1873 | if (!inode) { |
1559 | printk("UDF-fs: Error in udf_iget, block=%d, partition=%d\n", | 1874 | printk(KERN_ERR "UDF-fs: Error in udf_iget, block=%d, " |
1875 | "partition=%d\n", | ||
1560 | rootdir.logicalBlockNum, rootdir.partitionReferenceNum); | 1876 | rootdir.logicalBlockNum, rootdir.partitionReferenceNum); |
1561 | goto error_out; | 1877 | goto error_out; |
1562 | } | 1878 | } |
@@ -1564,7 +1880,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1564 | /* Allocate a dentry for the root inode */ | 1880 | /* Allocate a dentry for the root inode */ |
1565 | sb->s_root = d_alloc_root(inode); | 1881 | sb->s_root = d_alloc_root(inode); |
1566 | if (!sb->s_root) { | 1882 | if (!sb->s_root) { |
1567 | printk("UDF-fs: Couldn't allocate root dentry\n"); | 1883 | printk(KERN_ERR "UDF-fs: Couldn't allocate root dentry\n"); |
1568 | iput(inode); | 1884 | iput(inode); |
1569 | goto error_out; | 1885 | goto error_out; |
1570 | } | 1886 | } |
@@ -1572,30 +1888,32 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1572 | return 0; | 1888 | return 0; |
1573 | 1889 | ||
1574 | error_out: | 1890 | error_out: |
1575 | if (UDF_SB_VAT(sb)) | 1891 | if (sbi->s_vat_inode) |
1576 | iput(UDF_SB_VAT(sb)); | 1892 | iput(sbi->s_vat_inode); |
1577 | if (UDF_SB_NUMPARTS(sb)) { | 1893 | if (sbi->s_partitions) { |
1578 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) | 1894 | struct udf_part_map *map = &sbi->s_partmaps[sbi->s_partition]; |
1579 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); | 1895 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) |
1580 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) | 1896 | iput(map->s_uspace.s_table); |
1581 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); | 1897 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) |
1582 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) | 1898 | iput(map->s_fspace.s_table); |
1583 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace); | 1899 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) |
1584 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) | 1900 | udf_sb_free_bitmap(map->s_uspace.s_bitmap); |
1585 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace); | 1901 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) |
1586 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) { | 1902 | udf_sb_free_bitmap(map->s_fspace.s_bitmap); |
1903 | if (map->s_partition_type == UDF_SPARABLE_MAP15) | ||
1587 | for (i = 0; i < 4; i++) | 1904 | for (i = 0; i < 4; i++) |
1588 | brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]); | 1905 | brelse(map->s_type_specific.s_sparing. |
1589 | } | 1906 | s_spar_map[i]); |
1590 | } | 1907 | } |
1591 | #ifdef CONFIG_UDF_NLS | 1908 | #ifdef CONFIG_UDF_NLS |
1592 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) | 1909 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) |
1593 | unload_nls(UDF_SB(sb)->s_nls_map); | 1910 | unload_nls(sbi->s_nls_map); |
1594 | #endif | 1911 | #endif |
1595 | if (!(sb->s_flags & MS_RDONLY)) | 1912 | if (!(sb->s_flags & MS_RDONLY)) |
1596 | udf_close_lvid(sb); | 1913 | udf_close_lvid(sb); |
1597 | brelse(UDF_SB_LVIDBH(sb)); | 1914 | brelse(sbi->s_lvid_bh); |
1598 | UDF_SB_FREE(sb); | 1915 | |
1916 | kfree(sbi->s_partmaps); | ||
1599 | kfree(sbi); | 1917 | kfree(sbi); |
1600 | sb->s_fs_info = NULL; | 1918 | sb->s_fs_info = NULL; |
1601 | 1919 | ||
@@ -1614,7 +1932,7 @@ void udf_error(struct super_block *sb, const char *function, | |||
1614 | va_start(args, fmt); | 1932 | va_start(args, fmt); |
1615 | vsnprintf(error_buf, sizeof(error_buf), fmt, args); | 1933 | vsnprintf(error_buf, sizeof(error_buf), fmt, args); |
1616 | va_end(args); | 1934 | va_end(args); |
1617 | printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n", | 1935 | printk(KERN_CRIT "UDF-fs error (device %s): %s: %s\n", |
1618 | sb->s_id, function, error_buf); | 1936 | sb->s_id, function, error_buf); |
1619 | } | 1937 | } |
1620 | 1938 | ||
@@ -1646,31 +1964,34 @@ void udf_warning(struct super_block *sb, const char *function, | |||
1646 | static void udf_put_super(struct super_block *sb) | 1964 | static void udf_put_super(struct super_block *sb) |
1647 | { | 1965 | { |
1648 | int i; | 1966 | int i; |
1967 | struct udf_sb_info *sbi; | ||
1649 | 1968 | ||
1650 | if (UDF_SB_VAT(sb)) | 1969 | sbi = UDF_SB(sb); |
1651 | iput(UDF_SB_VAT(sb)); | 1970 | if (sbi->s_vat_inode) |
1652 | if (UDF_SB_NUMPARTS(sb)) { | 1971 | iput(sbi->s_vat_inode); |
1653 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) | 1972 | if (sbi->s_partitions) { |
1654 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); | 1973 | struct udf_part_map *map = &sbi->s_partmaps[sbi->s_partition]; |
1655 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) | 1974 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) |
1656 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); | 1975 | iput(map->s_uspace.s_table); |
1657 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) | 1976 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) |
1658 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace); | 1977 | iput(map->s_fspace.s_table); |
1659 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) | 1978 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) |
1660 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace); | 1979 | udf_sb_free_bitmap(map->s_uspace.s_bitmap); |
1661 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) { | 1980 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) |
1981 | udf_sb_free_bitmap(map->s_fspace.s_bitmap); | ||
1982 | if (map->s_partition_type == UDF_SPARABLE_MAP15) | ||
1662 | for (i = 0; i < 4; i++) | 1983 | for (i = 0; i < 4; i++) |
1663 | brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]); | 1984 | brelse(map->s_type_specific.s_sparing. |
1664 | } | 1985 | s_spar_map[i]); |
1665 | } | 1986 | } |
1666 | #ifdef CONFIG_UDF_NLS | 1987 | #ifdef CONFIG_UDF_NLS |
1667 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) | 1988 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) |
1668 | unload_nls(UDF_SB(sb)->s_nls_map); | 1989 | unload_nls(sbi->s_nls_map); |
1669 | #endif | 1990 | #endif |
1670 | if (!(sb->s_flags & MS_RDONLY)) | 1991 | if (!(sb->s_flags & MS_RDONLY)) |
1671 | udf_close_lvid(sb); | 1992 | udf_close_lvid(sb); |
1672 | brelse(UDF_SB_LVIDBH(sb)); | 1993 | brelse(sbi->s_lvid_bh); |
1673 | UDF_SB_FREE(sb); | 1994 | kfree(sbi->s_partmaps); |
1674 | kfree(sb->s_fs_info); | 1995 | kfree(sb->s_fs_info); |
1675 | sb->s_fs_info = NULL; | 1996 | sb->s_fs_info = NULL; |
1676 | } | 1997 | } |
@@ -1691,15 +2012,22 @@ static void udf_put_super(struct super_block *sb) | |||
1691 | static int udf_statfs(struct dentry *dentry, struct kstatfs *buf) | 2012 | static int udf_statfs(struct dentry *dentry, struct kstatfs *buf) |
1692 | { | 2013 | { |
1693 | struct super_block *sb = dentry->d_sb; | 2014 | struct super_block *sb = dentry->d_sb; |
2015 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
2016 | struct logicalVolIntegrityDescImpUse *lvidiu; | ||
2017 | |||
2018 | if (sbi->s_lvid_bh != NULL) | ||
2019 | lvidiu = udf_sb_lvidiu(sbi); | ||
2020 | else | ||
2021 | lvidiu = NULL; | ||
1694 | 2022 | ||
1695 | buf->f_type = UDF_SUPER_MAGIC; | 2023 | buf->f_type = UDF_SUPER_MAGIC; |
1696 | buf->f_bsize = sb->s_blocksize; | 2024 | buf->f_bsize = sb->s_blocksize; |
1697 | buf->f_blocks = UDF_SB_PARTLEN(sb, UDF_SB_PARTITION(sb)); | 2025 | buf->f_blocks = sbi->s_partmaps[sbi->s_partition].s_partition_len; |
1698 | buf->f_bfree = udf_count_free(sb); | 2026 | buf->f_bfree = udf_count_free(sb); |
1699 | buf->f_bavail = buf->f_bfree; | 2027 | buf->f_bavail = buf->f_bfree; |
1700 | buf->f_files = (UDF_SB_LVIDBH(sb) ? | 2028 | buf->f_files = (lvidiu != NULL ? (le32_to_cpu(lvidiu->numFiles) + |
1701 | (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + | 2029 | le32_to_cpu(lvidiu->numDirs)) : 0) |
1702 | le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + buf->f_bfree; | 2030 | + buf->f_bfree; |
1703 | buf->f_ffree = buf->f_bfree; | 2031 | buf->f_ffree = buf->f_bfree; |
1704 | /* __kernel_fsid_t f_fsid */ | 2032 | /* __kernel_fsid_t f_fsid */ |
1705 | buf->f_namelen = UDF_NAME_LEN - 2; | 2033 | buf->f_namelen = UDF_NAME_LEN - 2; |
@@ -1711,7 +2039,8 @@ static unsigned char udf_bitmap_lookup[16] = { | |||
1711 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 | 2039 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 |
1712 | }; | 2040 | }; |
1713 | 2041 | ||
1714 | static unsigned int udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap) | 2042 | static unsigned int udf_count_free_bitmap(struct super_block *sb, |
2043 | struct udf_bitmap *bitmap) | ||
1715 | { | 2044 | { |
1716 | struct buffer_head *bh = NULL; | 2045 | struct buffer_head *bh = NULL; |
1717 | unsigned int accum = 0; | 2046 | unsigned int accum = 0; |
@@ -1727,7 +2056,7 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb, struct udf_bit | |||
1727 | lock_kernel(); | 2056 | lock_kernel(); |
1728 | 2057 | ||
1729 | loc.logicalBlockNum = bitmap->s_extPosition; | 2058 | loc.logicalBlockNum = bitmap->s_extPosition; |
1730 | loc.partitionReferenceNum = UDF_SB_PARTITION(sb); | 2059 | loc.partitionReferenceNum = UDF_SB(sb)->s_partition; |
1731 | bh = udf_read_ptagged(sb, loc, 0, &ident); | 2060 | bh = udf_read_ptagged(sb, loc, 0, &ident); |
1732 | 2061 | ||
1733 | if (!bh) { | 2062 | if (!bh) { |
@@ -1772,7 +2101,8 @@ out: | |||
1772 | return accum; | 2101 | return accum; |
1773 | } | 2102 | } |
1774 | 2103 | ||
1775 | static unsigned int udf_count_free_table(struct super_block *sb, struct inode *table) | 2104 | static unsigned int udf_count_free_table(struct super_block *sb, |
2105 | struct inode *table) | ||
1776 | { | 2106 | { |
1777 | unsigned int accum = 0; | 2107 | unsigned int accum = 0; |
1778 | uint32_t elen; | 2108 | uint32_t elen; |
@@ -1782,13 +2112,13 @@ static unsigned int udf_count_free_table(struct super_block *sb, struct inode *t | |||
1782 | 2112 | ||
1783 | lock_kernel(); | 2113 | lock_kernel(); |
1784 | 2114 | ||
1785 | epos.block = UDF_I_LOCATION(table); | 2115 | epos.block = UDF_I(table)->i_location; |
1786 | epos.offset = sizeof(struct unallocSpaceEntry); | 2116 | epos.offset = sizeof(struct unallocSpaceEntry); |
1787 | epos.bh = NULL; | 2117 | epos.bh = NULL; |
1788 | 2118 | ||
1789 | while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { | 2119 | while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) |
1790 | accum += (elen >> table->i_sb->s_blocksize_bits); | 2120 | accum += (elen >> table->i_sb->s_blocksize_bits); |
1791 | } | 2121 | |
1792 | brelse(epos.bh); | 2122 | brelse(epos.bh); |
1793 | 2123 | ||
1794 | unlock_kernel(); | 2124 | unlock_kernel(); |
@@ -1799,10 +2129,17 @@ static unsigned int udf_count_free_table(struct super_block *sb, struct inode *t | |||
1799 | static unsigned int udf_count_free(struct super_block *sb) | 2129 | static unsigned int udf_count_free(struct super_block *sb) |
1800 | { | 2130 | { |
1801 | unsigned int accum = 0; | 2131 | unsigned int accum = 0; |
1802 | 2132 | struct udf_sb_info *sbi; | |
1803 | if (UDF_SB_LVIDBH(sb)) { | 2133 | struct udf_part_map *map; |
1804 | if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > UDF_SB_PARTITION(sb)) { | 2134 | |
1805 | accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]); | 2135 | sbi = UDF_SB(sb); |
2136 | if (sbi->s_lvid_bh) { | ||
2137 | struct logicalVolIntegrityDesc *lvid = | ||
2138 | (struct logicalVolIntegrityDesc *) | ||
2139 | sbi->s_lvid_bh->b_data; | ||
2140 | if (le32_to_cpu(lvid->numOfPartitions) > sbi->s_partition) { | ||
2141 | accum = le32_to_cpu( | ||
2142 | lvid->freeSpaceTable[sbi->s_partition]); | ||
1806 | if (accum == 0xFFFFFFFF) | 2143 | if (accum == 0xFFFFFFFF) |
1807 | accum = 0; | 2144 | accum = 0; |
1808 | } | 2145 | } |
@@ -1811,24 +2148,25 @@ static unsigned int udf_count_free(struct super_block *sb) | |||
1811 | if (accum) | 2148 | if (accum) |
1812 | return accum; | 2149 | return accum; |
1813 | 2150 | ||
1814 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) { | 2151 | map = &sbi->s_partmaps[sbi->s_partition]; |
2152 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { | ||
1815 | accum += udf_count_free_bitmap(sb, | 2153 | accum += udf_count_free_bitmap(sb, |
1816 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap); | 2154 | map->s_uspace.s_bitmap); |
1817 | } | 2155 | } |
1818 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) { | 2156 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { |
1819 | accum += udf_count_free_bitmap(sb, | 2157 | accum += udf_count_free_bitmap(sb, |
1820 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap); | 2158 | map->s_fspace.s_bitmap); |
1821 | } | 2159 | } |
1822 | if (accum) | 2160 | if (accum) |
1823 | return accum; | 2161 | return accum; |
1824 | 2162 | ||
1825 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) { | 2163 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { |
1826 | accum += udf_count_free_table(sb, | 2164 | accum += udf_count_free_table(sb, |
1827 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); | 2165 | map->s_uspace.s_table); |
1828 | } | 2166 | } |
1829 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) { | 2167 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { |
1830 | accum += udf_count_free_table(sb, | 2168 | accum += udf_count_free_table(sb, |
1831 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); | 2169 | map->s_fspace.s_table); |
1832 | } | 2170 | } |
1833 | 2171 | ||
1834 | return accum; | 2172 | return accum; |
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c index e6f933dd6a7b..6ec99221e50c 100644 --- a/fs/udf/symlink.c +++ b/fs/udf/symlink.c | |||
@@ -33,7 +33,8 @@ | |||
33 | #include <linux/buffer_head.h> | 33 | #include <linux/buffer_head.h> |
34 | #include "udf_i.h" | 34 | #include "udf_i.h" |
35 | 35 | ||
36 | static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, char *to) | 36 | static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, |
37 | char *to) | ||
37 | { | 38 | { |
38 | struct pathComponent *pc; | 39 | struct pathComponent *pc; |
39 | int elen = 0; | 40 | int elen = 0; |
@@ -78,10 +79,12 @@ static int udf_symlink_filler(struct file *file, struct page *page) | |||
78 | char *symlink; | 79 | char *symlink; |
79 | int err = -EIO; | 80 | int err = -EIO; |
80 | char *p = kmap(page); | 81 | char *p = kmap(page); |
82 | struct udf_inode_info *iinfo; | ||
81 | 83 | ||
82 | lock_kernel(); | 84 | lock_kernel(); |
83 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 85 | iinfo = UDF_I(inode); |
84 | symlink = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); | 86 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
87 | symlink = iinfo->i_ext.i_data + iinfo->i_lenEAttr; | ||
85 | } else { | 88 | } else { |
86 | bh = sb_bread(inode->i_sb, udf_block_map(inode, 0)); | 89 | bh = sb_bread(inode->i_sb, udf_block_map(inode, 0)); |
87 | 90 | ||
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c index 7fc3912885a5..fe61be17cdab 100644 --- a/fs/udf/truncate.c +++ b/fs/udf/truncate.c | |||
@@ -74,17 +74,18 @@ void udf_truncate_tail_extent(struct inode *inode) | |||
74 | uint64_t lbcount = 0; | 74 | uint64_t lbcount = 0; |
75 | int8_t etype = -1, netype; | 75 | int8_t etype = -1, netype; |
76 | int adsize; | 76 | int adsize; |
77 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
77 | 78 | ||
78 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB || | 79 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB || |
79 | inode->i_size == UDF_I_LENEXTENTS(inode)) | 80 | inode->i_size == iinfo->i_lenExtents) |
80 | return; | 81 | return; |
81 | /* Are we going to delete the file anyway? */ | 82 | /* Are we going to delete the file anyway? */ |
82 | if (inode->i_nlink == 0) | 83 | if (inode->i_nlink == 0) |
83 | return; | 84 | return; |
84 | 85 | ||
85 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) | 86 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
86 | adsize = sizeof(short_ad); | 87 | adsize = sizeof(short_ad); |
87 | else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG) | 88 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
88 | adsize = sizeof(long_ad); | 89 | adsize = sizeof(long_ad); |
89 | else | 90 | else |
90 | BUG(); | 91 | BUG(); |
@@ -117,7 +118,7 @@ void udf_truncate_tail_extent(struct inode *inode) | |||
117 | } | 118 | } |
118 | /* This inode entry is in-memory only and thus we don't have to mark | 119 | /* This inode entry is in-memory only and thus we don't have to mark |
119 | * the inode dirty */ | 120 | * the inode dirty */ |
120 | UDF_I_LENEXTENTS(inode) = inode->i_size; | 121 | iinfo->i_lenExtents = inode->i_size; |
121 | brelse(epos.bh); | 122 | brelse(epos.bh); |
122 | } | 123 | } |
123 | 124 | ||
@@ -129,19 +130,20 @@ void udf_discard_prealloc(struct inode *inode) | |||
129 | uint64_t lbcount = 0; | 130 | uint64_t lbcount = 0; |
130 | int8_t etype = -1, netype; | 131 | int8_t etype = -1, netype; |
131 | int adsize; | 132 | int adsize; |
133 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
132 | 134 | ||
133 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB || | 135 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB || |
134 | inode->i_size == UDF_I_LENEXTENTS(inode)) | 136 | inode->i_size == iinfo->i_lenExtents) |
135 | return; | 137 | return; |
136 | 138 | ||
137 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) | 139 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
138 | adsize = sizeof(short_ad); | 140 | adsize = sizeof(short_ad); |
139 | else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG) | 141 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
140 | adsize = sizeof(long_ad); | 142 | adsize = sizeof(long_ad); |
141 | else | 143 | else |
142 | adsize = 0; | 144 | adsize = 0; |
143 | 145 | ||
144 | epos.block = UDF_I_LOCATION(inode); | 146 | epos.block = iinfo->i_location; |
145 | 147 | ||
146 | /* Find the last extent in the file */ | 148 | /* Find the last extent in the file */ |
147 | while ((netype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1) { | 149 | while ((netype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1) { |
@@ -153,8 +155,9 @@ void udf_discard_prealloc(struct inode *inode) | |||
153 | lbcount -= elen; | 155 | lbcount -= elen; |
154 | extent_trunc(inode, &epos, eloc, etype, elen, 0); | 156 | extent_trunc(inode, &epos, eloc, etype, elen, 0); |
155 | if (!epos.bh) { | 157 | if (!epos.bh) { |
156 | UDF_I_LENALLOC(inode) = | 158 | iinfo->i_lenAlloc = |
157 | epos.offset - udf_file_entry_alloc_offset(inode); | 159 | epos.offset - |
160 | udf_file_entry_alloc_offset(inode); | ||
158 | mark_inode_dirty(inode); | 161 | mark_inode_dirty(inode); |
159 | } else { | 162 | } else { |
160 | struct allocExtDesc *aed = | 163 | struct allocExtDesc *aed = |
@@ -163,7 +166,7 @@ void udf_discard_prealloc(struct inode *inode) | |||
163 | cpu_to_le32(epos.offset - | 166 | cpu_to_le32(epos.offset - |
164 | sizeof(struct allocExtDesc)); | 167 | sizeof(struct allocExtDesc)); |
165 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 168 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
166 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 169 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
167 | udf_update_tag(epos.bh->b_data, epos.offset); | 170 | udf_update_tag(epos.bh->b_data, epos.offset); |
168 | else | 171 | else |
169 | udf_update_tag(epos.bh->b_data, | 172 | udf_update_tag(epos.bh->b_data, |
@@ -173,7 +176,7 @@ void udf_discard_prealloc(struct inode *inode) | |||
173 | } | 176 | } |
174 | /* This inode entry is in-memory only and thus we don't have to mark | 177 | /* This inode entry is in-memory only and thus we don't have to mark |
175 | * the inode dirty */ | 178 | * the inode dirty */ |
176 | UDF_I_LENEXTENTS(inode) = lbcount; | 179 | iinfo->i_lenExtents = lbcount; |
177 | brelse(epos.bh); | 180 | brelse(epos.bh); |
178 | } | 181 | } |
179 | 182 | ||
@@ -184,13 +187,15 @@ void udf_truncate_extents(struct inode *inode) | |||
184 | uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc; | 187 | uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc; |
185 | int8_t etype; | 188 | int8_t etype; |
186 | struct super_block *sb = inode->i_sb; | 189 | struct super_block *sb = inode->i_sb; |
190 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
187 | sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset; | 191 | sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset; |
188 | loff_t byte_offset; | 192 | loff_t byte_offset; |
189 | int adsize; | 193 | int adsize; |
194 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
190 | 195 | ||
191 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) | 196 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
192 | adsize = sizeof(short_ad); | 197 | adsize = sizeof(short_ad); |
193 | else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG) | 198 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
194 | adsize = sizeof(long_ad); | 199 | adsize = sizeof(long_ad); |
195 | else | 200 | else |
196 | BUG(); | 201 | BUG(); |
@@ -212,7 +217,8 @@ void udf_truncate_extents(struct inode *inode) | |||
212 | else | 217 | else |
213 | lenalloc -= sizeof(struct allocExtDesc); | 218 | lenalloc -= sizeof(struct allocExtDesc); |
214 | 219 | ||
215 | while ((etype = udf_current_aext(inode, &epos, &eloc, &elen, 0)) != -1) { | 220 | while ((etype = udf_current_aext(inode, &epos, &eloc, |
221 | &elen, 0)) != -1) { | ||
216 | if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { | 222 | if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { |
217 | udf_write_aext(inode, &epos, neloc, nelen, 0); | 223 | udf_write_aext(inode, &epos, neloc, nelen, 0); |
218 | if (indirect_ext_len) { | 224 | if (indirect_ext_len) { |
@@ -224,35 +230,43 @@ void udf_truncate_extents(struct inode *inode) | |||
224 | 0, indirect_ext_len); | 230 | 0, indirect_ext_len); |
225 | } else { | 231 | } else { |
226 | if (!epos.bh) { | 232 | if (!epos.bh) { |
227 | UDF_I_LENALLOC(inode) = lenalloc; | 233 | iinfo->i_lenAlloc = |
234 | lenalloc; | ||
228 | mark_inode_dirty(inode); | 235 | mark_inode_dirty(inode); |
229 | } else { | 236 | } else { |
230 | struct allocExtDesc *aed = | 237 | struct allocExtDesc *aed = |
231 | (struct allocExtDesc *)(epos.bh->b_data); | 238 | (struct allocExtDesc *) |
239 | (epos.bh->b_data); | ||
240 | int len = | ||
241 | sizeof(struct allocExtDesc); | ||
242 | |||
232 | aed->lengthAllocDescs = | 243 | aed->lengthAllocDescs = |
233 | cpu_to_le32(lenalloc); | 244 | cpu_to_le32(lenalloc); |
234 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || | 245 | if (!UDF_QUERY_FLAG(sb, |
235 | UDF_SB_UDFREV(sb) >= 0x0201) | 246 | UDF_FLAG_STRICT) || |
236 | udf_update_tag(epos.bh->b_data, | 247 | sbi->s_udfrev >= 0x0201) |
237 | lenalloc + | 248 | len += lenalloc; |
238 | sizeof(struct allocExtDesc)); | 249 | |
239 | else | 250 | udf_update_tag(epos.bh->b_data, |
240 | udf_update_tag(epos.bh->b_data, | 251 | len); |
241 | sizeof(struct allocExtDesc)); | 252 | mark_buffer_dirty_inode( |
242 | mark_buffer_dirty_inode(epos.bh, inode); | 253 | epos.bh, inode); |
243 | } | 254 | } |
244 | } | 255 | } |
245 | brelse(epos.bh); | 256 | brelse(epos.bh); |
246 | epos.offset = sizeof(struct allocExtDesc); | 257 | epos.offset = sizeof(struct allocExtDesc); |
247 | epos.block = eloc; | 258 | epos.block = eloc; |
248 | epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, eloc, 0)); | 259 | epos.bh = udf_tread(sb, |
260 | udf_get_lb_pblock(sb, eloc, 0)); | ||
249 | if (elen) | 261 | if (elen) |
250 | indirect_ext_len = (elen + sb->s_blocksize -1) >> | 262 | indirect_ext_len = |
263 | (elen + sb->s_blocksize - 1) >> | ||
251 | sb->s_blocksize_bits; | 264 | sb->s_blocksize_bits; |
252 | else | 265 | else |
253 | indirect_ext_len = 1; | 266 | indirect_ext_len = 1; |
254 | } else { | 267 | } else { |
255 | extent_trunc(inode, &epos, eloc, etype, elen, 0); | 268 | extent_trunc(inode, &epos, eloc, etype, |
269 | elen, 0); | ||
256 | epos.offset += adsize; | 270 | epos.offset += adsize; |
257 | } | 271 | } |
258 | } | 272 | } |
@@ -264,19 +278,20 @@ void udf_truncate_extents(struct inode *inode) | |||
264 | indirect_ext_len); | 278 | indirect_ext_len); |
265 | } else { | 279 | } else { |
266 | if (!epos.bh) { | 280 | if (!epos.bh) { |
267 | UDF_I_LENALLOC(inode) = lenalloc; | 281 | iinfo->i_lenAlloc = lenalloc; |
268 | mark_inode_dirty(inode); | 282 | mark_inode_dirty(inode); |
269 | } else { | 283 | } else { |
270 | struct allocExtDesc *aed = | 284 | struct allocExtDesc *aed = |
271 | (struct allocExtDesc *)(epos.bh->b_data); | 285 | (struct allocExtDesc *)(epos.bh->b_data); |
272 | aed->lengthAllocDescs = cpu_to_le32(lenalloc); | 286 | aed->lengthAllocDescs = cpu_to_le32(lenalloc); |
273 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || | 287 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || |
274 | UDF_SB_UDFREV(sb) >= 0x0201) | 288 | sbi->s_udfrev >= 0x0201) |
275 | udf_update_tag(epos.bh->b_data, | 289 | udf_update_tag(epos.bh->b_data, |
276 | lenalloc + sizeof(struct allocExtDesc)); | 290 | lenalloc + |
291 | sizeof(struct allocExtDesc)); | ||
277 | else | 292 | else |
278 | udf_update_tag(epos.bh->b_data, | 293 | udf_update_tag(epos.bh->b_data, |
279 | sizeof(struct allocExtDesc)); | 294 | sizeof(struct allocExtDesc)); |
280 | mark_buffer_dirty_inode(epos.bh, inode); | 295 | mark_buffer_dirty_inode(epos.bh, inode); |
281 | } | 296 | } |
282 | } | 297 | } |
@@ -290,13 +305,16 @@ void udf_truncate_extents(struct inode *inode) | |||
290 | * extending the file by 'offset' blocks. | 305 | * extending the file by 'offset' blocks. |
291 | */ | 306 | */ |
292 | if ((!epos.bh && | 307 | if ((!epos.bh && |
293 | epos.offset == udf_file_entry_alloc_offset(inode)) || | 308 | epos.offset == |
294 | (epos.bh && epos.offset == sizeof(struct allocExtDesc))) { | 309 | udf_file_entry_alloc_offset(inode)) || |
310 | (epos.bh && epos.offset == | ||
311 | sizeof(struct allocExtDesc))) { | ||
295 | /* File has no extents at all or has empty last | 312 | /* File has no extents at all or has empty last |
296 | * indirect extent! Create a fake extent... */ | 313 | * indirect extent! Create a fake extent... */ |
297 | extent.extLocation.logicalBlockNum = 0; | 314 | extent.extLocation.logicalBlockNum = 0; |
298 | extent.extLocation.partitionReferenceNum = 0; | 315 | extent.extLocation.partitionReferenceNum = 0; |
299 | extent.extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; | 316 | extent.extLength = |
317 | EXT_NOT_RECORDED_NOT_ALLOCATED; | ||
300 | } else { | 318 | } else { |
301 | epos.offset -= adsize; | 319 | epos.offset -= adsize; |
302 | etype = udf_next_aext(inode, &epos, | 320 | etype = udf_next_aext(inode, &epos, |
@@ -305,10 +323,12 @@ void udf_truncate_extents(struct inode *inode) | |||
305 | extent.extLength |= etype << 30; | 323 | extent.extLength |= etype << 30; |
306 | } | 324 | } |
307 | udf_extend_file(inode, &epos, &extent, | 325 | udf_extend_file(inode, &epos, &extent, |
308 | offset + ((inode->i_size & (sb->s_blocksize - 1)) != 0)); | 326 | offset + |
327 | ((inode->i_size & | ||
328 | (sb->s_blocksize - 1)) != 0)); | ||
309 | } | 329 | } |
310 | } | 330 | } |
311 | UDF_I_LENEXTENTS(inode) = inode->i_size; | 331 | iinfo->i_lenExtents = inode->i_size; |
312 | 332 | ||
313 | brelse(epos.bh); | 333 | brelse(epos.bh); |
314 | } | 334 | } |
diff --git a/fs/udf/udf_i.h b/fs/udf/udf_i.h index d7dbe6f3ba0c..ccc52f16bf7d 100644 --- a/fs/udf/udf_i.h +++ b/fs/udf/udf_i.h | |||
@@ -7,20 +7,4 @@ static inline struct udf_inode_info *UDF_I(struct inode *inode) | |||
7 | return list_entry(inode, struct udf_inode_info, vfs_inode); | 7 | return list_entry(inode, struct udf_inode_info, vfs_inode); |
8 | } | 8 | } |
9 | 9 | ||
10 | #define UDF_I_LOCATION(X) ( UDF_I(X)->i_location ) | ||
11 | #define UDF_I_LENEATTR(X) ( UDF_I(X)->i_lenEAttr ) | ||
12 | #define UDF_I_LENALLOC(X) ( UDF_I(X)->i_lenAlloc ) | ||
13 | #define UDF_I_LENEXTENTS(X) ( UDF_I(X)->i_lenExtents ) | ||
14 | #define UDF_I_UNIQUE(X) ( UDF_I(X)->i_unique ) | ||
15 | #define UDF_I_ALLOCTYPE(X) ( UDF_I(X)->i_alloc_type ) | ||
16 | #define UDF_I_EFE(X) ( UDF_I(X)->i_efe ) | ||
17 | #define UDF_I_USE(X) ( UDF_I(X)->i_use ) | ||
18 | #define UDF_I_STRAT4096(X) ( UDF_I(X)->i_strat4096 ) | ||
19 | #define UDF_I_NEXT_ALLOC_BLOCK(X) ( UDF_I(X)->i_next_alloc_block ) | ||
20 | #define UDF_I_NEXT_ALLOC_GOAL(X) ( UDF_I(X)->i_next_alloc_goal ) | ||
21 | #define UDF_I_CRTIME(X) ( UDF_I(X)->i_crtime ) | ||
22 | #define UDF_I_SAD(X) ( UDF_I(X)->i_ext.i_sad ) | ||
23 | #define UDF_I_LAD(X) ( UDF_I(X)->i_ext.i_lad ) | ||
24 | #define UDF_I_DATA(X) ( UDF_I(X)->i_ext.i_data ) | ||
25 | |||
26 | #endif /* !defined(_LINUX_UDF_I_H) */ | 10 | #endif /* !defined(_LINUX_UDF_I_H) */ |
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index 3c2982017c6d..737d1c604eea 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h | |||
@@ -26,6 +26,8 @@ | |||
26 | #define UDF_FLAG_GID_IGNORE 14 | 26 | #define UDF_FLAG_GID_IGNORE 14 |
27 | #define UDF_FLAG_UID_SET 15 | 27 | #define UDF_FLAG_UID_SET 15 |
28 | #define UDF_FLAG_GID_SET 16 | 28 | #define UDF_FLAG_GID_SET 16 |
29 | #define UDF_FLAG_SESSION_SET 17 | ||
30 | #define UDF_FLAG_LASTBLOCK_SET 18 | ||
29 | 31 | ||
30 | #define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001 | 32 | #define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001 |
31 | #define UDF_PART_FLAG_UNALLOC_TABLE 0x0002 | 33 | #define UDF_PART_FLAG_UNALLOC_TABLE 0x0002 |
@@ -41,96 +43,12 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) | |||
41 | return sb->s_fs_info; | 43 | return sb->s_fs_info; |
42 | } | 44 | } |
43 | 45 | ||
44 | #define UDF_SB_FREE(X)\ | 46 | struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi); |
45 | {\ | ||
46 | if (UDF_SB(X)) {\ | ||
47 | kfree(UDF_SB_PARTMAPS(X));\ | ||
48 | UDF_SB_PARTMAPS(X) = NULL;\ | ||
49 | }\ | ||
50 | } | ||
51 | |||
52 | #define UDF_SB_ALLOC_PARTMAPS(X,Y)\ | ||
53 | {\ | ||
54 | UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\ | ||
55 | if (UDF_SB_PARTMAPS(X) != NULL) {\ | ||
56 | UDF_SB_NUMPARTS(X) = Y;\ | ||
57 | memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\ | ||
58 | } else {\ | ||
59 | UDF_SB_NUMPARTS(X) = 0;\ | ||
60 | udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\ | ||
61 | }\ | ||
62 | } | ||
63 | |||
64 | #define UDF_SB_ALLOC_BITMAP(X,Y,Z)\ | ||
65 | {\ | ||
66 | int nr_groups = ((UDF_SB_PARTLEN((X),(Y)) + (sizeof(struct spaceBitmapDesc) << 3) +\ | ||
67 | ((X)->s_blocksize * 8) - 1) / ((X)->s_blocksize * 8));\ | ||
68 | int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\ | ||
69 | if (size <= PAGE_SIZE)\ | ||
70 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\ | ||
71 | else\ | ||
72 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = vmalloc(size);\ | ||
73 | if (UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap != NULL) {\ | ||
74 | memset(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap, 0x00, size);\ | ||
75 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap =\ | ||
76 | (struct buffer_head **)(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap + 1);\ | ||
77 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\ | ||
78 | } else {\ | ||
79 | udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap and %d buffer_head pointers", nr_groups);\ | ||
80 | }\ | ||
81 | } | ||
82 | 47 | ||
83 | #define UDF_SB_FREE_BITMAP(X,Y,Z)\ | 48 | int udf_compute_nr_groups(struct super_block *sb, u32 partition); |
84 | {\ | ||
85 | int i;\ | ||
86 | int nr_groups = UDF_SB_BITMAP_NR_GROUPS(X,Y,Z);\ | ||
87 | int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\ | ||
88 | for (i = 0; i < nr_groups; i++) {\ | ||
89 | if (UDF_SB_BITMAP(X,Y,Z,i))\ | ||
90 | brelse(UDF_SB_BITMAP(X,Y,Z,i));\ | ||
91 | }\ | ||
92 | if (size <= PAGE_SIZE)\ | ||
93 | kfree(UDF_SB_PARTMAPS(X)[Y].Z.s_bitmap);\ | ||
94 | else\ | ||
95 | vfree(UDF_SB_PARTMAPS(X)[Y].Z.s_bitmap);\ | ||
96 | } | ||
97 | 49 | ||
98 | #define UDF_QUERY_FLAG(X,Y) ( UDF_SB(X)->s_flags & ( 1 << (Y) ) ) | 50 | #define UDF_QUERY_FLAG(X,Y) ( UDF_SB(X)->s_flags & ( 1 << (Y) ) ) |
99 | #define UDF_SET_FLAG(X,Y) ( UDF_SB(X)->s_flags |= ( 1 << (Y) ) ) | 51 | #define UDF_SET_FLAG(X,Y) ( UDF_SB(X)->s_flags |= ( 1 << (Y) ) ) |
100 | #define UDF_CLEAR_FLAG(X,Y) ( UDF_SB(X)->s_flags &= ~( 1 << (Y) ) ) | 52 | #define UDF_CLEAR_FLAG(X,Y) ( UDF_SB(X)->s_flags &= ~( 1 << (Y) ) ) |
101 | 53 | ||
102 | #define UDF_UPDATE_UDFREV(X,Y) ( ((Y) > UDF_SB_UDFREV(X)) ? UDF_SB_UDFREV(X) = (Y) : UDF_SB_UDFREV(X) ) | ||
103 | |||
104 | #define UDF_SB_PARTMAPS(X) ( UDF_SB(X)->s_partmaps ) | ||
105 | #define UDF_SB_PARTTYPE(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_type ) | ||
106 | #define UDF_SB_PARTROOT(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_root ) | ||
107 | #define UDF_SB_PARTLEN(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_len ) | ||
108 | #define UDF_SB_PARTVSN(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_volumeseqnum ) | ||
109 | #define UDF_SB_PARTNUM(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_num ) | ||
110 | #define UDF_SB_TYPESPAR(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_type_specific.s_sparing ) | ||
111 | #define UDF_SB_TYPEVIRT(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_type_specific.s_virtual ) | ||
112 | #define UDF_SB_PARTFUNC(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_func ) | ||
113 | #define UDF_SB_PARTFLAGS(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_flags ) | ||
114 | #define UDF_SB_BITMAP(X,Y,Z,I) ( UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] ) | ||
115 | #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z) ( UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups ) | ||
116 | |||
117 | #define UDF_SB_VOLIDENT(X) ( UDF_SB(X)->s_volident ) | ||
118 | #define UDF_SB_NUMPARTS(X) ( UDF_SB(X)->s_partitions ) | ||
119 | #define UDF_SB_PARTITION(X) ( UDF_SB(X)->s_partition ) | ||
120 | #define UDF_SB_SESSION(X) ( UDF_SB(X)->s_session ) | ||
121 | #define UDF_SB_ANCHOR(X) ( UDF_SB(X)->s_anchor ) | ||
122 | #define UDF_SB_LASTBLOCK(X) ( UDF_SB(X)->s_lastblock ) | ||
123 | #define UDF_SB_LVIDBH(X) ( UDF_SB(X)->s_lvidbh ) | ||
124 | #define UDF_SB_LVID(X) ( (struct logicalVolIntegrityDesc *)UDF_SB_LVIDBH(X)->b_data ) | ||
125 | #define UDF_SB_LVIDIU(X) ( (struct logicalVolIntegrityDescImpUse *)&(UDF_SB_LVID(X)->impUse[le32_to_cpu(UDF_SB_LVID(X)->numOfPartitions) * 2 * sizeof(uint32_t)/sizeof(uint8_t)]) ) | ||
126 | |||
127 | #define UDF_SB_UMASK(X) ( UDF_SB(X)->s_umask ) | ||
128 | #define UDF_SB_GID(X) ( UDF_SB(X)->s_gid ) | ||
129 | #define UDF_SB_UID(X) ( UDF_SB(X)->s_uid ) | ||
130 | #define UDF_SB_RECORDTIME(X) ( UDF_SB(X)->s_recordtime ) | ||
131 | #define UDF_SB_SERIALNUM(X) ( UDF_SB(X)->s_serialnum ) | ||
132 | #define UDF_SB_UDFREV(X) ( UDF_SB(X)->s_udfrev ) | ||
133 | #define UDF_SB_FLAGS(X) ( UDF_SB(X)->s_flags ) | ||
134 | #define UDF_SB_VAT(X) ( UDF_SB(X)->s_vat ) | ||
135 | |||
136 | #endif /* __LINUX_UDF_SB_H */ | 54 | #endif /* __LINUX_UDF_SB_H */ |
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index c8016cc9e7e6..681dc2b66cdb 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h | |||
@@ -24,18 +24,21 @@ | |||
24 | #define UDF_PATH_LEN 1023 | 24 | #define UDF_PATH_LEN 1023 |
25 | 25 | ||
26 | #define udf_file_entry_alloc_offset(inode)\ | 26 | #define udf_file_entry_alloc_offset(inode)\ |
27 | (UDF_I_USE(inode) ?\ | 27 | (UDF_I(inode)->i_use ?\ |
28 | sizeof(struct unallocSpaceEntry) :\ | 28 | sizeof(struct unallocSpaceEntry) :\ |
29 | ((UDF_I_EFE(inode) ?\ | 29 | ((UDF_I(inode)->i_efe ?\ |
30 | sizeof(struct extendedFileEntry) :\ | 30 | sizeof(struct extendedFileEntry) :\ |
31 | sizeof(struct fileEntry)) + UDF_I_LENEATTR(inode))) | 31 | sizeof(struct fileEntry)) + UDF_I(inode)->i_lenEAttr)) |
32 | 32 | ||
33 | #define udf_ext0_offset(inode)\ | 33 | #define udf_ext0_offset(inode)\ |
34 | (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB ?\ | 34 | (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ?\ |
35 | udf_file_entry_alloc_offset(inode) : 0) | 35 | udf_file_entry_alloc_offset(inode) : 0) |
36 | 36 | ||
37 | #define udf_get_lb_pblock(sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset)) | 37 | #define udf_get_lb_pblock(sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset)) |
38 | 38 | ||
39 | /* computes tag checksum */ | ||
40 | u8 udf_tag_checksum(const tag *t); | ||
41 | |||
39 | struct dentry; | 42 | struct dentry; |
40 | struct inode; | 43 | struct inode; |
41 | struct task_struct; | 44 | struct task_struct; |
@@ -185,8 +188,8 @@ extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *, | |||
185 | sector_t *); | 188 | sector_t *); |
186 | extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, | 189 | extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, |
187 | int *offset); | 190 | int *offset); |
188 | extern long_ad *udf_get_filelongad(uint8_t *, int, int *, int); | 191 | extern long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int); |
189 | extern short_ad *udf_get_fileshortad(uint8_t *, int, int *, int); | 192 | extern short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int); |
190 | 193 | ||
191 | /* crc.c */ | 194 | /* crc.c */ |
192 | extern uint16_t udf_crc(uint8_t *, uint32_t, uint16_t); | 195 | extern uint16_t udf_crc(uint8_t *, uint32_t, uint16_t); |
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c index adcb87c2da7e..ce595732ba6f 100644 --- a/fs/udf/udftime.c +++ b/fs/udf/udftime.c | |||
@@ -18,8 +18,10 @@ | |||
18 | Boston, MA 02111-1307, USA. */ | 18 | Boston, MA 02111-1307, USA. */ |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * dgb 10/02/98: ripped this from glibc source to help convert timestamps to unix time | 21 | * dgb 10/02/98: ripped this from glibc source to help convert timestamps |
22 | * 10/04/98: added new table-based lookup after seeing how ugly the gnu code is | 22 | * to unix time |
23 | * 10/04/98: added new table-based lookup after seeing how ugly | ||
24 | * the gnu code is | ||
23 | * blf 09/27/99: ripped out all the old code and inserted new table from | 25 | * blf 09/27/99: ripped out all the old code and inserted new table from |
24 | * John Brockmeyer (without leap second corrections) | 26 | * John Brockmeyer (without leap second corrections) |
25 | * rewrote udf_stamp_to_time and fixed timezone accounting in | 27 | * rewrote udf_stamp_to_time and fixed timezone accounting in |
@@ -55,27 +57,27 @@ static const unsigned short int __mon_yday[2][13] = { | |||
55 | 57 | ||
56 | #define MAX_YEAR_SECONDS 69 | 58 | #define MAX_YEAR_SECONDS 69 |
57 | #define SPD 0x15180 /*3600*24 */ | 59 | #define SPD 0x15180 /*3600*24 */ |
58 | #define SPY(y,l,s) (SPD * (365*y+l)+s) | 60 | #define SPY(y, l, s) (SPD * (365 * y + l) + s) |
59 | 61 | ||
60 | static time_t year_seconds[MAX_YEAR_SECONDS]= { | 62 | static time_t year_seconds[MAX_YEAR_SECONDS] = { |
61 | /*1970*/ SPY( 0, 0,0), SPY( 1, 0,0), SPY( 2, 0,0), SPY( 3, 1,0), | 63 | /*1970*/ SPY(0, 0, 0), SPY(1, 0, 0), SPY(2, 0, 0), SPY(3, 1, 0), |
62 | /*1974*/ SPY( 4, 1,0), SPY( 5, 1,0), SPY( 6, 1,0), SPY( 7, 2,0), | 64 | /*1974*/ SPY(4, 1, 0), SPY(5, 1, 0), SPY(6, 1, 0), SPY(7, 2, 0), |
63 | /*1978*/ SPY( 8, 2,0), SPY( 9, 2,0), SPY(10, 2,0), SPY(11, 3,0), | 65 | /*1978*/ SPY(8, 2, 0), SPY(9, 2, 0), SPY(10, 2, 0), SPY(11, 3, 0), |
64 | /*1982*/ SPY(12, 3,0), SPY(13, 3,0), SPY(14, 3,0), SPY(15, 4,0), | 66 | /*1982*/ SPY(12, 3, 0), SPY(13, 3, 0), SPY(14, 3, 0), SPY(15, 4, 0), |
65 | /*1986*/ SPY(16, 4,0), SPY(17, 4,0), SPY(18, 4,0), SPY(19, 5,0), | 67 | /*1986*/ SPY(16, 4, 0), SPY(17, 4, 0), SPY(18, 4, 0), SPY(19, 5, 0), |
66 | /*1990*/ SPY(20, 5,0), SPY(21, 5,0), SPY(22, 5,0), SPY(23, 6,0), | 68 | /*1990*/ SPY(20, 5, 0), SPY(21, 5, 0), SPY(22, 5, 0), SPY(23, 6, 0), |
67 | /*1994*/ SPY(24, 6,0), SPY(25, 6,0), SPY(26, 6,0), SPY(27, 7,0), | 69 | /*1994*/ SPY(24, 6, 0), SPY(25, 6, 0), SPY(26, 6, 0), SPY(27, 7, 0), |
68 | /*1998*/ SPY(28, 7,0), SPY(29, 7,0), SPY(30, 7,0), SPY(31, 8,0), | 70 | /*1998*/ SPY(28, 7, 0), SPY(29, 7, 0), SPY(30, 7, 0), SPY(31, 8, 0), |
69 | /*2002*/ SPY(32, 8,0), SPY(33, 8,0), SPY(34, 8,0), SPY(35, 9,0), | 71 | /*2002*/ SPY(32, 8, 0), SPY(33, 8, 0), SPY(34, 8, 0), SPY(35, 9, 0), |
70 | /*2006*/ SPY(36, 9,0), SPY(37, 9,0), SPY(38, 9,0), SPY(39,10,0), | 72 | /*2006*/ SPY(36, 9, 0), SPY(37, 9, 0), SPY(38, 9, 0), SPY(39, 10, 0), |
71 | /*2010*/ SPY(40,10,0), SPY(41,10,0), SPY(42,10,0), SPY(43,11,0), | 73 | /*2010*/ SPY(40, 10, 0), SPY(41, 10, 0), SPY(42, 10, 0), SPY(43, 11, 0), |
72 | /*2014*/ SPY(44,11,0), SPY(45,11,0), SPY(46,11,0), SPY(47,12,0), | 74 | /*2014*/ SPY(44, 11, 0), SPY(45, 11, 0), SPY(46, 11, 0), SPY(47, 12, 0), |
73 | /*2018*/ SPY(48,12,0), SPY(49,12,0), SPY(50,12,0), SPY(51,13,0), | 75 | /*2018*/ SPY(48, 12, 0), SPY(49, 12, 0), SPY(50, 12, 0), SPY(51, 13, 0), |
74 | /*2022*/ SPY(52,13,0), SPY(53,13,0), SPY(54,13,0), SPY(55,14,0), | 76 | /*2022*/ SPY(52, 13, 0), SPY(53, 13, 0), SPY(54, 13, 0), SPY(55, 14, 0), |
75 | /*2026*/ SPY(56,14,0), SPY(57,14,0), SPY(58,14,0), SPY(59,15,0), | 77 | /*2026*/ SPY(56, 14, 0), SPY(57, 14, 0), SPY(58, 14, 0), SPY(59, 15, 0), |
76 | /*2030*/ SPY(60,15,0), SPY(61,15,0), SPY(62,15,0), SPY(63,16,0), | 78 | /*2030*/ SPY(60, 15, 0), SPY(61, 15, 0), SPY(62, 15, 0), SPY(63, 16, 0), |
77 | /*2034*/ SPY(64,16,0), SPY(65,16,0), SPY(66,16,0), SPY(67,17,0), | 79 | /*2034*/ SPY(64, 16, 0), SPY(65, 16, 0), SPY(66, 16, 0), SPY(67, 17, 0), |
78 | /*2038*/ SPY(68,17,0) | 80 | /*2038*/ SPY(68, 17, 0) |
79 | }; | 81 | }; |
80 | 82 | ||
81 | extern struct timezone sys_tz; | 83 | extern struct timezone sys_tz; |
@@ -115,7 +117,7 @@ time_t *udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src) | |||
115 | return dest; | 117 | return dest; |
116 | } | 118 | } |
117 | 119 | ||
118 | kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) | 120 | kernel_timestamp *udf_time_to_stamp(kernel_timestamp *dest, struct timespec ts) |
119 | { | 121 | { |
120 | long int days, rem, y; | 122 | long int days, rem, y; |
121 | const unsigned short int *ip; | 123 | const unsigned short int *ip; |
@@ -137,7 +139,7 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) | |||
137 | dest->second = rem % 60; | 139 | dest->second = rem % 60; |
138 | y = 1970; | 140 | y = 1970; |
139 | 141 | ||
140 | #define DIV(a,b) ((a) / (b) - ((a) % (b) < 0)) | 142 | #define DIV(a, b) ((a) / (b) - ((a) % (b) < 0)) |
141 | #define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400)) | 143 | #define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400)) |
142 | 144 | ||
143 | while (days < 0 || days >= (__isleap(y) ? 366 : 365)) { | 145 | while (days < 0 || days >= (__isleap(y) ? 366 : 365)) { |
@@ -145,8 +147,8 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) | |||
145 | 147 | ||
146 | /* Adjust DAYS and Y to match the guessed year. */ | 148 | /* Adjust DAYS and Y to match the guessed year. */ |
147 | days -= ((yg - y) * 365 | 149 | days -= ((yg - y) * 365 |
148 | + LEAPS_THRU_END_OF (yg - 1) | 150 | + LEAPS_THRU_END_OF(yg - 1) |
149 | - LEAPS_THRU_END_OF (y - 1)); | 151 | - LEAPS_THRU_END_OF(y - 1)); |
150 | y = yg; | 152 | y = yg; |
151 | } | 153 | } |
152 | dest->year = y; | 154 | dest->year = y; |
@@ -158,7 +160,8 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) | |||
158 | dest->day = days + 1; | 160 | dest->day = days + 1; |
159 | 161 | ||
160 | dest->centiseconds = ts.tv_nsec / 10000000; | 162 | dest->centiseconds = ts.tv_nsec / 10000000; |
161 | dest->hundredsOfMicroseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100; | 163 | dest->hundredsOfMicroseconds = (ts.tv_nsec / 1000 - |
164 | dest->centiseconds * 10000) / 100; | ||
162 | dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 - | 165 | dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 - |
163 | dest->hundredsOfMicroseconds * 100); | 166 | dest->hundredsOfMicroseconds * 100); |
164 | return dest; | 167 | return dest; |
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c index 9e6099c26c27..e533b11703bf 100644 --- a/fs/udf/unicode.c +++ b/fs/udf/unicode.c | |||
@@ -136,12 +136,18 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i) | |||
136 | if (c < 0x80U) { | 136 | if (c < 0x80U) { |
137 | utf_o->u_name[utf_o->u_len++] = (uint8_t)c; | 137 | utf_o->u_name[utf_o->u_len++] = (uint8_t)c; |
138 | } else if (c < 0x800U) { | 138 | } else if (c < 0x800U) { |
139 | utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xc0 | (c >> 6)); | 139 | utf_o->u_name[utf_o->u_len++] = |
140 | utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f)); | 140 | (uint8_t)(0xc0 | (c >> 6)); |
141 | utf_o->u_name[utf_o->u_len++] = | ||
142 | (uint8_t)(0x80 | (c & 0x3f)); | ||
141 | } else { | 143 | } else { |
142 | utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xe0 | (c >> 12)); | 144 | utf_o->u_name[utf_o->u_len++] = |
143 | utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | ((c >> 6) & 0x3f)); | 145 | (uint8_t)(0xe0 | (c >> 12)); |
144 | utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f)); | 146 | utf_o->u_name[utf_o->u_len++] = |
147 | (uint8_t)(0x80 | | ||
148 | ((c >> 6) & 0x3f)); | ||
149 | utf_o->u_name[utf_o->u_len++] = | ||
150 | (uint8_t)(0x80 | (c & 0x3f)); | ||
145 | } | 151 | } |
146 | } | 152 | } |
147 | utf_o->u_cmpID = 8; | 153 | utf_o->u_cmpID = 8; |
@@ -232,9 +238,8 @@ try_again: | |||
232 | goto error_out; | 238 | goto error_out; |
233 | } | 239 | } |
234 | 240 | ||
235 | if (max_val == 0xffffU) { | 241 | if (max_val == 0xffffU) |
236 | ocu[++u_len] = (uint8_t)(utf_char >> 8); | 242 | ocu[++u_len] = (uint8_t)(utf_char >> 8); |
237 | } | ||
238 | ocu[++u_len] = (uint8_t)(utf_char & 0xffU); | 243 | ocu[++u_len] = (uint8_t)(utf_char & 0xffU); |
239 | } | 244 | } |
240 | 245 | ||
@@ -330,29 +335,29 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname, | |||
330 | struct ustr filename, unifilename; | 335 | struct ustr filename, unifilename; |
331 | int len; | 336 | int len; |
332 | 337 | ||
333 | if (udf_build_ustr_exact(&unifilename, sname, flen)) { | 338 | if (udf_build_ustr_exact(&unifilename, sname, flen)) |
334 | return 0; | 339 | return 0; |
335 | } | ||
336 | 340 | ||
337 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { | 341 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { |
338 | if (!udf_CS0toUTF8(&filename, &unifilename)) { | 342 | if (!udf_CS0toUTF8(&filename, &unifilename)) { |
339 | udf_debug("Failed in udf_get_filename: sname = %s\n", sname); | 343 | udf_debug("Failed in udf_get_filename: sname = %s\n", |
344 | sname); | ||
340 | return 0; | 345 | return 0; |
341 | } | 346 | } |
342 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { | 347 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { |
343 | if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, &filename, &unifilename)) { | 348 | if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, &filename, |
344 | udf_debug("Failed in udf_get_filename: sname = %s\n", sname); | 349 | &unifilename)) { |
350 | udf_debug("Failed in udf_get_filename: sname = %s\n", | ||
351 | sname); | ||
345 | return 0; | 352 | return 0; |
346 | } | 353 | } |
347 | } else { | 354 | } else |
348 | return 0; | 355 | return 0; |
349 | } | ||
350 | 356 | ||
351 | len = udf_translate_to_linux(dname, filename.u_name, filename.u_len, | 357 | len = udf_translate_to_linux(dname, filename.u_name, filename.u_len, |
352 | unifilename.u_name, unifilename.u_len); | 358 | unifilename.u_name, unifilename.u_len); |
353 | if (len) { | 359 | if (len) |
354 | return len; | 360 | return len; |
355 | } | ||
356 | 361 | ||
357 | return 0; | 362 | return 0; |
358 | } | 363 | } |
@@ -363,23 +368,20 @@ int udf_put_filename(struct super_block *sb, const uint8_t *sname, | |||
363 | struct ustr unifilename; | 368 | struct ustr unifilename; |
364 | int namelen; | 369 | int namelen; |
365 | 370 | ||
366 | if (!(udf_char_to_ustr(&unifilename, sname, flen))) { | 371 | if (!udf_char_to_ustr(&unifilename, sname, flen)) |
367 | return 0; | 372 | return 0; |
368 | } | ||
369 | 373 | ||
370 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { | 374 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { |
371 | namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN); | 375 | namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN); |
372 | if (!namelen) { | 376 | if (!namelen) |
373 | return 0; | 377 | return 0; |
374 | } | ||
375 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { | 378 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { |
376 | namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename, UDF_NAME_LEN); | 379 | namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, |
377 | if (!namelen) { | 380 | &unifilename, UDF_NAME_LEN); |
381 | if (!namelen) | ||
378 | return 0; | 382 | return 0; |
379 | } | 383 | } else |
380 | } else { | ||
381 | return 0; | 384 | return 0; |
382 | } | ||
383 | 385 | ||
384 | return namelen; | 386 | return namelen; |
385 | } | 387 | } |
@@ -389,8 +391,9 @@ int udf_put_filename(struct super_block *sb, const uint8_t *sname, | |||
389 | #define CRC_MARK '#' | 391 | #define CRC_MARK '#' |
390 | #define EXT_SIZE 5 | 392 | #define EXT_SIZE 5 |
391 | 393 | ||
392 | static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen, | 394 | static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, |
393 | uint8_t *fidName, int fidNameLen) | 395 | int udfLen, uint8_t *fidName, |
396 | int fidNameLen) | ||
394 | { | 397 | { |
395 | int index, newIndex = 0, needsCRC = 0; | 398 | int index, newIndex = 0, needsCRC = 0; |
396 | int extIndex = 0, newExtIndex = 0, hasExt = 0; | 399 | int extIndex = 0, newExtIndex = 0, hasExt = 0; |
@@ -409,13 +412,16 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen | |||
409 | if (curr == '/' || curr == 0) { | 412 | if (curr == '/' || curr == 0) { |
410 | needsCRC = 1; | 413 | needsCRC = 1; |
411 | curr = ILLEGAL_CHAR_MARK; | 414 | curr = ILLEGAL_CHAR_MARK; |
412 | while (index + 1 < udfLen && (udfName[index + 1] == '/' || | 415 | while (index + 1 < udfLen && |
413 | udfName[index + 1] == 0)) | 416 | (udfName[index + 1] == '/' || |
417 | udfName[index + 1] == 0)) | ||
414 | index++; | 418 | index++; |
415 | } if (curr == EXT_MARK && (udfLen - index - 1) <= EXT_SIZE) { | 419 | } |
416 | if (udfLen == index + 1) { | 420 | if (curr == EXT_MARK && |
421 | (udfLen - index - 1) <= EXT_SIZE) { | ||
422 | if (udfLen == index + 1) | ||
417 | hasExt = 0; | 423 | hasExt = 0; |
418 | } else { | 424 | else { |
419 | hasExt = 1; | 425 | hasExt = 1; |
420 | extIndex = index; | 426 | extIndex = index; |
421 | newExtIndex = newIndex; | 427 | newExtIndex = newIndex; |
@@ -433,16 +439,18 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen | |||
433 | 439 | ||
434 | if (hasExt) { | 440 | if (hasExt) { |
435 | int maxFilenameLen; | 441 | int maxFilenameLen; |
436 | for(index = 0; index < EXT_SIZE && extIndex + index + 1 < udfLen; index++) { | 442 | for (index = 0; |
443 | index < EXT_SIZE && extIndex + index + 1 < udfLen; | ||
444 | index++) { | ||
437 | curr = udfName[extIndex + index + 1]; | 445 | curr = udfName[extIndex + index + 1]; |
438 | 446 | ||
439 | if (curr == '/' || curr == 0) { | 447 | if (curr == '/' || curr == 0) { |
440 | needsCRC = 1; | 448 | needsCRC = 1; |
441 | curr = ILLEGAL_CHAR_MARK; | 449 | curr = ILLEGAL_CHAR_MARK; |
442 | while(extIndex + index + 2 < udfLen && | 450 | while (extIndex + index + 2 < udfLen && |
443 | (index + 1 < EXT_SIZE | 451 | (index + 1 < EXT_SIZE && |
444 | && (udfName[extIndex + index + 2] == '/' || | 452 | (udfName[extIndex + index + 2] == '/' || |
445 | udfName[extIndex + index + 2] == 0))) | 453 | udfName[extIndex + index + 2] == 0))) |
446 | index++; | 454 | index++; |
447 | } | 455 | } |
448 | ext[localExtIndex++] = curr; | 456 | ext[localExtIndex++] = curr; |
@@ -452,9 +460,8 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen | |||
452 | newIndex = maxFilenameLen; | 460 | newIndex = maxFilenameLen; |
453 | else | 461 | else |
454 | newIndex = newExtIndex; | 462 | newIndex = newExtIndex; |
455 | } else if (newIndex > 250) { | 463 | } else if (newIndex > 250) |
456 | newIndex = 250; | 464 | newIndex = 250; |
457 | } | ||
458 | newName[newIndex++] = CRC_MARK; | 465 | newName[newIndex++] = CRC_MARK; |
459 | valueCRC = udf_crc(fidName, fidNameLen, 0); | 466 | valueCRC = udf_crc(fidName, fidNameLen, 0); |
460 | newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12]; | 467 | newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12]; |
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index f63a09ce8683..1fca381f0ce2 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c | |||
@@ -9,7 +9,6 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/fs.h> | 11 | #include <linux/fs.h> |
12 | #include <linux/ufs_fs.h> | ||
13 | #include <linux/stat.h> | 12 | #include <linux/stat.h> |
14 | #include <linux/time.h> | 13 | #include <linux/time.h> |
15 | #include <linux/string.h> | 14 | #include <linux/string.h> |
@@ -19,6 +18,7 @@ | |||
19 | #include <linux/bitops.h> | 18 | #include <linux/bitops.h> |
20 | #include <asm/byteorder.h> | 19 | #include <asm/byteorder.h> |
21 | 20 | ||
21 | #include "ufs_fs.h" | ||
22 | #include "ufs.h" | 22 | #include "ufs.h" |
23 | #include "swab.h" | 23 | #include "swab.h" |
24 | #include "util.h" | 24 | #include "util.h" |
diff --git a/fs/ufs/cylinder.c b/fs/ufs/cylinder.c index 2a815665644f..b4676322ddb6 100644 --- a/fs/ufs/cylinder.c +++ b/fs/ufs/cylinder.c | |||
@@ -9,7 +9,6 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/fs.h> | 11 | #include <linux/fs.h> |
12 | #include <linux/ufs_fs.h> | ||
13 | #include <linux/time.h> | 12 | #include <linux/time.h> |
14 | #include <linux/stat.h> | 13 | #include <linux/stat.h> |
15 | #include <linux/string.h> | 14 | #include <linux/string.h> |
@@ -17,6 +16,7 @@ | |||
17 | 16 | ||
18 | #include <asm/byteorder.h> | 17 | #include <asm/byteorder.h> |
19 | 18 | ||
19 | #include "ufs_fs.h" | ||
20 | #include "ufs.h" | 20 | #include "ufs.h" |
21 | #include "swab.h" | 21 | #include "swab.h" |
22 | #include "util.h" | 22 | #include "util.h" |
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index aaf2878305ce..ef563fc8d72c 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c | |||
@@ -18,9 +18,9 @@ | |||
18 | 18 | ||
19 | #include <linux/time.h> | 19 | #include <linux/time.h> |
20 | #include <linux/fs.h> | 20 | #include <linux/fs.h> |
21 | #include <linux/ufs_fs.h> | ||
22 | #include <linux/swap.h> | 21 | #include <linux/swap.h> |
23 | 22 | ||
23 | #include "ufs_fs.h" | ||
24 | #include "ufs.h" | 24 | #include "ufs.h" |
25 | #include "swab.h" | 25 | #include "swab.h" |
26 | #include "util.h" | 26 | #include "util.h" |
diff --git a/fs/ufs/file.c b/fs/ufs/file.c index a46c97bf023f..625ef17c6f83 100644 --- a/fs/ufs/file.c +++ b/fs/ufs/file.c | |||
@@ -24,9 +24,9 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
27 | #include <linux/ufs_fs.h> | ||
28 | #include <linux/buffer_head.h> /* for sync_mapping_buffers() */ | 27 | #include <linux/buffer_head.h> /* for sync_mapping_buffers() */ |
29 | 28 | ||
29 | #include "ufs_fs.h" | ||
30 | #include "ufs.h" | 30 | #include "ufs.h" |
31 | 31 | ||
32 | 32 | ||
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c index 7e260bc0d94f..ac181f6806a3 100644 --- a/fs/ufs/ialloc.c +++ b/fs/ufs/ialloc.c | |||
@@ -24,7 +24,6 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
27 | #include <linux/ufs_fs.h> | ||
28 | #include <linux/time.h> | 27 | #include <linux/time.h> |
29 | #include <linux/stat.h> | 28 | #include <linux/stat.h> |
30 | #include <linux/string.h> | 29 | #include <linux/string.h> |
@@ -34,6 +33,7 @@ | |||
34 | #include <linux/bitops.h> | 33 | #include <linux/bitops.h> |
35 | #include <asm/byteorder.h> | 34 | #include <asm/byteorder.h> |
36 | 35 | ||
36 | #include "ufs_fs.h" | ||
37 | #include "ufs.h" | 37 | #include "ufs.h" |
38 | #include "swab.h" | 38 | #include "swab.h" |
39 | #include "util.h" | 39 | #include "util.h" |
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 489f26bc26d9..5446b888fc8e 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c | |||
@@ -30,7 +30,6 @@ | |||
30 | 30 | ||
31 | #include <linux/errno.h> | 31 | #include <linux/errno.h> |
32 | #include <linux/fs.h> | 32 | #include <linux/fs.h> |
33 | #include <linux/ufs_fs.h> | ||
34 | #include <linux/time.h> | 33 | #include <linux/time.h> |
35 | #include <linux/stat.h> | 34 | #include <linux/stat.h> |
36 | #include <linux/string.h> | 35 | #include <linux/string.h> |
@@ -38,6 +37,7 @@ | |||
38 | #include <linux/smp_lock.h> | 37 | #include <linux/smp_lock.h> |
39 | #include <linux/buffer_head.h> | 38 | #include <linux/buffer_head.h> |
40 | 39 | ||
40 | #include "ufs_fs.h" | ||
41 | #include "ufs.h" | 41 | #include "ufs.h" |
42 | #include "swab.h" | 42 | #include "swab.h" |
43 | #include "util.h" | 43 | #include "util.h" |
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index 747a4de6c695..e3a9b1fac75a 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c | |||
@@ -29,8 +29,9 @@ | |||
29 | 29 | ||
30 | #include <linux/time.h> | 30 | #include <linux/time.h> |
31 | #include <linux/fs.h> | 31 | #include <linux/fs.h> |
32 | #include <linux/ufs_fs.h> | ||
33 | #include <linux/smp_lock.h> | 32 | #include <linux/smp_lock.h> |
33 | |||
34 | #include "ufs_fs.h" | ||
34 | #include "ufs.h" | 35 | #include "ufs.h" |
35 | #include "util.h" | 36 | #include "util.h" |
36 | 37 | ||
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 73deff475e63..85b22b5977fa 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -76,7 +76,6 @@ | |||
76 | 76 | ||
77 | #include <linux/errno.h> | 77 | #include <linux/errno.h> |
78 | #include <linux/fs.h> | 78 | #include <linux/fs.h> |
79 | #include <linux/ufs_fs.h> | ||
80 | #include <linux/slab.h> | 79 | #include <linux/slab.h> |
81 | #include <linux/time.h> | 80 | #include <linux/time.h> |
82 | #include <linux/stat.h> | 81 | #include <linux/stat.h> |
@@ -91,6 +90,7 @@ | |||
91 | #include <linux/mount.h> | 90 | #include <linux/mount.h> |
92 | #include <linux/seq_file.h> | 91 | #include <linux/seq_file.h> |
93 | 92 | ||
93 | #include "ufs_fs.h" | ||
94 | #include "ufs.h" | 94 | #include "ufs.h" |
95 | #include "swab.h" | 95 | #include "swab.h" |
96 | #include "util.h" | 96 | #include "util.h" |
@@ -131,6 +131,8 @@ static void ufs_print_super_stuff(struct super_block *sb, | |||
131 | printk(KERN_INFO" cs_nffree(Num of free frags): %llu\n", | 131 | printk(KERN_INFO" cs_nffree(Num of free frags): %llu\n", |
132 | (unsigned long long) | 132 | (unsigned long long) |
133 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree)); | 133 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree)); |
134 | printk(KERN_INFO" fs_maxsymlinklen: %u\n", | ||
135 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen)); | ||
134 | } else { | 136 | } else { |
135 | printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno)); | 137 | printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno)); |
136 | printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno)); | 138 | printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno)); |
@@ -1061,8 +1063,8 @@ magic_found: | |||
1061 | uspi->s_bpf = uspi->s_fsize << 3; | 1063 | uspi->s_bpf = uspi->s_fsize << 3; |
1062 | uspi->s_bpfshift = uspi->s_fshift + 3; | 1064 | uspi->s_bpfshift = uspi->s_fshift + 3; |
1063 | uspi->s_bpfmask = uspi->s_bpf - 1; | 1065 | uspi->s_bpfmask = uspi->s_bpf - 1; |
1064 | if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == | 1066 | if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_44BSD || |
1065 | UFS_MOUNT_UFSTYPE_44BSD) | 1067 | (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_UFS2) |
1066 | uspi->s_maxsymlinklen = | 1068 | uspi->s_maxsymlinklen = |
1067 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); | 1069 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); |
1068 | 1070 | ||
diff --git a/fs/ufs/symlink.c b/fs/ufs/symlink.c index 43ac10e75a4a..c0156eda44bc 100644 --- a/fs/ufs/symlink.c +++ b/fs/ufs/symlink.c | |||
@@ -27,7 +27,8 @@ | |||
27 | 27 | ||
28 | #include <linux/fs.h> | 28 | #include <linux/fs.h> |
29 | #include <linux/namei.h> | 29 | #include <linux/namei.h> |
30 | #include <linux/ufs_fs.h> | 30 | |
31 | #include "ufs_fs.h" | ||
31 | #include "ufs.h" | 32 | #include "ufs.h" |
32 | 33 | ||
33 | 34 | ||
diff --git a/fs/ufs/truncate.c b/fs/ufs/truncate.c index 311ded34c2b2..41dd431ce228 100644 --- a/fs/ufs/truncate.c +++ b/fs/ufs/truncate.c | |||
@@ -36,7 +36,6 @@ | |||
36 | 36 | ||
37 | #include <linux/errno.h> | 37 | #include <linux/errno.h> |
38 | #include <linux/fs.h> | 38 | #include <linux/fs.h> |
39 | #include <linux/ufs_fs.h> | ||
40 | #include <linux/fcntl.h> | 39 | #include <linux/fcntl.h> |
41 | #include <linux/time.h> | 40 | #include <linux/time.h> |
42 | #include <linux/stat.h> | 41 | #include <linux/stat.h> |
@@ -46,6 +45,7 @@ | |||
46 | #include <linux/blkdev.h> | 45 | #include <linux/blkdev.h> |
47 | #include <linux/sched.h> | 46 | #include <linux/sched.h> |
48 | 47 | ||
48 | #include "ufs_fs.h" | ||
49 | #include "ufs.h" | 49 | #include "ufs.h" |
50 | #include "swab.h" | 50 | #include "swab.h" |
51 | #include "util.h" | 51 | #include "util.h" |
diff --git a/fs/ufs/ufs_fs.h b/fs/ufs/ufs_fs.h new file mode 100644 index 000000000000..54bde1895a80 --- /dev/null +++ b/fs/ufs/ufs_fs.h | |||
@@ -0,0 +1,947 @@ | |||
1 | /* | ||
2 | * linux/include/linux/ufs_fs.h | ||
3 | * | ||
4 | * Copyright (C) 1996 | ||
5 | * Adrian Rodriguez (adrian@franklins-tower.rutgers.edu) | ||
6 | * Laboratory for Computer Science Research Computing Facility | ||
7 | * Rutgers, The State University of New Jersey | ||
8 | * | ||
9 | * Clean swab support by Fare <fare@tunes.org> | ||
10 | * just hope no one is using NNUUXXI on __?64 structure elements | ||
11 | * 64-bit clean thanks to Maciej W. Rozycki <macro@ds2.pg.gda.pl> | ||
12 | * | ||
13 | * 4.4BSD (FreeBSD) support added on February 1st 1998 by | ||
14 | * Niels Kristian Bech Jensen <nkbj@image.dk> partially based | ||
15 | * on code by Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de>. | ||
16 | * | ||
17 | * NeXTstep support added on February 5th 1998 by | ||
18 | * Niels Kristian Bech Jensen <nkbj@image.dk>. | ||
19 | * | ||
20 | * Write support by Daniel Pirkl <daniel.pirkl@email.cz> | ||
21 | * | ||
22 | * HP/UX hfs filesystem support added by | ||
23 | * Martin K. Petersen <mkp@mkp.net>, August 1999 | ||
24 | * | ||
25 | * UFS2 (of FreeBSD 5.x) support added by | ||
26 | * Niraj Kumar <niraj17@iitbombay.org> , Jan 2004 | ||
27 | * | ||
28 | */ | ||
29 | |||
30 | #ifndef __LINUX_UFS_FS_H | ||
31 | #define __LINUX_UFS_FS_H | ||
32 | |||
33 | #include <linux/types.h> | ||
34 | #include <linux/kernel.h> | ||
35 | #include <linux/stat.h> | ||
36 | #include <linux/fs.h> | ||
37 | |||
38 | #include <asm/div64.h> | ||
39 | typedef __u64 __bitwise __fs64; | ||
40 | typedef __u32 __bitwise __fs32; | ||
41 | typedef __u16 __bitwise __fs16; | ||
42 | |||
43 | #define UFS_BBLOCK 0 | ||
44 | #define UFS_BBSIZE 8192 | ||
45 | #define UFS_SBLOCK 8192 | ||
46 | #define UFS_SBSIZE 8192 | ||
47 | |||
48 | #define UFS_SECTOR_SIZE 512 | ||
49 | #define UFS_SECTOR_BITS 9 | ||
50 | #define UFS_MAGIC 0x00011954 | ||
51 | #define UFS2_MAGIC 0x19540119 | ||
52 | #define UFS_CIGAM 0x54190100 /* byteswapped MAGIC */ | ||
53 | |||
54 | /* Copied from FreeBSD */ | ||
55 | /* | ||
56 | * Each disk drive contains some number of filesystems. | ||
57 | * A filesystem consists of a number of cylinder groups. | ||
58 | * Each cylinder group has inodes and data. | ||
59 | * | ||
60 | * A filesystem is described by its super-block, which in turn | ||
61 | * describes the cylinder groups. The super-block is critical | ||
62 | * data and is replicated in each cylinder group to protect against | ||
63 | * catastrophic loss. This is done at `newfs' time and the critical | ||
64 | * super-block data does not change, so the copies need not be | ||
65 | * referenced further unless disaster strikes. | ||
66 | * | ||
67 | * For filesystem fs, the offsets of the various blocks of interest | ||
68 | * are given in the super block as: | ||
69 | * [fs->fs_sblkno] Super-block | ||
70 | * [fs->fs_cblkno] Cylinder group block | ||
71 | * [fs->fs_iblkno] Inode blocks | ||
72 | * [fs->fs_dblkno] Data blocks | ||
73 | * The beginning of cylinder group cg in fs, is given by | ||
74 | * the ``cgbase(fs, cg)'' macro. | ||
75 | * | ||
76 | * Depending on the architecture and the media, the superblock may | ||
77 | * reside in any one of four places. For tiny media where every block | ||
78 | * counts, it is placed at the very front of the partition. Historically, | ||
79 | * UFS1 placed it 8K from the front to leave room for the disk label and | ||
80 | * a small bootstrap. For UFS2 it got moved to 64K from the front to leave | ||
81 | * room for the disk label and a bigger bootstrap, and for really piggy | ||
82 | * systems we check at 256K from the front if the first three fail. In | ||
83 | * all cases the size of the superblock will be SBLOCKSIZE. All values are | ||
84 | * given in byte-offset form, so they do not imply a sector size. The | ||
85 | * SBLOCKSEARCH specifies the order in which the locations should be searched. | ||
86 | */ | ||
87 | #define SBLOCK_FLOPPY 0 | ||
88 | #define SBLOCK_UFS1 8192 | ||
89 | #define SBLOCK_UFS2 65536 | ||
90 | #define SBLOCK_PIGGY 262144 | ||
91 | #define SBLOCKSIZE 8192 | ||
92 | #define SBLOCKSEARCH \ | ||
93 | { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 } | ||
94 | |||
95 | |||
96 | /* HP specific MAGIC values */ | ||
97 | |||
98 | #define UFS_MAGIC_LFN 0x00095014 /* fs supports filenames > 14 chars */ | ||
99 | #define UFS_CIGAM_LFN 0x14500900 /* srahc 41 < semanelif stroppus sf */ | ||
100 | |||
101 | #define UFS_MAGIC_SEC 0x00612195 /* B1 security fs */ | ||
102 | #define UFS_CIGAM_SEC 0x95216100 | ||
103 | |||
104 | #define UFS_MAGIC_FEA 0x00195612 /* fs_featurebits supported */ | ||
105 | #define UFS_CIGAM_FEA 0x12561900 | ||
106 | |||
107 | #define UFS_MAGIC_4GB 0x05231994 /* fs > 4 GB && fs_featurebits */ | ||
108 | #define UFS_CIGAM_4GB 0x94192305 | ||
109 | |||
110 | /* Seems somebody at HP goofed here. B1 and lfs are both 0x2 !?! */ | ||
111 | #define UFS_FSF_LFN 0x00000001 /* long file names */ | ||
112 | #define UFS_FSF_B1 0x00000002 /* B1 security */ | ||
113 | #define UFS_FSF_LFS 0x00000002 /* large files */ | ||
114 | #define UFS_FSF_LUID 0x00000004 /* large UIDs */ | ||
115 | |||
116 | /* End of HP stuff */ | ||
117 | |||
118 | |||
119 | #define UFS_BSIZE 8192 | ||
120 | #define UFS_MINBSIZE 4096 | ||
121 | #define UFS_FSIZE 1024 | ||
122 | #define UFS_MAXFRAG (UFS_BSIZE / UFS_FSIZE) | ||
123 | |||
124 | #define UFS_NDADDR 12 | ||
125 | #define UFS_NINDIR 3 | ||
126 | |||
127 | #define UFS_IND_BLOCK (UFS_NDADDR + 0) | ||
128 | #define UFS_DIND_BLOCK (UFS_NDADDR + 1) | ||
129 | #define UFS_TIND_BLOCK (UFS_NDADDR + 2) | ||
130 | |||
131 | #define UFS_NDIR_FRAGMENT (UFS_NDADDR << uspi->s_fpbshift) | ||
132 | #define UFS_IND_FRAGMENT (UFS_IND_BLOCK << uspi->s_fpbshift) | ||
133 | #define UFS_DIND_FRAGMENT (UFS_DIND_BLOCK << uspi->s_fpbshift) | ||
134 | #define UFS_TIND_FRAGMENT (UFS_TIND_BLOCK << uspi->s_fpbshift) | ||
135 | |||
136 | #define UFS_ROOTINO 2 | ||
137 | #define UFS_FIRST_INO (UFS_ROOTINO + 1) | ||
138 | |||
139 | #define UFS_USEEFT ((__u16)65535) | ||
140 | |||
141 | #define UFS_FSOK 0x7c269d38 | ||
142 | #define UFS_FSACTIVE ((__s8)0x00) | ||
143 | #define UFS_FSCLEAN ((__s8)0x01) | ||
144 | #define UFS_FSSTABLE ((__s8)0x02) | ||
145 | #define UFS_FSOSF1 ((__s8)0x03) /* is this correct for DEC OSF/1? */ | ||
146 | #define UFS_FSBAD ((__s8)0xff) | ||
147 | |||
148 | /* From here to next blank line, s_flags for ufs_sb_info */ | ||
149 | /* directory entry encoding */ | ||
150 | #define UFS_DE_MASK 0x00000010 /* mask for the following */ | ||
151 | #define UFS_DE_OLD 0x00000000 | ||
152 | #define UFS_DE_44BSD 0x00000010 | ||
153 | /* uid encoding */ | ||
154 | #define UFS_UID_MASK 0x00000060 /* mask for the following */ | ||
155 | #define UFS_UID_OLD 0x00000000 | ||
156 | #define UFS_UID_44BSD 0x00000020 | ||
157 | #define UFS_UID_EFT 0x00000040 | ||
158 | /* superblock state encoding */ | ||
159 | #define UFS_ST_MASK 0x00000700 /* mask for the following */ | ||
160 | #define UFS_ST_OLD 0x00000000 | ||
161 | #define UFS_ST_44BSD 0x00000100 | ||
162 | #define UFS_ST_SUN 0x00000200 /* Solaris */ | ||
163 | #define UFS_ST_SUNOS 0x00000300 | ||
164 | #define UFS_ST_SUNx86 0x00000400 /* Solaris x86 */ | ||
165 | /*cylinder group encoding */ | ||
166 | #define UFS_CG_MASK 0x00003000 /* mask for the following */ | ||
167 | #define UFS_CG_OLD 0x00000000 | ||
168 | #define UFS_CG_44BSD 0x00002000 | ||
169 | #define UFS_CG_SUN 0x00001000 | ||
170 | /* filesystem type encoding */ | ||
171 | #define UFS_TYPE_MASK 0x00010000 /* mask for the following */ | ||
172 | #define UFS_TYPE_UFS1 0x00000000 | ||
173 | #define UFS_TYPE_UFS2 0x00010000 | ||
174 | |||
175 | |||
176 | /* fs_inodefmt options */ | ||
177 | #define UFS_42INODEFMT -1 | ||
178 | #define UFS_44INODEFMT 2 | ||
179 | |||
180 | /* | ||
181 | * MINFREE gives the minimum acceptable percentage of file system | ||
182 | * blocks which may be free. If the freelist drops below this level | ||
183 | * only the superuser may continue to allocate blocks. This may | ||
184 | * be set to 0 if no reserve of free blocks is deemed necessary, | ||
185 | * however throughput drops by fifty percent if the file system | ||
186 | * is run at between 95% and 100% full; thus the minimum default | ||
187 | * value of fs_minfree is 5%. However, to get good clustering | ||
188 | * performance, 10% is a better choice. hence we use 10% as our | ||
189 | * default value. With 10% free space, fragmentation is not a | ||
190 | * problem, so we choose to optimize for time. | ||
191 | */ | ||
192 | #define UFS_MINFREE 5 | ||
193 | #define UFS_DEFAULTOPT UFS_OPTTIME | ||
194 | |||
195 | /* | ||
196 | * Turn file system block numbers into disk block addresses. | ||
197 | * This maps file system blocks to device size blocks. | ||
198 | */ | ||
199 | #define ufs_fsbtodb(uspi, b) ((b) << (uspi)->s_fsbtodb) | ||
200 | #define ufs_dbtofsb(uspi, b) ((b) >> (uspi)->s_fsbtodb) | ||
201 | |||
202 | /* | ||
203 | * Cylinder group macros to locate things in cylinder groups. | ||
204 | * They calc file system addresses of cylinder group data structures. | ||
205 | */ | ||
206 | #define ufs_cgbase(c) (uspi->s_fpg * (c)) | ||
207 | #define ufs_cgstart(c) ((uspi)->fs_magic == UFS2_MAGIC ? ufs_cgbase(c) : \ | ||
208 | (ufs_cgbase(c) + uspi->s_cgoffset * ((c) & ~uspi->s_cgmask))) | ||
209 | #define ufs_cgsblock(c) (ufs_cgstart(c) + uspi->s_sblkno) /* super blk */ | ||
210 | #define ufs_cgcmin(c) (ufs_cgstart(c) + uspi->s_cblkno) /* cg block */ | ||
211 | #define ufs_cgimin(c) (ufs_cgstart(c) + uspi->s_iblkno) /* inode blk */ | ||
212 | #define ufs_cgdmin(c) (ufs_cgstart(c) + uspi->s_dblkno) /* 1st data */ | ||
213 | |||
214 | /* | ||
215 | * Macros for handling inode numbers: | ||
216 | * inode number to file system block offset. | ||
217 | * inode number to cylinder group number. | ||
218 | * inode number to file system block address. | ||
219 | */ | ||
220 | #define ufs_inotocg(x) ((x) / uspi->s_ipg) | ||
221 | #define ufs_inotocgoff(x) ((x) % uspi->s_ipg) | ||
222 | #define ufs_inotofsba(x) (((u64)ufs_cgimin(ufs_inotocg(x))) + ufs_inotocgoff(x) / uspi->s_inopf) | ||
223 | #define ufs_inotofsbo(x) ((x) % uspi->s_inopf) | ||
224 | |||
225 | /* | ||
226 | * Compute the cylinder and rotational position of a cyl block addr. | ||
227 | */ | ||
228 | #define ufs_cbtocylno(bno) \ | ||
229 | ((bno) * uspi->s_nspf / uspi->s_spc) | ||
230 | #define ufs_cbtorpos(bno) \ | ||
231 | ((((bno) * uspi->s_nspf % uspi->s_spc / uspi->s_nsect \ | ||
232 | * uspi->s_trackskew + (bno) * uspi->s_nspf % uspi->s_spc \ | ||
233 | % uspi->s_nsect * uspi->s_interleave) % uspi->s_nsect \ | ||
234 | * uspi->s_nrpos) / uspi->s_npsect) | ||
235 | |||
236 | /* | ||
237 | * The following macros optimize certain frequently calculated | ||
238 | * quantities by using shifts and masks in place of divisions | ||
239 | * modulos and multiplications. | ||
240 | */ | ||
241 | #define ufs_blkoff(loc) ((loc) & uspi->s_qbmask) | ||
242 | #define ufs_fragoff(loc) ((loc) & uspi->s_qfmask) | ||
243 | #define ufs_lblktosize(blk) ((blk) << uspi->s_bshift) | ||
244 | #define ufs_lblkno(loc) ((loc) >> uspi->s_bshift) | ||
245 | #define ufs_numfrags(loc) ((loc) >> uspi->s_fshift) | ||
246 | #define ufs_blkroundup(size) (((size) + uspi->s_qbmask) & uspi->s_bmask) | ||
247 | #define ufs_fragroundup(size) (((size) + uspi->s_qfmask) & uspi->s_fmask) | ||
248 | #define ufs_fragstoblks(frags) ((frags) >> uspi->s_fpbshift) | ||
249 | #define ufs_blkstofrags(blks) ((blks) << uspi->s_fpbshift) | ||
250 | #define ufs_fragnum(fsb) ((fsb) & uspi->s_fpbmask) | ||
251 | #define ufs_blknum(fsb) ((fsb) & ~uspi->s_fpbmask) | ||
252 | |||
253 | #define UFS_MAXNAMLEN 255 | ||
254 | #define UFS_MAXMNTLEN 512 | ||
255 | #define UFS2_MAXMNTLEN 468 | ||
256 | #define UFS2_MAXVOLLEN 32 | ||
257 | #define UFS_MAXCSBUFS 31 | ||
258 | #define UFS_LINK_MAX 32000 | ||
259 | /* | ||
260 | #define UFS2_NOCSPTRS ((128 / sizeof(void *)) - 4) | ||
261 | */ | ||
262 | #define UFS2_NOCSPTRS 28 | ||
263 | |||
264 | /* | ||
265 | * UFS_DIR_PAD defines the directory entries boundaries | ||
266 | * (must be a multiple of 4) | ||
267 | */ | ||
268 | #define UFS_DIR_PAD 4 | ||
269 | #define UFS_DIR_ROUND (UFS_DIR_PAD - 1) | ||
270 | #define UFS_DIR_REC_LEN(name_len) (((name_len) + 1 + 8 + UFS_DIR_ROUND) & ~UFS_DIR_ROUND) | ||
271 | |||
272 | struct ufs_timeval { | ||
273 | __fs32 tv_sec; | ||
274 | __fs32 tv_usec; | ||
275 | }; | ||
276 | |||
277 | struct ufs_dir_entry { | ||
278 | __fs32 d_ino; /* inode number of this entry */ | ||
279 | __fs16 d_reclen; /* length of this entry */ | ||
280 | union { | ||
281 | __fs16 d_namlen; /* actual length of d_name */ | ||
282 | struct { | ||
283 | __u8 d_type; /* file type */ | ||
284 | __u8 d_namlen; /* length of string in d_name */ | ||
285 | } d_44; | ||
286 | } d_u; | ||
287 | __u8 d_name[UFS_MAXNAMLEN + 1]; /* file name */ | ||
288 | }; | ||
289 | |||
290 | struct ufs_csum { | ||
291 | __fs32 cs_ndir; /* number of directories */ | ||
292 | __fs32 cs_nbfree; /* number of free blocks */ | ||
293 | __fs32 cs_nifree; /* number of free inodes */ | ||
294 | __fs32 cs_nffree; /* number of free frags */ | ||
295 | }; | ||
296 | struct ufs2_csum_total { | ||
297 | __fs64 cs_ndir; /* number of directories */ | ||
298 | __fs64 cs_nbfree; /* number of free blocks */ | ||
299 | __fs64 cs_nifree; /* number of free inodes */ | ||
300 | __fs64 cs_nffree; /* number of free frags */ | ||
301 | __fs64 cs_numclusters; /* number of free clusters */ | ||
302 | __fs64 cs_spare[3]; /* future expansion */ | ||
303 | }; | ||
304 | |||
305 | struct ufs_csum_core { | ||
306 | __u64 cs_ndir; /* number of directories */ | ||
307 | __u64 cs_nbfree; /* number of free blocks */ | ||
308 | __u64 cs_nifree; /* number of free inodes */ | ||
309 | __u64 cs_nffree; /* number of free frags */ | ||
310 | __u64 cs_numclusters; /* number of free clusters */ | ||
311 | }; | ||
312 | |||
313 | /* | ||
314 | * File system flags | ||
315 | */ | ||
316 | #define UFS_UNCLEAN 0x01 /* file system not clean at mount (unused) */ | ||
317 | #define UFS_DOSOFTDEP 0x02 /* file system using soft dependencies */ | ||
318 | #define UFS_NEEDSFSCK 0x04 /* needs sync fsck (FreeBSD compat, unused) */ | ||
319 | #define UFS_INDEXDIRS 0x08 /* kernel supports indexed directories */ | ||
320 | #define UFS_ACLS 0x10 /* file system has ACLs enabled */ | ||
321 | #define UFS_MULTILABEL 0x20 /* file system is MAC multi-label */ | ||
322 | #define UFS_FLAGS_UPDATED 0x80 /* flags have been moved to new location */ | ||
323 | |||
324 | #if 0 | ||
325 | /* | ||
326 | * This is the actual superblock, as it is laid out on the disk. | ||
327 | * Do NOT use this structure, because of sizeof(ufs_super_block) > 512 and | ||
328 | * it may occupy several blocks, use | ||
329 | * struct ufs_super_block_(first,second,third) instead. | ||
330 | */ | ||
331 | struct ufs_super_block { | ||
332 | union { | ||
333 | struct { | ||
334 | __fs32 fs_link; /* UNUSED */ | ||
335 | } fs_42; | ||
336 | struct { | ||
337 | __fs32 fs_state; /* file system state flag */ | ||
338 | } fs_sun; | ||
339 | } fs_u0; | ||
340 | __fs32 fs_rlink; /* UNUSED */ | ||
341 | __fs32 fs_sblkno; /* addr of super-block in filesys */ | ||
342 | __fs32 fs_cblkno; /* offset of cyl-block in filesys */ | ||
343 | __fs32 fs_iblkno; /* offset of inode-blocks in filesys */ | ||
344 | __fs32 fs_dblkno; /* offset of first data after cg */ | ||
345 | __fs32 fs_cgoffset; /* cylinder group offset in cylinder */ | ||
346 | __fs32 fs_cgmask; /* used to calc mod fs_ntrak */ | ||
347 | __fs32 fs_time; /* last time written -- time_t */ | ||
348 | __fs32 fs_size; /* number of blocks in fs */ | ||
349 | __fs32 fs_dsize; /* number of data blocks in fs */ | ||
350 | __fs32 fs_ncg; /* number of cylinder groups */ | ||
351 | __fs32 fs_bsize; /* size of basic blocks in fs */ | ||
352 | __fs32 fs_fsize; /* size of frag blocks in fs */ | ||
353 | __fs32 fs_frag; /* number of frags in a block in fs */ | ||
354 | /* these are configuration parameters */ | ||
355 | __fs32 fs_minfree; /* minimum percentage of free blocks */ | ||
356 | __fs32 fs_rotdelay; /* num of ms for optimal next block */ | ||
357 | __fs32 fs_rps; /* disk revolutions per second */ | ||
358 | /* these fields can be computed from the others */ | ||
359 | __fs32 fs_bmask; /* ``blkoff'' calc of blk offsets */ | ||
360 | __fs32 fs_fmask; /* ``fragoff'' calc of frag offsets */ | ||
361 | __fs32 fs_bshift; /* ``lblkno'' calc of logical blkno */ | ||
362 | __fs32 fs_fshift; /* ``numfrags'' calc number of frags */ | ||
363 | /* these are configuration parameters */ | ||
364 | __fs32 fs_maxcontig; /* max number of contiguous blks */ | ||
365 | __fs32 fs_maxbpg; /* max number of blks per cyl group */ | ||
366 | /* these fields can be computed from the others */ | ||
367 | __fs32 fs_fragshift; /* block to frag shift */ | ||
368 | __fs32 fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ | ||
369 | __fs32 fs_sbsize; /* actual size of super block */ | ||
370 | __fs32 fs_csmask; /* csum block offset */ | ||
371 | __fs32 fs_csshift; /* csum block number */ | ||
372 | __fs32 fs_nindir; /* value of NINDIR */ | ||
373 | __fs32 fs_inopb; /* value of INOPB */ | ||
374 | __fs32 fs_nspf; /* value of NSPF */ | ||
375 | /* yet another configuration parameter */ | ||
376 | __fs32 fs_optim; /* optimization preference, see below */ | ||
377 | /* these fields are derived from the hardware */ | ||
378 | union { | ||
379 | struct { | ||
380 | __fs32 fs_npsect; /* # sectors/track including spares */ | ||
381 | } fs_sun; | ||
382 | struct { | ||
383 | __fs32 fs_state; /* file system state time stamp */ | ||
384 | } fs_sunx86; | ||
385 | } fs_u1; | ||
386 | __fs32 fs_interleave; /* hardware sector interleave */ | ||
387 | __fs32 fs_trackskew; /* sector 0 skew, per track */ | ||
388 | /* a unique id for this filesystem (currently unused and unmaintained) */ | ||
389 | /* In 4.3 Tahoe this space is used by fs_headswitch and fs_trkseek */ | ||
390 | /* Neither of those fields is used in the Tahoe code right now but */ | ||
391 | /* there could be problems if they are. */ | ||
392 | __fs32 fs_id[2]; /* file system id */ | ||
393 | /* sizes determined by number of cylinder groups and their sizes */ | ||
394 | __fs32 fs_csaddr; /* blk addr of cyl grp summary area */ | ||
395 | __fs32 fs_cssize; /* size of cyl grp summary area */ | ||
396 | __fs32 fs_cgsize; /* cylinder group size */ | ||
397 | /* these fields are derived from the hardware */ | ||
398 | __fs32 fs_ntrak; /* tracks per cylinder */ | ||
399 | __fs32 fs_nsect; /* sectors per track */ | ||
400 | __fs32 fs_spc; /* sectors per cylinder */ | ||
401 | /* this comes from the disk driver partitioning */ | ||
402 | __fs32 fs_ncyl; /* cylinders in file system */ | ||
403 | /* these fields can be computed from the others */ | ||
404 | __fs32 fs_cpg; /* cylinders per group */ | ||
405 | __fs32 fs_ipg; /* inodes per cylinder group */ | ||
406 | __fs32 fs_fpg; /* blocks per group * fs_frag */ | ||
407 | /* this data must be re-computed after crashes */ | ||
408 | struct ufs_csum fs_cstotal; /* cylinder summary information */ | ||
409 | /* these fields are cleared at mount time */ | ||
410 | __s8 fs_fmod; /* super block modified flag */ | ||
411 | __s8 fs_clean; /* file system is clean flag */ | ||
412 | __s8 fs_ronly; /* mounted read-only flag */ | ||
413 | __s8 fs_flags; | ||
414 | union { | ||
415 | struct { | ||
416 | __s8 fs_fsmnt[UFS_MAXMNTLEN];/* name mounted on */ | ||
417 | __fs32 fs_cgrotor; /* last cg searched */ | ||
418 | __fs32 fs_csp[UFS_MAXCSBUFS];/*list of fs_cs info buffers */ | ||
419 | __fs32 fs_maxcluster; | ||
420 | __fs32 fs_cpc; /* cyl per cycle in postbl */ | ||
421 | __fs16 fs_opostbl[16][8]; /* old rotation block list head */ | ||
422 | } fs_u1; | ||
423 | struct { | ||
424 | __s8 fs_fsmnt[UFS2_MAXMNTLEN]; /* name mounted on */ | ||
425 | __u8 fs_volname[UFS2_MAXVOLLEN]; /* volume name */ | ||
426 | __fs64 fs_swuid; /* system-wide uid */ | ||
427 | __fs32 fs_pad; /* due to alignment of fs_swuid */ | ||
428 | __fs32 fs_cgrotor; /* last cg searched */ | ||
429 | __fs32 fs_ocsp[UFS2_NOCSPTRS]; /*list of fs_cs info buffers */ | ||
430 | __fs32 fs_contigdirs;/*# of contiguously allocated dirs */ | ||
431 | __fs32 fs_csp; /* cg summary info buffer for fs_cs */ | ||
432 | __fs32 fs_maxcluster; | ||
433 | __fs32 fs_active;/* used by snapshots to track fs */ | ||
434 | __fs32 fs_old_cpc; /* cyl per cycle in postbl */ | ||
435 | __fs32 fs_maxbsize;/*maximum blocking factor permitted */ | ||
436 | __fs64 fs_sparecon64[17];/*old rotation block list head */ | ||
437 | __fs64 fs_sblockloc; /* byte offset of standard superblock */ | ||
438 | struct ufs2_csum_total fs_cstotal;/*cylinder summary information*/ | ||
439 | struct ufs_timeval fs_time; /* last time written */ | ||
440 | __fs64 fs_size; /* number of blocks in fs */ | ||
441 | __fs64 fs_dsize; /* number of data blocks in fs */ | ||
442 | __fs64 fs_csaddr; /* blk addr of cyl grp summary area */ | ||
443 | __fs64 fs_pendingblocks;/* blocks in process of being freed */ | ||
444 | __fs32 fs_pendinginodes;/*inodes in process of being freed */ | ||
445 | } fs_u2; | ||
446 | } fs_u11; | ||
447 | union { | ||
448 | struct { | ||
449 | __fs32 fs_sparecon[53];/* reserved for future constants */ | ||
450 | __fs32 fs_reclaim; | ||
451 | __fs32 fs_sparecon2[1]; | ||
452 | __fs32 fs_state; /* file system state time stamp */ | ||
453 | __fs32 fs_qbmask[2]; /* ~usb_bmask */ | ||
454 | __fs32 fs_qfmask[2]; /* ~usb_fmask */ | ||
455 | } fs_sun; | ||
456 | struct { | ||
457 | __fs32 fs_sparecon[53];/* reserved for future constants */ | ||
458 | __fs32 fs_reclaim; | ||
459 | __fs32 fs_sparecon2[1]; | ||
460 | __fs32 fs_npsect; /* # sectors/track including spares */ | ||
461 | __fs32 fs_qbmask[2]; /* ~usb_bmask */ | ||
462 | __fs32 fs_qfmask[2]; /* ~usb_fmask */ | ||
463 | } fs_sunx86; | ||
464 | struct { | ||
465 | __fs32 fs_sparecon[50];/* reserved for future constants */ | ||
466 | __fs32 fs_contigsumsize;/* size of cluster summary array */ | ||
467 | __fs32 fs_maxsymlinklen;/* max length of an internal symlink */ | ||
468 | __fs32 fs_inodefmt; /* format of on-disk inodes */ | ||
469 | __fs32 fs_maxfilesize[2]; /* max representable file size */ | ||
470 | __fs32 fs_qbmask[2]; /* ~usb_bmask */ | ||
471 | __fs32 fs_qfmask[2]; /* ~usb_fmask */ | ||
472 | __fs32 fs_state; /* file system state time stamp */ | ||
473 | } fs_44; | ||
474 | } fs_u2; | ||
475 | __fs32 fs_postblformat; /* format of positional layout tables */ | ||
476 | __fs32 fs_nrpos; /* number of rotational positions */ | ||
477 | __fs32 fs_postbloff; /* (__s16) rotation block list head */ | ||
478 | __fs32 fs_rotbloff; /* (__u8) blocks for each rotation */ | ||
479 | __fs32 fs_magic; /* magic number */ | ||
480 | __u8 fs_space[1]; /* list of blocks for each rotation */ | ||
481 | }; | ||
482 | #endif/*struct ufs_super_block*/ | ||
483 | |||
484 | /* | ||
485 | * Preference for optimization. | ||
486 | */ | ||
487 | #define UFS_OPTTIME 0 /* minimize allocation time */ | ||
488 | #define UFS_OPTSPACE 1 /* minimize disk fragmentation */ | ||
489 | |||
490 | /* | ||
491 | * Rotational layout table format types | ||
492 | */ | ||
493 | #define UFS_42POSTBLFMT -1 /* 4.2BSD rotational table format */ | ||
494 | #define UFS_DYNAMICPOSTBLFMT 1 /* dynamic rotational table format */ | ||
495 | |||
496 | /* | ||
497 | * Convert cylinder group to base address of its global summary info. | ||
498 | */ | ||
499 | #define fs_cs(indx) s_csp[(indx)] | ||
500 | |||
501 | /* | ||
502 | * Cylinder group block for a file system. | ||
503 | * | ||
504 | * Writable fields in the cylinder group are protected by the associated | ||
505 | * super block lock fs->fs_lock. | ||
506 | */ | ||
507 | #define CG_MAGIC 0x090255 | ||
508 | #define ufs_cg_chkmagic(sb, ucg) \ | ||
509 | (fs32_to_cpu((sb), (ucg)->cg_magic) == CG_MAGIC) | ||
510 | /* | ||
511 | * Macros for access to old cylinder group array structures | ||
512 | */ | ||
513 | #define ufs_ocg_blktot(sb, ucg) fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_btot) | ||
514 | #define ufs_ocg_blks(sb, ucg, cylno) fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_b[cylno]) | ||
515 | #define ufs_ocg_inosused(sb, ucg) fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_iused) | ||
516 | #define ufs_ocg_blksfree(sb, ucg) fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_free) | ||
517 | #define ufs_ocg_chkmagic(sb, ucg) \ | ||
518 | (fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_magic) == CG_MAGIC) | ||
519 | |||
520 | /* | ||
521 | * size of this structure is 172 B | ||
522 | */ | ||
523 | struct ufs_cylinder_group { | ||
524 | __fs32 cg_link; /* linked list of cyl groups */ | ||
525 | __fs32 cg_magic; /* magic number */ | ||
526 | __fs32 cg_time; /* time last written */ | ||
527 | __fs32 cg_cgx; /* we are the cgx'th cylinder group */ | ||
528 | __fs16 cg_ncyl; /* number of cyl's this cg */ | ||
529 | __fs16 cg_niblk; /* number of inode blocks this cg */ | ||
530 | __fs32 cg_ndblk; /* number of data blocks this cg */ | ||
531 | struct ufs_csum cg_cs; /* cylinder summary information */ | ||
532 | __fs32 cg_rotor; /* position of last used block */ | ||
533 | __fs32 cg_frotor; /* position of last used frag */ | ||
534 | __fs32 cg_irotor; /* position of last used inode */ | ||
535 | __fs32 cg_frsum[UFS_MAXFRAG]; /* counts of available frags */ | ||
536 | __fs32 cg_btotoff; /* (__u32) block totals per cylinder */ | ||
537 | __fs32 cg_boff; /* (short) free block positions */ | ||
538 | __fs32 cg_iusedoff; /* (char) used inode map */ | ||
539 | __fs32 cg_freeoff; /* (u_char) free block map */ | ||
540 | __fs32 cg_nextfreeoff; /* (u_char) next available space */ | ||
541 | union { | ||
542 | struct { | ||
543 | __fs32 cg_clustersumoff; /* (u_int32) counts of avail clusters */ | ||
544 | __fs32 cg_clusteroff; /* (u_int8) free cluster map */ | ||
545 | __fs32 cg_nclusterblks; /* number of clusters this cg */ | ||
546 | __fs32 cg_sparecon[13]; /* reserved for future use */ | ||
547 | } cg_44; | ||
548 | struct { | ||
549 | __fs32 cg_clustersumoff;/* (u_int32) counts of avail clusters */ | ||
550 | __fs32 cg_clusteroff; /* (u_int8) free cluster map */ | ||
551 | __fs32 cg_nclusterblks;/* number of clusters this cg */ | ||
552 | __fs32 cg_niblk; /* number of inode blocks this cg */ | ||
553 | __fs32 cg_initediblk; /* last initialized inode */ | ||
554 | __fs32 cg_sparecon32[3];/* reserved for future use */ | ||
555 | __fs64 cg_time; /* time last written */ | ||
556 | __fs64 cg_sparecon[3]; /* reserved for future use */ | ||
557 | } cg_u2; | ||
558 | __fs32 cg_sparecon[16]; /* reserved for future use */ | ||
559 | } cg_u; | ||
560 | __u8 cg_space[1]; /* space for cylinder group maps */ | ||
561 | /* actually longer */ | ||
562 | }; | ||
563 | |||
564 | /* Historic Cylinder group info */ | ||
565 | struct ufs_old_cylinder_group { | ||
566 | __fs32 cg_link; /* linked list of cyl groups */ | ||
567 | __fs32 cg_rlink; /* for incore cyl groups */ | ||
568 | __fs32 cg_time; /* time last written */ | ||
569 | __fs32 cg_cgx; /* we are the cgx'th cylinder group */ | ||
570 | __fs16 cg_ncyl; /* number of cyl's this cg */ | ||
571 | __fs16 cg_niblk; /* number of inode blocks this cg */ | ||
572 | __fs32 cg_ndblk; /* number of data blocks this cg */ | ||
573 | struct ufs_csum cg_cs; /* cylinder summary information */ | ||
574 | __fs32 cg_rotor; /* position of last used block */ | ||
575 | __fs32 cg_frotor; /* position of last used frag */ | ||
576 | __fs32 cg_irotor; /* position of last used inode */ | ||
577 | __fs32 cg_frsum[8]; /* counts of available frags */ | ||
578 | __fs32 cg_btot[32]; /* block totals per cylinder */ | ||
579 | __fs16 cg_b[32][8]; /* positions of free blocks */ | ||
580 | __u8 cg_iused[256]; /* used inode map */ | ||
581 | __fs32 cg_magic; /* magic number */ | ||
582 | __u8 cg_free[1]; /* free block map */ | ||
583 | /* actually longer */ | ||
584 | }; | ||
585 | |||
586 | /* | ||
587 | * structure of an on-disk inode | ||
588 | */ | ||
589 | struct ufs_inode { | ||
590 | __fs16 ui_mode; /* 0x0 */ | ||
591 | __fs16 ui_nlink; /* 0x2 */ | ||
592 | union { | ||
593 | struct { | ||
594 | __fs16 ui_suid; /* 0x4 */ | ||
595 | __fs16 ui_sgid; /* 0x6 */ | ||
596 | } oldids; | ||
597 | __fs32 ui_inumber; /* 0x4 lsf: inode number */ | ||
598 | __fs32 ui_author; /* 0x4 GNU HURD: author */ | ||
599 | } ui_u1; | ||
600 | __fs64 ui_size; /* 0x8 */ | ||
601 | struct ufs_timeval ui_atime; /* 0x10 access */ | ||
602 | struct ufs_timeval ui_mtime; /* 0x18 modification */ | ||
603 | struct ufs_timeval ui_ctime; /* 0x20 creation */ | ||
604 | union { | ||
605 | struct { | ||
606 | __fs32 ui_db[UFS_NDADDR];/* 0x28 data blocks */ | ||
607 | __fs32 ui_ib[UFS_NINDIR];/* 0x58 indirect blocks */ | ||
608 | } ui_addr; | ||
609 | __u8 ui_symlink[4*(UFS_NDADDR+UFS_NINDIR)];/* 0x28 fast symlink */ | ||
610 | } ui_u2; | ||
611 | __fs32 ui_flags; /* 0x64 immutable, append-only... */ | ||
612 | __fs32 ui_blocks; /* 0x68 blocks in use */ | ||
613 | __fs32 ui_gen; /* 0x6c like ext2 i_version, for NFS support */ | ||
614 | union { | ||
615 | struct { | ||
616 | __fs32 ui_shadow; /* 0x70 shadow inode with security data */ | ||
617 | __fs32 ui_uid; /* 0x74 long EFT version of uid */ | ||
618 | __fs32 ui_gid; /* 0x78 long EFT version of gid */ | ||
619 | __fs32 ui_oeftflag; /* 0x7c reserved */ | ||
620 | } ui_sun; | ||
621 | struct { | ||
622 | __fs32 ui_uid; /* 0x70 File owner */ | ||
623 | __fs32 ui_gid; /* 0x74 File group */ | ||
624 | __fs32 ui_spare[2]; /* 0x78 reserved */ | ||
625 | } ui_44; | ||
626 | struct { | ||
627 | __fs32 ui_uid; /* 0x70 */ | ||
628 | __fs32 ui_gid; /* 0x74 */ | ||
629 | __fs16 ui_modeh; /* 0x78 mode high bits */ | ||
630 | __fs16 ui_spare; /* 0x7A unused */ | ||
631 | __fs32 ui_trans; /* 0x7c filesystem translator */ | ||
632 | } ui_hurd; | ||
633 | } ui_u3; | ||
634 | }; | ||
635 | |||
636 | #define UFS_NXADDR 2 /* External addresses in inode. */ | ||
637 | struct ufs2_inode { | ||
638 | __fs16 ui_mode; /* 0: IFMT, permissions; see below. */ | ||
639 | __fs16 ui_nlink; /* 2: File link count. */ | ||
640 | __fs32 ui_uid; /* 4: File owner. */ | ||
641 | __fs32 ui_gid; /* 8: File group. */ | ||
642 | __fs32 ui_blksize; /* 12: Inode blocksize. */ | ||
643 | __fs64 ui_size; /* 16: File byte count. */ | ||
644 | __fs64 ui_blocks; /* 24: Bytes actually held. */ | ||
645 | __fs64 ui_atime; /* 32: Last access time. */ | ||
646 | __fs64 ui_mtime; /* 40: Last modified time. */ | ||
647 | __fs64 ui_ctime; /* 48: Last inode change time. */ | ||
648 | __fs64 ui_birthtime; /* 56: Inode creation time. */ | ||
649 | __fs32 ui_mtimensec; /* 64: Last modified time. */ | ||
650 | __fs32 ui_atimensec; /* 68: Last access time. */ | ||
651 | __fs32 ui_ctimensec; /* 72: Last inode change time. */ | ||
652 | __fs32 ui_birthnsec; /* 76: Inode creation time. */ | ||
653 | __fs32 ui_gen; /* 80: Generation number. */ | ||
654 | __fs32 ui_kernflags; /* 84: Kernel flags. */ | ||
655 | __fs32 ui_flags; /* 88: Status flags (chflags). */ | ||
656 | __fs32 ui_extsize; /* 92: External attributes block. */ | ||
657 | __fs64 ui_extb[UFS_NXADDR];/* 96: External attributes block. */ | ||
658 | union { | ||
659 | struct { | ||
660 | __fs64 ui_db[UFS_NDADDR]; /* 112: Direct disk blocks. */ | ||
661 | __fs64 ui_ib[UFS_NINDIR];/* 208: Indirect disk blocks.*/ | ||
662 | } ui_addr; | ||
663 | __u8 ui_symlink[2*4*(UFS_NDADDR+UFS_NINDIR)];/* 0x28 fast symlink */ | ||
664 | } ui_u2; | ||
665 | __fs64 ui_spare[3]; /* 232: Reserved; currently unused */ | ||
666 | }; | ||
667 | |||
668 | |||
669 | /* FreeBSD has these in sys/stat.h */ | ||
670 | /* ui_flags that can be set by a file owner */ | ||
671 | #define UFS_UF_SETTABLE 0x0000ffff | ||
672 | #define UFS_UF_NODUMP 0x00000001 /* do not dump */ | ||
673 | #define UFS_UF_IMMUTABLE 0x00000002 /* immutable (can't "change") */ | ||
674 | #define UFS_UF_APPEND 0x00000004 /* append-only */ | ||
675 | #define UFS_UF_OPAQUE 0x00000008 /* directory is opaque (unionfs) */ | ||
676 | #define UFS_UF_NOUNLINK 0x00000010 /* can't be removed or renamed */ | ||
677 | /* ui_flags that only root can set */ | ||
678 | #define UFS_SF_SETTABLE 0xffff0000 | ||
679 | #define UFS_SF_ARCHIVED 0x00010000 /* archived */ | ||
680 | #define UFS_SF_IMMUTABLE 0x00020000 /* immutable (can't "change") */ | ||
681 | #define UFS_SF_APPEND 0x00040000 /* append-only */ | ||
682 | #define UFS_SF_NOUNLINK 0x00100000 /* can't be removed or renamed */ | ||
683 | |||
684 | /* | ||
685 | * This structure is used for reading disk structures larger | ||
686 | * than the size of fragment. | ||
687 | */ | ||
688 | struct ufs_buffer_head { | ||
689 | __u64 fragment; /* first fragment */ | ||
690 | __u64 count; /* number of fragments */ | ||
691 | struct buffer_head * bh[UFS_MAXFRAG]; /* buffers */ | ||
692 | }; | ||
693 | |||
694 | struct ufs_cg_private_info { | ||
695 | struct ufs_buffer_head c_ubh; | ||
696 | __u32 c_cgx; /* number of cylidner group */ | ||
697 | __u16 c_ncyl; /* number of cyl's this cg */ | ||
698 | __u16 c_niblk; /* number of inode blocks this cg */ | ||
699 | __u32 c_ndblk; /* number of data blocks this cg */ | ||
700 | __u32 c_rotor; /* position of last used block */ | ||
701 | __u32 c_frotor; /* position of last used frag */ | ||
702 | __u32 c_irotor; /* position of last used inode */ | ||
703 | __u32 c_btotoff; /* (__u32) block totals per cylinder */ | ||
704 | __u32 c_boff; /* (short) free block positions */ | ||
705 | __u32 c_iusedoff; /* (char) used inode map */ | ||
706 | __u32 c_freeoff; /* (u_char) free block map */ | ||
707 | __u32 c_nextfreeoff; /* (u_char) next available space */ | ||
708 | __u32 c_clustersumoff;/* (u_int32) counts of avail clusters */ | ||
709 | __u32 c_clusteroff; /* (u_int8) free cluster map */ | ||
710 | __u32 c_nclusterblks; /* number of clusters this cg */ | ||
711 | }; | ||
712 | |||
713 | |||
714 | struct ufs_sb_private_info { | ||
715 | struct ufs_buffer_head s_ubh; /* buffer containing super block */ | ||
716 | struct ufs_csum_core cs_total; | ||
717 | __u32 s_sblkno; /* offset of super-blocks in filesys */ | ||
718 | __u32 s_cblkno; /* offset of cg-block in filesys */ | ||
719 | __u32 s_iblkno; /* offset of inode-blocks in filesys */ | ||
720 | __u32 s_dblkno; /* offset of first data after cg */ | ||
721 | __u32 s_cgoffset; /* cylinder group offset in cylinder */ | ||
722 | __u32 s_cgmask; /* used to calc mod fs_ntrak */ | ||
723 | __u32 s_size; /* number of blocks (fragments) in fs */ | ||
724 | __u32 s_dsize; /* number of data blocks in fs */ | ||
725 | __u64 s_u2_size; /* ufs2: number of blocks (fragments) in fs */ | ||
726 | __u64 s_u2_dsize; /*ufs2: number of data blocks in fs */ | ||
727 | __u32 s_ncg; /* number of cylinder groups */ | ||
728 | __u32 s_bsize; /* size of basic blocks */ | ||
729 | __u32 s_fsize; /* size of fragments */ | ||
730 | __u32 s_fpb; /* fragments per block */ | ||
731 | __u32 s_minfree; /* minimum percentage of free blocks */ | ||
732 | __u32 s_bmask; /* `blkoff'' calc of blk offsets */ | ||
733 | __u32 s_fmask; /* s_fsize mask */ | ||
734 | __u32 s_bshift; /* `lblkno'' calc of logical blkno */ | ||
735 | __u32 s_fshift; /* s_fsize shift */ | ||
736 | __u32 s_fpbshift; /* fragments per block shift */ | ||
737 | __u32 s_fsbtodb; /* fsbtodb and dbtofsb shift constant */ | ||
738 | __u32 s_sbsize; /* actual size of super block */ | ||
739 | __u32 s_csmask; /* csum block offset */ | ||
740 | __u32 s_csshift; /* csum block number */ | ||
741 | __u32 s_nindir; /* value of NINDIR */ | ||
742 | __u32 s_inopb; /* value of INOPB */ | ||
743 | __u32 s_nspf; /* value of NSPF */ | ||
744 | __u32 s_npsect; /* # sectors/track including spares */ | ||
745 | __u32 s_interleave; /* hardware sector interleave */ | ||
746 | __u32 s_trackskew; /* sector 0 skew, per track */ | ||
747 | __u64 s_csaddr; /* blk addr of cyl grp summary area */ | ||
748 | __u32 s_cssize; /* size of cyl grp summary area */ | ||
749 | __u32 s_cgsize; /* cylinder group size */ | ||
750 | __u32 s_ntrak; /* tracks per cylinder */ | ||
751 | __u32 s_nsect; /* sectors per track */ | ||
752 | __u32 s_spc; /* sectors per cylinder */ | ||
753 | __u32 s_ipg; /* inodes per cylinder group */ | ||
754 | __u32 s_fpg; /* fragments per group */ | ||
755 | __u32 s_cpc; /* cyl per cycle in postbl */ | ||
756 | __s32 s_contigsumsize;/* size of cluster summary array, 44bsd */ | ||
757 | __s64 s_qbmask; /* ~usb_bmask */ | ||
758 | __s64 s_qfmask; /* ~usb_fmask */ | ||
759 | __s32 s_postblformat; /* format of positional layout tables */ | ||
760 | __s32 s_nrpos; /* number of rotational positions */ | ||
761 | __s32 s_postbloff; /* (__s16) rotation block list head */ | ||
762 | __s32 s_rotbloff; /* (__u8) blocks for each rotation */ | ||
763 | |||
764 | __u32 s_fpbmask; /* fragments per block mask */ | ||
765 | __u32 s_apb; /* address per block */ | ||
766 | __u32 s_2apb; /* address per block^2 */ | ||
767 | __u32 s_3apb; /* address per block^3 */ | ||
768 | __u32 s_apbmask; /* address per block mask */ | ||
769 | __u32 s_apbshift; /* address per block shift */ | ||
770 | __u32 s_2apbshift; /* address per block shift * 2 */ | ||
771 | __u32 s_3apbshift; /* address per block shift * 3 */ | ||
772 | __u32 s_nspfshift; /* number of sector per fragment shift */ | ||
773 | __u32 s_nspb; /* number of sector per block */ | ||
774 | __u32 s_inopf; /* inodes per fragment */ | ||
775 | __u32 s_sbbase; /* offset of NeXTstep superblock */ | ||
776 | __u32 s_bpf; /* bits per fragment */ | ||
777 | __u32 s_bpfshift; /* bits per fragment shift*/ | ||
778 | __u32 s_bpfmask; /* bits per fragment mask */ | ||
779 | |||
780 | __u32 s_maxsymlinklen;/* upper limit on fast symlinks' size */ | ||
781 | __s32 fs_magic; /* filesystem magic */ | ||
782 | unsigned int s_dirblksize; | ||
783 | }; | ||
784 | |||
785 | /* | ||
786 | * Sizes of this structures are: | ||
787 | * ufs_super_block_first 512 | ||
788 | * ufs_super_block_second 512 | ||
789 | * ufs_super_block_third 356 | ||
790 | */ | ||
791 | struct ufs_super_block_first { | ||
792 | union { | ||
793 | struct { | ||
794 | __fs32 fs_link; /* UNUSED */ | ||
795 | } fs_42; | ||
796 | struct { | ||
797 | __fs32 fs_state; /* file system state flag */ | ||
798 | } fs_sun; | ||
799 | } fs_u0; | ||
800 | __fs32 fs_rlink; | ||
801 | __fs32 fs_sblkno; | ||
802 | __fs32 fs_cblkno; | ||
803 | __fs32 fs_iblkno; | ||
804 | __fs32 fs_dblkno; | ||
805 | __fs32 fs_cgoffset; | ||
806 | __fs32 fs_cgmask; | ||
807 | __fs32 fs_time; | ||
808 | __fs32 fs_size; | ||
809 | __fs32 fs_dsize; | ||
810 | __fs32 fs_ncg; | ||
811 | __fs32 fs_bsize; | ||
812 | __fs32 fs_fsize; | ||
813 | __fs32 fs_frag; | ||
814 | __fs32 fs_minfree; | ||
815 | __fs32 fs_rotdelay; | ||
816 | __fs32 fs_rps; | ||
817 | __fs32 fs_bmask; | ||
818 | __fs32 fs_fmask; | ||
819 | __fs32 fs_bshift; | ||
820 | __fs32 fs_fshift; | ||
821 | __fs32 fs_maxcontig; | ||
822 | __fs32 fs_maxbpg; | ||
823 | __fs32 fs_fragshift; | ||
824 | __fs32 fs_fsbtodb; | ||
825 | __fs32 fs_sbsize; | ||
826 | __fs32 fs_csmask; | ||
827 | __fs32 fs_csshift; | ||
828 | __fs32 fs_nindir; | ||
829 | __fs32 fs_inopb; | ||
830 | __fs32 fs_nspf; | ||
831 | __fs32 fs_optim; | ||
832 | union { | ||
833 | struct { | ||
834 | __fs32 fs_npsect; | ||
835 | } fs_sun; | ||
836 | struct { | ||
837 | __fs32 fs_state; | ||
838 | } fs_sunx86; | ||
839 | } fs_u1; | ||
840 | __fs32 fs_interleave; | ||
841 | __fs32 fs_trackskew; | ||
842 | __fs32 fs_id[2]; | ||
843 | __fs32 fs_csaddr; | ||
844 | __fs32 fs_cssize; | ||
845 | __fs32 fs_cgsize; | ||
846 | __fs32 fs_ntrak; | ||
847 | __fs32 fs_nsect; | ||
848 | __fs32 fs_spc; | ||
849 | __fs32 fs_ncyl; | ||
850 | __fs32 fs_cpg; | ||
851 | __fs32 fs_ipg; | ||
852 | __fs32 fs_fpg; | ||
853 | struct ufs_csum fs_cstotal; | ||
854 | __s8 fs_fmod; | ||
855 | __s8 fs_clean; | ||
856 | __s8 fs_ronly; | ||
857 | __s8 fs_flags; | ||
858 | __s8 fs_fsmnt[UFS_MAXMNTLEN - 212]; | ||
859 | |||
860 | }; | ||
861 | |||
862 | struct ufs_super_block_second { | ||
863 | union { | ||
864 | struct { | ||
865 | __s8 fs_fsmnt[212]; | ||
866 | __fs32 fs_cgrotor; | ||
867 | __fs32 fs_csp[UFS_MAXCSBUFS]; | ||
868 | __fs32 fs_maxcluster; | ||
869 | __fs32 fs_cpc; | ||
870 | __fs16 fs_opostbl[82]; | ||
871 | } fs_u1; | ||
872 | struct { | ||
873 | __s8 fs_fsmnt[UFS2_MAXMNTLEN - UFS_MAXMNTLEN + 212]; | ||
874 | __u8 fs_volname[UFS2_MAXVOLLEN]; | ||
875 | __fs64 fs_swuid; | ||
876 | __fs32 fs_pad; | ||
877 | __fs32 fs_cgrotor; | ||
878 | __fs32 fs_ocsp[UFS2_NOCSPTRS]; | ||
879 | __fs32 fs_contigdirs; | ||
880 | __fs32 fs_csp; | ||
881 | __fs32 fs_maxcluster; | ||
882 | __fs32 fs_active; | ||
883 | __fs32 fs_old_cpc; | ||
884 | __fs32 fs_maxbsize; | ||
885 | __fs64 fs_sparecon64[17]; | ||
886 | __fs64 fs_sblockloc; | ||
887 | __fs64 cs_ndir; | ||
888 | __fs64 cs_nbfree; | ||
889 | } fs_u2; | ||
890 | } fs_un; | ||
891 | }; | ||
892 | |||
893 | struct ufs_super_block_third { | ||
894 | union { | ||
895 | struct { | ||
896 | __fs16 fs_opostbl[46]; | ||
897 | } fs_u1; | ||
898 | struct { | ||
899 | __fs64 cs_nifree; /* number of free inodes */ | ||
900 | __fs64 cs_nffree; /* number of free frags */ | ||
901 | __fs64 cs_numclusters; /* number of free clusters */ | ||
902 | __fs64 cs_spare[3]; /* future expansion */ | ||
903 | struct ufs_timeval fs_time; /* last time written */ | ||
904 | __fs64 fs_size; /* number of blocks in fs */ | ||
905 | __fs64 fs_dsize; /* number of data blocks in fs */ | ||
906 | __fs64 fs_csaddr; /* blk addr of cyl grp summary area */ | ||
907 | __fs64 fs_pendingblocks;/* blocks in process of being freed */ | ||
908 | __fs32 fs_pendinginodes;/*inodes in process of being freed */ | ||
909 | } __attribute__ ((packed)) fs_u2; | ||
910 | } fs_un1; | ||
911 | union { | ||
912 | struct { | ||
913 | __fs32 fs_sparecon[53];/* reserved for future constants */ | ||
914 | __fs32 fs_reclaim; | ||
915 | __fs32 fs_sparecon2[1]; | ||
916 | __fs32 fs_state; /* file system state time stamp */ | ||
917 | __fs32 fs_qbmask[2]; /* ~usb_bmask */ | ||
918 | __fs32 fs_qfmask[2]; /* ~usb_fmask */ | ||
919 | } fs_sun; | ||
920 | struct { | ||
921 | __fs32 fs_sparecon[53];/* reserved for future constants */ | ||
922 | __fs32 fs_reclaim; | ||
923 | __fs32 fs_sparecon2[1]; | ||
924 | __fs32 fs_npsect; /* # sectors/track including spares */ | ||
925 | __fs32 fs_qbmask[2]; /* ~usb_bmask */ | ||
926 | __fs32 fs_qfmask[2]; /* ~usb_fmask */ | ||
927 | } fs_sunx86; | ||
928 | struct { | ||
929 | __fs32 fs_sparecon[50];/* reserved for future constants */ | ||
930 | __fs32 fs_contigsumsize;/* size of cluster summary array */ | ||
931 | __fs32 fs_maxsymlinklen;/* max length of an internal symlink */ | ||
932 | __fs32 fs_inodefmt; /* format of on-disk inodes */ | ||
933 | __fs32 fs_maxfilesize[2]; /* max representable file size */ | ||
934 | __fs32 fs_qbmask[2]; /* ~usb_bmask */ | ||
935 | __fs32 fs_qfmask[2]; /* ~usb_fmask */ | ||
936 | __fs32 fs_state; /* file system state time stamp */ | ||
937 | } fs_44; | ||
938 | } fs_un2; | ||
939 | __fs32 fs_postblformat; | ||
940 | __fs32 fs_nrpos; | ||
941 | __fs32 fs_postbloff; | ||
942 | __fs32 fs_rotbloff; | ||
943 | __fs32 fs_magic; | ||
944 | __u8 fs_space[1]; | ||
945 | }; | ||
946 | |||
947 | #endif /* __LINUX_UFS_FS_H */ | ||
diff --git a/fs/ufs/util.c b/fs/ufs/util.c index 410084dae389..85a7fc9e4a4e 100644 --- a/fs/ufs/util.c +++ b/fs/ufs/util.c | |||
@@ -8,9 +8,9 @@ | |||
8 | 8 | ||
9 | #include <linux/string.h> | 9 | #include <linux/string.h> |
10 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
11 | #include <linux/ufs_fs.h> | ||
12 | #include <linux/buffer_head.h> | 11 | #include <linux/buffer_head.h> |
13 | 12 | ||
13 | #include "ufs_fs.h" | ||
14 | #include "ufs.h" | 14 | #include "ufs.h" |
15 | #include "swab.h" | 15 | #include "swab.h" |
16 | #include "util.h" | 16 | #include "util.h" |