diff options
Diffstat (limited to 'fs/autofs4/root.c')
-rw-r--r-- | fs/autofs4/root.c | 165 |
1 files changed, 92 insertions, 73 deletions
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index c6d7d3dbd52a..7ab923940d18 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
@@ -1,16 +1,12 @@ | |||
1 | /* -*- c -*- --------------------------------------------------------------- * | 1 | /* |
2 | * | 2 | * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved |
3 | * linux/fs/autofs/root.c | 3 | * Copyright 1999-2000 Jeremy Fitzhardinge <jeremy@goop.org> |
4 | * | 4 | * Copyright 2001-2006 Ian Kent <raven@themaw.net> |
5 | * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved | ||
6 | * Copyright 1999-2000 Jeremy Fitzhardinge <jeremy@goop.org> | ||
7 | * Copyright 2001-2006 Ian Kent <raven@themaw.net> | ||
8 | * | 5 | * |
9 | * This file is part of the Linux kernel and is made available under | 6 | * This file is part of the Linux kernel and is made available under |
10 | * the terms of the GNU General Public License, version 2, or at your | 7 | * the terms of the GNU General Public License, version 2, or at your |
11 | * option, any later version, incorporated herein by reference. | 8 | * option, any later version, incorporated herein by reference. |
12 | * | 9 | */ |
13 | * ------------------------------------------------------------------------- */ | ||
14 | 10 | ||
15 | #include <linux/capability.h> | 11 | #include <linux/capability.h> |
16 | #include <linux/errno.h> | 12 | #include <linux/errno.h> |
@@ -23,16 +19,18 @@ | |||
23 | 19 | ||
24 | #include "autofs_i.h" | 20 | #include "autofs_i.h" |
25 | 21 | ||
26 | static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *); | 22 | static int autofs4_dir_symlink(struct inode *, struct dentry *, const char *); |
27 | static int autofs4_dir_unlink(struct inode *,struct dentry *); | 23 | static int autofs4_dir_unlink(struct inode *, struct dentry *); |
28 | static int autofs4_dir_rmdir(struct inode *,struct dentry *); | 24 | static int autofs4_dir_rmdir(struct inode *, struct dentry *); |
29 | static int autofs4_dir_mkdir(struct inode *,struct dentry *,umode_t); | 25 | static int autofs4_dir_mkdir(struct inode *, struct dentry *, umode_t); |
30 | static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long); | 26 | static long autofs4_root_ioctl(struct file *, unsigned int, unsigned long); |
31 | #ifdef CONFIG_COMPAT | 27 | #ifdef CONFIG_COMPAT |
32 | static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long); | 28 | static long autofs4_root_compat_ioctl(struct file *, |
29 | unsigned int, unsigned long); | ||
33 | #endif | 30 | #endif |
34 | static int autofs4_dir_open(struct inode *inode, struct file *file); | 31 | static int autofs4_dir_open(struct inode *inode, struct file *file); |
35 | static struct dentry *autofs4_lookup(struct inode *,struct dentry *, unsigned int); | 32 | static struct dentry *autofs4_lookup(struct inode *, |
33 | struct dentry *, unsigned int); | ||
36 | static struct vfsmount *autofs4_d_automount(struct path *); | 34 | static struct vfsmount *autofs4_d_automount(struct path *); |
37 | static int autofs4_d_manage(struct dentry *, bool); | 35 | static int autofs4_d_manage(struct dentry *, bool); |
38 | static void autofs4_dentry_release(struct dentry *); | 36 | static void autofs4_dentry_release(struct dentry *); |
@@ -74,7 +72,9 @@ const struct dentry_operations autofs4_dentry_operations = { | |||
74 | static void autofs4_add_active(struct dentry *dentry) | 72 | static void autofs4_add_active(struct dentry *dentry) |
75 | { | 73 | { |
76 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | 74 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); |
77 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 75 | struct autofs_info *ino; |
76 | |||
77 | ino = autofs4_dentry_ino(dentry); | ||
78 | if (ino) { | 78 | if (ino) { |
79 | spin_lock(&sbi->lookup_lock); | 79 | spin_lock(&sbi->lookup_lock); |
80 | if (!ino->active_count) { | 80 | if (!ino->active_count) { |
@@ -84,13 +84,14 @@ static void autofs4_add_active(struct dentry *dentry) | |||
84 | ino->active_count++; | 84 | ino->active_count++; |
85 | spin_unlock(&sbi->lookup_lock); | 85 | spin_unlock(&sbi->lookup_lock); |
86 | } | 86 | } |
87 | return; | ||
88 | } | 87 | } |
89 | 88 | ||
90 | static void autofs4_del_active(struct dentry *dentry) | 89 | static void autofs4_del_active(struct dentry *dentry) |
91 | { | 90 | { |
92 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | 91 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); |
93 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 92 | struct autofs_info *ino; |
93 | |||
94 | ino = autofs4_dentry_ino(dentry); | ||
94 | if (ino) { | 95 | if (ino) { |
95 | spin_lock(&sbi->lookup_lock); | 96 | spin_lock(&sbi->lookup_lock); |
96 | ino->active_count--; | 97 | ino->active_count--; |
@@ -100,7 +101,6 @@ static void autofs4_del_active(struct dentry *dentry) | |||
100 | } | 101 | } |
101 | spin_unlock(&sbi->lookup_lock); | 102 | spin_unlock(&sbi->lookup_lock); |
102 | } | 103 | } |
103 | return; | ||
104 | } | 104 | } |
105 | 105 | ||
106 | static int autofs4_dir_open(struct inode *inode, struct file *file) | 106 | static int autofs4_dir_open(struct inode *inode, struct file *file) |
@@ -108,7 +108,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) | |||
108 | struct dentry *dentry = file->f_path.dentry; | 108 | struct dentry *dentry = file->f_path.dentry; |
109 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | 109 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); |
110 | 110 | ||
111 | DPRINTK("file=%p dentry=%p %pd", file, dentry, dentry); | 111 | pr_debug("file=%p dentry=%p %pd\n", file, dentry, dentry); |
112 | 112 | ||
113 | if (autofs4_oz_mode(sbi)) | 113 | if (autofs4_oz_mode(sbi)) |
114 | goto out; | 114 | goto out; |
@@ -138,7 +138,7 @@ static void autofs4_dentry_release(struct dentry *de) | |||
138 | struct autofs_info *ino = autofs4_dentry_ino(de); | 138 | struct autofs_info *ino = autofs4_dentry_ino(de); |
139 | struct autofs_sb_info *sbi = autofs4_sbi(de->d_sb); | 139 | struct autofs_sb_info *sbi = autofs4_sbi(de->d_sb); |
140 | 140 | ||
141 | DPRINTK("releasing %p", de); | 141 | pr_debug("releasing %p\n", de); |
142 | 142 | ||
143 | if (!ino) | 143 | if (!ino) |
144 | return; | 144 | return; |
@@ -278,9 +278,9 @@ static int autofs4_mount_wait(struct dentry *dentry, bool rcu_walk) | |||
278 | if (ino->flags & AUTOFS_INF_PENDING) { | 278 | if (ino->flags & AUTOFS_INF_PENDING) { |
279 | if (rcu_walk) | 279 | if (rcu_walk) |
280 | return -ECHILD; | 280 | return -ECHILD; |
281 | DPRINTK("waiting for mount name=%pd", dentry); | 281 | pr_debug("waiting for mount name=%pd\n", dentry); |
282 | status = autofs4_wait(sbi, dentry, NFY_MOUNT); | 282 | status = autofs4_wait(sbi, dentry, NFY_MOUNT); |
283 | DPRINTK("mount wait done status=%d", status); | 283 | pr_debug("mount wait done status=%d\n", status); |
284 | } | 284 | } |
285 | ino->last_used = jiffies; | 285 | ino->last_used = jiffies; |
286 | return status; | 286 | return status; |
@@ -320,7 +320,9 @@ static struct dentry *autofs4_mountpoint_changed(struct path *path) | |||
320 | if (autofs_type_indirect(sbi->type) && d_unhashed(dentry)) { | 320 | if (autofs_type_indirect(sbi->type) && d_unhashed(dentry)) { |
321 | struct dentry *parent = dentry->d_parent; | 321 | struct dentry *parent = dentry->d_parent; |
322 | struct autofs_info *ino; | 322 | struct autofs_info *ino; |
323 | struct dentry *new = d_lookup(parent, &dentry->d_name); | 323 | struct dentry *new; |
324 | |||
325 | new = d_lookup(parent, &dentry->d_name); | ||
324 | if (!new) | 326 | if (!new) |
325 | return NULL; | 327 | return NULL; |
326 | ino = autofs4_dentry_ino(new); | 328 | ino = autofs4_dentry_ino(new); |
@@ -338,7 +340,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path) | |||
338 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 340 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
339 | int status; | 341 | int status; |
340 | 342 | ||
341 | DPRINTK("dentry=%p %pd", dentry, dentry); | 343 | pr_debug("dentry=%p %pd\n", dentry, dentry); |
342 | 344 | ||
343 | /* The daemon never triggers a mount. */ | 345 | /* The daemon never triggers a mount. */ |
344 | if (autofs4_oz_mode(sbi)) | 346 | if (autofs4_oz_mode(sbi)) |
@@ -425,7 +427,7 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) | |||
425 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 427 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
426 | int status; | 428 | int status; |
427 | 429 | ||
428 | DPRINTK("dentry=%p %pd", dentry, dentry); | 430 | pr_debug("dentry=%p %pd\n", dentry, dentry); |
429 | 431 | ||
430 | /* The daemon never waits. */ | 432 | /* The daemon never waits. */ |
431 | if (autofs4_oz_mode(sbi)) { | 433 | if (autofs4_oz_mode(sbi)) { |
@@ -455,6 +457,7 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) | |||
455 | * a mount-trap. | 457 | * a mount-trap. |
456 | */ | 458 | */ |
457 | struct inode *inode; | 459 | struct inode *inode; |
460 | |||
458 | if (ino->flags & (AUTOFS_INF_EXPIRING | AUTOFS_INF_NO_RCU)) | 461 | if (ino->flags & (AUTOFS_INF_EXPIRING | AUTOFS_INF_NO_RCU)) |
459 | return 0; | 462 | return 0; |
460 | if (d_mountpoint(dentry)) | 463 | if (d_mountpoint(dentry)) |
@@ -494,13 +497,14 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) | |||
494 | } | 497 | } |
495 | 498 | ||
496 | /* Lookups in the root directory */ | 499 | /* Lookups in the root directory */ |
497 | static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) | 500 | static struct dentry *autofs4_lookup(struct inode *dir, |
501 | struct dentry *dentry, unsigned int flags) | ||
498 | { | 502 | { |
499 | struct autofs_sb_info *sbi; | 503 | struct autofs_sb_info *sbi; |
500 | struct autofs_info *ino; | 504 | struct autofs_info *ino; |
501 | struct dentry *active; | 505 | struct dentry *active; |
502 | 506 | ||
503 | DPRINTK("name = %pd", dentry); | 507 | pr_debug("name = %pd\n", dentry); |
504 | 508 | ||
505 | /* File name too long to exist */ | 509 | /* File name too long to exist */ |
506 | if (dentry->d_name.len > NAME_MAX) | 510 | if (dentry->d_name.len > NAME_MAX) |
@@ -508,14 +512,14 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, u | |||
508 | 512 | ||
509 | sbi = autofs4_sbi(dir->i_sb); | 513 | sbi = autofs4_sbi(dir->i_sb); |
510 | 514 | ||
511 | DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d", | 515 | pr_debug("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n", |
512 | current->pid, task_pgrp_nr(current), sbi->catatonic, | 516 | current->pid, task_pgrp_nr(current), sbi->catatonic, |
513 | autofs4_oz_mode(sbi)); | 517 | autofs4_oz_mode(sbi)); |
514 | 518 | ||
515 | active = autofs4_lookup_active(dentry); | 519 | active = autofs4_lookup_active(dentry); |
516 | if (active) { | 520 | if (active) |
517 | return active; | 521 | return active; |
518 | } else { | 522 | else { |
519 | /* | 523 | /* |
520 | * A dentry that is not within the root can never trigger a | 524 | * A dentry that is not within the root can never trigger a |
521 | * mount operation, unless the directory already exists, so we | 525 | * mount operation, unless the directory already exists, so we |
@@ -526,7 +530,8 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, u | |||
526 | return ERR_PTR(-ENOENT); | 530 | return ERR_PTR(-ENOENT); |
527 | 531 | ||
528 | /* Mark entries in the root as mount triggers */ | 532 | /* Mark entries in the root as mount triggers */ |
529 | if (autofs_type_indirect(sbi->type) && IS_ROOT(dentry->d_parent)) | 533 | if (IS_ROOT(dentry->d_parent) && |
534 | autofs_type_indirect(sbi->type)) | ||
530 | __managed_dentry_set_managed(dentry); | 535 | __managed_dentry_set_managed(dentry); |
531 | 536 | ||
532 | ino = autofs4_new_ino(sbi); | 537 | ino = autofs4_new_ino(sbi); |
@@ -537,8 +542,6 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, u | |||
537 | ino->dentry = dentry; | 542 | ino->dentry = dentry; |
538 | 543 | ||
539 | autofs4_add_active(dentry); | 544 | autofs4_add_active(dentry); |
540 | |||
541 | d_instantiate(dentry, NULL); | ||
542 | } | 545 | } |
543 | return NULL; | 546 | return NULL; |
544 | } | 547 | } |
@@ -554,7 +557,7 @@ static int autofs4_dir_symlink(struct inode *dir, | |||
554 | size_t size = strlen(symname); | 557 | size_t size = strlen(symname); |
555 | char *cp; | 558 | char *cp; |
556 | 559 | ||
557 | DPRINTK("%s <- %pd", symname, dentry); | 560 | pr_debug("%s <- %pd\n", symname, dentry); |
558 | 561 | ||
559 | if (!autofs4_oz_mode(sbi)) | 562 | if (!autofs4_oz_mode(sbi)) |
560 | return -EACCES; | 563 | return -EACCES; |
@@ -613,7 +616,7 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry) | |||
613 | struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); | 616 | struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); |
614 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 617 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
615 | struct autofs_info *p_ino; | 618 | struct autofs_info *p_ino; |
616 | 619 | ||
617 | /* This allows root to remove symlinks */ | 620 | /* This allows root to remove symlinks */ |
618 | if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN)) | 621 | if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN)) |
619 | return -EPERM; | 622 | return -EPERM; |
@@ -664,7 +667,6 @@ static void autofs_set_leaf_automount_flags(struct dentry *dentry) | |||
664 | if (IS_ROOT(parent->d_parent)) | 667 | if (IS_ROOT(parent->d_parent)) |
665 | return; | 668 | return; |
666 | managed_dentry_clear_managed(parent); | 669 | managed_dentry_clear_managed(parent); |
667 | return; | ||
668 | } | 670 | } |
669 | 671 | ||
670 | static void autofs_clear_leaf_automount_flags(struct dentry *dentry) | 672 | static void autofs_clear_leaf_automount_flags(struct dentry *dentry) |
@@ -687,7 +689,6 @@ static void autofs_clear_leaf_automount_flags(struct dentry *dentry) | |||
687 | if (d_child->next == &parent->d_subdirs && | 689 | if (d_child->next == &parent->d_subdirs && |
688 | d_child->prev == &parent->d_subdirs) | 690 | d_child->prev == &parent->d_subdirs) |
689 | managed_dentry_set_managed(parent); | 691 | managed_dentry_set_managed(parent); |
690 | return; | ||
691 | } | 692 | } |
692 | 693 | ||
693 | static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry) | 694 | static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry) |
@@ -695,8 +696,8 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry) | |||
695 | struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); | 696 | struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); |
696 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 697 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
697 | struct autofs_info *p_ino; | 698 | struct autofs_info *p_ino; |
698 | 699 | ||
699 | DPRINTK("dentry %p, removing %pd", dentry, dentry); | 700 | pr_debug("dentry %p, removing %pd\n", dentry, dentry); |
700 | 701 | ||
701 | if (!autofs4_oz_mode(sbi)) | 702 | if (!autofs4_oz_mode(sbi)) |
702 | return -EACCES; | 703 | return -EACCES; |
@@ -728,7 +729,8 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry) | |||
728 | return 0; | 729 | return 0; |
729 | } | 730 | } |
730 | 731 | ||
731 | static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | 732 | static int autofs4_dir_mkdir(struct inode *dir, |
733 | struct dentry *dentry, umode_t mode) | ||
732 | { | 734 | { |
733 | struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); | 735 | struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); |
734 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 736 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
@@ -738,7 +740,7 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, umode_t m | |||
738 | if (!autofs4_oz_mode(sbi)) | 740 | if (!autofs4_oz_mode(sbi)) |
739 | return -EACCES; | 741 | return -EACCES; |
740 | 742 | ||
741 | DPRINTK("dentry %p, creating %pd", dentry, dentry); | 743 | pr_debug("dentry %p, creating %pd\n", dentry, dentry); |
742 | 744 | ||
743 | BUG_ON(!ino); | 745 | BUG_ON(!ino); |
744 | 746 | ||
@@ -768,14 +770,18 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, umode_t m | |||
768 | /* Get/set timeout ioctl() operation */ | 770 | /* Get/set timeout ioctl() operation */ |
769 | #ifdef CONFIG_COMPAT | 771 | #ifdef CONFIG_COMPAT |
770 | static inline int autofs4_compat_get_set_timeout(struct autofs_sb_info *sbi, | 772 | static inline int autofs4_compat_get_set_timeout(struct autofs_sb_info *sbi, |
771 | compat_ulong_t __user *p) | 773 | compat_ulong_t __user *p) |
772 | { | 774 | { |
773 | int rv; | ||
774 | unsigned long ntimeout; | 775 | unsigned long ntimeout; |
776 | int rv; | ||
777 | |||
778 | rv = get_user(ntimeout, p); | ||
779 | if (rv) | ||
780 | goto error; | ||
775 | 781 | ||
776 | if ((rv = get_user(ntimeout, p)) || | 782 | rv = put_user(sbi->exp_timeout/HZ, p); |
777 | (rv = put_user(sbi->exp_timeout/HZ, p))) | 783 | if (rv) |
778 | return rv; | 784 | goto error; |
779 | 785 | ||
780 | if (ntimeout > UINT_MAX/HZ) | 786 | if (ntimeout > UINT_MAX/HZ) |
781 | sbi->exp_timeout = 0; | 787 | sbi->exp_timeout = 0; |
@@ -783,18 +789,24 @@ static inline int autofs4_compat_get_set_timeout(struct autofs_sb_info *sbi, | |||
783 | sbi->exp_timeout = ntimeout * HZ; | 789 | sbi->exp_timeout = ntimeout * HZ; |
784 | 790 | ||
785 | return 0; | 791 | return 0; |
792 | error: | ||
793 | return rv; | ||
786 | } | 794 | } |
787 | #endif | 795 | #endif |
788 | 796 | ||
789 | static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi, | 797 | static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi, |
790 | unsigned long __user *p) | 798 | unsigned long __user *p) |
791 | { | 799 | { |
792 | int rv; | ||
793 | unsigned long ntimeout; | 800 | unsigned long ntimeout; |
801 | int rv; | ||
802 | |||
803 | rv = get_user(ntimeout, p); | ||
804 | if (rv) | ||
805 | goto error; | ||
794 | 806 | ||
795 | if ((rv = get_user(ntimeout, p)) || | 807 | rv = put_user(sbi->exp_timeout/HZ, p); |
796 | (rv = put_user(sbi->exp_timeout/HZ, p))) | 808 | if (rv) |
797 | return rv; | 809 | goto error; |
798 | 810 | ||
799 | if (ntimeout > ULONG_MAX/HZ) | 811 | if (ntimeout > ULONG_MAX/HZ) |
800 | sbi->exp_timeout = 0; | 812 | sbi->exp_timeout = 0; |
@@ -802,16 +814,20 @@ static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi, | |||
802 | sbi->exp_timeout = ntimeout * HZ; | 814 | sbi->exp_timeout = ntimeout * HZ; |
803 | 815 | ||
804 | return 0; | 816 | return 0; |
817 | error: | ||
818 | return rv; | ||
805 | } | 819 | } |
806 | 820 | ||
807 | /* Return protocol version */ | 821 | /* Return protocol version */ |
808 | static inline int autofs4_get_protover(struct autofs_sb_info *sbi, int __user *p) | 822 | static inline int autofs4_get_protover(struct autofs_sb_info *sbi, |
823 | int __user *p) | ||
809 | { | 824 | { |
810 | return put_user(sbi->version, p); | 825 | return put_user(sbi->version, p); |
811 | } | 826 | } |
812 | 827 | ||
813 | /* Return protocol sub version */ | 828 | /* Return protocol sub version */ |
814 | static inline int autofs4_get_protosubver(struct autofs_sb_info *sbi, int __user *p) | 829 | static inline int autofs4_get_protosubver(struct autofs_sb_info *sbi, |
830 | int __user *p) | ||
815 | { | 831 | { |
816 | return put_user(sbi->sub_version, p); | 832 | return put_user(sbi->sub_version, p); |
817 | } | 833 | } |
@@ -826,7 +842,7 @@ static inline int autofs4_ask_umount(struct vfsmount *mnt, int __user *p) | |||
826 | if (may_umount(mnt)) | 842 | if (may_umount(mnt)) |
827 | status = 1; | 843 | status = 1; |
828 | 844 | ||
829 | DPRINTK("returning %d", status); | 845 | pr_debug("returning %d\n", status); |
830 | 846 | ||
831 | status = put_user(status, p); | 847 | status = put_user(status, p); |
832 | 848 | ||
@@ -834,9 +850,9 @@ static inline int autofs4_ask_umount(struct vfsmount *mnt, int __user *p) | |||
834 | } | 850 | } |
835 | 851 | ||
836 | /* Identify autofs4_dentries - this is so we can tell if there's | 852 | /* Identify autofs4_dentries - this is so we can tell if there's |
837 | an extra dentry refcount or not. We only hold a refcount on the | 853 | * an extra dentry refcount or not. We only hold a refcount on the |
838 | dentry if its non-negative (ie, d_inode != NULL) | 854 | * dentry if its non-negative (ie, d_inode != NULL) |
839 | */ | 855 | */ |
840 | int is_autofs4_dentry(struct dentry *dentry) | 856 | int is_autofs4_dentry(struct dentry *dentry) |
841 | { | 857 | { |
842 | return dentry && d_really_is_positive(dentry) && | 858 | return dentry && d_really_is_positive(dentry) && |
@@ -854,21 +870,21 @@ static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp, | |||
854 | struct autofs_sb_info *sbi = autofs4_sbi(inode->i_sb); | 870 | struct autofs_sb_info *sbi = autofs4_sbi(inode->i_sb); |
855 | void __user *p = (void __user *)arg; | 871 | void __user *p = (void __user *)arg; |
856 | 872 | ||
857 | DPRINTK("cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u", | 873 | pr_debug("cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n", |
858 | cmd,arg,sbi,task_pgrp_nr(current)); | 874 | cmd, arg, sbi, task_pgrp_nr(current)); |
859 | 875 | ||
860 | if (_IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) || | 876 | if (_IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) || |
861 | _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT) | 877 | _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT) |
862 | return -ENOTTY; | 878 | return -ENOTTY; |
863 | 879 | ||
864 | if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN)) | 880 | if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN)) |
865 | return -EPERM; | 881 | return -EPERM; |
866 | 882 | ||
867 | switch(cmd) { | 883 | switch (cmd) { |
868 | case AUTOFS_IOC_READY: /* Wait queue: go ahead and retry */ | 884 | case AUTOFS_IOC_READY: /* Wait queue: go ahead and retry */ |
869 | return autofs4_wait_release(sbi,(autofs_wqt_t)arg,0); | 885 | return autofs4_wait_release(sbi, (autofs_wqt_t) arg, 0); |
870 | case AUTOFS_IOC_FAIL: /* Wait queue: fail with ENOENT */ | 886 | case AUTOFS_IOC_FAIL: /* Wait queue: fail with ENOENT */ |
871 | return autofs4_wait_release(sbi,(autofs_wqt_t)arg,-ENOENT); | 887 | return autofs4_wait_release(sbi, (autofs_wqt_t) arg, -ENOENT); |
872 | case AUTOFS_IOC_CATATONIC: /* Enter catatonic mode (daemon shutdown) */ | 888 | case AUTOFS_IOC_CATATONIC: /* Enter catatonic mode (daemon shutdown) */ |
873 | autofs4_catatonic_mode(sbi); | 889 | autofs4_catatonic_mode(sbi); |
874 | return 0; | 890 | return 0; |
@@ -888,13 +904,15 @@ static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp, | |||
888 | 904 | ||
889 | /* return a single thing to expire */ | 905 | /* return a single thing to expire */ |
890 | case AUTOFS_IOC_EXPIRE: | 906 | case AUTOFS_IOC_EXPIRE: |
891 | return autofs4_expire_run(inode->i_sb,filp->f_path.mnt,sbi, p); | 907 | return autofs4_expire_run(inode->i_sb, |
908 | filp->f_path.mnt, sbi, p); | ||
892 | /* same as above, but can send multiple expires through pipe */ | 909 | /* same as above, but can send multiple expires through pipe */ |
893 | case AUTOFS_IOC_EXPIRE_MULTI: | 910 | case AUTOFS_IOC_EXPIRE_MULTI: |
894 | return autofs4_expire_multi(inode->i_sb,filp->f_path.mnt,sbi, p); | 911 | return autofs4_expire_multi(inode->i_sb, |
912 | filp->f_path.mnt, sbi, p); | ||
895 | 913 | ||
896 | default: | 914 | default: |
897 | return -ENOSYS; | 915 | return -EINVAL; |
898 | } | 916 | } |
899 | } | 917 | } |
900 | 918 | ||
@@ -902,12 +920,13 @@ static long autofs4_root_ioctl(struct file *filp, | |||
902 | unsigned int cmd, unsigned long arg) | 920 | unsigned int cmd, unsigned long arg) |
903 | { | 921 | { |
904 | struct inode *inode = file_inode(filp); | 922 | struct inode *inode = file_inode(filp); |
923 | |||
905 | return autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); | 924 | return autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); |
906 | } | 925 | } |
907 | 926 | ||
908 | #ifdef CONFIG_COMPAT | 927 | #ifdef CONFIG_COMPAT |
909 | static long autofs4_root_compat_ioctl(struct file *filp, | 928 | static long autofs4_root_compat_ioctl(struct file *filp, |
910 | unsigned int cmd, unsigned long arg) | 929 | unsigned int cmd, unsigned long arg) |
911 | { | 930 | { |
912 | struct inode *inode = file_inode(filp); | 931 | struct inode *inode = file_inode(filp); |
913 | int ret; | 932 | int ret; |
@@ -916,7 +935,7 @@ static long autofs4_root_compat_ioctl(struct file *filp, | |||
916 | ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); | 935 | ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); |
917 | else | 936 | else |
918 | ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, | 937 | ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, |
919 | (unsigned long)compat_ptr(arg)); | 938 | (unsigned long) compat_ptr(arg)); |
920 | 939 | ||
921 | return ret; | 940 | return ret; |
922 | } | 941 | } |