diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-04 11:15:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-04 11:15:33 -0500 |
commit | 0f2cc4ecd81dc1917a041dc93db0ada28f8356fa (patch) | |
tree | f128b50f48f50f0cda6d2b20b53e9ad6e2dfded3 | |
parent | 1fae4cfb97302289bb5df6a8195eb28385d0b002 (diff) | |
parent | 9643f5d94aadd47a5fa9754fb60f2c957de05903 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (52 commits)
init: Open /dev/console from rootfs
mqueue: fix typo "failues" -> "failures"
mqueue: only set error codes if they are really necessary
mqueue: simplify do_open() error handling
mqueue: apply mathematics distributivity on mq_bytes calculation
mqueue: remove unneeded info->messages initialization
mqueue: fix mq_open() file descriptor leak on user-space processes
fix race in d_splice_alias()
set S_DEAD on unlink() and non-directory rename() victims
vfs: add NOFOLLOW flag to umount(2)
get rid of ->mnt_parent in tomoyo/realpath
hppfs can use existing proc_mnt, no need for do_kern_mount() in there
Mirror MS_KERNMOUNT in ->mnt_flags
get rid of useless vfsmount_lock use in put_mnt_ns()
Take vfsmount_lock to fs/internal.h
get rid of insanity with namespace roots in tomoyo
take check for new events in namespace (guts of mounts_poll()) to namespace.c
Don't mess with generic_permission() under ->d_lock in hpfs
sanitize const/signedness for udf
nilfs: sanitize const/signedness in dealing with ->d_name.name
...
Fix up fairly trivial (famous last words...) conflicts in
drivers/infiniband/core/uverbs_main.c and security/tomoyo/realpath.c
73 files changed, 773 insertions, 1080 deletions
diff --git a/Documentation/filesystems/sharedsubtree.txt b/Documentation/filesystems/sharedsubtree.txt index 23a181074f94..fc0e39af43c3 100644 --- a/Documentation/filesystems/sharedsubtree.txt +++ b/Documentation/filesystems/sharedsubtree.txt | |||
@@ -837,6 +837,9 @@ replicas continue to be exactly same. | |||
837 | individual lists does not affect propagation or the way propagation | 837 | individual lists does not affect propagation or the way propagation |
838 | tree is modified by operations. | 838 | tree is modified by operations. |
839 | 839 | ||
840 | All vfsmounts in a peer group have the same ->mnt_master. If it is | ||
841 | non-NULL, they form a contiguous (ordered) segment of slave list. | ||
842 | |||
840 | A example propagation tree looks as shown in the figure below. | 843 | A example propagation tree looks as shown in the figure below. |
841 | [ NOTE: Though it looks like a forest, if we consider all the shared | 844 | [ NOTE: Though it looks like a forest, if we consider all the shared |
842 | mounts as a conceptual entity called 'pnode', it becomes a tree] | 845 | mounts as a conceptual entity called 'pnode', it becomes a tree] |
@@ -874,8 +877,19 @@ replicas continue to be exactly same. | |||
874 | 877 | ||
875 | NOTE: The propagation tree is orthogonal to the mount tree. | 878 | NOTE: The propagation tree is orthogonal to the mount tree. |
876 | 879 | ||
880 | 8B Locking: | ||
881 | |||
882 | ->mnt_share, ->mnt_slave, ->mnt_slave_list, ->mnt_master are protected | ||
883 | by namespace_sem (exclusive for modifications, shared for reading). | ||
884 | |||
885 | Normally we have ->mnt_flags modifications serialized by vfsmount_lock. | ||
886 | There are two exceptions: do_add_mount() and clone_mnt(). | ||
887 | The former modifies a vfsmount that has not been visible in any shared | ||
888 | data structures yet. | ||
889 | The latter holds namespace_sem and the only references to vfsmount | ||
890 | are in lists that can't be traversed without namespace_sem. | ||
877 | 891 | ||
878 | 8B Algorithm: | 892 | 8C Algorithm: |
879 | 893 | ||
880 | The crux of the implementation resides in rbind/move operation. | 894 | The crux of the implementation resides in rbind/move operation. |
881 | 895 | ||
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 341aff2687a5..cd128b07beda 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c | |||
@@ -288,46 +288,30 @@ static int hypfs_fill_super(struct super_block *sb, void *data, int silent) | |||
288 | sb->s_blocksize_bits = PAGE_CACHE_SHIFT; | 288 | sb->s_blocksize_bits = PAGE_CACHE_SHIFT; |
289 | sb->s_magic = HYPFS_MAGIC; | 289 | sb->s_magic = HYPFS_MAGIC; |
290 | sb->s_op = &hypfs_s_ops; | 290 | sb->s_op = &hypfs_s_ops; |
291 | if (hypfs_parse_options(data, sb)) { | 291 | if (hypfs_parse_options(data, sb)) |
292 | rc = -EINVAL; | 292 | return -EINVAL; |
293 | goto err_alloc; | ||
294 | } | ||
295 | root_inode = hypfs_make_inode(sb, S_IFDIR | 0755); | 293 | root_inode = hypfs_make_inode(sb, S_IFDIR | 0755); |
296 | if (!root_inode) { | 294 | if (!root_inode) |
297 | rc = -ENOMEM; | 295 | return -ENOMEM; |
298 | goto err_alloc; | ||
299 | } | ||
300 | root_inode->i_op = &simple_dir_inode_operations; | 296 | root_inode->i_op = &simple_dir_inode_operations; |
301 | root_inode->i_fop = &simple_dir_operations; | 297 | root_inode->i_fop = &simple_dir_operations; |
302 | root_dentry = d_alloc_root(root_inode); | 298 | sb->s_root = root_dentry = d_alloc_root(root_inode); |
303 | if (!root_dentry) { | 299 | if (!root_dentry) { |
304 | iput(root_inode); | 300 | iput(root_inode); |
305 | rc = -ENOMEM; | 301 | return -ENOMEM; |
306 | goto err_alloc; | ||
307 | } | 302 | } |
308 | if (MACHINE_IS_VM) | 303 | if (MACHINE_IS_VM) |
309 | rc = hypfs_vm_create_files(sb, root_dentry); | 304 | rc = hypfs_vm_create_files(sb, root_dentry); |
310 | else | 305 | else |
311 | rc = hypfs_diag_create_files(sb, root_dentry); | 306 | rc = hypfs_diag_create_files(sb, root_dentry); |
312 | if (rc) | 307 | if (rc) |
313 | goto err_tree; | 308 | return rc; |
314 | sbi->update_file = hypfs_create_update_file(sb, root_dentry); | 309 | sbi->update_file = hypfs_create_update_file(sb, root_dentry); |
315 | if (IS_ERR(sbi->update_file)) { | 310 | if (IS_ERR(sbi->update_file)) |
316 | rc = PTR_ERR(sbi->update_file); | 311 | return PTR_ERR(sbi->update_file); |
317 | goto err_tree; | ||
318 | } | ||
319 | hypfs_update_update(sb); | 312 | hypfs_update_update(sb); |
320 | sb->s_root = root_dentry; | ||
321 | pr_info("Hypervisor filesystem mounted\n"); | 313 | pr_info("Hypervisor filesystem mounted\n"); |
322 | return 0; | 314 | return 0; |
323 | |||
324 | err_tree: | ||
325 | hypfs_delete_tree(root_dentry); | ||
326 | d_genocide(root_dentry); | ||
327 | dput(root_dentry); | ||
328 | err_alloc: | ||
329 | kfree(sbi); | ||
330 | return rc; | ||
331 | } | 315 | } |
332 | 316 | ||
333 | static int hypfs_get_super(struct file_system_type *fst, int flags, | 317 | static int hypfs_get_super(struct file_system_type *fst, int flags, |
@@ -340,12 +324,12 @@ static void hypfs_kill_super(struct super_block *sb) | |||
340 | { | 324 | { |
341 | struct hypfs_sb_info *sb_info = sb->s_fs_info; | 325 | struct hypfs_sb_info *sb_info = sb->s_fs_info; |
342 | 326 | ||
343 | if (sb->s_root) { | 327 | if (sb->s_root) |
344 | hypfs_delete_tree(sb->s_root); | 328 | hypfs_delete_tree(sb->s_root); |
329 | if (sb_info->update_file) | ||
345 | hypfs_remove(sb_info->update_file); | 330 | hypfs_remove(sb_info->update_file); |
346 | kfree(sb->s_fs_info); | 331 | kfree(sb->s_fs_info); |
347 | sb->s_fs_info = NULL; | 332 | sb->s_fs_info = NULL; |
348 | } | ||
349 | kill_litter_super(sb); | 333 | kill_litter_super(sb); |
350 | } | 334 | } |
351 | 335 | ||
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index 3b3c36601a7b..de317d0c3294 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c | |||
@@ -140,7 +140,7 @@ void mconsole_proc(struct mc_request *req) | |||
140 | goto out; | 140 | goto out; |
141 | } | 141 | } |
142 | 142 | ||
143 | err = may_open(&nd.path, MAY_READ, FMODE_READ); | 143 | err = may_open(&nd.path, MAY_READ, O_RDONLY); |
144 | if (result) { | 144 | if (result) { |
145 | mconsole_reply(req, "Failed to open file", 1, 0); | 145 | mconsole_reply(req, "Failed to open file", 1, 0); |
146 | path_put(&nd.path); | 146 | path_put(&nd.path); |
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index e54d9ac6d1ca..a078e5624d22 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h | |||
@@ -146,7 +146,7 @@ extern struct idr ib_uverbs_srq_idr; | |||
146 | void idr_remove_uobj(struct idr *idp, struct ib_uobject *uobj); | 146 | void idr_remove_uobj(struct idr *idp, struct ib_uobject *uobj); |
147 | 147 | ||
148 | struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file, | 148 | struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file, |
149 | int is_async, int *fd); | 149 | int is_async); |
150 | struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd); | 150 | struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd); |
151 | 151 | ||
152 | void ib_uverbs_release_ucq(struct ib_uverbs_file *file, | 152 | void ib_uverbs_release_ucq(struct ib_uverbs_file *file, |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 112d3970222a..f71cf138d674 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -301,10 +301,15 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, | |||
301 | 301 | ||
302 | resp.num_comp_vectors = file->device->num_comp_vectors; | 302 | resp.num_comp_vectors = file->device->num_comp_vectors; |
303 | 303 | ||
304 | filp = ib_uverbs_alloc_event_file(file, 1, &resp.async_fd); | 304 | ret = get_unused_fd(); |
305 | if (ret < 0) | ||
306 | goto err_free; | ||
307 | resp.async_fd = ret; | ||
308 | |||
309 | filp = ib_uverbs_alloc_event_file(file, 1); | ||
305 | if (IS_ERR(filp)) { | 310 | if (IS_ERR(filp)) { |
306 | ret = PTR_ERR(filp); | 311 | ret = PTR_ERR(filp); |
307 | goto err_free; | 312 | goto err_fd; |
308 | } | 313 | } |
309 | 314 | ||
310 | if (copy_to_user((void __user *) (unsigned long) cmd.response, | 315 | if (copy_to_user((void __user *) (unsigned long) cmd.response, |
@@ -332,9 +337,11 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, | |||
332 | return in_len; | 337 | return in_len; |
333 | 338 | ||
334 | err_file: | 339 | err_file: |
335 | put_unused_fd(resp.async_fd); | ||
336 | fput(filp); | 340 | fput(filp); |
337 | 341 | ||
342 | err_fd: | ||
343 | put_unused_fd(resp.async_fd); | ||
344 | |||
338 | err_free: | 345 | err_free: |
339 | ibdev->dealloc_ucontext(ucontext); | 346 | ibdev->dealloc_ucontext(ucontext); |
340 | 347 | ||
@@ -715,6 +722,7 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file, | |||
715 | struct ib_uverbs_create_comp_channel cmd; | 722 | struct ib_uverbs_create_comp_channel cmd; |
716 | struct ib_uverbs_create_comp_channel_resp resp; | 723 | struct ib_uverbs_create_comp_channel_resp resp; |
717 | struct file *filp; | 724 | struct file *filp; |
725 | int ret; | ||
718 | 726 | ||
719 | if (out_len < sizeof resp) | 727 | if (out_len < sizeof resp) |
720 | return -ENOSPC; | 728 | return -ENOSPC; |
@@ -722,9 +730,16 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file, | |||
722 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 730 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
723 | return -EFAULT; | 731 | return -EFAULT; |
724 | 732 | ||
725 | filp = ib_uverbs_alloc_event_file(file, 0, &resp.fd); | 733 | ret = get_unused_fd(); |
726 | if (IS_ERR(filp)) | 734 | if (ret < 0) |
735 | return ret; | ||
736 | resp.fd = ret; | ||
737 | |||
738 | filp = ib_uverbs_alloc_event_file(file, 0); | ||
739 | if (IS_ERR(filp)) { | ||
740 | put_unused_fd(resp.fd); | ||
727 | return PTR_ERR(filp); | 741 | return PTR_ERR(filp); |
742 | } | ||
728 | 743 | ||
729 | if (copy_to_user((void __user *) (unsigned long) cmd.response, | 744 | if (copy_to_user((void __user *) (unsigned long) cmd.response, |
730 | &resp, sizeof resp)) { | 745 | &resp, sizeof resp)) { |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index ff59a795e840..4fa2e6516441 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -484,11 +484,10 @@ void ib_uverbs_event_handler(struct ib_event_handler *handler, | |||
484 | } | 484 | } |
485 | 485 | ||
486 | struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file, | 486 | struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file, |
487 | int is_async, int *fd) | 487 | int is_async) |
488 | { | 488 | { |
489 | struct ib_uverbs_event_file *ev_file; | 489 | struct ib_uverbs_event_file *ev_file; |
490 | struct file *filp; | 490 | struct file *filp; |
491 | int ret; | ||
492 | 491 | ||
493 | ev_file = kmalloc(sizeof *ev_file, GFP_KERNEL); | 492 | ev_file = kmalloc(sizeof *ev_file, GFP_KERNEL); |
494 | if (!ev_file) | 493 | if (!ev_file) |
@@ -503,27 +502,12 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file, | |||
503 | ev_file->is_async = is_async; | 502 | ev_file->is_async = is_async; |
504 | ev_file->is_closed = 0; | 503 | ev_file->is_closed = 0; |
505 | 504 | ||
506 | *fd = get_unused_fd(); | 505 | filp = anon_inode_getfile("[infinibandevent]", &uverbs_event_fops, |
507 | if (*fd < 0) { | ||
508 | ret = *fd; | ||
509 | goto err; | ||
510 | } | ||
511 | |||
512 | filp = anon_inode_getfile("[uverbs-event]", &uverbs_event_fops, | ||
513 | ev_file, O_RDONLY); | 506 | ev_file, O_RDONLY); |
514 | if (!filp) { | 507 | if (IS_ERR(filp)) |
515 | ret = -ENFILE; | 508 | kfree(ev_file); |
516 | goto err_fd; | ||
517 | } | ||
518 | 509 | ||
519 | return filp; | 510 | return filp; |
520 | |||
521 | err_fd: | ||
522 | put_unused_fd(*fd); | ||
523 | |||
524 | err: | ||
525 | kfree(ev_file); | ||
526 | return ERR_PTR(ret); | ||
527 | } | 511 | } |
528 | 512 | ||
529 | /* | 513 | /* |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index b1935fe156a0..5a3cdd08f1d0 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -1050,7 +1050,7 @@ static void invalidate_sub(struct fsg_lun *curlun) | |||
1050 | unsigned long rc; | 1050 | unsigned long rc; |
1051 | 1051 | ||
1052 | rc = invalidate_mapping_pages(inode->i_mapping, 0, -1); | 1052 | rc = invalidate_mapping_pages(inode->i_mapping, 0, -1); |
1053 | VLDBG(curlun, "invalidate_inode_pages -> %ld\n", rc); | 1053 | VLDBG(curlun, "invalidate_mapping_pages -> %ld\n", rc); |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | static int do_verify(struct fsg_common *common) | 1056 | static int do_verify(struct fsg_common *common) |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index a90dd2db0488..b49d86e3e45b 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -1448,7 +1448,7 @@ static void invalidate_sub(struct fsg_lun *curlun) | |||
1448 | unsigned long rc; | 1448 | unsigned long rc; |
1449 | 1449 | ||
1450 | rc = invalidate_mapping_pages(inode->i_mapping, 0, -1); | 1450 | rc = invalidate_mapping_pages(inode->i_mapping, 0, -1); |
1451 | VLDBG(curlun, "invalidate_inode_pages -> %ld\n", rc); | 1451 | VLDBG(curlun, "invalidate_mapping_pages -> %ld\n", rc); |
1452 | } | 1452 | } |
1453 | 1453 | ||
1454 | static int do_verify(struct fsg_dev *fsg) | 1454 | static int do_verify(struct fsg_dev *fsg) |
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h index 0118d67221b2..3d283abf67d7 100644 --- a/fs/autofs4/autofs_i.h +++ b/fs/autofs4/autofs_i.h | |||
@@ -60,11 +60,6 @@ do { \ | |||
60 | current->pid, __func__, ##args); \ | 60 | current->pid, __func__, ##args); \ |
61 | } while (0) | 61 | } while (0) |
62 | 62 | ||
63 | struct rehash_entry { | ||
64 | struct task_struct *task; | ||
65 | struct list_head list; | ||
66 | }; | ||
67 | |||
68 | /* Unified info structure. This is pointed to by both the dentry and | 63 | /* Unified info structure. This is pointed to by both the dentry and |
69 | inode structures. Each file in the filesystem has an instance of this | 64 | inode structures. Each file in the filesystem has an instance of this |
70 | structure. It holds a reference to the dentry, so dentries are never | 65 | structure. It holds a reference to the dentry, so dentries are never |
@@ -81,7 +76,6 @@ struct autofs_info { | |||
81 | 76 | ||
82 | struct list_head active; | 77 | struct list_head active; |
83 | int active_count; | 78 | int active_count; |
84 | struct list_head rehash_list; | ||
85 | 79 | ||
86 | struct list_head expiring; | 80 | struct list_head expiring; |
87 | 81 | ||
@@ -104,7 +98,6 @@ struct autofs_info { | |||
104 | #define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */ | 98 | #define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */ |
105 | #define AUTOFS_INF_MOUNTPOINT (1<<1) /* mountpoint status for direct expire */ | 99 | #define AUTOFS_INF_MOUNTPOINT (1<<1) /* mountpoint status for direct expire */ |
106 | #define AUTOFS_INF_PENDING (1<<2) /* dentry pending mount */ | 100 | #define AUTOFS_INF_PENDING (1<<2) /* dentry pending mount */ |
107 | #define AUTOFS_INF_REHASH (1<<3) /* dentry in transit to ->lookup() */ | ||
108 | 101 | ||
109 | struct autofs_wait_queue { | 102 | struct autofs_wait_queue { |
110 | wait_queue_head_t queue; | 103 | wait_queue_head_t queue; |
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c index 00bf8fcb245f..c8a80dffb455 100644 --- a/fs/autofs4/dev-ioctl.c +++ b/fs/autofs4/dev-ioctl.c | |||
@@ -544,10 +544,9 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp, | |||
544 | goto out; | 544 | goto out; |
545 | devid = new_encode_dev(path.mnt->mnt_sb->s_dev); | 545 | devid = new_encode_dev(path.mnt->mnt_sb->s_dev); |
546 | err = 0; | 546 | err = 0; |
547 | if (path.dentry->d_inode && | 547 | if (path.mnt->mnt_root == path.dentry) { |
548 | path.mnt->mnt_root == path.dentry) { | ||
549 | err = 1; | 548 | err = 1; |
550 | magic = path.dentry->d_inode->i_sb->s_magic; | 549 | magic = path.mnt->mnt_sb->s_magic; |
551 | } | 550 | } |
552 | } else { | 551 | } else { |
553 | dev_t dev = sbi->sb->s_dev; | 552 | dev_t dev = sbi->sb->s_dev; |
@@ -560,10 +559,8 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp, | |||
560 | 559 | ||
561 | err = have_submounts(path.dentry); | 560 | err = have_submounts(path.dentry); |
562 | 561 | ||
563 | if (path.mnt->mnt_mountpoint != path.mnt->mnt_root) { | 562 | if (follow_down(&path)) |
564 | if (follow_down(&path)) | 563 | magic = path.mnt->mnt_sb->s_magic; |
565 | magic = path.mnt->mnt_sb->s_magic; | ||
566 | } | ||
567 | } | 564 | } |
568 | 565 | ||
569 | param->ismountpoint.out.devid = devid; | 566 | param->ismountpoint.out.devid = devid; |
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c index 74bc9aa6df31..a796c9417fb1 100644 --- a/fs/autofs4/expire.c +++ b/fs/autofs4/expire.c | |||
@@ -279,7 +279,6 @@ struct dentry *autofs4_expire_direct(struct super_block *sb, | |||
279 | root->d_mounted--; | 279 | root->d_mounted--; |
280 | } | 280 | } |
281 | ino->flags |= AUTOFS_INF_EXPIRING; | 281 | ino->flags |= AUTOFS_INF_EXPIRING; |
282 | autofs4_add_expiring(root); | ||
283 | init_completion(&ino->expire_complete); | 282 | init_completion(&ino->expire_complete); |
284 | spin_unlock(&sbi->fs_lock); | 283 | spin_unlock(&sbi->fs_lock); |
285 | return root; | 284 | return root; |
@@ -407,7 +406,6 @@ found: | |||
407 | expired, (int)expired->d_name.len, expired->d_name.name); | 406 | expired, (int)expired->d_name.len, expired->d_name.name); |
408 | ino = autofs4_dentry_ino(expired); | 407 | ino = autofs4_dentry_ino(expired); |
409 | ino->flags |= AUTOFS_INF_EXPIRING; | 408 | ino->flags |= AUTOFS_INF_EXPIRING; |
410 | autofs4_add_expiring(expired); | ||
411 | init_completion(&ino->expire_complete); | 409 | init_completion(&ino->expire_complete); |
412 | spin_unlock(&sbi->fs_lock); | 410 | spin_unlock(&sbi->fs_lock); |
413 | spin_lock(&dcache_lock); | 411 | spin_lock(&dcache_lock); |
@@ -435,7 +433,7 @@ int autofs4_expire_wait(struct dentry *dentry) | |||
435 | 433 | ||
436 | DPRINTK("expire done status=%d", status); | 434 | DPRINTK("expire done status=%d", status); |
437 | 435 | ||
438 | if (d_unhashed(dentry) && IS_DEADDIR(dentry->d_inode)) | 436 | if (d_unhashed(dentry)) |
439 | return -EAGAIN; | 437 | return -EAGAIN; |
440 | 438 | ||
441 | return status; | 439 | return status; |
@@ -475,7 +473,6 @@ int autofs4_expire_run(struct super_block *sb, | |||
475 | spin_lock(&sbi->fs_lock); | 473 | spin_lock(&sbi->fs_lock); |
476 | ino = autofs4_dentry_ino(dentry); | 474 | ino = autofs4_dentry_ino(dentry); |
477 | ino->flags &= ~AUTOFS_INF_EXPIRING; | 475 | ino->flags &= ~AUTOFS_INF_EXPIRING; |
478 | autofs4_del_expiring(dentry); | ||
479 | complete_all(&ino->expire_complete); | 476 | complete_all(&ino->expire_complete); |
480 | spin_unlock(&sbi->fs_lock); | 477 | spin_unlock(&sbi->fs_lock); |
481 | 478 | ||
@@ -506,7 +503,6 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, | |||
506 | ino->flags &= ~AUTOFS_INF_MOUNTPOINT; | 503 | ino->flags &= ~AUTOFS_INF_MOUNTPOINT; |
507 | } | 504 | } |
508 | ino->flags &= ~AUTOFS_INF_EXPIRING; | 505 | ino->flags &= ~AUTOFS_INF_EXPIRING; |
509 | autofs4_del_expiring(dentry); | ||
510 | complete_all(&ino->expire_complete); | 506 | complete_all(&ino->expire_complete); |
511 | spin_unlock(&sbi->fs_lock); | 507 | spin_unlock(&sbi->fs_lock); |
512 | dput(dentry); | 508 | dput(dentry); |
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c index d0a3de247458..821b2b955dac 100644 --- a/fs/autofs4/inode.c +++ b/fs/autofs4/inode.c | |||
@@ -49,7 +49,6 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino, | |||
49 | ino->dentry = NULL; | 49 | ino->dentry = NULL; |
50 | ino->size = 0; | 50 | ino->size = 0; |
51 | INIT_LIST_HEAD(&ino->active); | 51 | INIT_LIST_HEAD(&ino->active); |
52 | INIT_LIST_HEAD(&ino->rehash_list); | ||
53 | ino->active_count = 0; | 52 | ino->active_count = 0; |
54 | INIT_LIST_HEAD(&ino->expiring); | 53 | INIT_LIST_HEAD(&ino->expiring); |
55 | atomic_set(&ino->count, 0); | 54 | atomic_set(&ino->count, 0); |
@@ -97,63 +96,6 @@ void autofs4_free_ino(struct autofs_info *ino) | |||
97 | kfree(ino); | 96 | kfree(ino); |
98 | } | 97 | } |
99 | 98 | ||
100 | /* | ||
101 | * Deal with the infamous "Busy inodes after umount ..." message. | ||
102 | * | ||
103 | * Clean up the dentry tree. This happens with autofs if the user | ||
104 | * space program goes away due to a SIGKILL, SIGSEGV etc. | ||
105 | */ | ||
106 | static void autofs4_force_release(struct autofs_sb_info *sbi) | ||
107 | { | ||
108 | struct dentry *this_parent = sbi->sb->s_root; | ||
109 | struct list_head *next; | ||
110 | |||
111 | if (!sbi->sb->s_root) | ||
112 | return; | ||
113 | |||
114 | spin_lock(&dcache_lock); | ||
115 | repeat: | ||
116 | next = this_parent->d_subdirs.next; | ||
117 | resume: | ||
118 | while (next != &this_parent->d_subdirs) { | ||
119 | struct dentry *dentry = list_entry(next, struct dentry, d_u.d_child); | ||
120 | |||
121 | /* Negative dentry - don`t care */ | ||
122 | if (!simple_positive(dentry)) { | ||
123 | next = next->next; | ||
124 | continue; | ||
125 | } | ||
126 | |||
127 | if (!list_empty(&dentry->d_subdirs)) { | ||
128 | this_parent = dentry; | ||
129 | goto repeat; | ||
130 | } | ||
131 | |||
132 | next = next->next; | ||
133 | spin_unlock(&dcache_lock); | ||
134 | |||
135 | DPRINTK("dentry %p %.*s", | ||
136 | dentry, (int)dentry->d_name.len, dentry->d_name.name); | ||
137 | |||
138 | dput(dentry); | ||
139 | spin_lock(&dcache_lock); | ||
140 | } | ||
141 | |||
142 | if (this_parent != sbi->sb->s_root) { | ||
143 | struct dentry *dentry = this_parent; | ||
144 | |||
145 | next = this_parent->d_u.d_child.next; | ||
146 | this_parent = this_parent->d_parent; | ||
147 | spin_unlock(&dcache_lock); | ||
148 | DPRINTK("parent dentry %p %.*s", | ||
149 | dentry, (int)dentry->d_name.len, dentry->d_name.name); | ||
150 | dput(dentry); | ||
151 | spin_lock(&dcache_lock); | ||
152 | goto resume; | ||
153 | } | ||
154 | spin_unlock(&dcache_lock); | ||
155 | } | ||
156 | |||
157 | void autofs4_kill_sb(struct super_block *sb) | 99 | void autofs4_kill_sb(struct super_block *sb) |
158 | { | 100 | { |
159 | struct autofs_sb_info *sbi = autofs4_sbi(sb); | 101 | struct autofs_sb_info *sbi = autofs4_sbi(sb); |
@@ -170,15 +112,12 @@ void autofs4_kill_sb(struct super_block *sb) | |||
170 | /* Free wait queues, close pipe */ | 112 | /* Free wait queues, close pipe */ |
171 | autofs4_catatonic_mode(sbi); | 113 | autofs4_catatonic_mode(sbi); |
172 | 114 | ||
173 | /* Clean up and release dangling references */ | ||
174 | autofs4_force_release(sbi); | ||
175 | |||
176 | sb->s_fs_info = NULL; | 115 | sb->s_fs_info = NULL; |
177 | kfree(sbi); | 116 | kfree(sbi); |
178 | 117 | ||
179 | out_kill_sb: | 118 | out_kill_sb: |
180 | DPRINTK("shutting down"); | 119 | DPRINTK("shutting down"); |
181 | kill_anon_super(sb); | 120 | kill_litter_super(sb); |
182 | } | 121 | } |
183 | 122 | ||
184 | static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt) | 123 | static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt) |
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index 30cc9ddf4b70..a015b49891df 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
@@ -104,99 +104,6 @@ static void autofs4_del_active(struct dentry *dentry) | |||
104 | return; | 104 | return; |
105 | } | 105 | } |
106 | 106 | ||
107 | static void autofs4_add_rehash_entry(struct autofs_info *ino, | ||
108 | struct rehash_entry *entry) | ||
109 | { | ||
110 | entry->task = current; | ||
111 | INIT_LIST_HEAD(&entry->list); | ||
112 | list_add(&entry->list, &ino->rehash_list); | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | static void autofs4_remove_rehash_entry(struct autofs_info *ino) | ||
117 | { | ||
118 | struct list_head *head = &ino->rehash_list; | ||
119 | struct rehash_entry *entry; | ||
120 | list_for_each_entry(entry, head, list) { | ||
121 | if (entry->task == current) { | ||
122 | list_del(&entry->list); | ||
123 | kfree(entry); | ||
124 | break; | ||
125 | } | ||
126 | } | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | static void autofs4_remove_rehash_entrys(struct autofs_info *ino) | ||
131 | { | ||
132 | struct autofs_sb_info *sbi = ino->sbi; | ||
133 | struct rehash_entry *entry, *next; | ||
134 | struct list_head *head; | ||
135 | |||
136 | spin_lock(&sbi->fs_lock); | ||
137 | spin_lock(&sbi->lookup_lock); | ||
138 | if (!(ino->flags & AUTOFS_INF_REHASH)) { | ||
139 | spin_unlock(&sbi->lookup_lock); | ||
140 | spin_unlock(&sbi->fs_lock); | ||
141 | return; | ||
142 | } | ||
143 | ino->flags &= ~AUTOFS_INF_REHASH; | ||
144 | head = &ino->rehash_list; | ||
145 | list_for_each_entry_safe(entry, next, head, list) { | ||
146 | list_del(&entry->list); | ||
147 | kfree(entry); | ||
148 | } | ||
149 | spin_unlock(&sbi->lookup_lock); | ||
150 | spin_unlock(&sbi->fs_lock); | ||
151 | dput(ino->dentry); | ||
152 | |||
153 | return; | ||
154 | } | ||
155 | |||
156 | static void autofs4_revalidate_drop(struct dentry *dentry, | ||
157 | struct rehash_entry *entry) | ||
158 | { | ||
159 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | ||
160 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | ||
161 | /* | ||
162 | * Add to the active list so we can pick this up in | ||
163 | * ->lookup(). Also add an entry to a rehash list so | ||
164 | * we know when there are no dentrys in flight so we | ||
165 | * know when we can rehash the dentry. | ||
166 | */ | ||
167 | spin_lock(&sbi->lookup_lock); | ||
168 | if (list_empty(&ino->active)) | ||
169 | list_add(&ino->active, &sbi->active_list); | ||
170 | autofs4_add_rehash_entry(ino, entry); | ||
171 | spin_unlock(&sbi->lookup_lock); | ||
172 | if (!(ino->flags & AUTOFS_INF_REHASH)) { | ||
173 | ino->flags |= AUTOFS_INF_REHASH; | ||
174 | dget(dentry); | ||
175 | spin_lock(&dentry->d_lock); | ||
176 | __d_drop(dentry); | ||
177 | spin_unlock(&dentry->d_lock); | ||
178 | } | ||
179 | return; | ||
180 | } | ||
181 | |||
182 | static void autofs4_revalidate_rehash(struct dentry *dentry) | ||
183 | { | ||
184 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | ||
185 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | ||
186 | if (ino->flags & AUTOFS_INF_REHASH) { | ||
187 | spin_lock(&sbi->lookup_lock); | ||
188 | autofs4_remove_rehash_entry(ino); | ||
189 | if (list_empty(&ino->rehash_list)) { | ||
190 | spin_unlock(&sbi->lookup_lock); | ||
191 | ino->flags &= ~AUTOFS_INF_REHASH; | ||
192 | d_rehash(dentry); | ||
193 | dput(ino->dentry); | ||
194 | } else | ||
195 | spin_unlock(&sbi->lookup_lock); | ||
196 | } | ||
197 | return; | ||
198 | } | ||
199 | |||
200 | static unsigned int autofs4_need_mount(unsigned int flags) | 107 | static unsigned int autofs4_need_mount(unsigned int flags) |
201 | { | 108 | { |
202 | unsigned int res = 0; | 109 | unsigned int res = 0; |
@@ -236,7 +143,7 @@ out: | |||
236 | return dcache_dir_open(inode, file); | 143 | return dcache_dir_open(inode, file); |
237 | } | 144 | } |
238 | 145 | ||
239 | static int try_to_fill_dentry(struct dentry *dentry) | 146 | static int try_to_fill_dentry(struct dentry *dentry, int flags) |
240 | { | 147 | { |
241 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | 148 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); |
242 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 149 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
@@ -249,17 +156,55 @@ static int try_to_fill_dentry(struct dentry *dentry) | |||
249 | * Wait for a pending mount, triggering one if there | 156 | * Wait for a pending mount, triggering one if there |
250 | * isn't one already | 157 | * isn't one already |
251 | */ | 158 | */ |
252 | DPRINTK("waiting for mount name=%.*s", | 159 | if (dentry->d_inode == NULL) { |
253 | dentry->d_name.len, dentry->d_name.name); | 160 | DPRINTK("waiting for mount name=%.*s", |
161 | dentry->d_name.len, dentry->d_name.name); | ||
254 | 162 | ||
255 | status = autofs4_wait(sbi, dentry, NFY_MOUNT); | 163 | status = autofs4_wait(sbi, dentry, NFY_MOUNT); |
256 | 164 | ||
257 | DPRINTK("mount done status=%d", status); | 165 | DPRINTK("mount done status=%d", status); |
258 | 166 | ||
259 | /* Update expiry counter */ | 167 | /* Turn this into a real negative dentry? */ |
260 | ino->last_used = jiffies; | 168 | if (status == -ENOENT) { |
169 | spin_lock(&sbi->fs_lock); | ||
170 | ino->flags &= ~AUTOFS_INF_PENDING; | ||
171 | spin_unlock(&sbi->fs_lock); | ||
172 | return status; | ||
173 | } else if (status) { | ||
174 | /* Return a negative dentry, but leave it "pending" */ | ||
175 | return status; | ||
176 | } | ||
177 | /* Trigger mount for path component or follow link */ | ||
178 | } else if (ino->flags & AUTOFS_INF_PENDING || | ||
179 | autofs4_need_mount(flags) || | ||
180 | current->link_count) { | ||
181 | DPRINTK("waiting for mount name=%.*s", | ||
182 | dentry->d_name.len, dentry->d_name.name); | ||
261 | 183 | ||
262 | return status; | 184 | spin_lock(&sbi->fs_lock); |
185 | ino->flags |= AUTOFS_INF_PENDING; | ||
186 | spin_unlock(&sbi->fs_lock); | ||
187 | status = autofs4_wait(sbi, dentry, NFY_MOUNT); | ||
188 | |||
189 | DPRINTK("mount done status=%d", status); | ||
190 | |||
191 | if (status) { | ||
192 | spin_lock(&sbi->fs_lock); | ||
193 | ino->flags &= ~AUTOFS_INF_PENDING; | ||
194 | spin_unlock(&sbi->fs_lock); | ||
195 | return status; | ||
196 | } | ||
197 | } | ||
198 | |||
199 | /* Initialize expiry counter after successful mount */ | ||
200 | if (ino) | ||
201 | ino->last_used = jiffies; | ||
202 | |||
203 | spin_lock(&sbi->fs_lock); | ||
204 | ino->flags &= ~AUTOFS_INF_PENDING; | ||
205 | spin_unlock(&sbi->fs_lock); | ||
206 | |||
207 | return 0; | ||
263 | } | 208 | } |
264 | 209 | ||
265 | /* For autofs direct mounts the follow link triggers the mount */ | 210 | /* For autofs direct mounts the follow link triggers the mount */ |
@@ -313,16 +258,10 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
313 | */ | 258 | */ |
314 | if (ino->flags & AUTOFS_INF_PENDING || | 259 | if (ino->flags & AUTOFS_INF_PENDING || |
315 | (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs))) { | 260 | (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs))) { |
316 | ino->flags |= AUTOFS_INF_PENDING; | ||
317 | spin_unlock(&dcache_lock); | 261 | spin_unlock(&dcache_lock); |
318 | spin_unlock(&sbi->fs_lock); | 262 | spin_unlock(&sbi->fs_lock); |
319 | 263 | ||
320 | status = try_to_fill_dentry(dentry); | 264 | status = try_to_fill_dentry(dentry, 0); |
321 | |||
322 | spin_lock(&sbi->fs_lock); | ||
323 | ino->flags &= ~AUTOFS_INF_PENDING; | ||
324 | spin_unlock(&sbi->fs_lock); | ||
325 | |||
326 | if (status) | 265 | if (status) |
327 | goto out_error; | 266 | goto out_error; |
328 | 267 | ||
@@ -361,47 +300,18 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
361 | { | 300 | { |
362 | struct inode *dir = dentry->d_parent->d_inode; | 301 | struct inode *dir = dentry->d_parent->d_inode; |
363 | struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); | 302 | struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); |
364 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 303 | int oz_mode = autofs4_oz_mode(sbi); |
365 | struct rehash_entry *entry; | ||
366 | int flags = nd ? nd->flags : 0; | 304 | int flags = nd ? nd->flags : 0; |
367 | unsigned int mutex_aquired; | 305 | int status = 1; |
368 | 306 | ||
369 | DPRINTK("name = %.*s oz_mode = %d", | ||
370 | dentry->d_name.len, dentry->d_name.name, oz_mode); | ||
371 | |||
372 | /* Daemon never causes a mount to trigger */ | ||
373 | if (autofs4_oz_mode(sbi)) | ||
374 | return 1; | ||
375 | |||
376 | entry = kmalloc(sizeof(struct rehash_entry), GFP_KERNEL); | ||
377 | if (!entry) | ||
378 | return -ENOMEM; | ||
379 | |||
380 | mutex_aquired = mutex_trylock(&dir->i_mutex); | ||
381 | |||
382 | spin_lock(&sbi->fs_lock); | ||
383 | spin_lock(&dcache_lock); | ||
384 | /* Pending dentry */ | 307 | /* Pending dentry */ |
308 | spin_lock(&sbi->fs_lock); | ||
385 | if (autofs4_ispending(dentry)) { | 309 | if (autofs4_ispending(dentry)) { |
386 | int status; | 310 | /* The daemon never causes a mount to trigger */ |
387 | |||
388 | /* | ||
389 | * We can only unhash and send this to ->lookup() if | ||
390 | * the directory mutex is held over d_revalidate() and | ||
391 | * ->lookup(). This prevents the VFS from incorrectly | ||
392 | * seeing the dentry as non-existent. | ||
393 | */ | ||
394 | ino->flags |= AUTOFS_INF_PENDING; | ||
395 | if (!mutex_aquired) { | ||
396 | autofs4_revalidate_drop(dentry, entry); | ||
397 | spin_unlock(&dcache_lock); | ||
398 | spin_unlock(&sbi->fs_lock); | ||
399 | return 0; | ||
400 | } | ||
401 | spin_unlock(&dcache_lock); | ||
402 | spin_unlock(&sbi->fs_lock); | 311 | spin_unlock(&sbi->fs_lock); |
403 | mutex_unlock(&dir->i_mutex); | 312 | |
404 | kfree(entry); | 313 | if (oz_mode) |
314 | return 1; | ||
405 | 315 | ||
406 | /* | 316 | /* |
407 | * If the directory has gone away due to an expire | 317 | * If the directory has gone away due to an expire |
@@ -415,82 +325,45 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
415 | * A zero status is success otherwise we have a | 325 | * A zero status is success otherwise we have a |
416 | * negative error code. | 326 | * negative error code. |
417 | */ | 327 | */ |
418 | status = try_to_fill_dentry(dentry); | 328 | status = try_to_fill_dentry(dentry, flags); |
419 | |||
420 | spin_lock(&sbi->fs_lock); | ||
421 | ino->flags &= ~AUTOFS_INF_PENDING; | ||
422 | spin_unlock(&sbi->fs_lock); | ||
423 | |||
424 | if (status == 0) | 329 | if (status == 0) |
425 | return 1; | 330 | return 1; |
426 | 331 | ||
427 | return status; | 332 | return status; |
428 | } | 333 | } |
334 | spin_unlock(&sbi->fs_lock); | ||
335 | |||
336 | /* Negative dentry.. invalidate if "old" */ | ||
337 | if (dentry->d_inode == NULL) | ||
338 | return 0; | ||
429 | 339 | ||
430 | /* Check for a non-mountpoint directory with no contents */ | 340 | /* Check for a non-mountpoint directory with no contents */ |
341 | spin_lock(&dcache_lock); | ||
431 | if (S_ISDIR(dentry->d_inode->i_mode) && | 342 | if (S_ISDIR(dentry->d_inode->i_mode) && |
432 | !d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) { | 343 | !d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) { |
433 | DPRINTK("dentry=%p %.*s, emptydir", | 344 | DPRINTK("dentry=%p %.*s, emptydir", |
434 | dentry, dentry->d_name.len, dentry->d_name.name); | 345 | dentry, dentry->d_name.len, dentry->d_name.name); |
346 | spin_unlock(&dcache_lock); | ||
435 | 347 | ||
436 | if (autofs4_need_mount(flags) || current->link_count) { | 348 | /* The daemon never causes a mount to trigger */ |
437 | int status; | 349 | if (oz_mode) |
438 | 350 | return 1; | |
439 | /* | ||
440 | * We can only unhash and send this to ->lookup() if | ||
441 | * the directory mutex is held over d_revalidate() and | ||
442 | * ->lookup(). This prevents the VFS from incorrectly | ||
443 | * seeing the dentry as non-existent. | ||
444 | */ | ||
445 | ino->flags |= AUTOFS_INF_PENDING; | ||
446 | if (!mutex_aquired) { | ||
447 | autofs4_revalidate_drop(dentry, entry); | ||
448 | spin_unlock(&dcache_lock); | ||
449 | spin_unlock(&sbi->fs_lock); | ||
450 | return 0; | ||
451 | } | ||
452 | spin_unlock(&dcache_lock); | ||
453 | spin_unlock(&sbi->fs_lock); | ||
454 | mutex_unlock(&dir->i_mutex); | ||
455 | kfree(entry); | ||
456 | |||
457 | /* | ||
458 | * A zero status is success otherwise we have a | ||
459 | * negative error code. | ||
460 | */ | ||
461 | status = try_to_fill_dentry(dentry); | ||
462 | |||
463 | spin_lock(&sbi->fs_lock); | ||
464 | ino->flags &= ~AUTOFS_INF_PENDING; | ||
465 | spin_unlock(&sbi->fs_lock); | ||
466 | 351 | ||
467 | if (status == 0) | 352 | /* |
468 | return 1; | 353 | * A zero status is success otherwise we have a |
354 | * negative error code. | ||
355 | */ | ||
356 | status = try_to_fill_dentry(dentry, flags); | ||
357 | if (status == 0) | ||
358 | return 1; | ||
469 | 359 | ||
470 | return status; | 360 | return status; |
471 | } | ||
472 | } | 361 | } |
473 | spin_unlock(&dcache_lock); | 362 | spin_unlock(&dcache_lock); |
474 | spin_unlock(&sbi->fs_lock); | ||
475 | |||
476 | if (mutex_aquired) | ||
477 | mutex_unlock(&dir->i_mutex); | ||
478 | |||
479 | kfree(entry); | ||
480 | 363 | ||
481 | return 1; | 364 | return 1; |
482 | } | 365 | } |
483 | 366 | ||
484 | static void autofs4_free_rehash_entrys(struct autofs_info *inf) | ||
485 | { | ||
486 | struct list_head *head = &inf->rehash_list; | ||
487 | struct rehash_entry *entry, *next; | ||
488 | list_for_each_entry_safe(entry, next, head, list) { | ||
489 | list_del(&entry->list); | ||
490 | kfree(entry); | ||
491 | } | ||
492 | } | ||
493 | |||
494 | void autofs4_dentry_release(struct dentry *de) | 367 | void autofs4_dentry_release(struct dentry *de) |
495 | { | 368 | { |
496 | struct autofs_info *inf; | 369 | struct autofs_info *inf; |
@@ -509,8 +382,6 @@ void autofs4_dentry_release(struct dentry *de) | |||
509 | list_del(&inf->active); | 382 | list_del(&inf->active); |
510 | if (!list_empty(&inf->expiring)) | 383 | if (!list_empty(&inf->expiring)) |
511 | list_del(&inf->expiring); | 384 | list_del(&inf->expiring); |
512 | if (!list_empty(&inf->rehash_list)) | ||
513 | autofs4_free_rehash_entrys(inf); | ||
514 | spin_unlock(&sbi->lookup_lock); | 385 | spin_unlock(&sbi->lookup_lock); |
515 | } | 386 | } |
516 | 387 | ||
@@ -543,7 +414,6 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry) | |||
543 | const unsigned char *str = name->name; | 414 | const unsigned char *str = name->name; |
544 | struct list_head *p, *head; | 415 | struct list_head *p, *head; |
545 | 416 | ||
546 | restart: | ||
547 | spin_lock(&dcache_lock); | 417 | spin_lock(&dcache_lock); |
548 | spin_lock(&sbi->lookup_lock); | 418 | spin_lock(&sbi->lookup_lock); |
549 | head = &sbi->active_list; | 419 | head = &sbi->active_list; |
@@ -561,19 +431,6 @@ restart: | |||
561 | if (atomic_read(&active->d_count) == 0) | 431 | if (atomic_read(&active->d_count) == 0) |
562 | goto next; | 432 | goto next; |
563 | 433 | ||
564 | if (active->d_inode && IS_DEADDIR(active->d_inode)) { | ||
565 | if (!list_empty(&ino->rehash_list)) { | ||
566 | dget(active); | ||
567 | spin_unlock(&active->d_lock); | ||
568 | spin_unlock(&sbi->lookup_lock); | ||
569 | spin_unlock(&dcache_lock); | ||
570 | autofs4_remove_rehash_entrys(ino); | ||
571 | dput(active); | ||
572 | goto restart; | ||
573 | } | ||
574 | goto next; | ||
575 | } | ||
576 | |||
577 | qstr = &active->d_name; | 434 | qstr = &active->d_name; |
578 | 435 | ||
579 | if (active->d_name.hash != hash) | 436 | if (active->d_name.hash != hash) |
@@ -586,11 +443,13 @@ restart: | |||
586 | if (memcmp(qstr->name, str, len)) | 443 | if (memcmp(qstr->name, str, len)) |
587 | goto next; | 444 | goto next; |
588 | 445 | ||
589 | dget(active); | 446 | if (d_unhashed(active)) { |
590 | spin_unlock(&active->d_lock); | 447 | dget(active); |
591 | spin_unlock(&sbi->lookup_lock); | 448 | spin_unlock(&active->d_lock); |
592 | spin_unlock(&dcache_lock); | 449 | spin_unlock(&sbi->lookup_lock); |
593 | return active; | 450 | spin_unlock(&dcache_lock); |
451 | return active; | ||
452 | } | ||
594 | next: | 453 | next: |
595 | spin_unlock(&active->d_lock); | 454 | spin_unlock(&active->d_lock); |
596 | } | 455 | } |
@@ -639,11 +498,13 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry) | |||
639 | if (memcmp(qstr->name, str, len)) | 498 | if (memcmp(qstr->name, str, len)) |
640 | goto next; | 499 | goto next; |
641 | 500 | ||
642 | dget(expiring); | 501 | if (d_unhashed(expiring)) { |
643 | spin_unlock(&expiring->d_lock); | 502 | dget(expiring); |
644 | spin_unlock(&sbi->lookup_lock); | 503 | spin_unlock(&expiring->d_lock); |
645 | spin_unlock(&dcache_lock); | 504 | spin_unlock(&sbi->lookup_lock); |
646 | return expiring; | 505 | spin_unlock(&dcache_lock); |
506 | return expiring; | ||
507 | } | ||
647 | next: | 508 | next: |
648 | spin_unlock(&expiring->d_lock); | 509 | spin_unlock(&expiring->d_lock); |
649 | } | 510 | } |
@@ -653,48 +514,6 @@ next: | |||
653 | return NULL; | 514 | return NULL; |
654 | } | 515 | } |
655 | 516 | ||
656 | static struct autofs_info *init_new_dentry(struct autofs_sb_info *sbi, | ||
657 | struct dentry *dentry, int oz_mode) | ||
658 | { | ||
659 | struct autofs_info *ino; | ||
660 | |||
661 | /* | ||
662 | * Mark the dentry incomplete but don't hash it. We do this | ||
663 | * to serialize our inode creation operations (symlink and | ||
664 | * mkdir) which prevents deadlock during the callback to | ||
665 | * the daemon. Subsequent user space lookups for the same | ||
666 | * dentry are placed on the wait queue while the daemon | ||
667 | * itself is allowed passage unresticted so the create | ||
668 | * operation itself can then hash the dentry. Finally, | ||
669 | * we check for the hashed dentry and return the newly | ||
670 | * hashed dentry. | ||
671 | */ | ||
672 | dentry->d_op = &autofs4_root_dentry_operations; | ||
673 | |||
674 | /* | ||
675 | * And we need to ensure that the same dentry is used for | ||
676 | * all following lookup calls until it is hashed so that | ||
677 | * the dentry flags are persistent throughout the request. | ||
678 | */ | ||
679 | ino = autofs4_init_ino(NULL, sbi, 0555); | ||
680 | if (!ino) | ||
681 | return ERR_PTR(-ENOMEM); | ||
682 | |||
683 | dentry->d_fsdata = ino; | ||
684 | ino->dentry = dentry; | ||
685 | |||
686 | /* | ||
687 | * Only set the mount pending flag for new dentrys not created | ||
688 | * by the daemon. | ||
689 | */ | ||
690 | if (!oz_mode) | ||
691 | ino->flags |= AUTOFS_INF_PENDING; | ||
692 | |||
693 | d_instantiate(dentry, NULL); | ||
694 | |||
695 | return ino; | ||
696 | } | ||
697 | |||
698 | /* Lookups in the root directory */ | 517 | /* Lookups in the root directory */ |
699 | static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | 518 | static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) |
700 | { | 519 | { |
@@ -702,7 +521,6 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s | |||
702 | struct autofs_info *ino; | 521 | struct autofs_info *ino; |
703 | struct dentry *expiring, *active; | 522 | struct dentry *expiring, *active; |
704 | int oz_mode; | 523 | int oz_mode; |
705 | int status = 0; | ||
706 | 524 | ||
707 | DPRINTK("name = %.*s", | 525 | DPRINTK("name = %.*s", |
708 | dentry->d_name.len, dentry->d_name.name); | 526 | dentry->d_name.len, dentry->d_name.name); |
@@ -717,26 +535,44 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s | |||
717 | DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d", | 535 | DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d", |
718 | current->pid, task_pgrp_nr(current), sbi->catatonic, oz_mode); | 536 | current->pid, task_pgrp_nr(current), sbi->catatonic, oz_mode); |
719 | 537 | ||
720 | spin_lock(&sbi->fs_lock); | ||
721 | active = autofs4_lookup_active(dentry); | 538 | active = autofs4_lookup_active(dentry); |
722 | if (active) { | 539 | if (active) { |
723 | dentry = active; | 540 | dentry = active; |
724 | ino = autofs4_dentry_ino(dentry); | 541 | ino = autofs4_dentry_ino(dentry); |
725 | /* If this came from revalidate, rehash it */ | ||
726 | autofs4_revalidate_rehash(dentry); | ||
727 | spin_unlock(&sbi->fs_lock); | ||
728 | } else { | 542 | } else { |
729 | spin_unlock(&sbi->fs_lock); | 543 | /* |
730 | ino = init_new_dentry(sbi, dentry, oz_mode); | 544 | * Mark the dentry incomplete but don't hash it. We do this |
731 | if (IS_ERR(ino)) | 545 | * to serialize our inode creation operations (symlink and |
732 | return (struct dentry *) ino; | 546 | * mkdir) which prevents deadlock during the callback to |
733 | } | 547 | * the daemon. Subsequent user space lookups for the same |
548 | * dentry are placed on the wait queue while the daemon | ||
549 | * itself is allowed passage unresticted so the create | ||
550 | * operation itself can then hash the dentry. Finally, | ||
551 | * we check for the hashed dentry and return the newly | ||
552 | * hashed dentry. | ||
553 | */ | ||
554 | dentry->d_op = &autofs4_root_dentry_operations; | ||
555 | |||
556 | /* | ||
557 | * And we need to ensure that the same dentry is used for | ||
558 | * all following lookup calls until it is hashed so that | ||
559 | * the dentry flags are persistent throughout the request. | ||
560 | */ | ||
561 | ino = autofs4_init_ino(NULL, sbi, 0555); | ||
562 | if (!ino) | ||
563 | return ERR_PTR(-ENOMEM); | ||
734 | 564 | ||
735 | autofs4_add_active(dentry); | 565 | dentry->d_fsdata = ino; |
566 | ino->dentry = dentry; | ||
567 | |||
568 | autofs4_add_active(dentry); | ||
569 | |||
570 | d_instantiate(dentry, NULL); | ||
571 | } | ||
736 | 572 | ||
737 | if (!oz_mode) { | 573 | if (!oz_mode) { |
738 | expiring = autofs4_lookup_expiring(dentry); | ||
739 | mutex_unlock(&dir->i_mutex); | 574 | mutex_unlock(&dir->i_mutex); |
575 | expiring = autofs4_lookup_expiring(dentry); | ||
740 | if (expiring) { | 576 | if (expiring) { |
741 | /* | 577 | /* |
742 | * If we are racing with expire the request might not | 578 | * If we are racing with expire the request might not |
@@ -744,22 +580,23 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s | |||
744 | * so it must have been successful, so just wait for it. | 580 | * so it must have been successful, so just wait for it. |
745 | */ | 581 | */ |
746 | autofs4_expire_wait(expiring); | 582 | autofs4_expire_wait(expiring); |
583 | autofs4_del_expiring(expiring); | ||
747 | dput(expiring); | 584 | dput(expiring); |
748 | } | 585 | } |
749 | status = try_to_fill_dentry(dentry); | 586 | |
750 | mutex_lock(&dir->i_mutex); | ||
751 | spin_lock(&sbi->fs_lock); | 587 | spin_lock(&sbi->fs_lock); |
752 | ino->flags &= ~AUTOFS_INF_PENDING; | 588 | ino->flags |= AUTOFS_INF_PENDING; |
753 | spin_unlock(&sbi->fs_lock); | 589 | spin_unlock(&sbi->fs_lock); |
590 | if (dentry->d_op && dentry->d_op->d_revalidate) | ||
591 | (dentry->d_op->d_revalidate)(dentry, nd); | ||
592 | mutex_lock(&dir->i_mutex); | ||
754 | } | 593 | } |
755 | 594 | ||
756 | autofs4_del_active(dentry); | ||
757 | |||
758 | /* | 595 | /* |
759 | * If we had a mount fail, check if we had to handle | 596 | * If we are still pending, check if we had to handle |
760 | * a signal. If so we can force a restart.. | 597 | * a signal. If so we can force a restart.. |
761 | */ | 598 | */ |
762 | if (status) { | 599 | if (ino->flags & AUTOFS_INF_PENDING) { |
763 | /* See if we were interrupted */ | 600 | /* See if we were interrupted */ |
764 | if (signal_pending(current)) { | 601 | if (signal_pending(current)) { |
765 | sigset_t *sigset = ¤t->pending.signal; | 602 | sigset_t *sigset = ¤t->pending.signal; |
@@ -771,46 +608,43 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s | |||
771 | return ERR_PTR(-ERESTARTNOINTR); | 608 | return ERR_PTR(-ERESTARTNOINTR); |
772 | } | 609 | } |
773 | } | 610 | } |
774 | } | 611 | if (!oz_mode) { |
775 | 612 | spin_lock(&sbi->fs_lock); | |
776 | /* | 613 | ino->flags &= ~AUTOFS_INF_PENDING; |
777 | * User space can (and has done in the past) remove and re-create | 614 | spin_unlock(&sbi->fs_lock); |
778 | * this directory during the callback. This can leave us with an | ||
779 | * unhashed dentry, but a successful mount! So we need to | ||
780 | * perform another cached lookup in case the dentry now exists. | ||
781 | */ | ||
782 | if (!oz_mode && !have_submounts(dentry)) { | ||
783 | struct dentry *new; | ||
784 | new = d_lookup(dentry->d_parent, &dentry->d_name); | ||
785 | if (new) { | ||
786 | if (active) | ||
787 | dput(active); | ||
788 | return new; | ||
789 | } else { | ||
790 | if (!status) | ||
791 | status = -ENOENT; | ||
792 | } | 615 | } |
793 | } | 616 | } |
794 | 617 | ||
795 | /* | 618 | /* |
796 | * If we had a mount failure, return status to user space. | 619 | * If this dentry is unhashed, then we shouldn't honour this |
797 | * If the mount succeeded and we used a dentry from the active queue | 620 | * lookup. Returning ENOENT here doesn't do the right thing |
798 | * return it. | 621 | * for all system calls, but it should be OK for the operations |
622 | * we permit from an autofs. | ||
799 | */ | 623 | */ |
800 | if (status) { | 624 | if (!oz_mode && d_unhashed(dentry)) { |
801 | dentry = ERR_PTR(status); | ||
802 | if (active) | ||
803 | dput(active); | ||
804 | return dentry; | ||
805 | } else { | ||
806 | /* | 625 | /* |
807 | * Valid successful mount, return active dentry or NULL | 626 | * A user space application can (and has done in the past) |
808 | * for a new dentry. | 627 | * remove and re-create this directory during the callback. |
628 | * This can leave us with an unhashed dentry, but a | ||
629 | * successful mount! So we need to perform another | ||
630 | * cached lookup in case the dentry now exists. | ||
809 | */ | 631 | */ |
632 | struct dentry *parent = dentry->d_parent; | ||
633 | struct dentry *new = d_lookup(parent, &dentry->d_name); | ||
634 | if (new != NULL) | ||
635 | dentry = new; | ||
636 | else | ||
637 | dentry = ERR_PTR(-ENOENT); | ||
638 | |||
810 | if (active) | 639 | if (active) |
811 | return active; | 640 | dput(active); |
641 | |||
642 | return dentry; | ||
812 | } | 643 | } |
813 | 644 | ||
645 | if (active) | ||
646 | return active; | ||
647 | |||
814 | return NULL; | 648 | return NULL; |
815 | } | 649 | } |
816 | 650 | ||
@@ -834,6 +668,8 @@ static int autofs4_dir_symlink(struct inode *dir, | |||
834 | if (!ino) | 668 | if (!ino) |
835 | return -ENOMEM; | 669 | return -ENOMEM; |
836 | 670 | ||
671 | autofs4_del_active(dentry); | ||
672 | |||
837 | ino->size = strlen(symname); | 673 | ino->size = strlen(symname); |
838 | cp = kmalloc(ino->size + 1, GFP_KERNEL); | 674 | cp = kmalloc(ino->size + 1, GFP_KERNEL); |
839 | if (!cp) { | 675 | if (!cp) { |
@@ -910,6 +746,7 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry) | |||
910 | dir->i_mtime = CURRENT_TIME; | 746 | dir->i_mtime = CURRENT_TIME; |
911 | 747 | ||
912 | spin_lock(&dcache_lock); | 748 | spin_lock(&dcache_lock); |
749 | autofs4_add_expiring(dentry); | ||
913 | spin_lock(&dentry->d_lock); | 750 | spin_lock(&dentry->d_lock); |
914 | __d_drop(dentry); | 751 | __d_drop(dentry); |
915 | spin_unlock(&dentry->d_lock); | 752 | spin_unlock(&dentry->d_lock); |
@@ -935,6 +772,7 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry) | |||
935 | spin_unlock(&dcache_lock); | 772 | spin_unlock(&dcache_lock); |
936 | return -ENOTEMPTY; | 773 | return -ENOTEMPTY; |
937 | } | 774 | } |
775 | autofs4_add_expiring(dentry); | ||
938 | spin_lock(&dentry->d_lock); | 776 | spin_lock(&dentry->d_lock); |
939 | __d_drop(dentry); | 777 | __d_drop(dentry); |
940 | spin_unlock(&dentry->d_lock); | 778 | spin_unlock(&dentry->d_lock); |
@@ -972,6 +810,8 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
972 | if (!ino) | 810 | if (!ino) |
973 | return -ENOMEM; | 811 | return -ENOMEM; |
974 | 812 | ||
813 | autofs4_del_active(dentry); | ||
814 | |||
975 | inode = autofs4_get_inode(dir->i_sb, ino); | 815 | inode = autofs4_get_inode(dir->i_sb, ino); |
976 | if (!inode) { | 816 | if (!inode) { |
977 | if (!dentry->d_fsdata) | 817 | if (!dentry->d_fsdata) |
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 057e1dae12ab..3d8f8a96f5a3 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -2289,9 +2289,9 @@ cifs_oplock_break(struct slow_work *work) | |||
2289 | if (inode && S_ISREG(inode->i_mode)) { | 2289 | if (inode && S_ISREG(inode->i_mode)) { |
2290 | #ifdef CONFIG_CIFS_EXPERIMENTAL | 2290 | #ifdef CONFIG_CIFS_EXPERIMENTAL |
2291 | if (cinode->clientCanCacheAll == 0) | 2291 | if (cinode->clientCanCacheAll == 0) |
2292 | break_lease(inode, FMODE_READ); | 2292 | break_lease(inode, O_RDONLY); |
2293 | else if (cinode->clientCanCacheRead == 0) | 2293 | else if (cinode->clientCanCacheRead == 0) |
2294 | break_lease(inode, FMODE_WRITE); | 2294 | break_lease(inode, O_WRONLY); |
2295 | #endif | 2295 | #endif |
2296 | rc = filemap_fdatawrite(inode->i_mapping); | 2296 | rc = filemap_fdatawrite(inode->i_mapping); |
2297 | if (cinode->clientCanCacheRead == 0) { | 2297 | if (cinode->clientCanCacheRead == 0) { |
diff --git a/fs/dcache.c b/fs/dcache.c index 953173a293a9..f1358e5c3a59 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -257,6 +257,7 @@ kill_it: | |||
257 | if (dentry) | 257 | if (dentry) |
258 | goto repeat; | 258 | goto repeat; |
259 | } | 259 | } |
260 | EXPORT_SYMBOL(dput); | ||
260 | 261 | ||
261 | /** | 262 | /** |
262 | * d_invalidate - invalidate a dentry | 263 | * d_invalidate - invalidate a dentry |
@@ -314,6 +315,7 @@ int d_invalidate(struct dentry * dentry) | |||
314 | spin_unlock(&dcache_lock); | 315 | spin_unlock(&dcache_lock); |
315 | return 0; | 316 | return 0; |
316 | } | 317 | } |
318 | EXPORT_SYMBOL(d_invalidate); | ||
317 | 319 | ||
318 | /* This should be called _only_ with dcache_lock held */ | 320 | /* This should be called _only_ with dcache_lock held */ |
319 | 321 | ||
@@ -328,6 +330,7 @@ struct dentry * dget_locked(struct dentry *dentry) | |||
328 | { | 330 | { |
329 | return __dget_locked(dentry); | 331 | return __dget_locked(dentry); |
330 | } | 332 | } |
333 | EXPORT_SYMBOL(dget_locked); | ||
331 | 334 | ||
332 | /** | 335 | /** |
333 | * d_find_alias - grab a hashed alias of inode | 336 | * d_find_alias - grab a hashed alias of inode |
@@ -384,6 +387,7 @@ struct dentry * d_find_alias(struct inode *inode) | |||
384 | } | 387 | } |
385 | return de; | 388 | return de; |
386 | } | 389 | } |
390 | EXPORT_SYMBOL(d_find_alias); | ||
387 | 391 | ||
388 | /* | 392 | /* |
389 | * Try to kill dentries associated with this inode. | 393 | * Try to kill dentries associated with this inode. |
@@ -408,6 +412,7 @@ restart: | |||
408 | } | 412 | } |
409 | spin_unlock(&dcache_lock); | 413 | spin_unlock(&dcache_lock); |
410 | } | 414 | } |
415 | EXPORT_SYMBOL(d_prune_aliases); | ||
411 | 416 | ||
412 | /* | 417 | /* |
413 | * Throw away a dentry - free the inode, dput the parent. This requires that | 418 | * Throw away a dentry - free the inode, dput the parent. This requires that |
@@ -610,6 +615,7 @@ void shrink_dcache_sb(struct super_block * sb) | |||
610 | { | 615 | { |
611 | __shrink_dcache_sb(sb, NULL, 0); | 616 | __shrink_dcache_sb(sb, NULL, 0); |
612 | } | 617 | } |
618 | EXPORT_SYMBOL(shrink_dcache_sb); | ||
613 | 619 | ||
614 | /* | 620 | /* |
615 | * destroy a single subtree of dentries for unmount | 621 | * destroy a single subtree of dentries for unmount |
@@ -792,6 +798,7 @@ positive: | |||
792 | spin_unlock(&dcache_lock); | 798 | spin_unlock(&dcache_lock); |
793 | return 1; | 799 | return 1; |
794 | } | 800 | } |
801 | EXPORT_SYMBOL(have_submounts); | ||
795 | 802 | ||
796 | /* | 803 | /* |
797 | * Search the dentry child list for the specified parent, | 804 | * Search the dentry child list for the specified parent, |
@@ -876,6 +883,7 @@ void shrink_dcache_parent(struct dentry * parent) | |||
876 | while ((found = select_parent(parent)) != 0) | 883 | while ((found = select_parent(parent)) != 0) |
877 | __shrink_dcache_sb(sb, &found, 0); | 884 | __shrink_dcache_sb(sb, &found, 0); |
878 | } | 885 | } |
886 | EXPORT_SYMBOL(shrink_dcache_parent); | ||
879 | 887 | ||
880 | /* | 888 | /* |
881 | * Scan `nr' dentries and return the number which remain. | 889 | * Scan `nr' dentries and return the number which remain. |
@@ -968,6 +976,7 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name) | |||
968 | 976 | ||
969 | return dentry; | 977 | return dentry; |
970 | } | 978 | } |
979 | EXPORT_SYMBOL(d_alloc); | ||
971 | 980 | ||
972 | struct dentry *d_alloc_name(struct dentry *parent, const char *name) | 981 | struct dentry *d_alloc_name(struct dentry *parent, const char *name) |
973 | { | 982 | { |
@@ -1012,6 +1021,7 @@ void d_instantiate(struct dentry *entry, struct inode * inode) | |||
1012 | spin_unlock(&dcache_lock); | 1021 | spin_unlock(&dcache_lock); |
1013 | security_d_instantiate(entry, inode); | 1022 | security_d_instantiate(entry, inode); |
1014 | } | 1023 | } |
1024 | EXPORT_SYMBOL(d_instantiate); | ||
1015 | 1025 | ||
1016 | /** | 1026 | /** |
1017 | * d_instantiate_unique - instantiate a non-aliased dentry | 1027 | * d_instantiate_unique - instantiate a non-aliased dentry |
@@ -1108,6 +1118,7 @@ struct dentry * d_alloc_root(struct inode * root_inode) | |||
1108 | } | 1118 | } |
1109 | return res; | 1119 | return res; |
1110 | } | 1120 | } |
1121 | EXPORT_SYMBOL(d_alloc_root); | ||
1111 | 1122 | ||
1112 | static inline struct hlist_head *d_hash(struct dentry *parent, | 1123 | static inline struct hlist_head *d_hash(struct dentry *parent, |
1113 | unsigned long hash) | 1124 | unsigned long hash) |
@@ -1211,7 +1222,6 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) | |||
1211 | BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED)); | 1222 | BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED)); |
1212 | spin_unlock(&dcache_lock); | 1223 | spin_unlock(&dcache_lock); |
1213 | security_d_instantiate(new, inode); | 1224 | security_d_instantiate(new, inode); |
1214 | d_rehash(dentry); | ||
1215 | d_move(new, dentry); | 1225 | d_move(new, dentry); |
1216 | iput(inode); | 1226 | iput(inode); |
1217 | } else { | 1227 | } else { |
@@ -1225,6 +1235,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) | |||
1225 | d_add(dentry, inode); | 1235 | d_add(dentry, inode); |
1226 | return new; | 1236 | return new; |
1227 | } | 1237 | } |
1238 | EXPORT_SYMBOL(d_splice_alias); | ||
1228 | 1239 | ||
1229 | /** | 1240 | /** |
1230 | * d_add_ci - lookup or allocate new dentry with case-exact name | 1241 | * d_add_ci - lookup or allocate new dentry with case-exact name |
@@ -1314,6 +1325,7 @@ err_out: | |||
1314 | iput(inode); | 1325 | iput(inode); |
1315 | return ERR_PTR(error); | 1326 | return ERR_PTR(error); |
1316 | } | 1327 | } |
1328 | EXPORT_SYMBOL(d_add_ci); | ||
1317 | 1329 | ||
1318 | /** | 1330 | /** |
1319 | * d_lookup - search for a dentry | 1331 | * d_lookup - search for a dentry |
@@ -1357,6 +1369,7 @@ struct dentry * d_lookup(struct dentry * parent, struct qstr * name) | |||
1357 | } while (read_seqretry(&rename_lock, seq)); | 1369 | } while (read_seqretry(&rename_lock, seq)); |
1358 | return dentry; | 1370 | return dentry; |
1359 | } | 1371 | } |
1372 | EXPORT_SYMBOL(d_lookup); | ||
1360 | 1373 | ||
1361 | struct dentry * __d_lookup(struct dentry * parent, struct qstr * name) | 1374 | struct dentry * __d_lookup(struct dentry * parent, struct qstr * name) |
1362 | { | 1375 | { |
@@ -1483,6 +1496,7 @@ int d_validate(struct dentry *dentry, struct dentry *dparent) | |||
1483 | out: | 1496 | out: |
1484 | return 0; | 1497 | return 0; |
1485 | } | 1498 | } |
1499 | EXPORT_SYMBOL(d_validate); | ||
1486 | 1500 | ||
1487 | /* | 1501 | /* |
1488 | * When a file is deleted, we have two options: | 1502 | * When a file is deleted, we have two options: |
@@ -1528,6 +1542,7 @@ void d_delete(struct dentry * dentry) | |||
1528 | 1542 | ||
1529 | fsnotify_nameremove(dentry, isdir); | 1543 | fsnotify_nameremove(dentry, isdir); |
1530 | } | 1544 | } |
1545 | EXPORT_SYMBOL(d_delete); | ||
1531 | 1546 | ||
1532 | static void __d_rehash(struct dentry * entry, struct hlist_head *list) | 1547 | static void __d_rehash(struct dentry * entry, struct hlist_head *list) |
1533 | { | 1548 | { |
@@ -1556,6 +1571,7 @@ void d_rehash(struct dentry * entry) | |||
1556 | spin_unlock(&entry->d_lock); | 1571 | spin_unlock(&entry->d_lock); |
1557 | spin_unlock(&dcache_lock); | 1572 | spin_unlock(&dcache_lock); |
1558 | } | 1573 | } |
1574 | EXPORT_SYMBOL(d_rehash); | ||
1559 | 1575 | ||
1560 | /* | 1576 | /* |
1561 | * When switching names, the actual string doesn't strictly have to | 1577 | * When switching names, the actual string doesn't strictly have to |
@@ -1702,6 +1718,7 @@ void d_move(struct dentry * dentry, struct dentry * target) | |||
1702 | d_move_locked(dentry, target); | 1718 | d_move_locked(dentry, target); |
1703 | spin_unlock(&dcache_lock); | 1719 | spin_unlock(&dcache_lock); |
1704 | } | 1720 | } |
1721 | EXPORT_SYMBOL(d_move); | ||
1705 | 1722 | ||
1706 | /** | 1723 | /** |
1707 | * d_ancestor - search for an ancestor | 1724 | * d_ancestor - search for an ancestor |
@@ -1868,6 +1885,7 @@ shouldnt_be_hashed: | |||
1868 | spin_unlock(&dcache_lock); | 1885 | spin_unlock(&dcache_lock); |
1869 | BUG(); | 1886 | BUG(); |
1870 | } | 1887 | } |
1888 | EXPORT_SYMBOL_GPL(d_materialise_unique); | ||
1871 | 1889 | ||
1872 | static int prepend(char **buffer, int *buflen, const char *str, int namelen) | 1890 | static int prepend(char **buffer, int *buflen, const char *str, int namelen) |
1873 | { | 1891 | { |
@@ -2005,6 +2023,7 @@ char *d_path(const struct path *path, char *buf, int buflen) | |||
2005 | path_put(&root); | 2023 | path_put(&root); |
2006 | return res; | 2024 | return res; |
2007 | } | 2025 | } |
2026 | EXPORT_SYMBOL(d_path); | ||
2008 | 2027 | ||
2009 | /* | 2028 | /* |
2010 | * Helper function for dentry_operations.d_dname() members | 2029 | * Helper function for dentry_operations.d_dname() members |
@@ -2171,6 +2190,30 @@ int is_subdir(struct dentry *new_dentry, struct dentry *old_dentry) | |||
2171 | return result; | 2190 | return result; |
2172 | } | 2191 | } |
2173 | 2192 | ||
2193 | int path_is_under(struct path *path1, struct path *path2) | ||
2194 | { | ||
2195 | struct vfsmount *mnt = path1->mnt; | ||
2196 | struct dentry *dentry = path1->dentry; | ||
2197 | int res; | ||
2198 | spin_lock(&vfsmount_lock); | ||
2199 | if (mnt != path2->mnt) { | ||
2200 | for (;;) { | ||
2201 | if (mnt->mnt_parent == mnt) { | ||
2202 | spin_unlock(&vfsmount_lock); | ||
2203 | return 0; | ||
2204 | } | ||
2205 | if (mnt->mnt_parent == path2->mnt) | ||
2206 | break; | ||
2207 | mnt = mnt->mnt_parent; | ||
2208 | } | ||
2209 | dentry = mnt->mnt_mountpoint; | ||
2210 | } | ||
2211 | res = is_subdir(dentry, path2->dentry); | ||
2212 | spin_unlock(&vfsmount_lock); | ||
2213 | return res; | ||
2214 | } | ||
2215 | EXPORT_SYMBOL(path_is_under); | ||
2216 | |||
2174 | void d_genocide(struct dentry *root) | 2217 | void d_genocide(struct dentry *root) |
2175 | { | 2218 | { |
2176 | struct dentry *this_parent = root; | 2219 | struct dentry *this_parent = root; |
@@ -2228,6 +2271,7 @@ ino_t find_inode_number(struct dentry *dir, struct qstr *name) | |||
2228 | } | 2271 | } |
2229 | return ino; | 2272 | return ino; |
2230 | } | 2273 | } |
2274 | EXPORT_SYMBOL(find_inode_number); | ||
2231 | 2275 | ||
2232 | static __initdata unsigned long dhash_entries; | 2276 | static __initdata unsigned long dhash_entries; |
2233 | static int __init set_dhash_entries(char *str) | 2277 | static int __init set_dhash_entries(char *str) |
@@ -2297,6 +2341,7 @@ static void __init dcache_init(void) | |||
2297 | 2341 | ||
2298 | /* SLAB cache for __getname() consumers */ | 2342 | /* SLAB cache for __getname() consumers */ |
2299 | struct kmem_cache *names_cachep __read_mostly; | 2343 | struct kmem_cache *names_cachep __read_mostly; |
2344 | EXPORT_SYMBOL(names_cachep); | ||
2300 | 2345 | ||
2301 | EXPORT_SYMBOL(d_genocide); | 2346 | EXPORT_SYMBOL(d_genocide); |
2302 | 2347 | ||
@@ -2326,26 +2371,3 @@ void __init vfs_caches_init(unsigned long mempages) | |||
2326 | bdev_cache_init(); | 2371 | bdev_cache_init(); |
2327 | chrdev_init(); | 2372 | chrdev_init(); |
2328 | } | 2373 | } |
2329 | |||
2330 | EXPORT_SYMBOL(d_alloc); | ||
2331 | EXPORT_SYMBOL(d_alloc_root); | ||
2332 | EXPORT_SYMBOL(d_delete); | ||
2333 | EXPORT_SYMBOL(d_find_alias); | ||
2334 | EXPORT_SYMBOL(d_instantiate); | ||
2335 | EXPORT_SYMBOL(d_invalidate); | ||
2336 | EXPORT_SYMBOL(d_lookup); | ||
2337 | EXPORT_SYMBOL(d_move); | ||
2338 | EXPORT_SYMBOL_GPL(d_materialise_unique); | ||
2339 | EXPORT_SYMBOL(d_path); | ||
2340 | EXPORT_SYMBOL(d_prune_aliases); | ||
2341 | EXPORT_SYMBOL(d_rehash); | ||
2342 | EXPORT_SYMBOL(d_splice_alias); | ||
2343 | EXPORT_SYMBOL(d_add_ci); | ||
2344 | EXPORT_SYMBOL(d_validate); | ||
2345 | EXPORT_SYMBOL(dget_locked); | ||
2346 | EXPORT_SYMBOL(dput); | ||
2347 | EXPORT_SYMBOL(find_inode_number); | ||
2348 | EXPORT_SYMBOL(have_submounts); | ||
2349 | EXPORT_SYMBOL(names_cachep); | ||
2350 | EXPORT_SYMBOL(shrink_dcache_parent); | ||
2351 | EXPORT_SYMBOL(shrink_dcache_sb); | ||
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 274ac865bae8..049d6c36da09 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
@@ -496,7 +496,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, | |||
496 | } | 496 | } |
497 | d_move(old_dentry, dentry); | 497 | d_move(old_dentry, dentry); |
498 | fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name, | 498 | fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name, |
499 | old_dentry->d_name.name, S_ISDIR(old_dentry->d_inode->i_mode), | 499 | S_ISDIR(old_dentry->d_inode->i_mode), |
500 | NULL, old_dentry); | 500 | NULL, old_dentry); |
501 | fsnotify_oldname_free(old_name); | 501 | fsnotify_oldname_free(old_name); |
502 | unlock_rename(new_dir, old_dir); | 502 | unlock_rename(new_dir, old_dir); |
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 9630583cef28..56eee3d796c2 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -116,11 +116,9 @@ static int ext4_file_open(struct inode * inode, struct file * filp) | |||
116 | * devices or filesystem images. | 116 | * devices or filesystem images. |
117 | */ | 117 | */ |
118 | memset(buf, 0, sizeof(buf)); | 118 | memset(buf, 0, sizeof(buf)); |
119 | path.mnt = mnt->mnt_parent; | 119 | path.mnt = mnt; |
120 | path.dentry = mnt->mnt_mountpoint; | 120 | path.dentry = mnt->mnt_root; |
121 | path_get(&path); | ||
122 | cp = d_path(&path, buf, sizeof(buf)); | 121 | cp = d_path(&path, buf, sizeof(buf)); |
123 | path_put(&path); | ||
124 | if (!IS_ERR(cp)) { | 122 | if (!IS_ERR(cp)) { |
125 | memcpy(sbi->s_es->s_last_mounted, cp, | 123 | memcpy(sbi->s_es->s_last_mounted, cp, |
126 | sizeof(sbi->s_es->s_last_mounted)); | 124 | sizeof(sbi->s_es->s_last_mounted)); |
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 84350e1be66d..4e64352d49de 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c | |||
@@ -976,122 +976,62 @@ out: | |||
976 | } | 976 | } |
977 | 977 | ||
978 | /** | 978 | /** |
979 | * gfs2_readlinki - return the contents of a symlink | 979 | * gfs2_follow_link - Follow a symbolic link |
980 | * @ip: the symlink's inode | 980 | * @dentry: The dentry of the link |
981 | * @buf: a pointer to the buffer to be filled | 981 | * @nd: Data that we pass to vfs_follow_link() |
982 | * @len: a pointer to the length of @buf | ||
983 | * | 982 | * |
984 | * If @buf is too small, a piece of memory is kmalloc()ed and needs | 983 | * This can handle symlinks of any size. |
985 | * to be freed by the caller. | ||
986 | * | 984 | * |
987 | * Returns: errno | 985 | * Returns: 0 on success or error code |
988 | */ | 986 | */ |
989 | 987 | ||
990 | static int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len) | 988 | static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) |
991 | { | 989 | { |
990 | struct gfs2_inode *ip = GFS2_I(dentry->d_inode); | ||
992 | struct gfs2_holder i_gh; | 991 | struct gfs2_holder i_gh; |
993 | struct buffer_head *dibh; | 992 | struct buffer_head *dibh; |
994 | unsigned int x; | 993 | unsigned int x; |
994 | char *buf; | ||
995 | int error; | 995 | int error; |
996 | 996 | ||
997 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh); | 997 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh); |
998 | error = gfs2_glock_nq(&i_gh); | 998 | error = gfs2_glock_nq(&i_gh); |
999 | if (error) { | 999 | if (error) { |
1000 | gfs2_holder_uninit(&i_gh); | 1000 | gfs2_holder_uninit(&i_gh); |
1001 | return error; | 1001 | nd_set_link(nd, ERR_PTR(error)); |
1002 | return NULL; | ||
1002 | } | 1003 | } |
1003 | 1004 | ||
1004 | if (!ip->i_disksize) { | 1005 | if (!ip->i_disksize) { |
1005 | gfs2_consist_inode(ip); | 1006 | gfs2_consist_inode(ip); |
1006 | error = -EIO; | 1007 | buf = ERR_PTR(-EIO); |
1007 | goto out; | 1008 | goto out; |
1008 | } | 1009 | } |
1009 | 1010 | ||
1010 | error = gfs2_meta_inode_buffer(ip, &dibh); | 1011 | error = gfs2_meta_inode_buffer(ip, &dibh); |
1011 | if (error) | 1012 | if (error) { |
1013 | buf = ERR_PTR(error); | ||
1012 | goto out; | 1014 | goto out; |
1013 | |||
1014 | x = ip->i_disksize + 1; | ||
1015 | if (x > *len) { | ||
1016 | *buf = kmalloc(x, GFP_NOFS); | ||
1017 | if (!*buf) { | ||
1018 | error = -ENOMEM; | ||
1019 | goto out_brelse; | ||
1020 | } | ||
1021 | } | 1015 | } |
1022 | 1016 | ||
1023 | memcpy(*buf, dibh->b_data + sizeof(struct gfs2_dinode), x); | 1017 | x = ip->i_disksize + 1; |
1024 | *len = x; | 1018 | buf = kmalloc(x, GFP_NOFS); |
1025 | 1019 | if (!buf) | |
1026 | out_brelse: | 1020 | buf = ERR_PTR(-ENOMEM); |
1021 | else | ||
1022 | memcpy(buf, dibh->b_data + sizeof(struct gfs2_dinode), x); | ||
1027 | brelse(dibh); | 1023 | brelse(dibh); |
1028 | out: | 1024 | out: |
1029 | gfs2_glock_dq_uninit(&i_gh); | 1025 | gfs2_glock_dq_uninit(&i_gh); |
1030 | return error; | 1026 | nd_set_link(nd, buf); |
1031 | } | 1027 | return NULL; |
1032 | |||
1033 | /** | ||
1034 | * gfs2_readlink - Read the value of a symlink | ||
1035 | * @dentry: the symlink | ||
1036 | * @buf: the buffer to read the symlink data into | ||
1037 | * @size: the size of the buffer | ||
1038 | * | ||
1039 | * Returns: errno | ||
1040 | */ | ||
1041 | |||
1042 | static int gfs2_readlink(struct dentry *dentry, char __user *user_buf, | ||
1043 | int user_size) | ||
1044 | { | ||
1045 | struct gfs2_inode *ip = GFS2_I(dentry->d_inode); | ||
1046 | char array[GFS2_FAST_NAME_SIZE], *buf = array; | ||
1047 | unsigned int len = GFS2_FAST_NAME_SIZE; | ||
1048 | int error; | ||
1049 | |||
1050 | error = gfs2_readlinki(ip, &buf, &len); | ||
1051 | if (error) | ||
1052 | return error; | ||
1053 | |||
1054 | if (user_size > len - 1) | ||
1055 | user_size = len - 1; | ||
1056 | |||
1057 | if (copy_to_user(user_buf, buf, user_size)) | ||
1058 | error = -EFAULT; | ||
1059 | else | ||
1060 | error = user_size; | ||
1061 | |||
1062 | if (buf != array) | ||
1063 | kfree(buf); | ||
1064 | |||
1065 | return error; | ||
1066 | } | 1028 | } |
1067 | 1029 | ||
1068 | /** | 1030 | static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p) |
1069 | * gfs2_follow_link - Follow a symbolic link | ||
1070 | * @dentry: The dentry of the link | ||
1071 | * @nd: Data that we pass to vfs_follow_link() | ||
1072 | * | ||
1073 | * This can handle symlinks of any size. It is optimised for symlinks | ||
1074 | * under GFS2_FAST_NAME_SIZE. | ||
1075 | * | ||
1076 | * Returns: 0 on success or error code | ||
1077 | */ | ||
1078 | |||
1079 | static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) | ||
1080 | { | 1031 | { |
1081 | struct gfs2_inode *ip = GFS2_I(dentry->d_inode); | 1032 | char *s = nd_get_link(nd); |
1082 | char array[GFS2_FAST_NAME_SIZE], *buf = array; | 1033 | if (!IS_ERR(s)) |
1083 | unsigned int len = GFS2_FAST_NAME_SIZE; | 1034 | kfree(s); |
1084 | int error; | ||
1085 | |||
1086 | error = gfs2_readlinki(ip, &buf, &len); | ||
1087 | if (!error) { | ||
1088 | error = vfs_follow_link(nd, buf); | ||
1089 | if (buf != array) | ||
1090 | kfree(buf); | ||
1091 | } else | ||
1092 | path_put(&nd->path); | ||
1093 | |||
1094 | return ERR_PTR(error); | ||
1095 | } | 1035 | } |
1096 | 1036 | ||
1097 | /** | 1037 | /** |
@@ -1426,8 +1366,9 @@ const struct inode_operations gfs2_dir_iops = { | |||
1426 | }; | 1366 | }; |
1427 | 1367 | ||
1428 | const struct inode_operations gfs2_symlink_iops = { | 1368 | const struct inode_operations gfs2_symlink_iops = { |
1429 | .readlink = gfs2_readlink, | 1369 | .readlink = generic_readlink, |
1430 | .follow_link = gfs2_follow_link, | 1370 | .follow_link = gfs2_follow_link, |
1371 | .put_link = gfs2_put_link, | ||
1431 | .permission = gfs2_permission, | 1372 | .permission = gfs2_permission, |
1432 | .setattr = gfs2_setattr, | 1373 | .setattr = gfs2_setattr, |
1433 | .getattr = gfs2_getattr, | 1374 | .getattr = gfs2_getattr, |
diff --git a/fs/hpfs/anode.c b/fs/hpfs/anode.c index 1aa88c4e0964..6a2f04bf3df0 100644 --- a/fs/hpfs/anode.c +++ b/fs/hpfs/anode.c | |||
@@ -353,7 +353,7 @@ int hpfs_ea_read(struct super_block *s, secno a, int ano, unsigned pos, | |||
353 | } | 353 | } |
354 | 354 | ||
355 | int hpfs_ea_write(struct super_block *s, secno a, int ano, unsigned pos, | 355 | int hpfs_ea_write(struct super_block *s, secno a, int ano, unsigned pos, |
356 | unsigned len, char *buf) | 356 | unsigned len, const char *buf) |
357 | { | 357 | { |
358 | struct buffer_head *bh; | 358 | struct buffer_head *bh; |
359 | char *data; | 359 | char *data; |
diff --git a/fs/hpfs/dentry.c b/fs/hpfs/dentry.c index 940d6d150bee..67d9d36b3d5f 100644 --- a/fs/hpfs/dentry.c +++ b/fs/hpfs/dentry.c | |||
@@ -20,8 +20,8 @@ static int hpfs_hash_dentry(struct dentry *dentry, struct qstr *qstr) | |||
20 | 20 | ||
21 | if (l == 1) if (qstr->name[0]=='.') goto x; | 21 | if (l == 1) if (qstr->name[0]=='.') goto x; |
22 | if (l == 2) if (qstr->name[0]=='.' || qstr->name[1]=='.') goto x; | 22 | if (l == 2) if (qstr->name[0]=='.' || qstr->name[1]=='.') goto x; |
23 | hpfs_adjust_length((char *)qstr->name, &l); | 23 | hpfs_adjust_length(qstr->name, &l); |
24 | /*if (hpfs_chk_name((char *)qstr->name,&l))*/ | 24 | /*if (hpfs_chk_name(qstr->name,&l))*/ |
25 | /*return -ENAMETOOLONG;*/ | 25 | /*return -ENAMETOOLONG;*/ |
26 | /*return -ENOENT;*/ | 26 | /*return -ENOENT;*/ |
27 | x: | 27 | x: |
@@ -38,14 +38,16 @@ static int hpfs_compare_dentry(struct dentry *dentry, struct qstr *a, struct qst | |||
38 | { | 38 | { |
39 | unsigned al=a->len; | 39 | unsigned al=a->len; |
40 | unsigned bl=b->len; | 40 | unsigned bl=b->len; |
41 | hpfs_adjust_length((char *)a->name, &al); | 41 | hpfs_adjust_length(a->name, &al); |
42 | /*hpfs_adjust_length((char *)b->name, &bl);*/ | 42 | /*hpfs_adjust_length(b->name, &bl);*/ |
43 | /* 'a' is the qstr of an already existing dentry, so the name | 43 | /* 'a' is the qstr of an already existing dentry, so the name |
44 | * must be valid. 'b' must be validated first. | 44 | * must be valid. 'b' must be validated first. |
45 | */ | 45 | */ |
46 | 46 | ||
47 | if (hpfs_chk_name((char *)b->name, &bl)) return 1; | 47 | if (hpfs_chk_name(b->name, &bl)) |
48 | if (hpfs_compare_names(dentry->d_sb, (char *)a->name, al, (char *)b->name, bl, 0)) return 1; | 48 | return 1; |
49 | if (hpfs_compare_names(dentry->d_sb, a->name, al, b->name, bl, 0)) | ||
50 | return 1; | ||
49 | return 0; | 51 | return 0; |
50 | } | 52 | } |
51 | 53 | ||
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c index 8865c94f55f6..26e3964a4b8c 100644 --- a/fs/hpfs/dir.c +++ b/fs/hpfs/dir.c | |||
@@ -59,7 +59,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
59 | struct hpfs_dirent *de; | 59 | struct hpfs_dirent *de; |
60 | int lc; | 60 | int lc; |
61 | long old_pos; | 61 | long old_pos; |
62 | char *tempname; | 62 | unsigned char *tempname; |
63 | int c1, c2 = 0; | 63 | int c1, c2 = 0; |
64 | int ret = 0; | 64 | int ret = 0; |
65 | 65 | ||
@@ -158,11 +158,11 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
158 | tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3); | 158 | tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3); |
159 | if (filldir(dirent, tempname, de->namelen, old_pos, de->fnode, DT_UNKNOWN) < 0) { | 159 | if (filldir(dirent, tempname, de->namelen, old_pos, de->fnode, DT_UNKNOWN) < 0) { |
160 | filp->f_pos = old_pos; | 160 | filp->f_pos = old_pos; |
161 | if (tempname != (char *)de->name) kfree(tempname); | 161 | if (tempname != de->name) kfree(tempname); |
162 | hpfs_brelse4(&qbh); | 162 | hpfs_brelse4(&qbh); |
163 | goto out; | 163 | goto out; |
164 | } | 164 | } |
165 | if (tempname != (char *)de->name) kfree(tempname); | 165 | if (tempname != de->name) kfree(tempname); |
166 | hpfs_brelse4(&qbh); | 166 | hpfs_brelse4(&qbh); |
167 | } | 167 | } |
168 | out: | 168 | out: |
@@ -187,7 +187,7 @@ out: | |||
187 | 187 | ||
188 | struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | 188 | struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) |
189 | { | 189 | { |
190 | const char *name = dentry->d_name.name; | 190 | const unsigned char *name = dentry->d_name.name; |
191 | unsigned len = dentry->d_name.len; | 191 | unsigned len = dentry->d_name.len; |
192 | struct quad_buffer_head qbh; | 192 | struct quad_buffer_head qbh; |
193 | struct hpfs_dirent *de; | 193 | struct hpfs_dirent *de; |
@@ -197,7 +197,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name | |||
197 | struct hpfs_inode_info *hpfs_result; | 197 | struct hpfs_inode_info *hpfs_result; |
198 | 198 | ||
199 | lock_kernel(); | 199 | lock_kernel(); |
200 | if ((err = hpfs_chk_name((char *)name, &len))) { | 200 | if ((err = hpfs_chk_name(name, &len))) { |
201 | if (err == -ENAMETOOLONG) { | 201 | if (err == -ENAMETOOLONG) { |
202 | unlock_kernel(); | 202 | unlock_kernel(); |
203 | return ERR_PTR(-ENAMETOOLONG); | 203 | return ERR_PTR(-ENAMETOOLONG); |
@@ -209,7 +209,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name | |||
209 | * '.' and '..' will never be passed here. | 209 | * '.' and '..' will never be passed here. |
210 | */ | 210 | */ |
211 | 211 | ||
212 | de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *) name, len, NULL, &qbh); | 212 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, NULL, &qbh); |
213 | 213 | ||
214 | /* | 214 | /* |
215 | * This is not really a bailout, just means file not found. | 215 | * This is not really a bailout, just means file not found. |
@@ -250,7 +250,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name | |||
250 | hpfs_result = hpfs_i(result); | 250 | hpfs_result = hpfs_i(result); |
251 | if (!de->directory) hpfs_result->i_parent_dir = dir->i_ino; | 251 | if (!de->directory) hpfs_result->i_parent_dir = dir->i_ino; |
252 | 252 | ||
253 | hpfs_decide_conv(result, (char *)name, len); | 253 | hpfs_decide_conv(result, name, len); |
254 | 254 | ||
255 | if (de->has_acl || de->has_xtd_perm) if (!(dir->i_sb->s_flags & MS_RDONLY)) { | 255 | if (de->has_acl || de->has_xtd_perm) if (!(dir->i_sb->s_flags & MS_RDONLY)) { |
256 | hpfs_error(result->i_sb, "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures"); | 256 | hpfs_error(result->i_sb, "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures"); |
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c index fe83c2b7d2d8..9b2ffadfc8c4 100644 --- a/fs/hpfs/dnode.c +++ b/fs/hpfs/dnode.c | |||
@@ -158,7 +158,8 @@ static void set_last_pointer(struct super_block *s, struct dnode *d, dnode_secno | |||
158 | 158 | ||
159 | /* Add an entry to dnode and don't care if it grows over 2048 bytes */ | 159 | /* Add an entry to dnode and don't care if it grows over 2048 bytes */ |
160 | 160 | ||
161 | struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d, unsigned char *name, | 161 | struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d, |
162 | const unsigned char *name, | ||
162 | unsigned namelen, secno down_ptr) | 163 | unsigned namelen, secno down_ptr) |
163 | { | 164 | { |
164 | struct hpfs_dirent *de; | 165 | struct hpfs_dirent *de; |
@@ -223,7 +224,7 @@ static void fix_up_ptrs(struct super_block *s, struct dnode *d) | |||
223 | /* Add an entry to dnode and do dnode splitting if required */ | 224 | /* Add an entry to dnode and do dnode splitting if required */ |
224 | 225 | ||
225 | static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | 226 | static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, |
226 | unsigned char *name, unsigned namelen, | 227 | const unsigned char *name, unsigned namelen, |
227 | struct hpfs_dirent *new_de, dnode_secno down_ptr) | 228 | struct hpfs_dirent *new_de, dnode_secno down_ptr) |
228 | { | 229 | { |
229 | struct quad_buffer_head qbh, qbh1, qbh2; | 230 | struct quad_buffer_head qbh, qbh1, qbh2; |
@@ -231,7 +232,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
231 | dnode_secno adno, rdno; | 232 | dnode_secno adno, rdno; |
232 | struct hpfs_dirent *de; | 233 | struct hpfs_dirent *de; |
233 | struct hpfs_dirent nde; | 234 | struct hpfs_dirent nde; |
234 | char *nname; | 235 | unsigned char *nname; |
235 | int h; | 236 | int h; |
236 | int pos; | 237 | int pos; |
237 | struct buffer_head *bh; | 238 | struct buffer_head *bh; |
@@ -305,7 +306,9 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
305 | pos++; | 306 | pos++; |
306 | } | 307 | } |
307 | copy_de(new_de = &nde, de); | 308 | copy_de(new_de = &nde, de); |
308 | memcpy(name = nname, de->name, namelen = de->namelen); | 309 | memcpy(nname, de->name, de->namelen); |
310 | name = nname; | ||
311 | namelen = de->namelen; | ||
309 | for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | pos, 4); | 312 | for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | pos, 4); |
310 | down_ptr = adno; | 313 | down_ptr = adno; |
311 | set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); | 314 | set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); |
@@ -368,7 +371,8 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
368 | * I hope, now it's finally bug-free. | 371 | * I hope, now it's finally bug-free. |
369 | */ | 372 | */ |
370 | 373 | ||
371 | int hpfs_add_dirent(struct inode *i, unsigned char *name, unsigned namelen, | 374 | int hpfs_add_dirent(struct inode *i, |
375 | const unsigned char *name, unsigned namelen, | ||
372 | struct hpfs_dirent *new_de, int cdepth) | 376 | struct hpfs_dirent *new_de, int cdepth) |
373 | { | 377 | { |
374 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); | 378 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); |
@@ -897,7 +901,8 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp, | |||
897 | 901 | ||
898 | /* Find a dirent in tree */ | 902 | /* Find a dirent in tree */ |
899 | 903 | ||
900 | struct hpfs_dirent *map_dirent(struct inode *inode, dnode_secno dno, char *name, unsigned len, | 904 | struct hpfs_dirent *map_dirent(struct inode *inode, dnode_secno dno, |
905 | const unsigned char *name, unsigned len, | ||
901 | dnode_secno *dd, struct quad_buffer_head *qbh) | 906 | dnode_secno *dd, struct quad_buffer_head *qbh) |
902 | { | 907 | { |
903 | struct dnode *dnode; | 908 | struct dnode *dnode; |
@@ -988,8 +993,8 @@ void hpfs_remove_dtree(struct super_block *s, dnode_secno dno) | |||
988 | struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, | 993 | struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, |
989 | struct fnode *f, struct quad_buffer_head *qbh) | 994 | struct fnode *f, struct quad_buffer_head *qbh) |
990 | { | 995 | { |
991 | char *name1; | 996 | unsigned char *name1; |
992 | char *name2; | 997 | unsigned char *name2; |
993 | int name1len, name2len; | 998 | int name1len, name2len; |
994 | struct dnode *d; | 999 | struct dnode *d; |
995 | dnode_secno dno, downd; | 1000 | dnode_secno dno, downd; |
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c index 547a8384571f..45e53d972b42 100644 --- a/fs/hpfs/ea.c +++ b/fs/hpfs/ea.c | |||
@@ -62,8 +62,8 @@ static char *get_indirect_ea(struct super_block *s, int ano, secno a, int size) | |||
62 | return ret; | 62 | return ret; |
63 | } | 63 | } |
64 | 64 | ||
65 | static void set_indirect_ea(struct super_block *s, int ano, secno a, char *data, | 65 | static void set_indirect_ea(struct super_block *s, int ano, secno a, |
66 | int size) | 66 | const char *data, int size) |
67 | { | 67 | { |
68 | hpfs_ea_write(s, a, ano, 0, size, data); | 68 | hpfs_ea_write(s, a, ano, 0, size, data); |
69 | } | 69 | } |
@@ -186,7 +186,8 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si | |||
186 | * This driver can't change sizes of eas ('cause I just don't need it). | 186 | * This driver can't change sizes of eas ('cause I just don't need it). |
187 | */ | 187 | */ |
188 | 188 | ||
189 | void hpfs_set_ea(struct inode *inode, struct fnode *fnode, char *key, char *data, int size) | 189 | void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, |
190 | const char *data, int size) | ||
190 | { | 191 | { |
191 | fnode_secno fno = inode->i_ino; | 192 | fnode_secno fno = inode->i_ino; |
192 | struct super_block *s = inode->i_sb; | 193 | struct super_block *s = inode->i_sb; |
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h index 701ca54c0867..97bf738cd5d6 100644 --- a/fs/hpfs/hpfs_fn.h +++ b/fs/hpfs/hpfs_fn.h | |||
@@ -215,7 +215,7 @@ secno hpfs_bplus_lookup(struct super_block *, struct inode *, struct bplus_heade | |||
215 | secno hpfs_add_sector_to_btree(struct super_block *, secno, int, unsigned); | 215 | secno hpfs_add_sector_to_btree(struct super_block *, secno, int, unsigned); |
216 | void hpfs_remove_btree(struct super_block *, struct bplus_header *); | 216 | void hpfs_remove_btree(struct super_block *, struct bplus_header *); |
217 | int hpfs_ea_read(struct super_block *, secno, int, unsigned, unsigned, char *); | 217 | int hpfs_ea_read(struct super_block *, secno, int, unsigned, unsigned, char *); |
218 | int hpfs_ea_write(struct super_block *, secno, int, unsigned, unsigned, char *); | 218 | int hpfs_ea_write(struct super_block *, secno, int, unsigned, unsigned, const char *); |
219 | void hpfs_ea_remove(struct super_block *, secno, int, unsigned); | 219 | void hpfs_ea_remove(struct super_block *, secno, int, unsigned); |
220 | void hpfs_truncate_btree(struct super_block *, secno, int, unsigned); | 220 | void hpfs_truncate_btree(struct super_block *, secno, int, unsigned); |
221 | void hpfs_remove_fnode(struct super_block *, fnode_secno fno); | 221 | void hpfs_remove_fnode(struct super_block *, fnode_secno fno); |
@@ -244,13 +244,17 @@ extern const struct file_operations hpfs_dir_ops; | |||
244 | 244 | ||
245 | void hpfs_add_pos(struct inode *, loff_t *); | 245 | void hpfs_add_pos(struct inode *, loff_t *); |
246 | void hpfs_del_pos(struct inode *, loff_t *); | 246 | void hpfs_del_pos(struct inode *, loff_t *); |
247 | struct hpfs_dirent *hpfs_add_de(struct super_block *, struct dnode *, unsigned char *, unsigned, secno); | 247 | struct hpfs_dirent *hpfs_add_de(struct super_block *, struct dnode *, |
248 | int hpfs_add_dirent(struct inode *, unsigned char *, unsigned, struct hpfs_dirent *, int); | 248 | const unsigned char *, unsigned, secno); |
249 | int hpfs_add_dirent(struct inode *, const unsigned char *, unsigned, | ||
250 | struct hpfs_dirent *, int); | ||
249 | int hpfs_remove_dirent(struct inode *, dnode_secno, struct hpfs_dirent *, struct quad_buffer_head *, int); | 251 | int hpfs_remove_dirent(struct inode *, dnode_secno, struct hpfs_dirent *, struct quad_buffer_head *, int); |
250 | void hpfs_count_dnodes(struct super_block *, dnode_secno, int *, int *, int *); | 252 | void hpfs_count_dnodes(struct super_block *, dnode_secno, int *, int *, int *); |
251 | dnode_secno hpfs_de_as_down_as_possible(struct super_block *, dnode_secno dno); | 253 | dnode_secno hpfs_de_as_down_as_possible(struct super_block *, dnode_secno dno); |
252 | struct hpfs_dirent *map_pos_dirent(struct inode *, loff_t *, struct quad_buffer_head *); | 254 | struct hpfs_dirent *map_pos_dirent(struct inode *, loff_t *, struct quad_buffer_head *); |
253 | struct hpfs_dirent *map_dirent(struct inode *, dnode_secno, char *, unsigned, dnode_secno *, struct quad_buffer_head *); | 255 | struct hpfs_dirent *map_dirent(struct inode *, dnode_secno, |
256 | const unsigned char *, unsigned, dnode_secno *, | ||
257 | struct quad_buffer_head *); | ||
254 | void hpfs_remove_dtree(struct super_block *, dnode_secno); | 258 | void hpfs_remove_dtree(struct super_block *, dnode_secno); |
255 | struct hpfs_dirent *map_fnode_dirent(struct super_block *, fnode_secno, struct fnode *, struct quad_buffer_head *); | 259 | struct hpfs_dirent *map_fnode_dirent(struct super_block *, fnode_secno, struct fnode *, struct quad_buffer_head *); |
256 | 260 | ||
@@ -259,7 +263,8 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *, fnode_secno, struct f | |||
259 | void hpfs_ea_ext_remove(struct super_block *, secno, int, unsigned); | 263 | void hpfs_ea_ext_remove(struct super_block *, secno, int, unsigned); |
260 | int hpfs_read_ea(struct super_block *, struct fnode *, char *, char *, int); | 264 | int hpfs_read_ea(struct super_block *, struct fnode *, char *, char *, int); |
261 | char *hpfs_get_ea(struct super_block *, struct fnode *, char *, int *); | 265 | char *hpfs_get_ea(struct super_block *, struct fnode *, char *, int *); |
262 | void hpfs_set_ea(struct inode *, struct fnode *, char *, char *, int); | 266 | void hpfs_set_ea(struct inode *, struct fnode *, const char *, |
267 | const char *, int); | ||
263 | 268 | ||
264 | /* file.c */ | 269 | /* file.c */ |
265 | 270 | ||
@@ -282,7 +287,7 @@ void hpfs_delete_inode(struct inode *); | |||
282 | 287 | ||
283 | unsigned *hpfs_map_dnode_bitmap(struct super_block *, struct quad_buffer_head *); | 288 | unsigned *hpfs_map_dnode_bitmap(struct super_block *, struct quad_buffer_head *); |
284 | unsigned *hpfs_map_bitmap(struct super_block *, unsigned, struct quad_buffer_head *, char *); | 289 | unsigned *hpfs_map_bitmap(struct super_block *, unsigned, struct quad_buffer_head *, char *); |
285 | char *hpfs_load_code_page(struct super_block *, secno); | 290 | unsigned char *hpfs_load_code_page(struct super_block *, secno); |
286 | secno *hpfs_load_bitmap_directory(struct super_block *, secno bmp); | 291 | secno *hpfs_load_bitmap_directory(struct super_block *, secno bmp); |
287 | struct fnode *hpfs_map_fnode(struct super_block *s, ino_t, struct buffer_head **); | 292 | struct fnode *hpfs_map_fnode(struct super_block *s, ino_t, struct buffer_head **); |
288 | struct anode *hpfs_map_anode(struct super_block *s, anode_secno, struct buffer_head **); | 293 | struct anode *hpfs_map_anode(struct super_block *s, anode_secno, struct buffer_head **); |
@@ -292,12 +297,13 @@ dnode_secno hpfs_fnode_dno(struct super_block *s, ino_t ino); | |||
292 | /* name.c */ | 297 | /* name.c */ |
293 | 298 | ||
294 | unsigned char hpfs_upcase(unsigned char *, unsigned char); | 299 | unsigned char hpfs_upcase(unsigned char *, unsigned char); |
295 | int hpfs_chk_name(unsigned char *, unsigned *); | 300 | int hpfs_chk_name(const unsigned char *, unsigned *); |
296 | char *hpfs_translate_name(struct super_block *, unsigned char *, unsigned, int, int); | 301 | unsigned char *hpfs_translate_name(struct super_block *, unsigned char *, unsigned, int, int); |
297 | int hpfs_compare_names(struct super_block *, unsigned char *, unsigned, unsigned char *, unsigned, int); | 302 | int hpfs_compare_names(struct super_block *, const unsigned char *, unsigned, |
298 | int hpfs_is_name_long(unsigned char *, unsigned); | 303 | const unsigned char *, unsigned, int); |
299 | void hpfs_adjust_length(unsigned char *, unsigned *); | 304 | int hpfs_is_name_long(const unsigned char *, unsigned); |
300 | void hpfs_decide_conv(struct inode *, unsigned char *, unsigned); | 305 | void hpfs_adjust_length(const unsigned char *, unsigned *); |
306 | void hpfs_decide_conv(struct inode *, const unsigned char *, unsigned); | ||
301 | 307 | ||
302 | /* namei.c */ | 308 | /* namei.c */ |
303 | 309 | ||
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c index fe703ae46bc7..ff90affb94e1 100644 --- a/fs/hpfs/inode.c +++ b/fs/hpfs/inode.c | |||
@@ -46,7 +46,7 @@ void hpfs_read_inode(struct inode *i) | |||
46 | struct fnode *fnode; | 46 | struct fnode *fnode; |
47 | struct super_block *sb = i->i_sb; | 47 | struct super_block *sb = i->i_sb; |
48 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); | 48 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); |
49 | unsigned char *ea; | 49 | void *ea; |
50 | int ea_size; | 50 | int ea_size; |
51 | 51 | ||
52 | if (!(fnode = hpfs_map_fnode(sb, i->i_ino, &bh))) { | 52 | if (!(fnode = hpfs_map_fnode(sb, i->i_ino, &bh))) { |
@@ -112,7 +112,7 @@ void hpfs_read_inode(struct inode *i) | |||
112 | } | 112 | } |
113 | } | 113 | } |
114 | if (fnode->dirflag) { | 114 | if (fnode->dirflag) { |
115 | unsigned n_dnodes, n_subdirs; | 115 | int n_dnodes, n_subdirs; |
116 | i->i_mode |= S_IFDIR; | 116 | i->i_mode |= S_IFDIR; |
117 | i->i_op = &hpfs_dir_iops; | 117 | i->i_op = &hpfs_dir_iops; |
118 | i->i_fop = &hpfs_dir_ops; | 118 | i->i_fop = &hpfs_dir_ops; |
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c index c4724589b2eb..840d033ecee8 100644 --- a/fs/hpfs/map.c +++ b/fs/hpfs/map.c | |||
@@ -35,7 +35,7 @@ unsigned int *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block, | |||
35 | * lowercasing table | 35 | * lowercasing table |
36 | */ | 36 | */ |
37 | 37 | ||
38 | char *hpfs_load_code_page(struct super_block *s, secno cps) | 38 | unsigned char *hpfs_load_code_page(struct super_block *s, secno cps) |
39 | { | 39 | { |
40 | struct buffer_head *bh; | 40 | struct buffer_head *bh; |
41 | secno cpds; | 41 | secno cpds; |
@@ -71,7 +71,7 @@ char *hpfs_load_code_page(struct super_block *s, secno cps) | |||
71 | brelse(bh); | 71 | brelse(bh); |
72 | return NULL; | 72 | return NULL; |
73 | } | 73 | } |
74 | ptr = (char *)cpd + cpd->offs[cpi] + 6; | 74 | ptr = (unsigned char *)cpd + cpd->offs[cpi] + 6; |
75 | if (!(cp_table = kmalloc(256, GFP_KERNEL))) { | 75 | if (!(cp_table = kmalloc(256, GFP_KERNEL))) { |
76 | printk("HPFS: out of memory for code page table\n"); | 76 | printk("HPFS: out of memory for code page table\n"); |
77 | brelse(bh); | 77 | brelse(bh); |
@@ -217,7 +217,7 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno, | |||
217 | if ((dnode = hpfs_map_4sectors(s, secno, qbh, DNODE_RD_AHEAD))) | 217 | if ((dnode = hpfs_map_4sectors(s, secno, qbh, DNODE_RD_AHEAD))) |
218 | if (hpfs_sb(s)->sb_chk) { | 218 | if (hpfs_sb(s)->sb_chk) { |
219 | unsigned p, pp = 0; | 219 | unsigned p, pp = 0; |
220 | unsigned char *d = (char *)dnode; | 220 | unsigned char *d = (unsigned char *)dnode; |
221 | int b = 0; | 221 | int b = 0; |
222 | if (dnode->magic != DNODE_MAGIC) { | 222 | if (dnode->magic != DNODE_MAGIC) { |
223 | hpfs_error(s, "bad magic on dnode %08x", secno); | 223 | hpfs_error(s, "bad magic on dnode %08x", secno); |
diff --git a/fs/hpfs/name.c b/fs/hpfs/name.c index 1f4a964384eb..f24736d7a439 100644 --- a/fs/hpfs/name.c +++ b/fs/hpfs/name.c | |||
@@ -8,16 +8,16 @@ | |||
8 | 8 | ||
9 | #include "hpfs_fn.h" | 9 | #include "hpfs_fn.h" |
10 | 10 | ||
11 | static char *text_postfix[]={ | 11 | static const char *text_postfix[]={ |
12 | ".ASM", ".BAS", ".BAT", ".C", ".CC", ".CFG", ".CMD", ".CON", ".CPP", ".DEF", | 12 | ".ASM", ".BAS", ".BAT", ".C", ".CC", ".CFG", ".CMD", ".CON", ".CPP", ".DEF", |
13 | ".DOC", ".DPR", ".ERX", ".H", ".HPP", ".HTM", ".HTML", ".JAVA", ".LOG", ".PAS", | 13 | ".DOC", ".DPR", ".ERX", ".H", ".HPP", ".HTM", ".HTML", ".JAVA", ".LOG", ".PAS", |
14 | ".RC", ".TEX", ".TXT", ".Y", ""}; | 14 | ".RC", ".TEX", ".TXT", ".Y", ""}; |
15 | 15 | ||
16 | static char *text_prefix[]={ | 16 | static const char *text_prefix[]={ |
17 | "AUTOEXEC.", "CHANGES", "COPYING", "CONFIG.", "CREDITS", "FAQ", "FILE_ID.DIZ", | 17 | "AUTOEXEC.", "CHANGES", "COPYING", "CONFIG.", "CREDITS", "FAQ", "FILE_ID.DIZ", |
18 | "MAKEFILE", "READ.ME", "README", "TERMCAP", ""}; | 18 | "MAKEFILE", "READ.ME", "README", "TERMCAP", ""}; |
19 | 19 | ||
20 | void hpfs_decide_conv(struct inode *inode, unsigned char *name, unsigned len) | 20 | void hpfs_decide_conv(struct inode *inode, const unsigned char *name, unsigned len) |
21 | { | 21 | { |
22 | struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); | 22 | struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); |
23 | int i; | 23 | int i; |
@@ -71,7 +71,7 @@ static inline unsigned char locase(unsigned char *dir, unsigned char a) | |||
71 | return dir[a]; | 71 | return dir[a]; |
72 | } | 72 | } |
73 | 73 | ||
74 | int hpfs_chk_name(unsigned char *name, unsigned *len) | 74 | int hpfs_chk_name(const unsigned char *name, unsigned *len) |
75 | { | 75 | { |
76 | int i; | 76 | int i; |
77 | if (*len > 254) return -ENAMETOOLONG; | 77 | if (*len > 254) return -ENAMETOOLONG; |
@@ -83,10 +83,10 @@ int hpfs_chk_name(unsigned char *name, unsigned *len) | |||
83 | return 0; | 83 | return 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | char *hpfs_translate_name(struct super_block *s, unsigned char *from, | 86 | unsigned char *hpfs_translate_name(struct super_block *s, unsigned char *from, |
87 | unsigned len, int lc, int lng) | 87 | unsigned len, int lc, int lng) |
88 | { | 88 | { |
89 | char *to; | 89 | unsigned char *to; |
90 | int i; | 90 | int i; |
91 | if (hpfs_sb(s)->sb_chk >= 2) if (hpfs_is_name_long(from, len) != lng) { | 91 | if (hpfs_sb(s)->sb_chk >= 2) if (hpfs_is_name_long(from, len) != lng) { |
92 | printk("HPFS: Long name flag mismatch - name "); | 92 | printk("HPFS: Long name flag mismatch - name "); |
@@ -103,8 +103,9 @@ char *hpfs_translate_name(struct super_block *s, unsigned char *from, | |||
103 | return to; | 103 | return to; |
104 | } | 104 | } |
105 | 105 | ||
106 | int hpfs_compare_names(struct super_block *s, unsigned char *n1, unsigned l1, | 106 | int hpfs_compare_names(struct super_block *s, |
107 | unsigned char *n2, unsigned l2, int last) | 107 | const unsigned char *n1, unsigned l1, |
108 | const unsigned char *n2, unsigned l2, int last) | ||
108 | { | 109 | { |
109 | unsigned l = l1 < l2 ? l1 : l2; | 110 | unsigned l = l1 < l2 ? l1 : l2; |
110 | unsigned i; | 111 | unsigned i; |
@@ -120,7 +121,7 @@ int hpfs_compare_names(struct super_block *s, unsigned char *n1, unsigned l1, | |||
120 | return 0; | 121 | return 0; |
121 | } | 122 | } |
122 | 123 | ||
123 | int hpfs_is_name_long(unsigned char *name, unsigned len) | 124 | int hpfs_is_name_long(const unsigned char *name, unsigned len) |
124 | { | 125 | { |
125 | int i,j; | 126 | int i,j; |
126 | for (i = 0; i < len && name[i] != '.'; i++) | 127 | for (i = 0; i < len && name[i] != '.'; i++) |
@@ -134,7 +135,7 @@ int hpfs_is_name_long(unsigned char *name, unsigned len) | |||
134 | 135 | ||
135 | /* OS/2 clears dots and spaces at the end of file name, so we have to */ | 136 | /* OS/2 clears dots and spaces at the end of file name, so we have to */ |
136 | 137 | ||
137 | void hpfs_adjust_length(unsigned char *name, unsigned *len) | 138 | void hpfs_adjust_length(const unsigned char *name, unsigned *len) |
138 | { | 139 | { |
139 | if (!*len) return; | 140 | if (!*len) return; |
140 | if (*len == 1 && name[0] == '.') return; | 141 | if (*len == 1 && name[0] == '.') return; |
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c index 82b9c4ba9ed0..11c2b4080f65 100644 --- a/fs/hpfs/namei.c +++ b/fs/hpfs/namei.c | |||
@@ -11,7 +11,7 @@ | |||
11 | 11 | ||
12 | static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | 12 | static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
13 | { | 13 | { |
14 | const char *name = dentry->d_name.name; | 14 | const unsigned char *name = dentry->d_name.name; |
15 | unsigned len = dentry->d_name.len; | 15 | unsigned len = dentry->d_name.len; |
16 | struct quad_buffer_head qbh0; | 16 | struct quad_buffer_head qbh0; |
17 | struct buffer_head *bh; | 17 | struct buffer_head *bh; |
@@ -24,7 +24,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
24 | int r; | 24 | int r; |
25 | struct hpfs_dirent dee; | 25 | struct hpfs_dirent dee; |
26 | int err; | 26 | int err; |
27 | if ((err = hpfs_chk_name((char *)name, &len))) return err==-ENOENT ? -EINVAL : err; | 27 | if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err; |
28 | lock_kernel(); | 28 | lock_kernel(); |
29 | err = -ENOSPC; | 29 | err = -ENOSPC; |
30 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); | 30 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); |
@@ -62,7 +62,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
62 | result->i_mode &= ~0222; | 62 | result->i_mode &= ~0222; |
63 | 63 | ||
64 | mutex_lock(&hpfs_i(dir)->i_mutex); | 64 | mutex_lock(&hpfs_i(dir)->i_mutex); |
65 | r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); | 65 | r = hpfs_add_dirent(dir, name, len, &dee, 0); |
66 | if (r == 1) | 66 | if (r == 1) |
67 | goto bail3; | 67 | goto bail3; |
68 | if (r == -1) { | 68 | if (r == -1) { |
@@ -121,7 +121,7 @@ bail: | |||
121 | 121 | ||
122 | static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) | 122 | static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) |
123 | { | 123 | { |
124 | const char *name = dentry->d_name.name; | 124 | const unsigned char *name = dentry->d_name.name; |
125 | unsigned len = dentry->d_name.len; | 125 | unsigned len = dentry->d_name.len; |
126 | struct inode *result = NULL; | 126 | struct inode *result = NULL; |
127 | struct buffer_head *bh; | 127 | struct buffer_head *bh; |
@@ -130,7 +130,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
130 | int r; | 130 | int r; |
131 | struct hpfs_dirent dee; | 131 | struct hpfs_dirent dee; |
132 | int err; | 132 | int err; |
133 | if ((err = hpfs_chk_name((char *)name, &len))) | 133 | if ((err = hpfs_chk_name(name, &len))) |
134 | return err==-ENOENT ? -EINVAL : err; | 134 | return err==-ENOENT ? -EINVAL : err; |
135 | lock_kernel(); | 135 | lock_kernel(); |
136 | err = -ENOSPC; | 136 | err = -ENOSPC; |
@@ -155,7 +155,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
155 | result->i_op = &hpfs_file_iops; | 155 | result->i_op = &hpfs_file_iops; |
156 | result->i_fop = &hpfs_file_ops; | 156 | result->i_fop = &hpfs_file_ops; |
157 | result->i_nlink = 1; | 157 | result->i_nlink = 1; |
158 | hpfs_decide_conv(result, (char *)name, len); | 158 | hpfs_decide_conv(result, name, len); |
159 | hpfs_i(result)->i_parent_dir = dir->i_ino; | 159 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
160 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); | 160 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); |
161 | result->i_ctime.tv_nsec = 0; | 161 | result->i_ctime.tv_nsec = 0; |
@@ -170,7 +170,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
170 | hpfs_i(result)->mmu_private = 0; | 170 | hpfs_i(result)->mmu_private = 0; |
171 | 171 | ||
172 | mutex_lock(&hpfs_i(dir)->i_mutex); | 172 | mutex_lock(&hpfs_i(dir)->i_mutex); |
173 | r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); | 173 | r = hpfs_add_dirent(dir, name, len, &dee, 0); |
174 | if (r == 1) | 174 | if (r == 1) |
175 | goto bail2; | 175 | goto bail2; |
176 | if (r == -1) { | 176 | if (r == -1) { |
@@ -211,7 +211,7 @@ bail: | |||
211 | 211 | ||
212 | static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) | 212 | static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) |
213 | { | 213 | { |
214 | const char *name = dentry->d_name.name; | 214 | const unsigned char *name = dentry->d_name.name; |
215 | unsigned len = dentry->d_name.len; | 215 | unsigned len = dentry->d_name.len; |
216 | struct buffer_head *bh; | 216 | struct buffer_head *bh; |
217 | struct fnode *fnode; | 217 | struct fnode *fnode; |
@@ -220,7 +220,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
220 | struct hpfs_dirent dee; | 220 | struct hpfs_dirent dee; |
221 | struct inode *result = NULL; | 221 | struct inode *result = NULL; |
222 | int err; | 222 | int err; |
223 | if ((err = hpfs_chk_name((char *)name, &len))) return err==-ENOENT ? -EINVAL : err; | 223 | if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err; |
224 | if (hpfs_sb(dir->i_sb)->sb_eas < 2) return -EPERM; | 224 | if (hpfs_sb(dir->i_sb)->sb_eas < 2) return -EPERM; |
225 | if (!new_valid_dev(rdev)) | 225 | if (!new_valid_dev(rdev)) |
226 | return -EINVAL; | 226 | return -EINVAL; |
@@ -256,7 +256,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
256 | init_special_inode(result, mode, rdev); | 256 | init_special_inode(result, mode, rdev); |
257 | 257 | ||
258 | mutex_lock(&hpfs_i(dir)->i_mutex); | 258 | mutex_lock(&hpfs_i(dir)->i_mutex); |
259 | r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); | 259 | r = hpfs_add_dirent(dir, name, len, &dee, 0); |
260 | if (r == 1) | 260 | if (r == 1) |
261 | goto bail2; | 261 | goto bail2; |
262 | if (r == -1) { | 262 | if (r == -1) { |
@@ -289,7 +289,7 @@ bail: | |||
289 | 289 | ||
290 | static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *symlink) | 290 | static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *symlink) |
291 | { | 291 | { |
292 | const char *name = dentry->d_name.name; | 292 | const unsigned char *name = dentry->d_name.name; |
293 | unsigned len = dentry->d_name.len; | 293 | unsigned len = dentry->d_name.len; |
294 | struct buffer_head *bh; | 294 | struct buffer_head *bh; |
295 | struct fnode *fnode; | 295 | struct fnode *fnode; |
@@ -298,7 +298,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
298 | struct hpfs_dirent dee; | 298 | struct hpfs_dirent dee; |
299 | struct inode *result; | 299 | struct inode *result; |
300 | int err; | 300 | int err; |
301 | if ((err = hpfs_chk_name((char *)name, &len))) return err==-ENOENT ? -EINVAL : err; | 301 | if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err; |
302 | lock_kernel(); | 302 | lock_kernel(); |
303 | if (hpfs_sb(dir->i_sb)->sb_eas < 2) { | 303 | if (hpfs_sb(dir->i_sb)->sb_eas < 2) { |
304 | unlock_kernel(); | 304 | unlock_kernel(); |
@@ -335,7 +335,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
335 | result->i_data.a_ops = &hpfs_symlink_aops; | 335 | result->i_data.a_ops = &hpfs_symlink_aops; |
336 | 336 | ||
337 | mutex_lock(&hpfs_i(dir)->i_mutex); | 337 | mutex_lock(&hpfs_i(dir)->i_mutex); |
338 | r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); | 338 | r = hpfs_add_dirent(dir, name, len, &dee, 0); |
339 | if (r == 1) | 339 | if (r == 1) |
340 | goto bail2; | 340 | goto bail2; |
341 | if (r == -1) { | 341 | if (r == -1) { |
@@ -345,7 +345,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
345 | fnode->len = len; | 345 | fnode->len = len; |
346 | memcpy(fnode->name, name, len > 15 ? 15 : len); | 346 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
347 | fnode->up = dir->i_ino; | 347 | fnode->up = dir->i_ino; |
348 | hpfs_set_ea(result, fnode, "SYMLINK", (char *)symlink, strlen(symlink)); | 348 | hpfs_set_ea(result, fnode, "SYMLINK", symlink, strlen(symlink)); |
349 | mark_buffer_dirty(bh); | 349 | mark_buffer_dirty(bh); |
350 | brelse(bh); | 350 | brelse(bh); |
351 | 351 | ||
@@ -369,7 +369,7 @@ bail: | |||
369 | 369 | ||
370 | static int hpfs_unlink(struct inode *dir, struct dentry *dentry) | 370 | static int hpfs_unlink(struct inode *dir, struct dentry *dentry) |
371 | { | 371 | { |
372 | const char *name = dentry->d_name.name; | 372 | const unsigned char *name = dentry->d_name.name; |
373 | unsigned len = dentry->d_name.len; | 373 | unsigned len = dentry->d_name.len; |
374 | struct quad_buffer_head qbh; | 374 | struct quad_buffer_head qbh; |
375 | struct hpfs_dirent *de; | 375 | struct hpfs_dirent *de; |
@@ -381,12 +381,12 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry) | |||
381 | int err; | 381 | int err; |
382 | 382 | ||
383 | lock_kernel(); | 383 | lock_kernel(); |
384 | hpfs_adjust_length((char *)name, &len); | 384 | hpfs_adjust_length(name, &len); |
385 | again: | 385 | again: |
386 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); | 386 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); |
387 | mutex_lock(&hpfs_i(dir)->i_mutex); | 387 | mutex_lock(&hpfs_i(dir)->i_mutex); |
388 | err = -ENOENT; | 388 | err = -ENOENT; |
389 | de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh); | 389 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); |
390 | if (!de) | 390 | if (!de) |
391 | goto out; | 391 | goto out; |
392 | 392 | ||
@@ -413,22 +413,25 @@ again: | |||
413 | 413 | ||
414 | mutex_unlock(&hpfs_i(dir)->i_mutex); | 414 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
415 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); | 415 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); |
416 | d_drop(dentry); | 416 | dentry_unhash(dentry); |
417 | spin_lock(&dentry->d_lock); | 417 | if (!d_unhashed(dentry)) { |
418 | if (atomic_read(&dentry->d_count) > 1 || | 418 | dput(dentry); |
419 | generic_permission(inode, MAY_WRITE, NULL) || | 419 | unlock_kernel(); |
420 | return -ENOSPC; | ||
421 | } | ||
422 | if (generic_permission(inode, MAY_WRITE, NULL) || | ||
420 | !S_ISREG(inode->i_mode) || | 423 | !S_ISREG(inode->i_mode) || |
421 | get_write_access(inode)) { | 424 | get_write_access(inode)) { |
422 | spin_unlock(&dentry->d_lock); | ||
423 | d_rehash(dentry); | 425 | d_rehash(dentry); |
426 | dput(dentry); | ||
424 | } else { | 427 | } else { |
425 | struct iattr newattrs; | 428 | struct iattr newattrs; |
426 | spin_unlock(&dentry->d_lock); | ||
427 | /*printk("HPFS: truncating file before delete.\n");*/ | 429 | /*printk("HPFS: truncating file before delete.\n");*/ |
428 | newattrs.ia_size = 0; | 430 | newattrs.ia_size = 0; |
429 | newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; | 431 | newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; |
430 | err = notify_change(dentry, &newattrs); | 432 | err = notify_change(dentry, &newattrs); |
431 | put_write_access(inode); | 433 | put_write_access(inode); |
434 | dput(dentry); | ||
432 | if (!err) | 435 | if (!err) |
433 | goto again; | 436 | goto again; |
434 | } | 437 | } |
@@ -451,7 +454,7 @@ out: | |||
451 | 454 | ||
452 | static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) | 455 | static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) |
453 | { | 456 | { |
454 | const char *name = dentry->d_name.name; | 457 | const unsigned char *name = dentry->d_name.name; |
455 | unsigned len = dentry->d_name.len; | 458 | unsigned len = dentry->d_name.len; |
456 | struct quad_buffer_head qbh; | 459 | struct quad_buffer_head qbh; |
457 | struct hpfs_dirent *de; | 460 | struct hpfs_dirent *de; |
@@ -462,12 +465,12 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
462 | int err; | 465 | int err; |
463 | int r; | 466 | int r; |
464 | 467 | ||
465 | hpfs_adjust_length((char *)name, &len); | 468 | hpfs_adjust_length(name, &len); |
466 | lock_kernel(); | 469 | lock_kernel(); |
467 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); | 470 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); |
468 | mutex_lock(&hpfs_i(dir)->i_mutex); | 471 | mutex_lock(&hpfs_i(dir)->i_mutex); |
469 | err = -ENOENT; | 472 | err = -ENOENT; |
470 | de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh); | 473 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); |
471 | if (!de) | 474 | if (!de) |
472 | goto out; | 475 | goto out; |
473 | 476 | ||
@@ -546,10 +549,10 @@ const struct address_space_operations hpfs_symlink_aops = { | |||
546 | static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | 549 | static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, |
547 | struct inode *new_dir, struct dentry *new_dentry) | 550 | struct inode *new_dir, struct dentry *new_dentry) |
548 | { | 551 | { |
549 | char *old_name = (char *)old_dentry->d_name.name; | 552 | const unsigned char *old_name = old_dentry->d_name.name; |
550 | int old_len = old_dentry->d_name.len; | 553 | unsigned old_len = old_dentry->d_name.len; |
551 | char *new_name = (char *)new_dentry->d_name.name; | 554 | const unsigned char *new_name = new_dentry->d_name.name; |
552 | int new_len = new_dentry->d_name.len; | 555 | unsigned new_len = new_dentry->d_name.len; |
553 | struct inode *i = old_dentry->d_inode; | 556 | struct inode *i = old_dentry->d_inode; |
554 | struct inode *new_inode = new_dentry->d_inode; | 557 | struct inode *new_inode = new_dentry->d_inode; |
555 | struct quad_buffer_head qbh, qbh1; | 558 | struct quad_buffer_head qbh, qbh1; |
@@ -560,9 +563,9 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
560 | struct buffer_head *bh; | 563 | struct buffer_head *bh; |
561 | struct fnode *fnode; | 564 | struct fnode *fnode; |
562 | int err; | 565 | int err; |
563 | if ((err = hpfs_chk_name((char *)new_name, &new_len))) return err; | 566 | if ((err = hpfs_chk_name(new_name, &new_len))) return err; |
564 | err = 0; | 567 | err = 0; |
565 | hpfs_adjust_length((char *)old_name, &old_len); | 568 | hpfs_adjust_length(old_name, &old_len); |
566 | 569 | ||
567 | lock_kernel(); | 570 | lock_kernel(); |
568 | /* order doesn't matter, due to VFS exclusion */ | 571 | /* order doesn't matter, due to VFS exclusion */ |
@@ -579,7 +582,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
579 | goto end1; | 582 | goto end1; |
580 | } | 583 | } |
581 | 584 | ||
582 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, (char *)old_name, old_len, &dno, &qbh))) { | 585 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { |
583 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed"); | 586 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed"); |
584 | err = -ENOENT; | 587 | err = -ENOENT; |
585 | goto end1; | 588 | goto end1; |
@@ -590,7 +593,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
590 | if (new_inode) { | 593 | if (new_inode) { |
591 | int r; | 594 | int r; |
592 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 1)) != 2) { | 595 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 1)) != 2) { |
593 | if ((nde = map_dirent(new_dir, hpfs_i(new_dir)->i_dno, (char *)new_name, new_len, NULL, &qbh1))) { | 596 | if ((nde = map_dirent(new_dir, hpfs_i(new_dir)->i_dno, new_name, new_len, NULL, &qbh1))) { |
594 | clear_nlink(new_inode); | 597 | clear_nlink(new_inode); |
595 | copy_de(nde, &de); | 598 | copy_de(nde, &de); |
596 | memcpy(nde->name, new_name, new_len); | 599 | memcpy(nde->name, new_name, new_len); |
@@ -618,7 +621,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
618 | } | 621 | } |
619 | 622 | ||
620 | if (new_dir == old_dir) | 623 | if (new_dir == old_dir) |
621 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, (char *)old_name, old_len, &dno, &qbh))) { | 624 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { |
622 | hpfs_unlock_creation(i->i_sb); | 625 | hpfs_unlock_creation(i->i_sb); |
623 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2"); | 626 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2"); |
624 | err = -ENOENT; | 627 | err = -ENOENT; |
@@ -648,7 +651,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
648 | brelse(bh); | 651 | brelse(bh); |
649 | } | 652 | } |
650 | hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv; | 653 | hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv; |
651 | hpfs_decide_conv(i, (char *)new_name, new_len); | 654 | hpfs_decide_conv(i, new_name, new_len); |
652 | end1: | 655 | end1: |
653 | if (old_dir != new_dir) | 656 | if (old_dir != new_dir) |
654 | mutex_unlock(&hpfs_i(new_dir)->i_mutex); | 657 | mutex_unlock(&hpfs_i(new_dir)->i_mutex); |
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c index 7239efc690d8..2e4dfa8593da 100644 --- a/fs/hppfs/hppfs.c +++ b/fs/hppfs/hppfs.c | |||
@@ -718,7 +718,7 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent) | |||
718 | struct vfsmount *proc_mnt; | 718 | struct vfsmount *proc_mnt; |
719 | int err = -ENOENT; | 719 | int err = -ENOENT; |
720 | 720 | ||
721 | proc_mnt = do_kern_mount("proc", 0, "proc", NULL); | 721 | proc_mnt = mntget(current->nsproxy->pid_ns->proc_mnt); |
722 | if (IS_ERR(proc_mnt)) | 722 | if (IS_ERR(proc_mnt)) |
723 | goto out; | 723 | goto out; |
724 | 724 | ||
diff --git a/fs/internal.h b/fs/internal.h index e96a1667d749..8a03a5447bdf 100644 --- a/fs/internal.h +++ b/fs/internal.h | |||
@@ -70,6 +70,8 @@ extern struct vfsmount *copy_tree(struct vfsmount *, struct dentry *, int); | |||
70 | 70 | ||
71 | extern void __init mnt_init(void); | 71 | extern void __init mnt_init(void); |
72 | 72 | ||
73 | extern spinlock_t vfsmount_lock; | ||
74 | |||
73 | /* | 75 | /* |
74 | * fs_struct.c | 76 | * fs_struct.c |
75 | */ | 77 | */ |
diff --git a/fs/libfs.c b/fs/libfs.c index 6e8d17e1dc4c..9e50bcf55857 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -338,28 +338,14 @@ int simple_readpage(struct file *file, struct page *page) | |||
338 | return 0; | 338 | return 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | int simple_prepare_write(struct file *file, struct page *page, | ||
342 | unsigned from, unsigned to) | ||
343 | { | ||
344 | if (!PageUptodate(page)) { | ||
345 | if (to - from != PAGE_CACHE_SIZE) | ||
346 | zero_user_segments(page, | ||
347 | 0, from, | ||
348 | to, PAGE_CACHE_SIZE); | ||
349 | } | ||
350 | return 0; | ||
351 | } | ||
352 | |||
353 | int simple_write_begin(struct file *file, struct address_space *mapping, | 341 | int simple_write_begin(struct file *file, struct address_space *mapping, |
354 | loff_t pos, unsigned len, unsigned flags, | 342 | loff_t pos, unsigned len, unsigned flags, |
355 | struct page **pagep, void **fsdata) | 343 | struct page **pagep, void **fsdata) |
356 | { | 344 | { |
357 | struct page *page; | 345 | struct page *page; |
358 | pgoff_t index; | 346 | pgoff_t index; |
359 | unsigned from; | ||
360 | 347 | ||
361 | index = pos >> PAGE_CACHE_SHIFT; | 348 | index = pos >> PAGE_CACHE_SHIFT; |
362 | from = pos & (PAGE_CACHE_SIZE - 1); | ||
363 | 349 | ||
364 | page = grab_cache_page_write_begin(mapping, index, flags); | 350 | page = grab_cache_page_write_begin(mapping, index, flags); |
365 | if (!page) | 351 | if (!page) |
@@ -367,43 +353,59 @@ int simple_write_begin(struct file *file, struct address_space *mapping, | |||
367 | 353 | ||
368 | *pagep = page; | 354 | *pagep = page; |
369 | 355 | ||
370 | return simple_prepare_write(file, page, from, from+len); | 356 | if (!PageUptodate(page) && (len != PAGE_CACHE_SIZE)) { |
371 | } | 357 | unsigned from = pos & (PAGE_CACHE_SIZE - 1); |
372 | |||
373 | static int simple_commit_write(struct file *file, struct page *page, | ||
374 | unsigned from, unsigned to) | ||
375 | { | ||
376 | struct inode *inode = page->mapping->host; | ||
377 | loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; | ||
378 | 358 | ||
379 | if (!PageUptodate(page)) | 359 | zero_user_segments(page, 0, from, from + len, PAGE_CACHE_SIZE); |
380 | SetPageUptodate(page); | 360 | } |
381 | /* | ||
382 | * No need to use i_size_read() here, the i_size | ||
383 | * cannot change under us because we hold the i_mutex. | ||
384 | */ | ||
385 | if (pos > inode->i_size) | ||
386 | i_size_write(inode, pos); | ||
387 | set_page_dirty(page); | ||
388 | return 0; | 361 | return 0; |
389 | } | 362 | } |
390 | 363 | ||
364 | /** | ||
365 | * simple_write_end - .write_end helper for non-block-device FSes | ||
366 | * @available: See .write_end of address_space_operations | ||
367 | * @file: " | ||
368 | * @mapping: " | ||
369 | * @pos: " | ||
370 | * @len: " | ||
371 | * @copied: " | ||
372 | * @page: " | ||
373 | * @fsdata: " | ||
374 | * | ||
375 | * simple_write_end does the minimum needed for updating a page after writing is | ||
376 | * done. It has the same API signature as the .write_end of | ||
377 | * address_space_operations vector. So it can just be set onto .write_end for | ||
378 | * FSes that don't need any other processing. i_mutex is assumed to be held. | ||
379 | * Block based filesystems should use generic_write_end(). | ||
380 | * NOTE: Even though i_size might get updated by this function, mark_inode_dirty | ||
381 | * is not called, so a filesystem that actually does store data in .write_inode | ||
382 | * should extend on what's done here with a call to mark_inode_dirty() in the | ||
383 | * case that i_size has changed. | ||
384 | */ | ||
391 | int simple_write_end(struct file *file, struct address_space *mapping, | 385 | int simple_write_end(struct file *file, struct address_space *mapping, |
392 | loff_t pos, unsigned len, unsigned copied, | 386 | loff_t pos, unsigned len, unsigned copied, |
393 | struct page *page, void *fsdata) | 387 | struct page *page, void *fsdata) |
394 | { | 388 | { |
395 | unsigned from = pos & (PAGE_CACHE_SIZE - 1); | 389 | struct inode *inode = page->mapping->host; |
390 | loff_t last_pos = pos + copied; | ||
396 | 391 | ||
397 | /* zero the stale part of the page if we did a short copy */ | 392 | /* zero the stale part of the page if we did a short copy */ |
398 | if (copied < len) { | 393 | if (copied < len) { |
399 | void *kaddr = kmap_atomic(page, KM_USER0); | 394 | unsigned from = pos & (PAGE_CACHE_SIZE - 1); |
400 | memset(kaddr + from + copied, 0, len - copied); | 395 | |
401 | flush_dcache_page(page); | 396 | zero_user(page, from + copied, len - copied); |
402 | kunmap_atomic(kaddr, KM_USER0); | ||
403 | } | 397 | } |
404 | 398 | ||
405 | simple_commit_write(file, page, from, from+copied); | 399 | if (!PageUptodate(page)) |
400 | SetPageUptodate(page); | ||
401 | /* | ||
402 | * No need to use i_size_read() here, the i_size | ||
403 | * cannot change under us because we hold the i_mutex. | ||
404 | */ | ||
405 | if (last_pos > inode->i_size) | ||
406 | i_size_write(inode, last_pos); | ||
406 | 407 | ||
408 | set_page_dirty(page); | ||
407 | unlock_page(page); | 409 | unlock_page(page); |
408 | page_cache_release(page); | 410 | page_cache_release(page); |
409 | 411 | ||
@@ -853,7 +855,6 @@ EXPORT_SYMBOL(simple_getattr); | |||
853 | EXPORT_SYMBOL(simple_link); | 855 | EXPORT_SYMBOL(simple_link); |
854 | EXPORT_SYMBOL(simple_lookup); | 856 | EXPORT_SYMBOL(simple_lookup); |
855 | EXPORT_SYMBOL(simple_pin_fs); | 857 | EXPORT_SYMBOL(simple_pin_fs); |
856 | EXPORT_UNUSED_SYMBOL(simple_prepare_write); | ||
857 | EXPORT_SYMBOL(simple_readpage); | 858 | EXPORT_SYMBOL(simple_readpage); |
858 | EXPORT_SYMBOL(simple_release_fs); | 859 | EXPORT_SYMBOL(simple_release_fs); |
859 | EXPORT_SYMBOL(simple_rename); | 860 | EXPORT_SYMBOL(simple_rename); |
diff --git a/fs/locks.c b/fs/locks.c index a8794f233bc9..ae9ded026b7c 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -1182,8 +1182,9 @@ int __break_lease(struct inode *inode, unsigned int mode) | |||
1182 | struct file_lock *fl; | 1182 | struct file_lock *fl; |
1183 | unsigned long break_time; | 1183 | unsigned long break_time; |
1184 | int i_have_this_lease = 0; | 1184 | int i_have_this_lease = 0; |
1185 | int want_write = (mode & O_ACCMODE) != O_RDONLY; | ||
1185 | 1186 | ||
1186 | new_fl = lease_alloc(NULL, mode & FMODE_WRITE ? F_WRLCK : F_RDLCK); | 1187 | new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK); |
1187 | 1188 | ||
1188 | lock_kernel(); | 1189 | lock_kernel(); |
1189 | 1190 | ||
@@ -1197,7 +1198,7 @@ int __break_lease(struct inode *inode, unsigned int mode) | |||
1197 | if (fl->fl_owner == current->files) | 1198 | if (fl->fl_owner == current->files) |
1198 | i_have_this_lease = 1; | 1199 | i_have_this_lease = 1; |
1199 | 1200 | ||
1200 | if (mode & FMODE_WRITE) { | 1201 | if (want_write) { |
1201 | /* If we want write access, we have to revoke any lease. */ | 1202 | /* If we want write access, we have to revoke any lease. */ |
1202 | future = F_UNLCK | F_INPROGRESS; | 1203 | future = F_UNLCK | F_INPROGRESS; |
1203 | } else if (flock->fl_type & F_INPROGRESS) { | 1204 | } else if (flock->fl_type & F_INPROGRESS) { |
diff --git a/fs/namei.c b/fs/namei.c index a4855af776a8..0741c69b3319 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -689,33 +689,20 @@ static __always_inline void follow_dotdot(struct nameidata *nd) | |||
689 | set_root(nd); | 689 | set_root(nd); |
690 | 690 | ||
691 | while(1) { | 691 | while(1) { |
692 | struct vfsmount *parent; | ||
693 | struct dentry *old = nd->path.dentry; | 692 | struct dentry *old = nd->path.dentry; |
694 | 693 | ||
695 | if (nd->path.dentry == nd->root.dentry && | 694 | if (nd->path.dentry == nd->root.dentry && |
696 | nd->path.mnt == nd->root.mnt) { | 695 | nd->path.mnt == nd->root.mnt) { |
697 | break; | 696 | break; |
698 | } | 697 | } |
699 | spin_lock(&dcache_lock); | ||
700 | if (nd->path.dentry != nd->path.mnt->mnt_root) { | 698 | if (nd->path.dentry != nd->path.mnt->mnt_root) { |
701 | nd->path.dentry = dget(nd->path.dentry->d_parent); | 699 | /* rare case of legitimate dget_parent()... */ |
702 | spin_unlock(&dcache_lock); | 700 | nd->path.dentry = dget_parent(nd->path.dentry); |
703 | dput(old); | 701 | dput(old); |
704 | break; | 702 | break; |
705 | } | 703 | } |
706 | spin_unlock(&dcache_lock); | 704 | if (!follow_up(&nd->path)) |
707 | spin_lock(&vfsmount_lock); | ||
708 | parent = nd->path.mnt->mnt_parent; | ||
709 | if (parent == nd->path.mnt) { | ||
710 | spin_unlock(&vfsmount_lock); | ||
711 | break; | 705 | break; |
712 | } | ||
713 | mntget(parent); | ||
714 | nd->path.dentry = dget(nd->path.mnt->mnt_mountpoint); | ||
715 | spin_unlock(&vfsmount_lock); | ||
716 | dput(old); | ||
717 | mntput(nd->path.mnt); | ||
718 | nd->path.mnt = parent; | ||
719 | } | 706 | } |
720 | follow_mount(&nd->path); | 707 | follow_mount(&nd->path); |
721 | } | 708 | } |
@@ -1347,7 +1334,7 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir) | |||
1347 | return -ENOENT; | 1334 | return -ENOENT; |
1348 | 1335 | ||
1349 | BUG_ON(victim->d_parent->d_inode != dir); | 1336 | BUG_ON(victim->d_parent->d_inode != dir); |
1350 | audit_inode_child(victim->d_name.name, victim, dir); | 1337 | audit_inode_child(victim, dir); |
1351 | 1338 | ||
1352 | error = inode_permission(dir, MAY_WRITE | MAY_EXEC); | 1339 | error = inode_permission(dir, MAY_WRITE | MAY_EXEC); |
1353 | if (error) | 1340 | if (error) |
@@ -1503,7 +1490,7 @@ int may_open(struct path *path, int acc_mode, int flag) | |||
1503 | * An append-only file must be opened in append mode for writing. | 1490 | * An append-only file must be opened in append mode for writing. |
1504 | */ | 1491 | */ |
1505 | if (IS_APPEND(inode)) { | 1492 | if (IS_APPEND(inode)) { |
1506 | if ((flag & FMODE_WRITE) && !(flag & O_APPEND)) | 1493 | if ((flag & O_ACCMODE) != O_RDONLY && !(flag & O_APPEND)) |
1507 | return -EPERM; | 1494 | return -EPERM; |
1508 | if (flag & O_TRUNC) | 1495 | if (flag & O_TRUNC) |
1509 | return -EPERM; | 1496 | return -EPERM; |
@@ -1547,7 +1534,7 @@ static int handle_truncate(struct path *path) | |||
1547 | * what get passed to sys_open(). | 1534 | * what get passed to sys_open(). |
1548 | */ | 1535 | */ |
1549 | static int __open_namei_create(struct nameidata *nd, struct path *path, | 1536 | static int __open_namei_create(struct nameidata *nd, struct path *path, |
1550 | int flag, int mode) | 1537 | int open_flag, int mode) |
1551 | { | 1538 | { |
1552 | int error; | 1539 | int error; |
1553 | struct dentry *dir = nd->path.dentry; | 1540 | struct dentry *dir = nd->path.dentry; |
@@ -1565,7 +1552,7 @@ out_unlock: | |||
1565 | if (error) | 1552 | if (error) |
1566 | return error; | 1553 | return error; |
1567 | /* Don't check for write permission, don't truncate */ | 1554 | /* Don't check for write permission, don't truncate */ |
1568 | return may_open(&nd->path, 0, flag & ~O_TRUNC); | 1555 | return may_open(&nd->path, 0, open_flag & ~O_TRUNC); |
1569 | } | 1556 | } |
1570 | 1557 | ||
1571 | /* | 1558 | /* |
@@ -1736,7 +1723,7 @@ do_last: | |||
1736 | error = mnt_want_write(nd.path.mnt); | 1723 | error = mnt_want_write(nd.path.mnt); |
1737 | if (error) | 1724 | if (error) |
1738 | goto exit_mutex_unlock; | 1725 | goto exit_mutex_unlock; |
1739 | error = __open_namei_create(&nd, &path, flag, mode); | 1726 | error = __open_namei_create(&nd, &path, open_flag, mode); |
1740 | if (error) { | 1727 | if (error) { |
1741 | mnt_drop_write(nd.path.mnt); | 1728 | mnt_drop_write(nd.path.mnt); |
1742 | goto exit; | 1729 | goto exit; |
@@ -1798,7 +1785,7 @@ ok: | |||
1798 | if (error) | 1785 | if (error) |
1799 | goto exit; | 1786 | goto exit; |
1800 | } | 1787 | } |
1801 | error = may_open(&nd.path, acc_mode, flag); | 1788 | error = may_open(&nd.path, acc_mode, open_flag); |
1802 | if (error) { | 1789 | if (error) { |
1803 | if (will_truncate) | 1790 | if (will_truncate) |
1804 | mnt_drop_write(nd.path.mnt); | 1791 | mnt_drop_write(nd.path.mnt); |
@@ -2275,8 +2262,11 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry) | |||
2275 | error = -EBUSY; | 2262 | error = -EBUSY; |
2276 | else { | 2263 | else { |
2277 | error = security_inode_unlink(dir, dentry); | 2264 | error = security_inode_unlink(dir, dentry); |
2278 | if (!error) | 2265 | if (!error) { |
2279 | error = dir->i_op->unlink(dir, dentry); | 2266 | error = dir->i_op->unlink(dir, dentry); |
2267 | if (!error) | ||
2268 | dentry->d_inode->i_flags |= S_DEAD; | ||
2269 | } | ||
2280 | } | 2270 | } |
2281 | mutex_unlock(&dentry->d_inode->i_mutex); | 2271 | mutex_unlock(&dentry->d_inode->i_mutex); |
2282 | 2272 | ||
@@ -2629,6 +2619,8 @@ static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry, | |||
2629 | else | 2619 | else |
2630 | error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); | 2620 | error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry); |
2631 | if (!error) { | 2621 | if (!error) { |
2622 | if (target) | ||
2623 | target->i_flags |= S_DEAD; | ||
2632 | if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) | 2624 | if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) |
2633 | d_move(old_dentry, new_dentry); | 2625 | d_move(old_dentry, new_dentry); |
2634 | } | 2626 | } |
@@ -2671,11 +2663,9 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2671 | error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry); | 2663 | error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry); |
2672 | else | 2664 | else |
2673 | error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry); | 2665 | error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry); |
2674 | if (!error) { | 2666 | if (!error) |
2675 | const char *new_name = old_dentry->d_name.name; | 2667 | fsnotify_move(old_dir, new_dir, old_name, is_dir, |
2676 | fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir, | ||
2677 | new_dentry->d_inode, old_dentry); | 2668 | new_dentry->d_inode, old_dentry); |
2678 | } | ||
2679 | fsnotify_oldname_free(old_name); | 2669 | fsnotify_oldname_free(old_name); |
2680 | 2670 | ||
2681 | return error; | 2671 | return error; |
diff --git a/fs/namespace.c b/fs/namespace.c index c768f733c8d6..8174c8ab5c70 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -573,7 +573,7 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root, | |||
573 | mnt->mnt_master = old; | 573 | mnt->mnt_master = old; |
574 | CLEAR_MNT_SHARED(mnt); | 574 | CLEAR_MNT_SHARED(mnt); |
575 | } else if (!(flag & CL_PRIVATE)) { | 575 | } else if (!(flag & CL_PRIVATE)) { |
576 | if ((flag & CL_PROPAGATION) || IS_MNT_SHARED(old)) | 576 | if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(old)) |
577 | list_add(&mnt->mnt_share, &old->mnt_share); | 577 | list_add(&mnt->mnt_share, &old->mnt_share); |
578 | if (IS_MNT_SLAVE(old)) | 578 | if (IS_MNT_SLAVE(old)) |
579 | list_add(&mnt->mnt_slave, &old->mnt_slave); | 579 | list_add(&mnt->mnt_slave, &old->mnt_slave); |
@@ -737,6 +737,21 @@ static void m_stop(struct seq_file *m, void *v) | |||
737 | up_read(&namespace_sem); | 737 | up_read(&namespace_sem); |
738 | } | 738 | } |
739 | 739 | ||
740 | int mnt_had_events(struct proc_mounts *p) | ||
741 | { | ||
742 | struct mnt_namespace *ns = p->ns; | ||
743 | int res = 0; | ||
744 | |||
745 | spin_lock(&vfsmount_lock); | ||
746 | if (p->event != ns->event) { | ||
747 | p->event = ns->event; | ||
748 | res = 1; | ||
749 | } | ||
750 | spin_unlock(&vfsmount_lock); | ||
751 | |||
752 | return res; | ||
753 | } | ||
754 | |||
740 | struct proc_fs_info { | 755 | struct proc_fs_info { |
741 | int flag; | 756 | int flag; |
742 | const char *str; | 757 | const char *str; |
@@ -1121,8 +1136,15 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags) | |||
1121 | { | 1136 | { |
1122 | struct path path; | 1137 | struct path path; |
1123 | int retval; | 1138 | int retval; |
1139 | int lookup_flags = 0; | ||
1124 | 1140 | ||
1125 | retval = user_path(name, &path); | 1141 | if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW)) |
1142 | return -EINVAL; | ||
1143 | |||
1144 | if (!(flags & UMOUNT_NOFOLLOW)) | ||
1145 | lookup_flags |= LOOKUP_FOLLOW; | ||
1146 | |||
1147 | retval = user_path_at(AT_FDCWD, name, lookup_flags, &path); | ||
1126 | if (retval) | 1148 | if (retval) |
1127 | goto out; | 1149 | goto out; |
1128 | retval = -EINVAL; | 1150 | retval = -EINVAL; |
@@ -1246,6 +1268,21 @@ void drop_collected_mounts(struct vfsmount *mnt) | |||
1246 | release_mounts(&umount_list); | 1268 | release_mounts(&umount_list); |
1247 | } | 1269 | } |
1248 | 1270 | ||
1271 | int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg, | ||
1272 | struct vfsmount *root) | ||
1273 | { | ||
1274 | struct vfsmount *mnt; | ||
1275 | int res = f(root, arg); | ||
1276 | if (res) | ||
1277 | return res; | ||
1278 | list_for_each_entry(mnt, &root->mnt_list, mnt_list) { | ||
1279 | res = f(mnt, arg); | ||
1280 | if (res) | ||
1281 | return res; | ||
1282 | } | ||
1283 | return 0; | ||
1284 | } | ||
1285 | |||
1249 | static void cleanup_group_ids(struct vfsmount *mnt, struct vfsmount *end) | 1286 | static void cleanup_group_ids(struct vfsmount *mnt, struct vfsmount *end) |
1250 | { | 1287 | { |
1251 | struct vfsmount *p; | 1288 | struct vfsmount *p; |
@@ -1538,7 +1575,7 @@ static int do_remount(struct path *path, int flags, int mnt_flags, | |||
1538 | err = do_remount_sb(sb, flags, data, 0); | 1575 | err = do_remount_sb(sb, flags, data, 0); |
1539 | if (!err) { | 1576 | if (!err) { |
1540 | spin_lock(&vfsmount_lock); | 1577 | spin_lock(&vfsmount_lock); |
1541 | mnt_flags |= path->mnt->mnt_flags & MNT_PNODE_MASK; | 1578 | mnt_flags |= path->mnt->mnt_flags & MNT_PROPAGATION_MASK; |
1542 | path->mnt->mnt_flags = mnt_flags; | 1579 | path->mnt->mnt_flags = mnt_flags; |
1543 | spin_unlock(&vfsmount_lock); | 1580 | spin_unlock(&vfsmount_lock); |
1544 | } | 1581 | } |
@@ -1671,7 +1708,7 @@ int do_add_mount(struct vfsmount *newmnt, struct path *path, | |||
1671 | { | 1708 | { |
1672 | int err; | 1709 | int err; |
1673 | 1710 | ||
1674 | mnt_flags &= ~(MNT_SHARED | MNT_WRITE_HOLD); | 1711 | mnt_flags &= ~(MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL); |
1675 | 1712 | ||
1676 | down_write(&namespace_sem); | 1713 | down_write(&namespace_sem); |
1677 | /* Something was mounted here while we slept */ | 1714 | /* Something was mounted here while we slept */ |
@@ -2314,17 +2351,13 @@ void __init mnt_init(void) | |||
2314 | 2351 | ||
2315 | void put_mnt_ns(struct mnt_namespace *ns) | 2352 | void put_mnt_ns(struct mnt_namespace *ns) |
2316 | { | 2353 | { |
2317 | struct vfsmount *root; | ||
2318 | LIST_HEAD(umount_list); | 2354 | LIST_HEAD(umount_list); |
2319 | 2355 | ||
2320 | if (!atomic_dec_and_lock(&ns->count, &vfsmount_lock)) | 2356 | if (!atomic_dec_and_test(&ns->count)) |
2321 | return; | 2357 | return; |
2322 | root = ns->root; | ||
2323 | ns->root = NULL; | ||
2324 | spin_unlock(&vfsmount_lock); | ||
2325 | down_write(&namespace_sem); | 2358 | down_write(&namespace_sem); |
2326 | spin_lock(&vfsmount_lock); | 2359 | spin_lock(&vfsmount_lock); |
2327 | umount_tree(root, 0, &umount_list); | 2360 | umount_tree(ns->root, 0, &umount_list); |
2328 | spin_unlock(&vfsmount_lock); | 2361 | spin_unlock(&vfsmount_lock); |
2329 | up_write(&namespace_sem); | 2362 | up_write(&namespace_sem); |
2330 | release_mounts(&umount_list); | 2363 | release_mounts(&umount_list); |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index f141bde7756a..7570573bdb30 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -574,14 +574,14 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync) | |||
574 | nfs_revalidate_inode(server, inode); | 574 | nfs_revalidate_inode(server, inode); |
575 | } | 575 | } |
576 | 576 | ||
577 | static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, struct dentry *dentry, struct rpc_cred *cred) | 577 | static struct nfs_open_context *alloc_nfs_open_context(struct path *path, struct rpc_cred *cred) |
578 | { | 578 | { |
579 | struct nfs_open_context *ctx; | 579 | struct nfs_open_context *ctx; |
580 | 580 | ||
581 | ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); | 581 | ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); |
582 | if (ctx != NULL) { | 582 | if (ctx != NULL) { |
583 | ctx->path.dentry = dget(dentry); | 583 | ctx->path = *path; |
584 | ctx->path.mnt = mntget(mnt); | 584 | path_get(&ctx->path); |
585 | ctx->cred = get_rpccred(cred); | 585 | ctx->cred = get_rpccred(cred); |
586 | ctx->state = NULL; | 586 | ctx->state = NULL; |
587 | ctx->lockowner = current->files; | 587 | ctx->lockowner = current->files; |
@@ -686,7 +686,7 @@ int nfs_open(struct inode *inode, struct file *filp) | |||
686 | cred = rpc_lookup_cred(); | 686 | cred = rpc_lookup_cred(); |
687 | if (IS_ERR(cred)) | 687 | if (IS_ERR(cred)) |
688 | return PTR_ERR(cred); | 688 | return PTR_ERR(cred); |
689 | ctx = alloc_nfs_open_context(filp->f_path.mnt, filp->f_path.dentry, cred); | 689 | ctx = alloc_nfs_open_context(&filp->f_path, cred); |
690 | put_rpccred(cred); | 690 | put_rpccred(cred); |
691 | if (ctx == NULL) | 691 | if (ctx == NULL) |
692 | return -ENOMEM; | 692 | return -ENOMEM; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 375f0fae2c6a..84d83be25a98 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -724,8 +724,8 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path, | |||
724 | p->o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid); | 724 | p->o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid); |
725 | if (p->o_arg.seqid == NULL) | 725 | if (p->o_arg.seqid == NULL) |
726 | goto err_free; | 726 | goto err_free; |
727 | p->path.mnt = mntget(path->mnt); | 727 | path_get(path); |
728 | p->path.dentry = dget(path->dentry); | 728 | p->path = *path; |
729 | p->dir = parent; | 729 | p->dir = parent; |
730 | p->owner = sp; | 730 | p->owner = sp; |
731 | atomic_inc(&sp->so_count); | 731 | atomic_inc(&sp->so_count); |
@@ -1944,8 +1944,8 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait) | |||
1944 | calldata->res.seqid = calldata->arg.seqid; | 1944 | calldata->res.seqid = calldata->arg.seqid; |
1945 | calldata->res.server = server; | 1945 | calldata->res.server = server; |
1946 | calldata->res.seq_res.sr_slotid = NFS4_MAX_SLOT_TABLE; | 1946 | calldata->res.seq_res.sr_slotid = NFS4_MAX_SLOT_TABLE; |
1947 | calldata->path.mnt = mntget(path->mnt); | 1947 | path_get(path); |
1948 | calldata->path.dentry = dget(path->dentry); | 1948 | calldata->path = *path; |
1949 | 1949 | ||
1950 | msg.rpc_argp = &calldata->arg, | 1950 | msg.rpc_argp = &calldata->arg, |
1951 | msg.rpc_resp = &calldata->res, | 1951 | msg.rpc_resp = &calldata->res, |
diff --git a/fs/nfsctl.c b/fs/nfsctl.c index d3854d94b7cf..bf9cbd242ddd 100644 --- a/fs/nfsctl.c +++ b/fs/nfsctl.c | |||
@@ -36,10 +36,9 @@ static struct file *do_open(char *name, int flags) | |||
36 | return ERR_PTR(error); | 36 | return ERR_PTR(error); |
37 | 37 | ||
38 | if (flags == O_RDWR) | 38 | if (flags == O_RDWR) |
39 | error = may_open(&nd.path, MAY_READ|MAY_WRITE, | 39 | error = may_open(&nd.path, MAY_READ|MAY_WRITE, flags); |
40 | FMODE_READ|FMODE_WRITE); | ||
41 | else | 40 | else |
42 | error = may_open(&nd.path, MAY_WRITE, FMODE_WRITE); | 41 | error = may_open(&nd.path, MAY_WRITE, flags); |
43 | 42 | ||
44 | if (!error) | 43 | if (!error) |
45 | return dentry_open(nd.path.dentry, nd.path.mnt, flags, | 44 | return dentry_open(nd.path.dentry, nd.path.mnt, flags, |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index a8587e90fd5a..bbf72d8f9fc0 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -2121,9 +2121,15 @@ out_acl: | |||
2121 | * and this is the root of a cross-mounted filesystem. | 2121 | * and this is the root of a cross-mounted filesystem. |
2122 | */ | 2122 | */ |
2123 | if (ignore_crossmnt == 0 && | 2123 | if (ignore_crossmnt == 0 && |
2124 | exp->ex_path.mnt->mnt_root->d_inode == dentry->d_inode) { | 2124 | dentry == exp->ex_path.mnt->mnt_root) { |
2125 | err = vfs_getattr(exp->ex_path.mnt->mnt_parent, | 2125 | struct path path = exp->ex_path; |
2126 | exp->ex_path.mnt->mnt_mountpoint, &stat); | 2126 | path_get(&path); |
2127 | while (follow_up(&path)) { | ||
2128 | if (path.dentry != path.mnt->mnt_root) | ||
2129 | break; | ||
2130 | } | ||
2131 | err = vfs_getattr(path.mnt, path.dentry, &stat); | ||
2132 | path_put(&path); | ||
2127 | if (err) | 2133 | if (err) |
2128 | goto out_nfserr; | 2134 | goto out_nfserr; |
2129 | } | 2135 | } |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 8715d194561a..15dc2deaac5f 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -361,7 +361,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, | |||
361 | * If we are changing the size of the file, then | 361 | * If we are changing the size of the file, then |
362 | * we need to break all leases. | 362 | * we need to break all leases. |
363 | */ | 363 | */ |
364 | host_err = break_lease(inode, FMODE_WRITE | O_NONBLOCK); | 364 | host_err = break_lease(inode, O_WRONLY | O_NONBLOCK); |
365 | if (host_err == -EWOULDBLOCK) | 365 | if (host_err == -EWOULDBLOCK) |
366 | host_err = -ETIMEDOUT; | 366 | host_err = -ETIMEDOUT; |
367 | if (host_err) /* ENOMEM or EWOULDBLOCK */ | 367 | if (host_err) /* ENOMEM or EWOULDBLOCK */ |
@@ -734,7 +734,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, | |||
734 | * Check to see if there are any leases on this file. | 734 | * Check to see if there are any leases on this file. |
735 | * This may block while leases are broken. | 735 | * This may block while leases are broken. |
736 | */ | 736 | */ |
737 | host_err = break_lease(inode, O_NONBLOCK | ((access & NFSD_MAY_WRITE) ? FMODE_WRITE : 0)); | 737 | host_err = break_lease(inode, O_NONBLOCK | ((access & NFSD_MAY_WRITE) ? O_WRONLY : 0)); |
738 | if (host_err == -EWOULDBLOCK) | 738 | if (host_err == -EWOULDBLOCK) |
739 | host_err = -ETIMEDOUT; | 739 | host_err = -ETIMEDOUT; |
740 | if (host_err) /* NOMEM or WOULDBLOCK */ | 740 | if (host_err) /* NOMEM or WOULDBLOCK */ |
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 76d803e060a9..0092840492ee 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c | |||
@@ -224,7 +224,7 @@ fail: | |||
224 | * len <= NILFS_NAME_LEN and de != NULL are guaranteed by caller. | 224 | * len <= NILFS_NAME_LEN and de != NULL are guaranteed by caller. |
225 | */ | 225 | */ |
226 | static int | 226 | static int |
227 | nilfs_match(int len, const char * const name, struct nilfs_dir_entry *de) | 227 | nilfs_match(int len, const unsigned char *name, struct nilfs_dir_entry *de) |
228 | { | 228 | { |
229 | if (len != de->name_len) | 229 | if (len != de->name_len) |
230 | return 0; | 230 | return 0; |
@@ -349,11 +349,11 @@ done: | |||
349 | * Entry is guaranteed to be valid. | 349 | * Entry is guaranteed to be valid. |
350 | */ | 350 | */ |
351 | struct nilfs_dir_entry * | 351 | struct nilfs_dir_entry * |
352 | nilfs_find_entry(struct inode *dir, struct dentry *dentry, | 352 | nilfs_find_entry(struct inode *dir, const struct qstr *qstr, |
353 | struct page **res_page) | 353 | struct page **res_page) |
354 | { | 354 | { |
355 | const char *name = dentry->d_name.name; | 355 | const unsigned char *name = qstr->name; |
356 | int namelen = dentry->d_name.len; | 356 | int namelen = qstr->len; |
357 | unsigned reclen = NILFS_DIR_REC_LEN(namelen); | 357 | unsigned reclen = NILFS_DIR_REC_LEN(namelen); |
358 | unsigned long start, n; | 358 | unsigned long start, n; |
359 | unsigned long npages = dir_pages(dir); | 359 | unsigned long npages = dir_pages(dir); |
@@ -424,13 +424,13 @@ struct nilfs_dir_entry *nilfs_dotdot(struct inode *dir, struct page **p) | |||
424 | return de; | 424 | return de; |
425 | } | 425 | } |
426 | 426 | ||
427 | ino_t nilfs_inode_by_name(struct inode *dir, struct dentry *dentry) | 427 | ino_t nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr) |
428 | { | 428 | { |
429 | ino_t res = 0; | 429 | ino_t res = 0; |
430 | struct nilfs_dir_entry *de; | 430 | struct nilfs_dir_entry *de; |
431 | struct page *page; | 431 | struct page *page; |
432 | 432 | ||
433 | de = nilfs_find_entry(dir, dentry, &page); | 433 | de = nilfs_find_entry(dir, qstr, &page); |
434 | if (de) { | 434 | if (de) { |
435 | res = le64_to_cpu(de->inode); | 435 | res = le64_to_cpu(de->inode); |
436 | kunmap(page); | 436 | kunmap(page); |
@@ -465,7 +465,7 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, | |||
465 | int nilfs_add_link(struct dentry *dentry, struct inode *inode) | 465 | int nilfs_add_link(struct dentry *dentry, struct inode *inode) |
466 | { | 466 | { |
467 | struct inode *dir = dentry->d_parent->d_inode; | 467 | struct inode *dir = dentry->d_parent->d_inode; |
468 | const char *name = dentry->d_name.name; | 468 | const unsigned char *name = dentry->d_name.name; |
469 | int namelen = dentry->d_name.len; | 469 | int namelen = dentry->d_name.len; |
470 | unsigned chunk_size = nilfs_chunk_size(dir); | 470 | unsigned chunk_size = nilfs_chunk_size(dir); |
471 | unsigned reclen = NILFS_DIR_REC_LEN(namelen); | 471 | unsigned reclen = NILFS_DIR_REC_LEN(namelen); |
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 07ba838ef089..ad6ed2cf19b4 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c | |||
@@ -67,7 +67,7 @@ nilfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | |||
67 | if (dentry->d_name.len > NILFS_NAME_LEN) | 67 | if (dentry->d_name.len > NILFS_NAME_LEN) |
68 | return ERR_PTR(-ENAMETOOLONG); | 68 | return ERR_PTR(-ENAMETOOLONG); |
69 | 69 | ||
70 | ino = nilfs_inode_by_name(dir, dentry); | 70 | ino = nilfs_inode_by_name(dir, &dentry->d_name); |
71 | inode = NULL; | 71 | inode = NULL; |
72 | if (ino) { | 72 | if (ino) { |
73 | inode = nilfs_iget(dir->i_sb, ino); | 73 | inode = nilfs_iget(dir->i_sb, ino); |
@@ -81,10 +81,7 @@ struct dentry *nilfs_get_parent(struct dentry *child) | |||
81 | { | 81 | { |
82 | unsigned long ino; | 82 | unsigned long ino; |
83 | struct inode *inode; | 83 | struct inode *inode; |
84 | struct dentry dotdot; | 84 | struct qstr dotdot = {.name = "..", .len = 2}; |
85 | |||
86 | dotdot.d_name.name = ".."; | ||
87 | dotdot.d_name.len = 2; | ||
88 | 85 | ||
89 | ino = nilfs_inode_by_name(child->d_inode, &dotdot); | 86 | ino = nilfs_inode_by_name(child->d_inode, &dotdot); |
90 | if (!ino) | 87 | if (!ino) |
@@ -296,7 +293,7 @@ static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry) | |||
296 | int err; | 293 | int err; |
297 | 294 | ||
298 | err = -ENOENT; | 295 | err = -ENOENT; |
299 | de = nilfs_find_entry(dir, dentry, &page); | 296 | de = nilfs_find_entry(dir, &dentry->d_name, &page); |
300 | if (!de) | 297 | if (!de) |
301 | goto out; | 298 | goto out; |
302 | 299 | ||
@@ -389,7 +386,7 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
389 | return err; | 386 | return err; |
390 | 387 | ||
391 | err = -ENOENT; | 388 | err = -ENOENT; |
392 | old_de = nilfs_find_entry(old_dir, old_dentry, &old_page); | 389 | old_de = nilfs_find_entry(old_dir, &old_dentry->d_name, &old_page); |
393 | if (!old_de) | 390 | if (!old_de) |
394 | goto out; | 391 | goto out; |
395 | 392 | ||
@@ -409,7 +406,7 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
409 | goto out_dir; | 406 | goto out_dir; |
410 | 407 | ||
411 | err = -ENOENT; | 408 | err = -ENOENT; |
412 | new_de = nilfs_find_entry(new_dir, new_dentry, &new_page); | 409 | new_de = nilfs_find_entry(new_dir, &new_dentry->d_name, &new_page); |
413 | if (!new_de) | 410 | if (!new_de) |
414 | goto out_dir; | 411 | goto out_dir; |
415 | inc_nlink(old_inode); | 412 | inc_nlink(old_inode); |
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index 4da6f67e9a91..8723e5bfd071 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h | |||
@@ -217,10 +217,10 @@ static inline int nilfs_init_acl(struct inode *inode, struct inode *dir) | |||
217 | 217 | ||
218 | /* dir.c */ | 218 | /* dir.c */ |
219 | extern int nilfs_add_link(struct dentry *, struct inode *); | 219 | extern int nilfs_add_link(struct dentry *, struct inode *); |
220 | extern ino_t nilfs_inode_by_name(struct inode *, struct dentry *); | 220 | extern ino_t nilfs_inode_by_name(struct inode *, const struct qstr *); |
221 | extern int nilfs_make_empty(struct inode *, struct inode *); | 221 | extern int nilfs_make_empty(struct inode *, struct inode *); |
222 | extern struct nilfs_dir_entry * | 222 | extern struct nilfs_dir_entry * |
223 | nilfs_find_entry(struct inode *, struct dentry *, struct page **); | 223 | nilfs_find_entry(struct inode *, const struct qstr *, struct page **); |
224 | extern int nilfs_delete_entry(struct nilfs_dir_entry *, struct page *); | 224 | extern int nilfs_delete_entry(struct nilfs_dir_entry *, struct page *); |
225 | extern int nilfs_empty_dir(struct inode *); | 225 | extern int nilfs_empty_dir(struct inode *); |
226 | extern struct nilfs_dir_entry *nilfs_dotdot(struct inode *, struct page **); | 226 | extern struct nilfs_dir_entry *nilfs_dotdot(struct inode *, struct page **); |
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index a94e8bd8eb1f..472cdf29ef82 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -29,14 +29,12 @@ | |||
29 | #include <linux/init.h> /* module_init */ | 29 | #include <linux/init.h> /* module_init */ |
30 | #include <linux/inotify.h> | 30 | #include <linux/inotify.h> |
31 | #include <linux/kernel.h> /* roundup() */ | 31 | #include <linux/kernel.h> /* roundup() */ |
32 | #include <linux/magic.h> /* superblock magic number */ | ||
33 | #include <linux/mount.h> /* mntget */ | ||
34 | #include <linux/namei.h> /* LOOKUP_FOLLOW */ | 32 | #include <linux/namei.h> /* LOOKUP_FOLLOW */ |
35 | #include <linux/path.h> /* struct path */ | ||
36 | #include <linux/sched.h> /* struct user */ | 33 | #include <linux/sched.h> /* struct user */ |
37 | #include <linux/slab.h> /* struct kmem_cache */ | 34 | #include <linux/slab.h> /* struct kmem_cache */ |
38 | #include <linux/syscalls.h> | 35 | #include <linux/syscalls.h> |
39 | #include <linux/types.h> | 36 | #include <linux/types.h> |
37 | #include <linux/anon_inodes.h> | ||
40 | #include <linux/uaccess.h> | 38 | #include <linux/uaccess.h> |
41 | #include <linux/poll.h> | 39 | #include <linux/poll.h> |
42 | #include <linux/wait.h> | 40 | #include <linux/wait.h> |
@@ -45,8 +43,6 @@ | |||
45 | 43 | ||
46 | #include <asm/ioctls.h> | 44 | #include <asm/ioctls.h> |
47 | 45 | ||
48 | static struct vfsmount *inotify_mnt __read_mostly; | ||
49 | |||
50 | /* these are configurable via /proc/sys/fs/inotify/ */ | 46 | /* these are configurable via /proc/sys/fs/inotify/ */ |
51 | static int inotify_max_user_instances __read_mostly; | 47 | static int inotify_max_user_instances __read_mostly; |
52 | static int inotify_max_queued_events __read_mostly; | 48 | static int inotify_max_queued_events __read_mostly; |
@@ -645,9 +641,7 @@ SYSCALL_DEFINE1(inotify_init1, int, flags) | |||
645 | { | 641 | { |
646 | struct fsnotify_group *group; | 642 | struct fsnotify_group *group; |
647 | struct user_struct *user; | 643 | struct user_struct *user; |
648 | struct file *filp; | 644 | int ret; |
649 | struct path path; | ||
650 | int fd, ret; | ||
651 | 645 | ||
652 | /* Check the IN_* constants for consistency. */ | 646 | /* Check the IN_* constants for consistency. */ |
653 | BUILD_BUG_ON(IN_CLOEXEC != O_CLOEXEC); | 647 | BUILD_BUG_ON(IN_CLOEXEC != O_CLOEXEC); |
@@ -656,10 +650,6 @@ SYSCALL_DEFINE1(inotify_init1, int, flags) | |||
656 | if (flags & ~(IN_CLOEXEC | IN_NONBLOCK)) | 650 | if (flags & ~(IN_CLOEXEC | IN_NONBLOCK)) |
657 | return -EINVAL; | 651 | return -EINVAL; |
658 | 652 | ||
659 | fd = get_unused_fd_flags(flags & O_CLOEXEC); | ||
660 | if (fd < 0) | ||
661 | return fd; | ||
662 | |||
663 | user = get_current_user(); | 653 | user = get_current_user(); |
664 | if (unlikely(atomic_read(&user->inotify_devs) >= | 654 | if (unlikely(atomic_read(&user->inotify_devs) >= |
665 | inotify_max_user_instances)) { | 655 | inotify_max_user_instances)) { |
@@ -676,27 +666,14 @@ SYSCALL_DEFINE1(inotify_init1, int, flags) | |||
676 | 666 | ||
677 | atomic_inc(&user->inotify_devs); | 667 | atomic_inc(&user->inotify_devs); |
678 | 668 | ||
679 | path.mnt = inotify_mnt; | 669 | ret = anon_inode_getfd("inotify", &inotify_fops, group, |
680 | path.dentry = inotify_mnt->mnt_root; | 670 | O_RDONLY | flags); |
681 | path_get(&path); | 671 | if (ret >= 0) |
682 | filp = alloc_file(&path, FMODE_READ, &inotify_fops); | 672 | return ret; |
683 | if (!filp) | ||
684 | goto Enfile; | ||
685 | 673 | ||
686 | filp->f_flags = O_RDONLY | (flags & O_NONBLOCK); | ||
687 | filp->private_data = group; | ||
688 | |||
689 | fd_install(fd, filp); | ||
690 | |||
691 | return fd; | ||
692 | |||
693 | Enfile: | ||
694 | ret = -ENFILE; | ||
695 | path_put(&path); | ||
696 | atomic_dec(&user->inotify_devs); | 674 | atomic_dec(&user->inotify_devs); |
697 | out_free_uid: | 675 | out_free_uid: |
698 | free_uid(user); | 676 | free_uid(user); |
699 | put_unused_fd(fd); | ||
700 | return ret; | 677 | return ret; |
701 | } | 678 | } |
702 | 679 | ||
@@ -783,20 +760,6 @@ out: | |||
783 | return ret; | 760 | return ret; |
784 | } | 761 | } |
785 | 762 | ||
786 | static int | ||
787 | inotify_get_sb(struct file_system_type *fs_type, int flags, | ||
788 | const char *dev_name, void *data, struct vfsmount *mnt) | ||
789 | { | ||
790 | return get_sb_pseudo(fs_type, "inotify", NULL, | ||
791 | INOTIFYFS_SUPER_MAGIC, mnt); | ||
792 | } | ||
793 | |||
794 | static struct file_system_type inotify_fs_type = { | ||
795 | .name = "inotifyfs", | ||
796 | .get_sb = inotify_get_sb, | ||
797 | .kill_sb = kill_anon_super, | ||
798 | }; | ||
799 | |||
800 | /* | 763 | /* |
801 | * inotify_user_setup - Our initialization function. Note that we cannnot return | 764 | * inotify_user_setup - Our initialization function. Note that we cannnot return |
802 | * error because we have compiled-in VFS hooks. So an (unlikely) failure here | 765 | * error because we have compiled-in VFS hooks. So an (unlikely) failure here |
@@ -804,16 +767,6 @@ static struct file_system_type inotify_fs_type = { | |||
804 | */ | 767 | */ |
805 | static int __init inotify_user_setup(void) | 768 | static int __init inotify_user_setup(void) |
806 | { | 769 | { |
807 | int ret; | ||
808 | |||
809 | ret = register_filesystem(&inotify_fs_type); | ||
810 | if (unlikely(ret)) | ||
811 | panic("inotify: register_filesystem returned %d!\n", ret); | ||
812 | |||
813 | inotify_mnt = kern_mount(&inotify_fs_type); | ||
814 | if (IS_ERR(inotify_mnt)) | ||
815 | panic("inotify: kern_mount ret %ld!\n", PTR_ERR(inotify_mnt)); | ||
816 | |||
817 | inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark_entry, SLAB_PANIC); | 770 | inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark_entry, SLAB_PANIC); |
818 | event_priv_cachep = KMEM_CACHE(inotify_event_private_data, SLAB_PANIC); | 771 | event_priv_cachep = KMEM_CACHE(inotify_event_private_data, SLAB_PANIC); |
819 | 772 | ||
@@ -271,7 +271,7 @@ static long do_sys_truncate(const char __user *pathname, loff_t length) | |||
271 | * Make sure that there are no leases. get_write_access() protects | 271 | * Make sure that there are no leases. get_write_access() protects |
272 | * against the truncate racing with a lease-granting setlease(). | 272 | * against the truncate racing with a lease-granting setlease(). |
273 | */ | 273 | */ |
274 | error = break_lease(inode, FMODE_WRITE); | 274 | error = break_lease(inode, O_WRONLY); |
275 | if (error) | 275 | if (error) |
276 | goto put_write_and_out; | 276 | goto put_write_and_out; |
277 | 277 | ||
diff --git a/fs/pnode.c b/fs/pnode.c index 8d5f392ec3d3..5cc564a83149 100644 --- a/fs/pnode.c +++ b/fs/pnode.c | |||
@@ -86,7 +86,7 @@ static int do_make_slave(struct vfsmount *mnt) | |||
86 | 86 | ||
87 | /* | 87 | /* |
88 | * slave 'mnt' to a peer mount that has the | 88 | * slave 'mnt' to a peer mount that has the |
89 | * same root dentry. If none is available than | 89 | * same root dentry. If none is available then |
90 | * slave it to anything that is available. | 90 | * slave it to anything that is available. |
91 | */ | 91 | */ |
92 | while ((peer_mnt = next_peer(peer_mnt)) != mnt && | 92 | while ((peer_mnt = next_peer(peer_mnt)) != mnt && |
@@ -147,6 +147,11 @@ void change_mnt_propagation(struct vfsmount *mnt, int type) | |||
147 | * get the next mount in the propagation tree. | 147 | * get the next mount in the propagation tree. |
148 | * @m: the mount seen last | 148 | * @m: the mount seen last |
149 | * @origin: the original mount from where the tree walk initiated | 149 | * @origin: the original mount from where the tree walk initiated |
150 | * | ||
151 | * Note that peer groups form contiguous segments of slave lists. | ||
152 | * We rely on that in get_source() to be able to find out if | ||
153 | * vfsmount found while iterating with propagation_next() is | ||
154 | * a peer of one we'd found earlier. | ||
150 | */ | 155 | */ |
151 | static struct vfsmount *propagation_next(struct vfsmount *m, | 156 | static struct vfsmount *propagation_next(struct vfsmount *m, |
152 | struct vfsmount *origin) | 157 | struct vfsmount *origin) |
@@ -186,10 +191,6 @@ static struct vfsmount *get_source(struct vfsmount *dest, | |||
186 | { | 191 | { |
187 | struct vfsmount *p_last_src = NULL; | 192 | struct vfsmount *p_last_src = NULL; |
188 | struct vfsmount *p_last_dest = NULL; | 193 | struct vfsmount *p_last_dest = NULL; |
189 | *type = CL_PROPAGATION; | ||
190 | |||
191 | if (IS_MNT_SHARED(dest)) | ||
192 | *type |= CL_MAKE_SHARED; | ||
193 | 194 | ||
194 | while (last_dest != dest->mnt_master) { | 195 | while (last_dest != dest->mnt_master) { |
195 | p_last_dest = last_dest; | 196 | p_last_dest = last_dest; |
@@ -202,13 +203,18 @@ static struct vfsmount *get_source(struct vfsmount *dest, | |||
202 | do { | 203 | do { |
203 | p_last_dest = next_peer(p_last_dest); | 204 | p_last_dest = next_peer(p_last_dest); |
204 | } while (IS_MNT_NEW(p_last_dest)); | 205 | } while (IS_MNT_NEW(p_last_dest)); |
206 | /* is that a peer of the earlier? */ | ||
207 | if (dest == p_last_dest) { | ||
208 | *type = CL_MAKE_SHARED; | ||
209 | return p_last_src; | ||
210 | } | ||
205 | } | 211 | } |
206 | 212 | /* slave of the earlier, then */ | |
207 | if (dest != p_last_dest) { | 213 | *type = CL_SLAVE; |
208 | *type |= CL_SLAVE; | 214 | /* beginning of peer group among the slaves? */ |
209 | return last_src; | 215 | if (IS_MNT_SHARED(dest)) |
210 | } else | 216 | *type |= CL_MAKE_SHARED; |
211 | return p_last_src; | 217 | return last_src; |
212 | } | 218 | } |
213 | 219 | ||
214 | /* | 220 | /* |
diff --git a/fs/pnode.h b/fs/pnode.h index 958665d662af..1ea4ae1efcd3 100644 --- a/fs/pnode.h +++ b/fs/pnode.h | |||
@@ -21,12 +21,11 @@ | |||
21 | #define CL_SLAVE 0x02 | 21 | #define CL_SLAVE 0x02 |
22 | #define CL_COPY_ALL 0x04 | 22 | #define CL_COPY_ALL 0x04 |
23 | #define CL_MAKE_SHARED 0x08 | 23 | #define CL_MAKE_SHARED 0x08 |
24 | #define CL_PROPAGATION 0x10 | 24 | #define CL_PRIVATE 0x10 |
25 | #define CL_PRIVATE 0x20 | ||
26 | 25 | ||
27 | static inline void set_mnt_shared(struct vfsmount *mnt) | 26 | static inline void set_mnt_shared(struct vfsmount *mnt) |
28 | { | 27 | { |
29 | mnt->mnt_flags &= ~MNT_PNODE_MASK; | 28 | mnt->mnt_flags &= ~MNT_SHARED_MASK; |
30 | mnt->mnt_flags |= MNT_SHARED; | 29 | mnt->mnt_flags |= MNT_SHARED; |
31 | } | 30 | } |
32 | 31 | ||
diff --git a/fs/proc/base.c b/fs/proc/base.c index 623e2ffb5d2b..a7310841c831 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -647,17 +647,11 @@ static int mounts_release(struct inode *inode, struct file *file) | |||
647 | static unsigned mounts_poll(struct file *file, poll_table *wait) | 647 | static unsigned mounts_poll(struct file *file, poll_table *wait) |
648 | { | 648 | { |
649 | struct proc_mounts *p = file->private_data; | 649 | struct proc_mounts *p = file->private_data; |
650 | struct mnt_namespace *ns = p->ns; | ||
651 | unsigned res = POLLIN | POLLRDNORM; | 650 | unsigned res = POLLIN | POLLRDNORM; |
652 | 651 | ||
653 | poll_wait(file, &ns->poll, wait); | 652 | poll_wait(file, &p->ns->poll, wait); |
654 | 653 | if (mnt_had_events(p)) | |
655 | spin_lock(&vfsmount_lock); | ||
656 | if (p->event != ns->event) { | ||
657 | p->event = ns->event; | ||
658 | res |= POLLERR | POLLPRI; | 654 | res |= POLLERR | POLLPRI; |
659 | } | ||
660 | spin_unlock(&vfsmount_lock); | ||
661 | 655 | ||
662 | return res; | 656 | return res; |
663 | } | 657 | } |
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 480cb1065eec..9580abeadeb3 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -662,6 +662,7 @@ struct proc_dir_entry *proc_symlink(const char *name, | |||
662 | } | 662 | } |
663 | return ent; | 663 | return ent; |
664 | } | 664 | } |
665 | EXPORT_SYMBOL(proc_symlink); | ||
665 | 666 | ||
666 | struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode, | 667 | struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode, |
667 | struct proc_dir_entry *parent) | 668 | struct proc_dir_entry *parent) |
@@ -700,6 +701,7 @@ struct proc_dir_entry *proc_mkdir(const char *name, | |||
700 | { | 701 | { |
701 | return proc_mkdir_mode(name, S_IRUGO | S_IXUGO, parent); | 702 | return proc_mkdir_mode(name, S_IRUGO | S_IXUGO, parent); |
702 | } | 703 | } |
704 | EXPORT_SYMBOL(proc_mkdir); | ||
703 | 705 | ||
704 | struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, | 706 | struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, |
705 | struct proc_dir_entry *parent) | 707 | struct proc_dir_entry *parent) |
@@ -728,6 +730,7 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, | |||
728 | } | 730 | } |
729 | return ent; | 731 | return ent; |
730 | } | 732 | } |
733 | EXPORT_SYMBOL(create_proc_entry); | ||
731 | 734 | ||
732 | struct proc_dir_entry *proc_create_data(const char *name, mode_t mode, | 735 | struct proc_dir_entry *proc_create_data(const char *name, mode_t mode, |
733 | struct proc_dir_entry *parent, | 736 | struct proc_dir_entry *parent, |
@@ -762,6 +765,7 @@ out_free: | |||
762 | out: | 765 | out: |
763 | return NULL; | 766 | return NULL; |
764 | } | 767 | } |
768 | EXPORT_SYMBOL(proc_create_data); | ||
765 | 769 | ||
766 | static void free_proc_entry(struct proc_dir_entry *de) | 770 | static void free_proc_entry(struct proc_dir_entry *de) |
767 | { | 771 | { |
@@ -853,3 +857,4 @@ continue_removing: | |||
853 | de->parent->name, de->name, de->subdir->name); | 857 | de->parent->name, de->name, de->subdir->name); |
854 | pde_put(de); | 858 | pde_put(de); |
855 | } | 859 | } |
860 | EXPORT_SYMBOL(remove_proc_entry); | ||
diff --git a/fs/proc/root.c b/fs/proc/root.c index b080b791d9e3..757c069f2a65 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c | |||
@@ -220,9 +220,3 @@ void pid_ns_release_proc(struct pid_namespace *ns) | |||
220 | { | 220 | { |
221 | mntput(ns->proc_mnt); | 221 | mntput(ns->proc_mnt); |
222 | } | 222 | } |
223 | |||
224 | EXPORT_SYMBOL(proc_symlink); | ||
225 | EXPORT_SYMBOL(proc_mkdir); | ||
226 | EXPORT_SYMBOL(create_proc_entry); | ||
227 | EXPORT_SYMBOL(proc_create_data); | ||
228 | EXPORT_SYMBOL(remove_proc_entry); | ||
diff --git a/fs/super.c b/fs/super.c index aff046b0fe78..f35ac6022109 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -568,7 +568,7 @@ out: | |||
568 | int do_remount_sb(struct super_block *sb, int flags, void *data, int force) | 568 | int do_remount_sb(struct super_block *sb, int flags, void *data, int force) |
569 | { | 569 | { |
570 | int retval; | 570 | int retval; |
571 | int remount_rw; | 571 | int remount_rw, remount_ro; |
572 | 572 | ||
573 | if (sb->s_frozen != SB_UNFROZEN) | 573 | if (sb->s_frozen != SB_UNFROZEN) |
574 | return -EBUSY; | 574 | return -EBUSY; |
@@ -583,9 +583,12 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) | |||
583 | shrink_dcache_sb(sb); | 583 | shrink_dcache_sb(sb); |
584 | sync_filesystem(sb); | 584 | sync_filesystem(sb); |
585 | 585 | ||
586 | remount_ro = (flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY); | ||
587 | remount_rw = !(flags & MS_RDONLY) && (sb->s_flags & MS_RDONLY); | ||
588 | |||
586 | /* If we are remounting RDONLY and current sb is read/write, | 589 | /* If we are remounting RDONLY and current sb is read/write, |
587 | make sure there are no rw files opened */ | 590 | make sure there are no rw files opened */ |
588 | if ((flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY)) { | 591 | if (remount_ro) { |
589 | if (force) | 592 | if (force) |
590 | mark_files_ro(sb); | 593 | mark_files_ro(sb); |
591 | else if (!fs_may_remount_ro(sb)) | 594 | else if (!fs_may_remount_ro(sb)) |
@@ -594,7 +597,6 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) | |||
594 | if (retval < 0 && retval != -ENOSYS) | 597 | if (retval < 0 && retval != -ENOSYS) |
595 | return -EBUSY; | 598 | return -EBUSY; |
596 | } | 599 | } |
597 | remount_rw = !(flags & MS_RDONLY) && (sb->s_flags & MS_RDONLY); | ||
598 | 600 | ||
599 | if (sb->s_op->remount_fs) { | 601 | if (sb->s_op->remount_fs) { |
600 | retval = sb->s_op->remount_fs(sb, &flags, data); | 602 | retval = sb->s_op->remount_fs(sb, &flags, data); |
@@ -604,6 +606,16 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) | |||
604 | sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK); | 606 | sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK); |
605 | if (remount_rw) | 607 | if (remount_rw) |
606 | vfs_dq_quota_on_remount(sb); | 608 | vfs_dq_quota_on_remount(sb); |
609 | /* | ||
610 | * Some filesystems modify their metadata via some other path than the | ||
611 | * bdev buffer cache (eg. use a private mapping, or directories in | ||
612 | * pagecache, etc). Also file data modifications go via their own | ||
613 | * mappings. So If we try to mount readonly then copy the filesystem | ||
614 | * from bdev, we could get stale data, so invalidate it to give a best | ||
615 | * effort at coherency. | ||
616 | */ | ||
617 | if (remount_ro && sb->s_bdev) | ||
618 | invalidate_bdev(sb->s_bdev); | ||
607 | return 0; | 619 | return 0; |
608 | } | 620 | } |
609 | 621 | ||
@@ -925,6 +937,9 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void | |||
925 | if (!mnt) | 937 | if (!mnt) |
926 | goto out; | 938 | goto out; |
927 | 939 | ||
940 | if (flags & MS_KERNMOUNT) | ||
941 | mnt->mnt_flags = MNT_INTERNAL; | ||
942 | |||
928 | if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) { | 943 | if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) { |
929 | secdata = alloc_secdata(); | 944 | secdata = alloc_secdata(); |
930 | if (!secdata) | 945 | if (!secdata) |
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index 82372e332f08..b2d96f45c12b 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c | |||
@@ -547,7 +547,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
547 | } | 547 | } |
548 | 548 | ||
549 | if (epos.offset + (2 * adsize) > sb->s_blocksize) { | 549 | if (epos.offset + (2 * adsize) > sb->s_blocksize) { |
550 | char *sptr, *dptr; | 550 | unsigned char *sptr, *dptr; |
551 | int loffset; | 551 | int loffset; |
552 | 552 | ||
553 | brelse(oepos.bh); | 553 | brelse(oepos.bh); |
diff --git a/fs/udf/dir.c b/fs/udf/dir.c index 61d9a76a3a69..f0f2a436251e 100644 --- a/fs/udf/dir.c +++ b/fs/udf/dir.c | |||
@@ -45,8 +45,8 @@ static int do_udf_readdir(struct inode *dir, struct file *filp, | |||
45 | int block, iblock; | 45 | int block, iblock; |
46 | loff_t nf_pos = (filp->f_pos - 1) << 2; | 46 | loff_t nf_pos = (filp->f_pos - 1) << 2; |
47 | int flen; | 47 | int flen; |
48 | char *fname = NULL; | 48 | unsigned char *fname = NULL; |
49 | char *nameptr; | 49 | unsigned char *nameptr; |
50 | uint16_t liu; | 50 | uint16_t liu; |
51 | uint8_t lfi; | 51 | uint8_t lfi; |
52 | loff_t size = udf_ext0_offset(dir) + dir->i_size; | 52 | loff_t size = udf_ext0_offset(dir) + dir->i_size; |
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index f90231eb2916..378a7592257c 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -1672,7 +1672,7 @@ int8_t udf_add_aext(struct inode *inode, struct extent_position *epos, | |||
1672 | return -1; | 1672 | return -1; |
1673 | 1673 | ||
1674 | if (epos->offset + (2 * adsize) > inode->i_sb->s_blocksize) { | 1674 | if (epos->offset + (2 * adsize) > inode->i_sb->s_blocksize) { |
1675 | char *sptr, *dptr; | 1675 | unsigned char *sptr, *dptr; |
1676 | struct buffer_head *nbh; | 1676 | struct buffer_head *nbh; |
1677 | int err, loffset; | 1677 | int err, loffset; |
1678 | struct kernel_lb_addr obloc = epos->block; | 1678 | struct kernel_lb_addr obloc = epos->block; |
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index cd2115060fdc..7c56ff00cd53 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -34,8 +34,8 @@ | |||
34 | #include <linux/crc-itu-t.h> | 34 | #include <linux/crc-itu-t.h> |
35 | #include <linux/exportfs.h> | 35 | #include <linux/exportfs.h> |
36 | 36 | ||
37 | static inline int udf_match(int len1, const char *name1, int len2, | 37 | static inline int udf_match(int len1, const unsigned char *name1, int len2, |
38 | const char *name2) | 38 | const unsigned char *name2) |
39 | { | 39 | { |
40 | if (len1 != len2) | 40 | if (len1 != len2) |
41 | return 0; | 41 | return 0; |
@@ -142,15 +142,15 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, | |||
142 | } | 142 | } |
143 | 143 | ||
144 | static struct fileIdentDesc *udf_find_entry(struct inode *dir, | 144 | static struct fileIdentDesc *udf_find_entry(struct inode *dir, |
145 | struct qstr *child, | 145 | const struct qstr *child, |
146 | struct udf_fileident_bh *fibh, | 146 | struct udf_fileident_bh *fibh, |
147 | struct fileIdentDesc *cfi) | 147 | struct fileIdentDesc *cfi) |
148 | { | 148 | { |
149 | struct fileIdentDesc *fi = NULL; | 149 | struct fileIdentDesc *fi = NULL; |
150 | loff_t f_pos; | 150 | loff_t f_pos; |
151 | int block, flen; | 151 | int block, flen; |
152 | char *fname = NULL; | 152 | unsigned char *fname = NULL; |
153 | char *nameptr; | 153 | unsigned char *nameptr; |
154 | uint8_t lfi; | 154 | uint8_t lfi; |
155 | uint16_t liu; | 155 | uint16_t liu; |
156 | loff_t size; | 156 | loff_t size; |
@@ -308,7 +308,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
308 | { | 308 | { |
309 | struct super_block *sb = dir->i_sb; | 309 | struct super_block *sb = dir->i_sb; |
310 | struct fileIdentDesc *fi = NULL; | 310 | struct fileIdentDesc *fi = NULL; |
311 | char *name = NULL; | 311 | unsigned char *name = NULL; |
312 | int namelen; | 312 | int namelen; |
313 | loff_t f_pos; | 313 | loff_t f_pos; |
314 | loff_t size = udf_ext0_offset(dir) + dir->i_size; | 314 | loff_t size = udf_ext0_offset(dir) + dir->i_size; |
@@ -885,16 +885,16 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
885 | { | 885 | { |
886 | struct inode *inode; | 886 | struct inode *inode; |
887 | struct pathComponent *pc; | 887 | struct pathComponent *pc; |
888 | char *compstart; | 888 | const char *compstart; |
889 | struct udf_fileident_bh fibh; | 889 | struct udf_fileident_bh fibh; |
890 | struct extent_position epos = {}; | 890 | struct extent_position epos = {}; |
891 | int eoffset, elen = 0; | 891 | int eoffset, elen = 0; |
892 | struct fileIdentDesc *fi; | 892 | struct fileIdentDesc *fi; |
893 | struct fileIdentDesc cfi; | 893 | struct fileIdentDesc cfi; |
894 | char *ea; | 894 | uint8_t *ea; |
895 | int err; | 895 | int err; |
896 | int block; | 896 | int block; |
897 | char *name = NULL; | 897 | unsigned char *name = NULL; |
898 | int namelen; | 898 | int namelen; |
899 | struct buffer_head *bh; | 899 | struct buffer_head *bh; |
900 | struct udf_inode_info *iinfo; | 900 | struct udf_inode_info *iinfo; |
@@ -970,7 +970,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
970 | 970 | ||
971 | pc = (struct pathComponent *)(ea + elen); | 971 | pc = (struct pathComponent *)(ea + elen); |
972 | 972 | ||
973 | compstart = (char *)symname; | 973 | compstart = symname; |
974 | 974 | ||
975 | do { | 975 | do { |
976 | symname++; | 976 | symname++; |
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c index c3265e1385d4..852e91845688 100644 --- a/fs/udf/symlink.c +++ b/fs/udf/symlink.c | |||
@@ -32,12 +32,12 @@ | |||
32 | #include <linux/buffer_head.h> | 32 | #include <linux/buffer_head.h> |
33 | #include "udf_i.h" | 33 | #include "udf_i.h" |
34 | 34 | ||
35 | static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, | 35 | static void udf_pc_to_char(struct super_block *sb, unsigned char *from, |
36 | char *to) | 36 | int fromlen, unsigned char *to) |
37 | { | 37 | { |
38 | struct pathComponent *pc; | 38 | struct pathComponent *pc; |
39 | int elen = 0; | 39 | int elen = 0; |
40 | char *p = to; | 40 | unsigned char *p = to; |
41 | 41 | ||
42 | while (elen < fromlen) { | 42 | while (elen < fromlen) { |
43 | pc = (struct pathComponent *)(from + elen); | 43 | pc = (struct pathComponent *)(from + elen); |
@@ -75,9 +75,9 @@ static int udf_symlink_filler(struct file *file, struct page *page) | |||
75 | { | 75 | { |
76 | struct inode *inode = page->mapping->host; | 76 | struct inode *inode = page->mapping->host; |
77 | struct buffer_head *bh = NULL; | 77 | struct buffer_head *bh = NULL; |
78 | char *symlink; | 78 | unsigned char *symlink; |
79 | int err = -EIO; | 79 | int err = -EIO; |
80 | char *p = kmap(page); | 80 | unsigned char *p = kmap(page); |
81 | struct udf_inode_info *iinfo; | 81 | struct udf_inode_info *iinfo; |
82 | 82 | ||
83 | lock_kernel(); | 83 | lock_kernel(); |
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 22af68f8b682..317a0d444f6b 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c | |||
@@ -31,7 +31,7 @@ | |||
31 | * len <= UFS_MAXNAMLEN and de != NULL are guaranteed by caller. | 31 | * len <= UFS_MAXNAMLEN and de != NULL are guaranteed by caller. |
32 | */ | 32 | */ |
33 | static inline int ufs_match(struct super_block *sb, int len, | 33 | static inline int ufs_match(struct super_block *sb, int len, |
34 | const char * const name, struct ufs_dir_entry * de) | 34 | const unsigned char *name, struct ufs_dir_entry *de) |
35 | { | 35 | { |
36 | if (len != ufs_get_de_namlen(sb, de)) | 36 | if (len != ufs_get_de_namlen(sb, de)) |
37 | return 0; | 37 | return 0; |
@@ -70,7 +70,7 @@ static inline unsigned long ufs_dir_pages(struct inode *inode) | |||
70 | return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT; | 70 | return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT; |
71 | } | 71 | } |
72 | 72 | ||
73 | ino_t ufs_inode_by_name(struct inode *dir, struct qstr *qstr) | 73 | ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr) |
74 | { | 74 | { |
75 | ino_t res = 0; | 75 | ino_t res = 0; |
76 | struct ufs_dir_entry *de; | 76 | struct ufs_dir_entry *de; |
@@ -249,11 +249,11 @@ struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct page **p) | |||
249 | * (as a parameter - res_dir). Page is returned mapped and unlocked. | 249 | * (as a parameter - res_dir). Page is returned mapped and unlocked. |
250 | * Entry is guaranteed to be valid. | 250 | * Entry is guaranteed to be valid. |
251 | */ | 251 | */ |
252 | struct ufs_dir_entry *ufs_find_entry(struct inode *dir, struct qstr *qstr, | 252 | struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr, |
253 | struct page **res_page) | 253 | struct page **res_page) |
254 | { | 254 | { |
255 | struct super_block *sb = dir->i_sb; | 255 | struct super_block *sb = dir->i_sb; |
256 | const char *name = qstr->name; | 256 | const unsigned char *name = qstr->name; |
257 | int namelen = qstr->len; | 257 | int namelen = qstr->len; |
258 | unsigned reclen = UFS_DIR_REC_LEN(namelen); | 258 | unsigned reclen = UFS_DIR_REC_LEN(namelen); |
259 | unsigned long start, n; | 259 | unsigned long start, n; |
@@ -313,7 +313,7 @@ found: | |||
313 | int ufs_add_link(struct dentry *dentry, struct inode *inode) | 313 | int ufs_add_link(struct dentry *dentry, struct inode *inode) |
314 | { | 314 | { |
315 | struct inode *dir = dentry->d_parent->d_inode; | 315 | struct inode *dir = dentry->d_parent->d_inode; |
316 | const char *name = dentry->d_name.name; | 316 | const unsigned char *name = dentry->d_name.name; |
317 | int namelen = dentry->d_name.len; | 317 | int namelen = dentry->d_name.len; |
318 | struct super_block *sb = dir->i_sb; | 318 | struct super_block *sb = dir->i_sb; |
319 | unsigned reclen = UFS_DIR_REC_LEN(namelen); | 319 | unsigned reclen = UFS_DIR_REC_LEN(namelen); |
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index 0b4c39bc0d9e..01d0e2a3b230 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h | |||
@@ -86,9 +86,9 @@ extern void ufs_put_cylinder (struct super_block *, unsigned); | |||
86 | /* dir.c */ | 86 | /* dir.c */ |
87 | extern const struct inode_operations ufs_dir_inode_operations; | 87 | extern const struct inode_operations ufs_dir_inode_operations; |
88 | extern int ufs_add_link (struct dentry *, struct inode *); | 88 | extern int ufs_add_link (struct dentry *, struct inode *); |
89 | extern ino_t ufs_inode_by_name(struct inode *, struct qstr *); | 89 | extern ino_t ufs_inode_by_name(struct inode *, const struct qstr *); |
90 | extern int ufs_make_empty(struct inode *, struct inode *); | 90 | extern int ufs_make_empty(struct inode *, struct inode *); |
91 | extern struct ufs_dir_entry *ufs_find_entry(struct inode *, struct qstr *, struct page **); | 91 | extern struct ufs_dir_entry *ufs_find_entry(struct inode *, const struct qstr *, struct page **); |
92 | extern int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page *); | 92 | extern int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page *); |
93 | extern int ufs_empty_dir (struct inode *); | 93 | extern int ufs_empty_dir (struct inode *); |
94 | extern struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **); | 94 | extern struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **); |
diff --git a/include/linux/audit.h b/include/linux/audit.h index 3c7a358241a7..f391d45c8aea 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h | |||
@@ -424,7 +424,7 @@ extern void audit_syscall_exit(int failed, long return_code); | |||
424 | extern void __audit_getname(const char *name); | 424 | extern void __audit_getname(const char *name); |
425 | extern void audit_putname(const char *name); | 425 | extern void audit_putname(const char *name); |
426 | extern void __audit_inode(const char *name, const struct dentry *dentry); | 426 | extern void __audit_inode(const char *name, const struct dentry *dentry); |
427 | extern void __audit_inode_child(const char *dname, const struct dentry *dentry, | 427 | extern void __audit_inode_child(const struct dentry *dentry, |
428 | const struct inode *parent); | 428 | const struct inode *parent); |
429 | extern void __audit_ptrace(struct task_struct *t); | 429 | extern void __audit_ptrace(struct task_struct *t); |
430 | 430 | ||
@@ -442,11 +442,10 @@ static inline void audit_inode(const char *name, const struct dentry *dentry) { | |||
442 | if (unlikely(!audit_dummy_context())) | 442 | if (unlikely(!audit_dummy_context())) |
443 | __audit_inode(name, dentry); | 443 | __audit_inode(name, dentry); |
444 | } | 444 | } |
445 | static inline void audit_inode_child(const char *dname, | 445 | static inline void audit_inode_child(const struct dentry *dentry, |
446 | const struct dentry *dentry, | ||
447 | const struct inode *parent) { | 446 | const struct inode *parent) { |
448 | if (unlikely(!audit_dummy_context())) | 447 | if (unlikely(!audit_dummy_context())) |
449 | __audit_inode_child(dname, dentry, parent); | 448 | __audit_inode_child(dentry, parent); |
450 | } | 449 | } |
451 | void audit_core_dumps(long signr); | 450 | void audit_core_dumps(long signr); |
452 | 451 | ||
@@ -544,9 +543,9 @@ extern int audit_signals; | |||
544 | #define audit_getname(n) do { ; } while (0) | 543 | #define audit_getname(n) do { ; } while (0) |
545 | #define audit_putname(n) do { ; } while (0) | 544 | #define audit_putname(n) do { ; } while (0) |
546 | #define __audit_inode(n,d) do { ; } while (0) | 545 | #define __audit_inode(n,d) do { ; } while (0) |
547 | #define __audit_inode_child(d,i,p) do { ; } while (0) | 546 | #define __audit_inode_child(i,p) do { ; } while (0) |
548 | #define audit_inode(n,d) do { ; } while (0) | 547 | #define audit_inode(n,d) do { ; } while (0) |
549 | #define audit_inode_child(d,i,p) do { ; } while (0) | 548 | #define audit_inode_child(i,p) do { ; } while (0) |
550 | #define audit_core_dumps(i) do { ; } while (0) | 549 | #define audit_core_dumps(i) do { ; } while (0) |
551 | #define auditsc_get_stamp(c,t,s) (0) | 550 | #define auditsc_get_stamp(c,t,s) (0) |
552 | #define audit_get_loginuid(t) (-1) | 551 | #define audit_get_loginuid(t) (-1) |
diff --git a/include/linux/fs.h b/include/linux/fs.h index ebb1cd5bc241..5b3182c7eb5f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1305,6 +1305,8 @@ extern int send_sigurg(struct fown_struct *fown); | |||
1305 | #define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */ | 1305 | #define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */ |
1306 | #define MNT_DETACH 0x00000002 /* Just detach from the tree */ | 1306 | #define MNT_DETACH 0x00000002 /* Just detach from the tree */ |
1307 | #define MNT_EXPIRE 0x00000004 /* Mark for expiry */ | 1307 | #define MNT_EXPIRE 0x00000004 /* Mark for expiry */ |
1308 | #define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */ | ||
1309 | #define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */ | ||
1308 | 1310 | ||
1309 | extern struct list_head super_blocks; | 1311 | extern struct list_head super_blocks; |
1310 | extern spinlock_t sb_lock; | 1312 | extern spinlock_t sb_lock; |
@@ -1314,9 +1316,9 @@ extern spinlock_t sb_lock; | |||
1314 | struct super_block { | 1316 | struct super_block { |
1315 | struct list_head s_list; /* Keep this first */ | 1317 | struct list_head s_list; /* Keep this first */ |
1316 | dev_t s_dev; /* search index; _not_ kdev_t */ | 1318 | dev_t s_dev; /* search index; _not_ kdev_t */ |
1317 | unsigned long s_blocksize; | ||
1318 | unsigned char s_blocksize_bits; | ||
1319 | unsigned char s_dirt; | 1319 | unsigned char s_dirt; |
1320 | unsigned char s_blocksize_bits; | ||
1321 | unsigned long s_blocksize; | ||
1320 | loff_t s_maxbytes; /* Max file size */ | 1322 | loff_t s_maxbytes; /* Max file size */ |
1321 | struct file_system_type *s_type; | 1323 | struct file_system_type *s_type; |
1322 | const struct super_operations *s_op; | 1324 | const struct super_operations *s_op; |
@@ -1357,16 +1359,16 @@ struct super_block { | |||
1357 | void *s_fs_info; /* Filesystem private info */ | 1359 | void *s_fs_info; /* Filesystem private info */ |
1358 | fmode_t s_mode; | 1360 | fmode_t s_mode; |
1359 | 1361 | ||
1362 | /* Granularity of c/m/atime in ns. | ||
1363 | Cannot be worse than a second */ | ||
1364 | u32 s_time_gran; | ||
1365 | |||
1360 | /* | 1366 | /* |
1361 | * The next field is for VFS *only*. No filesystems have any business | 1367 | * The next field is for VFS *only*. No filesystems have any business |
1362 | * even looking at it. You had been warned. | 1368 | * even looking at it. You had been warned. |
1363 | */ | 1369 | */ |
1364 | struct mutex s_vfs_rename_mutex; /* Kludge */ | 1370 | struct mutex s_vfs_rename_mutex; /* Kludge */ |
1365 | 1371 | ||
1366 | /* Granularity of c/m/atime in ns. | ||
1367 | Cannot be worse than a second */ | ||
1368 | u32 s_time_gran; | ||
1369 | |||
1370 | /* | 1372 | /* |
1371 | * Filesystem subtype. If non-empty the filesystem type field | 1373 | * Filesystem subtype. If non-empty the filesystem type field |
1372 | * in /proc/mounts will be "type.subtype" | 1374 | * in /proc/mounts will be "type.subtype" |
@@ -1794,7 +1796,8 @@ extern int may_umount(struct vfsmount *); | |||
1794 | extern long do_mount(char *, char *, char *, unsigned long, void *); | 1796 | extern long do_mount(char *, char *, char *, unsigned long, void *); |
1795 | extern struct vfsmount *collect_mounts(struct path *); | 1797 | extern struct vfsmount *collect_mounts(struct path *); |
1796 | extern void drop_collected_mounts(struct vfsmount *); | 1798 | extern void drop_collected_mounts(struct vfsmount *); |
1797 | 1799 | extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, | |
1800 | struct vfsmount *); | ||
1798 | extern int vfs_statfs(struct dentry *, struct kstatfs *); | 1801 | extern int vfs_statfs(struct dentry *, struct kstatfs *); |
1799 | 1802 | ||
1800 | extern int current_umask(void); | 1803 | extern int current_umask(void); |
@@ -2058,12 +2061,6 @@ extern int invalidate_inodes(struct super_block *); | |||
2058 | unsigned long invalidate_mapping_pages(struct address_space *mapping, | 2061 | unsigned long invalidate_mapping_pages(struct address_space *mapping, |
2059 | pgoff_t start, pgoff_t end); | 2062 | pgoff_t start, pgoff_t end); |
2060 | 2063 | ||
2061 | static inline unsigned long __deprecated | ||
2062 | invalidate_inode_pages(struct address_space *mapping) | ||
2063 | { | ||
2064 | return invalidate_mapping_pages(mapping, 0, ~0UL); | ||
2065 | } | ||
2066 | |||
2067 | static inline void invalidate_remote_inode(struct inode *inode) | 2064 | static inline void invalidate_remote_inode(struct inode *inode) |
2068 | { | 2065 | { |
2069 | if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || | 2066 | if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || |
@@ -2132,6 +2129,7 @@ extern struct file * open_exec(const char *); | |||
2132 | 2129 | ||
2133 | /* fs/dcache.c -- generic fs support functions */ | 2130 | /* fs/dcache.c -- generic fs support functions */ |
2134 | extern int is_subdir(struct dentry *, struct dentry *); | 2131 | extern int is_subdir(struct dentry *, struct dentry *); |
2132 | extern int path_is_under(struct path *, struct path *); | ||
2135 | extern ino_t find_inode_number(struct dentry *, struct qstr *); | 2133 | extern ino_t find_inode_number(struct dentry *, struct qstr *); |
2136 | 2134 | ||
2137 | #include <linux/err.h> | 2135 | #include <linux/err.h> |
@@ -2340,8 +2338,6 @@ extern int simple_rename(struct inode *, struct dentry *, struct inode *, struct | |||
2340 | extern int simple_sync_file(struct file *, struct dentry *, int); | 2338 | extern int simple_sync_file(struct file *, struct dentry *, int); |
2341 | extern int simple_empty(struct dentry *); | 2339 | extern int simple_empty(struct dentry *); |
2342 | extern int simple_readpage(struct file *file, struct page *page); | 2340 | extern int simple_readpage(struct file *file, struct page *page); |
2343 | extern int simple_prepare_write(struct file *file, struct page *page, | ||
2344 | unsigned offset, unsigned to); | ||
2345 | extern int simple_write_begin(struct file *file, struct address_space *mapping, | 2341 | extern int simple_write_begin(struct file *file, struct address_space *mapping, |
2346 | loff_t pos, unsigned len, unsigned flags, | 2342 | loff_t pos, unsigned len, unsigned flags, |
2347 | struct page **pagep, void **fsdata); | 2343 | struct page **pagep, void **fsdata); |
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 936f9aa8bb97..df8fd9a3b214 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h | |||
@@ -65,7 +65,7 @@ static inline void fsnotify_link_count(struct inode *inode) | |||
65 | * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir | 65 | * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir |
66 | */ | 66 | */ |
67 | static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, | 67 | static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, |
68 | const char *old_name, const char *new_name, | 68 | const char *old_name, |
69 | int isdir, struct inode *target, struct dentry *moved) | 69 | int isdir, struct inode *target, struct dentry *moved) |
70 | { | 70 | { |
71 | struct inode *source = moved->d_inode; | 71 | struct inode *source = moved->d_inode; |
@@ -73,6 +73,7 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, | |||
73 | u32 fs_cookie = fsnotify_get_cookie(); | 73 | u32 fs_cookie = fsnotify_get_cookie(); |
74 | __u32 old_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_FROM); | 74 | __u32 old_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_FROM); |
75 | __u32 new_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_TO); | 75 | __u32 new_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_TO); |
76 | const char *new_name = moved->d_name.name; | ||
76 | 77 | ||
77 | if (old_dir == new_dir) | 78 | if (old_dir == new_dir) |
78 | old_dir_mask |= FS_DN_RENAME; | 79 | old_dir_mask |= FS_DN_RENAME; |
@@ -103,7 +104,7 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, | |||
103 | inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL); | 104 | inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL); |
104 | fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0); | 105 | fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0); |
105 | } | 106 | } |
106 | audit_inode_child(new_name, moved, new_dir); | 107 | audit_inode_child(moved, new_dir); |
107 | } | 108 | } |
108 | 109 | ||
109 | /* | 110 | /* |
@@ -146,7 +147,7 @@ static inline void fsnotify_create(struct inode *inode, struct dentry *dentry) | |||
146 | { | 147 | { |
147 | inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name, | 148 | inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name, |
148 | dentry->d_inode); | 149 | dentry->d_inode); |
149 | audit_inode_child(dentry->d_name.name, dentry, inode); | 150 | audit_inode_child(dentry, inode); |
150 | 151 | ||
151 | fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); | 152 | fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); |
152 | } | 153 | } |
@@ -161,7 +162,7 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct | |||
161 | inotify_inode_queue_event(dir, IN_CREATE, 0, new_dentry->d_name.name, | 162 | inotify_inode_queue_event(dir, IN_CREATE, 0, new_dentry->d_name.name, |
162 | inode); | 163 | inode); |
163 | fsnotify_link_count(inode); | 164 | fsnotify_link_count(inode); |
164 | audit_inode_child(new_dentry->d_name.name, new_dentry, dir); | 165 | audit_inode_child(new_dentry, dir); |
165 | 166 | ||
166 | fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0); | 167 | fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0); |
167 | } | 168 | } |
@@ -175,7 +176,7 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) | |||
175 | struct inode *d_inode = dentry->d_inode; | 176 | struct inode *d_inode = dentry->d_inode; |
176 | 177 | ||
177 | inotify_inode_queue_event(inode, mask, 0, dentry->d_name.name, d_inode); | 178 | inotify_inode_queue_event(inode, mask, 0, dentry->d_name.name, d_inode); |
178 | audit_inode_child(dentry->d_name.name, dentry, inode); | 179 | audit_inode_child(dentry, inode); |
179 | 180 | ||
180 | fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); | 181 | fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); |
181 | } | 182 | } |
diff --git a/include/linux/magic.h b/include/linux/magic.h index 76285e01b39e..eb9800f05782 100644 --- a/include/linux/magic.h +++ b/include/linux/magic.h | |||
@@ -52,7 +52,6 @@ | |||
52 | #define CGROUP_SUPER_MAGIC 0x27e0eb | 52 | #define CGROUP_SUPER_MAGIC 0x27e0eb |
53 | 53 | ||
54 | #define FUTEXFS_SUPER_MAGIC 0xBAD1DEA | 54 | #define FUTEXFS_SUPER_MAGIC 0xBAD1DEA |
55 | #define INOTIFYFS_SUPER_MAGIC 0x2BAD1DEA | ||
56 | 55 | ||
57 | #define STACK_END_MAGIC 0x57AC6E9D | 56 | #define STACK_END_MAGIC 0x57AC6E9D |
58 | 57 | ||
diff --git a/include/linux/mnt_namespace.h b/include/linux/mnt_namespace.h index d74785c2393a..0b89efc6f215 100644 --- a/include/linux/mnt_namespace.h +++ b/include/linux/mnt_namespace.h | |||
@@ -35,6 +35,7 @@ static inline void get_mnt_ns(struct mnt_namespace *ns) | |||
35 | extern const struct seq_operations mounts_op; | 35 | extern const struct seq_operations mounts_op; |
36 | extern const struct seq_operations mountinfo_op; | 36 | extern const struct seq_operations mountinfo_op; |
37 | extern const struct seq_operations mountstats_op; | 37 | extern const struct seq_operations mountstats_op; |
38 | extern int mnt_had_events(struct proc_mounts *); | ||
38 | 39 | ||
39 | #endif | 40 | #endif |
40 | #endif | 41 | #endif |
diff --git a/include/linux/mount.h b/include/linux/mount.h index b5f43a34ef88..4bd05474d11d 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h | |||
@@ -34,7 +34,18 @@ struct mnt_namespace; | |||
34 | 34 | ||
35 | #define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */ | 35 | #define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */ |
36 | #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */ | 36 | #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */ |
37 | #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */ | 37 | /* |
38 | * MNT_SHARED_MASK is the set of flags that should be cleared when a | ||
39 | * mount becomes shared. Currently, this is only the flag that says a | ||
40 | * mount cannot be bind mounted, since this is how we create a mount | ||
41 | * that shares events with another mount. If you add a new MNT_* | ||
42 | * flag, consider how it interacts with shared mounts. | ||
43 | */ | ||
44 | #define MNT_SHARED_MASK (MNT_UNBINDABLE) | ||
45 | #define MNT_PROPAGATION_MASK (MNT_SHARED | MNT_UNBINDABLE) | ||
46 | |||
47 | |||
48 | #define MNT_INTERNAL 0x4000 | ||
38 | 49 | ||
39 | struct vfsmount { | 50 | struct vfsmount { |
40 | struct list_head mnt_hash; | 51 | struct list_head mnt_hash; |
@@ -123,7 +134,6 @@ extern int do_add_mount(struct vfsmount *newmnt, struct path *path, | |||
123 | 134 | ||
124 | extern void mark_mounts_for_expiry(struct list_head *mounts); | 135 | extern void mark_mounts_for_expiry(struct list_head *mounts); |
125 | 136 | ||
126 | extern spinlock_t vfsmount_lock; | ||
127 | extern dev_t name_to_dev_t(char *name); | 137 | extern dev_t name_to_dev_t(char *name); |
128 | 138 | ||
129 | #endif /* _LINUX_MOUNT_H */ | 139 | #endif /* _LINUX_MOUNT_H */ |
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index 614241b5200c..2b108538d0d9 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c | |||
@@ -30,11 +30,7 @@ static int __init do_linuxrc(void * shell) | |||
30 | extern char * envp_init[]; | 30 | extern char * envp_init[]; |
31 | 31 | ||
32 | sys_close(old_fd);sys_close(root_fd); | 32 | sys_close(old_fd);sys_close(root_fd); |
33 | sys_close(0);sys_close(1);sys_close(2); | ||
34 | sys_setsid(); | 33 | sys_setsid(); |
35 | (void) sys_open("/dev/console",O_RDWR,0); | ||
36 | (void) sys_dup(0); | ||
37 | (void) sys_dup(0); | ||
38 | return kernel_execve(shell, argv, envp_init); | 34 | return kernel_execve(shell, argv, envp_init); |
39 | } | 35 | } |
40 | 36 | ||
diff --git a/init/main.c b/init/main.c index 18098153c331..40aaa020cd68 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -822,11 +822,6 @@ static noinline int init_post(void) | |||
822 | system_state = SYSTEM_RUNNING; | 822 | system_state = SYSTEM_RUNNING; |
823 | numa_default_policy(); | 823 | numa_default_policy(); |
824 | 824 | ||
825 | if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) | ||
826 | printk(KERN_WARNING "Warning: unable to open an initial console.\n"); | ||
827 | |||
828 | (void) sys_dup(0); | ||
829 | (void) sys_dup(0); | ||
830 | 825 | ||
831 | current->signal->flags |= SIGNAL_UNKILLABLE; | 826 | current->signal->flags |= SIGNAL_UNKILLABLE; |
832 | 827 | ||
@@ -889,6 +884,12 @@ static int __init kernel_init(void * unused) | |||
889 | 884 | ||
890 | do_basic_setup(); | 885 | do_basic_setup(); |
891 | 886 | ||
887 | /* Open the /dev/console on the rootfs, this should never fail */ | ||
888 | if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) | ||
889 | printk(KERN_WARNING "Warning: unable to open an initial console.\n"); | ||
890 | |||
891 | (void) sys_dup(0); | ||
892 | (void) sys_dup(0); | ||
892 | /* | 893 | /* |
893 | * check if there is an early userspace init. If yes, let it do all | 894 | * check if there is an early userspace init. If yes, let it do all |
894 | * the work | 895 | * the work |
diff --git a/ipc/mqueue.c b/ipc/mqueue.c index c79bd57353e7..b6cb06451f4b 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c | |||
@@ -134,7 +134,6 @@ static struct inode *mqueue_get_inode(struct super_block *sb, | |||
134 | init_waitqueue_head(&info->wait_q); | 134 | init_waitqueue_head(&info->wait_q); |
135 | INIT_LIST_HEAD(&info->e_wait_q[0].list); | 135 | INIT_LIST_HEAD(&info->e_wait_q[0].list); |
136 | INIT_LIST_HEAD(&info->e_wait_q[1].list); | 136 | INIT_LIST_HEAD(&info->e_wait_q[1].list); |
137 | info->messages = NULL; | ||
138 | info->notify_owner = NULL; | 137 | info->notify_owner = NULL; |
139 | info->qsize = 0; | 138 | info->qsize = 0; |
140 | info->user = NULL; /* set when all is ok */ | 139 | info->user = NULL; /* set when all is ok */ |
@@ -146,6 +145,10 @@ static struct inode *mqueue_get_inode(struct super_block *sb, | |||
146 | info->attr.mq_msgsize = attr->mq_msgsize; | 145 | info->attr.mq_msgsize = attr->mq_msgsize; |
147 | } | 146 | } |
148 | mq_msg_tblsz = info->attr.mq_maxmsg * sizeof(struct msg_msg *); | 147 | mq_msg_tblsz = info->attr.mq_maxmsg * sizeof(struct msg_msg *); |
148 | info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL); | ||
149 | if (!info->messages) | ||
150 | goto out_inode; | ||
151 | |||
149 | mq_bytes = (mq_msg_tblsz + | 152 | mq_bytes = (mq_msg_tblsz + |
150 | (info->attr.mq_maxmsg * info->attr.mq_msgsize)); | 153 | (info->attr.mq_maxmsg * info->attr.mq_msgsize)); |
151 | 154 | ||
@@ -154,18 +157,12 @@ static struct inode *mqueue_get_inode(struct super_block *sb, | |||
154 | u->mq_bytes + mq_bytes > | 157 | u->mq_bytes + mq_bytes > |
155 | p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) { | 158 | p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) { |
156 | spin_unlock(&mq_lock); | 159 | spin_unlock(&mq_lock); |
160 | kfree(info->messages); | ||
157 | goto out_inode; | 161 | goto out_inode; |
158 | } | 162 | } |
159 | u->mq_bytes += mq_bytes; | 163 | u->mq_bytes += mq_bytes; |
160 | spin_unlock(&mq_lock); | 164 | spin_unlock(&mq_lock); |
161 | 165 | ||
162 | info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL); | ||
163 | if (!info->messages) { | ||
164 | spin_lock(&mq_lock); | ||
165 | u->mq_bytes -= mq_bytes; | ||
166 | spin_unlock(&mq_lock); | ||
167 | goto out_inode; | ||
168 | } | ||
169 | /* all is ok */ | 166 | /* all is ok */ |
170 | info->user = get_uid(u); | 167 | info->user = get_uid(u); |
171 | } else if (S_ISDIR(mode)) { | 168 | } else if (S_ISDIR(mode)) { |
@@ -187,7 +184,7 @@ static int mqueue_fill_super(struct super_block *sb, void *data, int silent) | |||
187 | { | 184 | { |
188 | struct inode *inode; | 185 | struct inode *inode; |
189 | struct ipc_namespace *ns = data; | 186 | struct ipc_namespace *ns = data; |
190 | int error = 0; | 187 | int error; |
191 | 188 | ||
192 | sb->s_blocksize = PAGE_CACHE_SIZE; | 189 | sb->s_blocksize = PAGE_CACHE_SIZE; |
193 | sb->s_blocksize_bits = PAGE_CACHE_SHIFT; | 190 | sb->s_blocksize_bits = PAGE_CACHE_SHIFT; |
@@ -205,7 +202,9 @@ static int mqueue_fill_super(struct super_block *sb, void *data, int silent) | |||
205 | if (!sb->s_root) { | 202 | if (!sb->s_root) { |
206 | iput(inode); | 203 | iput(inode); |
207 | error = -ENOMEM; | 204 | error = -ENOMEM; |
205 | goto out; | ||
208 | } | 206 | } |
207 | error = 0; | ||
209 | 208 | ||
210 | out: | 209 | out: |
211 | return error; | 210 | return error; |
@@ -264,8 +263,9 @@ static void mqueue_delete_inode(struct inode *inode) | |||
264 | 263 | ||
265 | clear_inode(inode); | 264 | clear_inode(inode); |
266 | 265 | ||
267 | mq_bytes = (info->attr.mq_maxmsg * sizeof(struct msg_msg *) + | 266 | /* Total amount of bytes accounted for the mqueue */ |
268 | (info->attr.mq_maxmsg * info->attr.mq_msgsize)); | 267 | mq_bytes = info->attr.mq_maxmsg * (sizeof(struct msg_msg *) |
268 | + info->attr.mq_msgsize); | ||
269 | user = info->user; | 269 | user = info->user; |
270 | if (user) { | 270 | if (user) { |
271 | spin_lock(&mq_lock); | 271 | spin_lock(&mq_lock); |
@@ -604,8 +604,8 @@ static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr) | |||
604 | /* check for overflow */ | 604 | /* check for overflow */ |
605 | if (attr->mq_msgsize > ULONG_MAX/attr->mq_maxmsg) | 605 | if (attr->mq_msgsize > ULONG_MAX/attr->mq_maxmsg) |
606 | return 0; | 606 | return 0; |
607 | if ((unsigned long)(attr->mq_maxmsg * attr->mq_msgsize) + | 607 | if ((unsigned long)(attr->mq_maxmsg * (attr->mq_msgsize |
608 | (attr->mq_maxmsg * sizeof (struct msg_msg *)) < | 608 | + sizeof (struct msg_msg *))) < |
609 | (unsigned long)(attr->mq_maxmsg * attr->mq_msgsize)) | 609 | (unsigned long)(attr->mq_maxmsg * attr->mq_msgsize)) |
610 | return 0; | 610 | return 0; |
611 | return 1; | 611 | return 1; |
@@ -623,9 +623,10 @@ static struct file *do_create(struct ipc_namespace *ipc_ns, struct dentry *dir, | |||
623 | int ret; | 623 | int ret; |
624 | 624 | ||
625 | if (attr) { | 625 | if (attr) { |
626 | ret = -EINVAL; | 626 | if (!mq_attr_ok(ipc_ns, attr)) { |
627 | if (!mq_attr_ok(ipc_ns, attr)) | 627 | ret = -EINVAL; |
628 | goto out; | 628 | goto out; |
629 | } | ||
629 | /* store for use during create */ | 630 | /* store for use during create */ |
630 | dentry->d_fsdata = attr; | 631 | dentry->d_fsdata = attr; |
631 | } | 632 | } |
@@ -659,24 +660,28 @@ out: | |||
659 | static struct file *do_open(struct ipc_namespace *ipc_ns, | 660 | static struct file *do_open(struct ipc_namespace *ipc_ns, |
660 | struct dentry *dentry, int oflag) | 661 | struct dentry *dentry, int oflag) |
661 | { | 662 | { |
663 | int ret; | ||
662 | const struct cred *cred = current_cred(); | 664 | const struct cred *cred = current_cred(); |
663 | 665 | ||
664 | static const int oflag2acc[O_ACCMODE] = { MAY_READ, MAY_WRITE, | 666 | static const int oflag2acc[O_ACCMODE] = { MAY_READ, MAY_WRITE, |
665 | MAY_READ | MAY_WRITE }; | 667 | MAY_READ | MAY_WRITE }; |
666 | 668 | ||
667 | if ((oflag & O_ACCMODE) == (O_RDWR | O_WRONLY)) { | 669 | if ((oflag & O_ACCMODE) == (O_RDWR | O_WRONLY)) { |
668 | dput(dentry); | 670 | ret = -EINVAL; |
669 | mntput(ipc_ns->mq_mnt); | 671 | goto err; |
670 | return ERR_PTR(-EINVAL); | ||
671 | } | 672 | } |
672 | 673 | ||
673 | if (inode_permission(dentry->d_inode, oflag2acc[oflag & O_ACCMODE])) { | 674 | if (inode_permission(dentry->d_inode, oflag2acc[oflag & O_ACCMODE])) { |
674 | dput(dentry); | 675 | ret = -EACCES; |
675 | mntput(ipc_ns->mq_mnt); | 676 | goto err; |
676 | return ERR_PTR(-EACCES); | ||
677 | } | 677 | } |
678 | 678 | ||
679 | return dentry_open(dentry, ipc_ns->mq_mnt, oflag, cred); | 679 | return dentry_open(dentry, ipc_ns->mq_mnt, oflag, cred); |
680 | |||
681 | err: | ||
682 | dput(dentry); | ||
683 | mntput(ipc_ns->mq_mnt); | ||
684 | return ERR_PTR(ret); | ||
680 | } | 685 | } |
681 | 686 | ||
682 | SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, mode_t, mode, | 687 | SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, mode_t, mode, |
@@ -705,16 +710,17 @@ SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, mode_t, mode, | |||
705 | dentry = lookup_one_len(name, ipc_ns->mq_mnt->mnt_root, strlen(name)); | 710 | dentry = lookup_one_len(name, ipc_ns->mq_mnt->mnt_root, strlen(name)); |
706 | if (IS_ERR(dentry)) { | 711 | if (IS_ERR(dentry)) { |
707 | error = PTR_ERR(dentry); | 712 | error = PTR_ERR(dentry); |
708 | goto out_err; | 713 | goto out_putfd; |
709 | } | 714 | } |
710 | mntget(ipc_ns->mq_mnt); | 715 | mntget(ipc_ns->mq_mnt); |
711 | 716 | ||
712 | if (oflag & O_CREAT) { | 717 | if (oflag & O_CREAT) { |
713 | if (dentry->d_inode) { /* entry already exists */ | 718 | if (dentry->d_inode) { /* entry already exists */ |
714 | audit_inode(name, dentry); | 719 | audit_inode(name, dentry); |
715 | error = -EEXIST; | 720 | if (oflag & O_EXCL) { |
716 | if (oflag & O_EXCL) | 721 | error = -EEXIST; |
717 | goto out; | 722 | goto out; |
723 | } | ||
718 | filp = do_open(ipc_ns, dentry, oflag); | 724 | filp = do_open(ipc_ns, dentry, oflag); |
719 | } else { | 725 | } else { |
720 | filp = do_create(ipc_ns, ipc_ns->mq_mnt->mnt_root, | 726 | filp = do_create(ipc_ns, ipc_ns->mq_mnt->mnt_root, |
@@ -722,9 +728,10 @@ SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, mode_t, mode, | |||
722 | u_attr ? &attr : NULL); | 728 | u_attr ? &attr : NULL); |
723 | } | 729 | } |
724 | } else { | 730 | } else { |
725 | error = -ENOENT; | 731 | if (!dentry->d_inode) { |
726 | if (!dentry->d_inode) | 732 | error = -ENOENT; |
727 | goto out; | 733 | goto out; |
734 | } | ||
728 | audit_inode(name, dentry); | 735 | audit_inode(name, dentry); |
729 | filp = do_open(ipc_ns, dentry, oflag); | 736 | filp = do_open(ipc_ns, dentry, oflag); |
730 | } | 737 | } |
@@ -742,7 +749,6 @@ out: | |||
742 | mntput(ipc_ns->mq_mnt); | 749 | mntput(ipc_ns->mq_mnt); |
743 | out_putfd: | 750 | out_putfd: |
744 | put_unused_fd(fd); | 751 | put_unused_fd(fd); |
745 | out_err: | ||
746 | fd = error; | 752 | fd = error; |
747 | out_upsem: | 753 | out_upsem: |
748 | mutex_unlock(&ipc_ns->mq_mnt->mnt_root->d_inode->i_mutex); | 754 | mutex_unlock(&ipc_ns->mq_mnt->mnt_root->d_inode->i_mutex); |
@@ -872,19 +878,24 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr, | |||
872 | audit_mq_sendrecv(mqdes, msg_len, msg_prio, p); | 878 | audit_mq_sendrecv(mqdes, msg_len, msg_prio, p); |
873 | timeout = prepare_timeout(p); | 879 | timeout = prepare_timeout(p); |
874 | 880 | ||
875 | ret = -EBADF; | ||
876 | filp = fget(mqdes); | 881 | filp = fget(mqdes); |
877 | if (unlikely(!filp)) | 882 | if (unlikely(!filp)) { |
883 | ret = -EBADF; | ||
878 | goto out; | 884 | goto out; |
885 | } | ||
879 | 886 | ||
880 | inode = filp->f_path.dentry->d_inode; | 887 | inode = filp->f_path.dentry->d_inode; |
881 | if (unlikely(filp->f_op != &mqueue_file_operations)) | 888 | if (unlikely(filp->f_op != &mqueue_file_operations)) { |
889 | ret = -EBADF; | ||
882 | goto out_fput; | 890 | goto out_fput; |
891 | } | ||
883 | info = MQUEUE_I(inode); | 892 | info = MQUEUE_I(inode); |
884 | audit_inode(NULL, filp->f_path.dentry); | 893 | audit_inode(NULL, filp->f_path.dentry); |
885 | 894 | ||
886 | if (unlikely(!(filp->f_mode & FMODE_WRITE))) | 895 | if (unlikely(!(filp->f_mode & FMODE_WRITE))) { |
896 | ret = -EBADF; | ||
887 | goto out_fput; | 897 | goto out_fput; |
898 | } | ||
888 | 899 | ||
889 | if (unlikely(msg_len > info->attr.mq_msgsize)) { | 900 | if (unlikely(msg_len > info->attr.mq_msgsize)) { |
890 | ret = -EMSGSIZE; | 901 | ret = -EMSGSIZE; |
@@ -961,19 +972,24 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr, | |||
961 | audit_mq_sendrecv(mqdes, msg_len, 0, p); | 972 | audit_mq_sendrecv(mqdes, msg_len, 0, p); |
962 | timeout = prepare_timeout(p); | 973 | timeout = prepare_timeout(p); |
963 | 974 | ||
964 | ret = -EBADF; | ||
965 | filp = fget(mqdes); | 975 | filp = fget(mqdes); |
966 | if (unlikely(!filp)) | 976 | if (unlikely(!filp)) { |
977 | ret = -EBADF; | ||
967 | goto out; | 978 | goto out; |
979 | } | ||
968 | 980 | ||
969 | inode = filp->f_path.dentry->d_inode; | 981 | inode = filp->f_path.dentry->d_inode; |
970 | if (unlikely(filp->f_op != &mqueue_file_operations)) | 982 | if (unlikely(filp->f_op != &mqueue_file_operations)) { |
983 | ret = -EBADF; | ||
971 | goto out_fput; | 984 | goto out_fput; |
985 | } | ||
972 | info = MQUEUE_I(inode); | 986 | info = MQUEUE_I(inode); |
973 | audit_inode(NULL, filp->f_path.dentry); | 987 | audit_inode(NULL, filp->f_path.dentry); |
974 | 988 | ||
975 | if (unlikely(!(filp->f_mode & FMODE_READ))) | 989 | if (unlikely(!(filp->f_mode & FMODE_READ))) { |
990 | ret = -EBADF; | ||
976 | goto out_fput; | 991 | goto out_fput; |
992 | } | ||
977 | 993 | ||
978 | /* checks if buffer is big enough */ | 994 | /* checks if buffer is big enough */ |
979 | if (unlikely(msg_len < info->attr.mq_msgsize)) { | 995 | if (unlikely(msg_len < info->attr.mq_msgsize)) { |
@@ -1063,13 +1079,14 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes, | |||
1063 | 1079 | ||
1064 | /* create the notify skb */ | 1080 | /* create the notify skb */ |
1065 | nc = alloc_skb(NOTIFY_COOKIE_LEN, GFP_KERNEL); | 1081 | nc = alloc_skb(NOTIFY_COOKIE_LEN, GFP_KERNEL); |
1066 | ret = -ENOMEM; | 1082 | if (!nc) { |
1067 | if (!nc) | 1083 | ret = -ENOMEM; |
1068 | goto out; | 1084 | goto out; |
1069 | ret = -EFAULT; | 1085 | } |
1070 | if (copy_from_user(nc->data, | 1086 | if (copy_from_user(nc->data, |
1071 | notification.sigev_value.sival_ptr, | 1087 | notification.sigev_value.sival_ptr, |
1072 | NOTIFY_COOKIE_LEN)) { | 1088 | NOTIFY_COOKIE_LEN)) { |
1089 | ret = -EFAULT; | ||
1073 | goto out; | 1090 | goto out; |
1074 | } | 1091 | } |
1075 | 1092 | ||
@@ -1078,9 +1095,10 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes, | |||
1078 | /* and attach it to the socket */ | 1095 | /* and attach it to the socket */ |
1079 | retry: | 1096 | retry: |
1080 | filp = fget(notification.sigev_signo); | 1097 | filp = fget(notification.sigev_signo); |
1081 | ret = -EBADF; | 1098 | if (!filp) { |
1082 | if (!filp) | 1099 | ret = -EBADF; |
1083 | goto out; | 1100 | goto out; |
1101 | } | ||
1084 | sock = netlink_getsockbyfilp(filp); | 1102 | sock = netlink_getsockbyfilp(filp); |
1085 | fput(filp); | 1103 | fput(filp); |
1086 | if (IS_ERR(sock)) { | 1104 | if (IS_ERR(sock)) { |
@@ -1092,7 +1110,7 @@ retry: | |||
1092 | timeo = MAX_SCHEDULE_TIMEOUT; | 1110 | timeo = MAX_SCHEDULE_TIMEOUT; |
1093 | ret = netlink_attachskb(sock, nc, &timeo, NULL); | 1111 | ret = netlink_attachskb(sock, nc, &timeo, NULL); |
1094 | if (ret == 1) | 1112 | if (ret == 1) |
1095 | goto retry; | 1113 | goto retry; |
1096 | if (ret) { | 1114 | if (ret) { |
1097 | sock = NULL; | 1115 | sock = NULL; |
1098 | nc = NULL; | 1116 | nc = NULL; |
@@ -1101,14 +1119,17 @@ retry: | |||
1101 | } | 1119 | } |
1102 | } | 1120 | } |
1103 | 1121 | ||
1104 | ret = -EBADF; | ||
1105 | filp = fget(mqdes); | 1122 | filp = fget(mqdes); |
1106 | if (!filp) | 1123 | if (!filp) { |
1124 | ret = -EBADF; | ||
1107 | goto out; | 1125 | goto out; |
1126 | } | ||
1108 | 1127 | ||
1109 | inode = filp->f_path.dentry->d_inode; | 1128 | inode = filp->f_path.dentry->d_inode; |
1110 | if (unlikely(filp->f_op != &mqueue_file_operations)) | 1129 | if (unlikely(filp->f_op != &mqueue_file_operations)) { |
1130 | ret = -EBADF; | ||
1111 | goto out_fput; | 1131 | goto out_fput; |
1132 | } | ||
1112 | info = MQUEUE_I(inode); | 1133 | info = MQUEUE_I(inode); |
1113 | 1134 | ||
1114 | ret = 0; | 1135 | ret = 0; |
@@ -1171,14 +1192,17 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes, | |||
1171 | return -EINVAL; | 1192 | return -EINVAL; |
1172 | } | 1193 | } |
1173 | 1194 | ||
1174 | ret = -EBADF; | ||
1175 | filp = fget(mqdes); | 1195 | filp = fget(mqdes); |
1176 | if (!filp) | 1196 | if (!filp) { |
1197 | ret = -EBADF; | ||
1177 | goto out; | 1198 | goto out; |
1199 | } | ||
1178 | 1200 | ||
1179 | inode = filp->f_path.dentry->d_inode; | 1201 | inode = filp->f_path.dentry->d_inode; |
1180 | if (unlikely(filp->f_op != &mqueue_file_operations)) | 1202 | if (unlikely(filp->f_op != &mqueue_file_operations)) { |
1203 | ret = -EBADF; | ||
1181 | goto out_fput; | 1204 | goto out_fput; |
1205 | } | ||
1182 | info = MQUEUE_I(inode); | 1206 | info = MQUEUE_I(inode); |
1183 | 1207 | ||
1184 | spin_lock(&info->lock); | 1208 | spin_lock(&info->lock); |
@@ -1272,7 +1296,7 @@ static int __init init_mqueue_fs(void) | |||
1272 | if (mqueue_inode_cachep == NULL) | 1296 | if (mqueue_inode_cachep == NULL) |
1273 | return -ENOMEM; | 1297 | return -ENOMEM; |
1274 | 1298 | ||
1275 | /* ignore failues - they are not fatal */ | 1299 | /* ignore failures - they are not fatal */ |
1276 | mq_sysctl_table = mq_register_sysctl_table(); | 1300 | mq_sysctl_table = mq_register_sysctl_table(); |
1277 | 1301 | ||
1278 | error = register_filesystem(&mqueue_fs_type); | 1302 | error = register_filesystem(&mqueue_fs_type); |
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c index 4b05bd9479db..028e85663f27 100644 --- a/kernel/audit_tree.c +++ b/kernel/audit_tree.c | |||
@@ -548,6 +548,11 @@ int audit_remove_tree_rule(struct audit_krule *rule) | |||
548 | return 0; | 548 | return 0; |
549 | } | 549 | } |
550 | 550 | ||
551 | static int compare_root(struct vfsmount *mnt, void *arg) | ||
552 | { | ||
553 | return mnt->mnt_root->d_inode == arg; | ||
554 | } | ||
555 | |||
551 | void audit_trim_trees(void) | 556 | void audit_trim_trees(void) |
552 | { | 557 | { |
553 | struct list_head cursor; | 558 | struct list_head cursor; |
@@ -559,7 +564,6 @@ void audit_trim_trees(void) | |||
559 | struct path path; | 564 | struct path path; |
560 | struct vfsmount *root_mnt; | 565 | struct vfsmount *root_mnt; |
561 | struct node *node; | 566 | struct node *node; |
562 | struct list_head list; | ||
563 | int err; | 567 | int err; |
564 | 568 | ||
565 | tree = container_of(cursor.next, struct audit_tree, list); | 569 | tree = container_of(cursor.next, struct audit_tree, list); |
@@ -577,24 +581,16 @@ void audit_trim_trees(void) | |||
577 | if (!root_mnt) | 581 | if (!root_mnt) |
578 | goto skip_it; | 582 | goto skip_it; |
579 | 583 | ||
580 | list_add_tail(&list, &root_mnt->mnt_list); | ||
581 | spin_lock(&hash_lock); | 584 | spin_lock(&hash_lock); |
582 | list_for_each_entry(node, &tree->chunks, list) { | 585 | list_for_each_entry(node, &tree->chunks, list) { |
583 | struct audit_chunk *chunk = find_chunk(node); | 586 | struct inode *inode = find_chunk(node)->watch.inode; |
584 | struct inode *inode = chunk->watch.inode; | ||
585 | struct vfsmount *mnt; | ||
586 | node->index |= 1U<<31; | 587 | node->index |= 1U<<31; |
587 | list_for_each_entry(mnt, &list, mnt_list) { | 588 | if (iterate_mounts(compare_root, inode, root_mnt)) |
588 | if (mnt->mnt_root->d_inode == inode) { | 589 | node->index &= ~(1U<<31); |
589 | node->index &= ~(1U<<31); | ||
590 | break; | ||
591 | } | ||
592 | } | ||
593 | } | 590 | } |
594 | spin_unlock(&hash_lock); | 591 | spin_unlock(&hash_lock); |
595 | trim_marked(tree); | 592 | trim_marked(tree); |
596 | put_tree(tree); | 593 | put_tree(tree); |
597 | list_del_init(&list); | ||
598 | drop_collected_mounts(root_mnt); | 594 | drop_collected_mounts(root_mnt); |
599 | skip_it: | 595 | skip_it: |
600 | mutex_lock(&audit_filter_mutex); | 596 | mutex_lock(&audit_filter_mutex); |
@@ -603,22 +599,6 @@ skip_it: | |||
603 | mutex_unlock(&audit_filter_mutex); | 599 | mutex_unlock(&audit_filter_mutex); |
604 | } | 600 | } |
605 | 601 | ||
606 | static int is_under(struct vfsmount *mnt, struct dentry *dentry, | ||
607 | struct path *path) | ||
608 | { | ||
609 | if (mnt != path->mnt) { | ||
610 | for (;;) { | ||
611 | if (mnt->mnt_parent == mnt) | ||
612 | return 0; | ||
613 | if (mnt->mnt_parent == path->mnt) | ||
614 | break; | ||
615 | mnt = mnt->mnt_parent; | ||
616 | } | ||
617 | dentry = mnt->mnt_mountpoint; | ||
618 | } | ||
619 | return is_subdir(dentry, path->dentry); | ||
620 | } | ||
621 | |||
622 | int audit_make_tree(struct audit_krule *rule, char *pathname, u32 op) | 602 | int audit_make_tree(struct audit_krule *rule, char *pathname, u32 op) |
623 | { | 603 | { |
624 | 604 | ||
@@ -638,13 +618,17 @@ void audit_put_tree(struct audit_tree *tree) | |||
638 | put_tree(tree); | 618 | put_tree(tree); |
639 | } | 619 | } |
640 | 620 | ||
621 | static int tag_mount(struct vfsmount *mnt, void *arg) | ||
622 | { | ||
623 | return tag_chunk(mnt->mnt_root->d_inode, arg); | ||
624 | } | ||
625 | |||
641 | /* called with audit_filter_mutex */ | 626 | /* called with audit_filter_mutex */ |
642 | int audit_add_tree_rule(struct audit_krule *rule) | 627 | int audit_add_tree_rule(struct audit_krule *rule) |
643 | { | 628 | { |
644 | struct audit_tree *seed = rule->tree, *tree; | 629 | struct audit_tree *seed = rule->tree, *tree; |
645 | struct path path; | 630 | struct path path; |
646 | struct vfsmount *mnt, *p; | 631 | struct vfsmount *mnt; |
647 | struct list_head list; | ||
648 | int err; | 632 | int err; |
649 | 633 | ||
650 | list_for_each_entry(tree, &tree_list, list) { | 634 | list_for_each_entry(tree, &tree_list, list) { |
@@ -670,16 +654,9 @@ int audit_add_tree_rule(struct audit_krule *rule) | |||
670 | err = -ENOMEM; | 654 | err = -ENOMEM; |
671 | goto Err; | 655 | goto Err; |
672 | } | 656 | } |
673 | list_add_tail(&list, &mnt->mnt_list); | ||
674 | 657 | ||
675 | get_tree(tree); | 658 | get_tree(tree); |
676 | list_for_each_entry(p, &list, mnt_list) { | 659 | err = iterate_mounts(tag_mount, tree, mnt); |
677 | err = tag_chunk(p->mnt_root->d_inode, tree); | ||
678 | if (err) | ||
679 | break; | ||
680 | } | ||
681 | |||
682 | list_del(&list); | ||
683 | drop_collected_mounts(mnt); | 660 | drop_collected_mounts(mnt); |
684 | 661 | ||
685 | if (!err) { | 662 | if (!err) { |
@@ -714,31 +691,23 @@ int audit_tag_tree(char *old, char *new) | |||
714 | { | 691 | { |
715 | struct list_head cursor, barrier; | 692 | struct list_head cursor, barrier; |
716 | int failed = 0; | 693 | int failed = 0; |
717 | struct path path; | 694 | struct path path1, path2; |
718 | struct vfsmount *tagged; | 695 | struct vfsmount *tagged; |
719 | struct list_head list; | ||
720 | struct vfsmount *mnt; | ||
721 | struct dentry *dentry; | ||
722 | int err; | 696 | int err; |
723 | 697 | ||
724 | err = kern_path(new, 0, &path); | 698 | err = kern_path(new, 0, &path2); |
725 | if (err) | 699 | if (err) |
726 | return err; | 700 | return err; |
727 | tagged = collect_mounts(&path); | 701 | tagged = collect_mounts(&path2); |
728 | path_put(&path); | 702 | path_put(&path2); |
729 | if (!tagged) | 703 | if (!tagged) |
730 | return -ENOMEM; | 704 | return -ENOMEM; |
731 | 705 | ||
732 | err = kern_path(old, 0, &path); | 706 | err = kern_path(old, 0, &path1); |
733 | if (err) { | 707 | if (err) { |
734 | drop_collected_mounts(tagged); | 708 | drop_collected_mounts(tagged); |
735 | return err; | 709 | return err; |
736 | } | 710 | } |
737 | mnt = mntget(path.mnt); | ||
738 | dentry = dget(path.dentry); | ||
739 | path_put(&path); | ||
740 | |||
741 | list_add_tail(&list, &tagged->mnt_list); | ||
742 | 711 | ||
743 | mutex_lock(&audit_filter_mutex); | 712 | mutex_lock(&audit_filter_mutex); |
744 | list_add(&barrier, &tree_list); | 713 | list_add(&barrier, &tree_list); |
@@ -746,7 +715,7 @@ int audit_tag_tree(char *old, char *new) | |||
746 | 715 | ||
747 | while (cursor.next != &tree_list) { | 716 | while (cursor.next != &tree_list) { |
748 | struct audit_tree *tree; | 717 | struct audit_tree *tree; |
749 | struct vfsmount *p; | 718 | int good_one = 0; |
750 | 719 | ||
751 | tree = container_of(cursor.next, struct audit_tree, list); | 720 | tree = container_of(cursor.next, struct audit_tree, list); |
752 | get_tree(tree); | 721 | get_tree(tree); |
@@ -754,30 +723,19 @@ int audit_tag_tree(char *old, char *new) | |||
754 | list_add(&cursor, &tree->list); | 723 | list_add(&cursor, &tree->list); |
755 | mutex_unlock(&audit_filter_mutex); | 724 | mutex_unlock(&audit_filter_mutex); |
756 | 725 | ||
757 | err = kern_path(tree->pathname, 0, &path); | 726 | err = kern_path(tree->pathname, 0, &path2); |
758 | if (err) { | 727 | if (!err) { |
759 | put_tree(tree); | 728 | good_one = path_is_under(&path1, &path2); |
760 | mutex_lock(&audit_filter_mutex); | 729 | path_put(&path2); |
761 | continue; | ||
762 | } | 730 | } |
763 | 731 | ||
764 | spin_lock(&vfsmount_lock); | 732 | if (!good_one) { |
765 | if (!is_under(mnt, dentry, &path)) { | ||
766 | spin_unlock(&vfsmount_lock); | ||
767 | path_put(&path); | ||
768 | put_tree(tree); | 733 | put_tree(tree); |
769 | mutex_lock(&audit_filter_mutex); | 734 | mutex_lock(&audit_filter_mutex); |
770 | continue; | 735 | continue; |
771 | } | 736 | } |
772 | spin_unlock(&vfsmount_lock); | ||
773 | path_put(&path); | ||
774 | |||
775 | list_for_each_entry(p, &list, mnt_list) { | ||
776 | failed = tag_chunk(p->mnt_root->d_inode, tree); | ||
777 | if (failed) | ||
778 | break; | ||
779 | } | ||
780 | 737 | ||
738 | failed = iterate_mounts(tag_mount, tree, tagged); | ||
781 | if (failed) { | 739 | if (failed) { |
782 | put_tree(tree); | 740 | put_tree(tree); |
783 | mutex_lock(&audit_filter_mutex); | 741 | mutex_lock(&audit_filter_mutex); |
@@ -818,10 +776,8 @@ int audit_tag_tree(char *old, char *new) | |||
818 | } | 776 | } |
819 | list_del(&barrier); | 777 | list_del(&barrier); |
820 | list_del(&cursor); | 778 | list_del(&cursor); |
821 | list_del(&list); | ||
822 | mutex_unlock(&audit_filter_mutex); | 779 | mutex_unlock(&audit_filter_mutex); |
823 | dput(dentry); | 780 | path_put(&path1); |
824 | mntput(mnt); | ||
825 | drop_collected_mounts(tagged); | 781 | drop_collected_mounts(tagged); |
826 | return failed; | 782 | return failed; |
827 | } | 783 | } |
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index fc0f928167e7..f3a461c0970a 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -1988,7 +1988,6 @@ void __audit_inode(const char *name, const struct dentry *dentry) | |||
1988 | 1988 | ||
1989 | /** | 1989 | /** |
1990 | * audit_inode_child - collect inode info for created/removed objects | 1990 | * audit_inode_child - collect inode info for created/removed objects |
1991 | * @dname: inode's dentry name | ||
1992 | * @dentry: dentry being audited | 1991 | * @dentry: dentry being audited |
1993 | * @parent: inode of dentry parent | 1992 | * @parent: inode of dentry parent |
1994 | * | 1993 | * |
@@ -2000,13 +1999,14 @@ void __audit_inode(const char *name, const struct dentry *dentry) | |||
2000 | * must be hooked prior, in order to capture the target inode during | 1999 | * must be hooked prior, in order to capture the target inode during |
2001 | * unsuccessful attempts. | 2000 | * unsuccessful attempts. |
2002 | */ | 2001 | */ |
2003 | void __audit_inode_child(const char *dname, const struct dentry *dentry, | 2002 | void __audit_inode_child(const struct dentry *dentry, |
2004 | const struct inode *parent) | 2003 | const struct inode *parent) |
2005 | { | 2004 | { |
2006 | int idx; | 2005 | int idx; |
2007 | struct audit_context *context = current->audit_context; | 2006 | struct audit_context *context = current->audit_context; |
2008 | const char *found_parent = NULL, *found_child = NULL; | 2007 | const char *found_parent = NULL, *found_child = NULL; |
2009 | const struct inode *inode = dentry->d_inode; | 2008 | const struct inode *inode = dentry->d_inode; |
2009 | const char *dname = dentry->d_name.name; | ||
2010 | int dirlen = 0; | 2010 | int dirlen = 0; |
2011 | 2011 | ||
2012 | if (!context->in_syscall) | 2012 | if (!context->in_syscall) |
@@ -2014,9 +2014,6 @@ void __audit_inode_child(const char *dname, const struct dentry *dentry, | |||
2014 | 2014 | ||
2015 | if (inode) | 2015 | if (inode) |
2016 | handle_one(inode); | 2016 | handle_one(inode); |
2017 | /* determine matching parent */ | ||
2018 | if (!dname) | ||
2019 | goto add_names; | ||
2020 | 2017 | ||
2021 | /* parent is more likely, look for it first */ | 2018 | /* parent is more likely, look for it first */ |
2022 | for (idx = 0; idx < context->name_count; idx++) { | 2019 | for (idx = 0; idx < context->name_count; idx++) { |
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c index 8f5d16e0707a..8cd50d8f9bde 100644 --- a/kernel/sysctl_binary.c +++ b/kernel/sysctl_binary.c | |||
@@ -1331,7 +1331,7 @@ static ssize_t binary_sysctl(const int *name, int nlen, | |||
1331 | ssize_t result; | 1331 | ssize_t result; |
1332 | char *pathname; | 1332 | char *pathname; |
1333 | int flags; | 1333 | int flags; |
1334 | int acc_mode, fmode; | 1334 | int acc_mode; |
1335 | 1335 | ||
1336 | pathname = sysctl_getname(name, nlen, &table); | 1336 | pathname = sysctl_getname(name, nlen, &table); |
1337 | result = PTR_ERR(pathname); | 1337 | result = PTR_ERR(pathname); |
@@ -1342,15 +1342,12 @@ static ssize_t binary_sysctl(const int *name, int nlen, | |||
1342 | if (oldval && oldlen && newval && newlen) { | 1342 | if (oldval && oldlen && newval && newlen) { |
1343 | flags = O_RDWR; | 1343 | flags = O_RDWR; |
1344 | acc_mode = MAY_READ | MAY_WRITE; | 1344 | acc_mode = MAY_READ | MAY_WRITE; |
1345 | fmode = FMODE_READ | FMODE_WRITE; | ||
1346 | } else if (newval && newlen) { | 1345 | } else if (newval && newlen) { |
1347 | flags = O_WRONLY; | 1346 | flags = O_WRONLY; |
1348 | acc_mode = MAY_WRITE; | 1347 | acc_mode = MAY_WRITE; |
1349 | fmode = FMODE_WRITE; | ||
1350 | } else if (oldval && oldlen) { | 1348 | } else if (oldval && oldlen) { |
1351 | flags = O_RDONLY; | 1349 | flags = O_RDONLY; |
1352 | acc_mode = MAY_READ; | 1350 | acc_mode = MAY_READ; |
1353 | fmode = FMODE_READ; | ||
1354 | } else { | 1351 | } else { |
1355 | result = 0; | 1352 | result = 0; |
1356 | goto out_putname; | 1353 | goto out_putname; |
@@ -1361,7 +1358,7 @@ static ssize_t binary_sysctl(const int *name, int nlen, | |||
1361 | if (result) | 1358 | if (result) |
1362 | goto out_putname; | 1359 | goto out_putname; |
1363 | 1360 | ||
1364 | result = may_open(&nd.path, acc_mode, fmode); | 1361 | result = may_open(&nd.path, acc_mode, flags); |
1365 | if (result) | 1362 | if (result) |
1366 | goto out_putpath; | 1363 | goto out_putpath; |
1367 | 1364 | ||
diff --git a/mm/filemap.c b/mm/filemap.c index 698ea80f2102..148b52a5bb7e 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -1117,7 +1117,7 @@ readpage: | |||
1117 | if (!PageUptodate(page)) { | 1117 | if (!PageUptodate(page)) { |
1118 | if (page->mapping == NULL) { | 1118 | if (page->mapping == NULL) { |
1119 | /* | 1119 | /* |
1120 | * invalidate_inode_pages got it | 1120 | * invalidate_mapping_pages got it |
1121 | */ | 1121 | */ |
1122 | unlock_page(page); | 1122 | unlock_page(page); |
1123 | page_cache_release(page); | 1123 | page_cache_release(page); |
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 9ea45383480e..8d63f8fd29b7 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c | |||
@@ -999,19 +999,14 @@ rpc_fill_super(struct super_block *sb, void *data, int silent) | |||
999 | inode = rpc_get_inode(sb, S_IFDIR | 0755); | 999 | inode = rpc_get_inode(sb, S_IFDIR | 0755); |
1000 | if (!inode) | 1000 | if (!inode) |
1001 | return -ENOMEM; | 1001 | return -ENOMEM; |
1002 | root = d_alloc_root(inode); | 1002 | sb->s_root = root = d_alloc_root(inode); |
1003 | if (!root) { | 1003 | if (!root) { |
1004 | iput(inode); | 1004 | iput(inode); |
1005 | return -ENOMEM; | 1005 | return -ENOMEM; |
1006 | } | 1006 | } |
1007 | if (rpc_populate(root, files, RPCAUTH_lockd, RPCAUTH_RootEOF, NULL)) | 1007 | if (rpc_populate(root, files, RPCAUTH_lockd, RPCAUTH_RootEOF, NULL)) |
1008 | goto out; | 1008 | return -ENOMEM; |
1009 | sb->s_root = root; | ||
1010 | return 0; | 1009 | return 0; |
1011 | out: | ||
1012 | d_genocide(root); | ||
1013 | dput(root); | ||
1014 | return -ENOMEM; | ||
1015 | } | 1010 | } |
1016 | 1011 | ||
1017 | static int | 1012 | static int |
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index a5721b373f53..5225e668dbf0 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
@@ -387,7 +387,7 @@ static int smack_sb_umount(struct vfsmount *mnt, int flags) | |||
387 | struct smk_audit_info ad; | 387 | struct smk_audit_info ad; |
388 | 388 | ||
389 | smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); | 389 | smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); |
390 | smk_ad_setfield_u_fs_path_dentry(&ad, mnt->mnt_mountpoint); | 390 | smk_ad_setfield_u_fs_path_dentry(&ad, mnt->mnt_root); |
391 | smk_ad_setfield_u_fs_path_mnt(&ad, mnt); | 391 | smk_ad_setfield_u_fs_path_mnt(&ad, mnt); |
392 | 392 | ||
393 | sbp = mnt->mnt_sb->s_security; | 393 | sbp = mnt->mnt_sb->s_security; |
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c index c00df45c7ede..cf7d61f781b9 100644 --- a/security/tomoyo/realpath.c +++ b/security/tomoyo/realpath.c | |||
@@ -88,29 +88,14 @@ int tomoyo_realpath_from_path2(struct path *path, char *newname, | |||
88 | sp = dentry->d_op->d_dname(dentry, newname + offset, | 88 | sp = dentry->d_op->d_dname(dentry, newname + offset, |
89 | newname_len - offset); | 89 | newname_len - offset); |
90 | } else { | 90 | } else { |
91 | /* Taken from d_namespace_path(). */ | 91 | struct path ns_root = {.mnt = NULL, .dentry = NULL}; |
92 | struct path root; | ||
93 | struct path ns_root = { }; | ||
94 | struct path tmp; | ||
95 | 92 | ||
96 | read_lock(¤t->fs->lock); | ||
97 | root = current->fs->root; | ||
98 | path_get(&root); | ||
99 | read_unlock(¤t->fs->lock); | ||
100 | spin_lock(&vfsmount_lock); | ||
101 | if (root.mnt && root.mnt->mnt_ns) | ||
102 | ns_root.mnt = mntget(root.mnt->mnt_ns->root); | ||
103 | if (ns_root.mnt) | ||
104 | ns_root.dentry = dget(ns_root.mnt->mnt_root); | ||
105 | spin_unlock(&vfsmount_lock); | ||
106 | spin_lock(&dcache_lock); | 93 | spin_lock(&dcache_lock); |
107 | tmp = ns_root; | 94 | /* go to whatever namespace root we are under */ |
108 | sp = __d_path(path, &tmp, newname, newname_len); | 95 | sp = __d_path(path, &ns_root, newname, newname_len); |
109 | spin_unlock(&dcache_lock); | 96 | spin_unlock(&dcache_lock); |
110 | path_put(&root); | ||
111 | path_put(&ns_root); | ||
112 | /* Prepend "/proc" prefix if using internal proc vfs mount. */ | 97 | /* Prepend "/proc" prefix if using internal proc vfs mount. */ |
113 | if (!IS_ERR(sp) && (path->mnt->mnt_parent == path->mnt) && | 98 | if (!IS_ERR(sp) && (path->mnt->mnt_flags & MNT_INTERNAL) && |
114 | (path->mnt->mnt_sb->s_magic == PROC_SUPER_MAGIC)) { | 99 | (path->mnt->mnt_sb->s_magic == PROC_SUPER_MAGIC)) { |
115 | sp -= 5; | 100 | sp -= 5; |
116 | if (sp >= newname) | 101 | if (sp >= newname) |