Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

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