aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs4
diff options
context:
space:
mode:
authorDavid Vrabel <david.vrabel@csr.com>2009-01-07 05:45:25 -0500
committerDavid Vrabel <david.vrabel@csr.com>2009-01-07 05:45:25 -0500
commita23e66f3b8cfdedec14541e71ef29a754870a20c (patch)
treef8ac23572982e92e6f8ae09c4039db627bdf53ee /fs/autofs4
parent04c470adb01c62bb9bd663cfc4875cf0a4eb01ab (diff)
parentede6f5aea054d3fb67c78857f7abdee602302043 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 into for-upstream
Diffstat (limited to 'fs/autofs4')
-rw-r--r--fs/autofs4/autofs_i.h2
-rw-r--r--fs/autofs4/dev-ioctl.c75
-rw-r--r--fs/autofs4/expire.c4
-rw-r--r--fs/autofs4/inode.c14
-rw-r--r--fs/autofs4/waitq.c8
5 files changed, 53 insertions, 50 deletions
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index e0f16da00e54..a76803108d06 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -25,8 +25,6 @@
25#define AUTOFS_DEV_IOCTL_IOC_FIRST (AUTOFS_DEV_IOCTL_VERSION) 25#define AUTOFS_DEV_IOCTL_IOC_FIRST (AUTOFS_DEV_IOCTL_VERSION)
26#define AUTOFS_DEV_IOCTL_IOC_COUNT (AUTOFS_IOC_COUNT - 11) 26#define AUTOFS_DEV_IOCTL_IOC_COUNT (AUTOFS_IOC_COUNT - 11)
27 27
28#define AUTOFS_TYPE_TRIGGER (AUTOFS_TYPE_DIRECT|AUTOFS_TYPE_OFFSET)
29
30#include <linux/kernel.h> 28#include <linux/kernel.h>
31#include <linux/slab.h> 29#include <linux/slab.h>
32#include <linux/time.h> 30#include <linux/time.h>
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 63b7c7afe8df..025e105bffea 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -124,7 +124,7 @@ static inline void free_dev_ioctl(struct autofs_dev_ioctl *param)
124 124
125/* 125/*
126 * Check sanity of parameter control fields and if a path is present 126 * Check sanity of parameter control fields and if a path is present
127 * check that it has a "/" and is terminated. 127 * check that it is terminated and contains at least one "/".
128 */ 128 */
129static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param) 129static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
130{ 130{
@@ -138,15 +138,16 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
138 } 138 }
139 139
140 if (param->size > sizeof(*param)) { 140 if (param->size > sizeof(*param)) {
141 err = check_name(param->path); 141 err = invalid_str(param->path,
142 (void *) ((size_t) param + param->size));
142 if (err) { 143 if (err) {
143 AUTOFS_WARN("invalid path supplied for cmd(0x%08x)", 144 AUTOFS_WARN(
144 cmd); 145 "path string terminator missing for cmd(0x%08x)",
146 cmd);
145 goto out; 147 goto out;
146 } 148 }
147 149
148 err = invalid_str(param->path, 150 err = check_name(param->path);
149 (void *) ((size_t) param + param->size));
150 if (err) { 151 if (err) {
151 AUTOFS_WARN("invalid path supplied for cmd(0x%08x)", 152 AUTOFS_WARN("invalid path supplied for cmd(0x%08x)",
152 cmd); 153 cmd);
@@ -180,7 +181,7 @@ static int autofs_dev_ioctl_protover(struct file *fp,
180 struct autofs_sb_info *sbi, 181 struct autofs_sb_info *sbi,
181 struct autofs_dev_ioctl *param) 182 struct autofs_dev_ioctl *param)
182{ 183{
183 param->arg1 = sbi->version; 184 param->protover.version = sbi->version;
184 return 0; 185 return 0;
185} 186}
186 187
@@ -189,7 +190,7 @@ static int autofs_dev_ioctl_protosubver(struct file *fp,
189 struct autofs_sb_info *sbi, 190 struct autofs_sb_info *sbi,
190 struct autofs_dev_ioctl *param) 191 struct autofs_dev_ioctl *param)
191{ 192{
192 param->arg1 = sbi->sub_version; 193 param->protosubver.sub_version = sbi->sub_version;
193 return 0; 194 return 0;
194} 195}
195 196
@@ -335,13 +336,13 @@ static int autofs_dev_ioctl_openmount(struct file *fp,
335 int err, fd; 336 int err, fd;
336 337
337 /* param->path has already been checked */ 338 /* param->path has already been checked */
338 if (!param->arg1) 339 if (!param->openmount.devid)
339 return -EINVAL; 340 return -EINVAL;
340 341
341 param->ioctlfd = -1; 342 param->ioctlfd = -1;
342 343
343 path = param->path; 344 path = param->path;
344 devid = param->arg1; 345 devid = param->openmount.devid;
345 346
346 err = 0; 347 err = 0;
347 fd = autofs_dev_ioctl_open_mountpoint(path, devid); 348 fd = autofs_dev_ioctl_open_mountpoint(path, devid);
@@ -373,7 +374,7 @@ static int autofs_dev_ioctl_ready(struct file *fp,
373{ 374{
374 autofs_wqt_t token; 375 autofs_wqt_t token;
375 376
376 token = (autofs_wqt_t) param->arg1; 377 token = (autofs_wqt_t) param->ready.token;
377 return autofs4_wait_release(sbi, token, 0); 378 return autofs4_wait_release(sbi, token, 0);
378} 379}
379 380
@@ -388,8 +389,8 @@ static int autofs_dev_ioctl_fail(struct file *fp,
388 autofs_wqt_t token; 389 autofs_wqt_t token;
389 int status; 390 int status;
390 391
391 token = (autofs_wqt_t) param->arg1; 392 token = (autofs_wqt_t) param->fail.token;
392 status = param->arg2 ? param->arg2 : -ENOENT; 393 status = param->fail.status ? param->fail.status : -ENOENT;
393 return autofs4_wait_release(sbi, token, status); 394 return autofs4_wait_release(sbi, token, status);
394} 395}
395 396
@@ -412,10 +413,10 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
412 int pipefd; 413 int pipefd;
413 int err = 0; 414 int err = 0;
414 415
415 if (param->arg1 == -1) 416 if (param->setpipefd.pipefd == -1)
416 return -EINVAL; 417 return -EINVAL;
417 418
418 pipefd = param->arg1; 419 pipefd = param->setpipefd.pipefd;
419 420
420 mutex_lock(&sbi->wq_mutex); 421 mutex_lock(&sbi->wq_mutex);
421 if (!sbi->catatonic) { 422 if (!sbi->catatonic) {
@@ -457,8 +458,8 @@ static int autofs_dev_ioctl_timeout(struct file *fp,
457{ 458{
458 unsigned long timeout; 459 unsigned long timeout;
459 460
460 timeout = param->arg1; 461 timeout = param->timeout.timeout;
461 param->arg1 = sbi->exp_timeout / HZ; 462 param->timeout.timeout = sbi->exp_timeout / HZ;
462 sbi->exp_timeout = timeout * HZ; 463 sbi->exp_timeout = timeout * HZ;
463 return 0; 464 return 0;
464} 465}
@@ -489,7 +490,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
489 path = param->path; 490 path = param->path;
490 devid = sbi->sb->s_dev; 491 devid = sbi->sb->s_dev;
491 492
492 param->arg1 = param->arg2 = -1; 493 param->requester.uid = param->requester.gid = -1;
493 494
494 /* Get nameidata of the parent directory */ 495 /* Get nameidata of the parent directory */
495 err = path_lookup(path, LOOKUP_PARENT, &nd); 496 err = path_lookup(path, LOOKUP_PARENT, &nd);
@@ -505,8 +506,8 @@ static int autofs_dev_ioctl_requester(struct file *fp,
505 err = 0; 506 err = 0;
506 autofs4_expire_wait(nd.path.dentry); 507 autofs4_expire_wait(nd.path.dentry);
507 spin_lock(&sbi->fs_lock); 508 spin_lock(&sbi->fs_lock);
508 param->arg1 = ino->uid; 509 param->requester.uid = ino->uid;
509 param->arg2 = ino->gid; 510 param->requester.gid = ino->gid;
510 spin_unlock(&sbi->fs_lock); 511 spin_unlock(&sbi->fs_lock);
511 } 512 }
512 513
@@ -529,10 +530,10 @@ static int autofs_dev_ioctl_expire(struct file *fp,
529 int err = -EAGAIN; 530 int err = -EAGAIN;
530 int how; 531 int how;
531 532
532 how = param->arg1; 533 how = param->expire.how;
533 mnt = fp->f_path.mnt; 534 mnt = fp->f_path.mnt;
534 535
535 if (sbi->type & AUTOFS_TYPE_TRIGGER) 536 if (autofs_type_trigger(sbi->type))
536 dentry = autofs4_expire_direct(sbi->sb, mnt, sbi, how); 537 dentry = autofs4_expire_direct(sbi->sb, mnt, sbi, how);
537 else 538 else
538 dentry = autofs4_expire_indirect(sbi->sb, mnt, sbi, how); 539 dentry = autofs4_expire_indirect(sbi->sb, mnt, sbi, how);
@@ -565,9 +566,9 @@ static int autofs_dev_ioctl_askumount(struct file *fp,
565 struct autofs_sb_info *sbi, 566 struct autofs_sb_info *sbi,
566 struct autofs_dev_ioctl *param) 567 struct autofs_dev_ioctl *param)
567{ 568{
568 param->arg1 = 0; 569 param->askumount.may_umount = 0;
569 if (may_umount(fp->f_path.mnt)) 570 if (may_umount(fp->f_path.mnt))
570 param->arg1 = 1; 571 param->askumount.may_umount = 1;
571 return 0; 572 return 0;
572} 573}
573 574
@@ -600,6 +601,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
600 struct nameidata nd; 601 struct nameidata nd;
601 const char *path; 602 const char *path;
602 unsigned int type; 603 unsigned int type;
604 unsigned int devid, magic;
603 int err = -ENOENT; 605 int err = -ENOENT;
604 606
605 if (param->size <= sizeof(*param)) { 607 if (param->size <= sizeof(*param)) {
@@ -608,13 +610,13 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
608 } 610 }
609 611
610 path = param->path; 612 path = param->path;
611 type = param->arg1; 613 type = param->ismountpoint.in.type;
612 614
613 param->arg1 = 0; 615 param->ismountpoint.out.devid = devid = 0;
614 param->arg2 = 0; 616 param->ismountpoint.out.magic = magic = 0;
615 617
616 if (!fp || param->ioctlfd == -1) { 618 if (!fp || param->ioctlfd == -1) {
617 if (type == AUTOFS_TYPE_ANY) { 619 if (autofs_type_any(type)) {
618 struct super_block *sb; 620 struct super_block *sb;
619 621
620 err = path_lookup(path, LOOKUP_FOLLOW, &nd); 622 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
@@ -622,7 +624,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
622 goto out; 624 goto out;
623 625
624 sb = nd.path.dentry->d_sb; 626 sb = nd.path.dentry->d_sb;
625 param->arg1 = new_encode_dev(sb->s_dev); 627 devid = new_encode_dev(sb->s_dev);
626 } else { 628 } else {
627 struct autofs_info *ino; 629 struct autofs_info *ino;
628 630
@@ -635,38 +637,41 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
635 goto out_release; 637 goto out_release;
636 638
637 ino = autofs4_dentry_ino(nd.path.dentry); 639 ino = autofs4_dentry_ino(nd.path.dentry);
638 param->arg1 = autofs4_get_dev(ino->sbi); 640 devid = autofs4_get_dev(ino->sbi);
639 } 641 }
640 642
641 err = 0; 643 err = 0;
642 if (nd.path.dentry->d_inode && 644 if (nd.path.dentry->d_inode &&
643 nd.path.mnt->mnt_root == nd.path.dentry) { 645 nd.path.mnt->mnt_root == nd.path.dentry) {
644 err = 1; 646 err = 1;
645 param->arg2 = nd.path.dentry->d_inode->i_sb->s_magic; 647 magic = nd.path.dentry->d_inode->i_sb->s_magic;
646 } 648 }
647 } else { 649 } else {
648 dev_t devid = new_encode_dev(sbi->sb->s_dev); 650 dev_t dev = autofs4_get_dev(sbi);
649 651
650 err = path_lookup(path, LOOKUP_PARENT, &nd); 652 err = path_lookup(path, LOOKUP_PARENT, &nd);
651 if (err) 653 if (err)
652 goto out; 654 goto out;
653 655
654 err = autofs_dev_ioctl_find_super(&nd, devid); 656 err = autofs_dev_ioctl_find_super(&nd, dev);
655 if (err) 657 if (err)
656 goto out_release; 658 goto out_release;
657 659
658 param->arg1 = autofs4_get_dev(sbi); 660 devid = dev;
659 661
660 err = have_submounts(nd.path.dentry); 662 err = have_submounts(nd.path.dentry);
661 663
662 if (nd.path.mnt->mnt_mountpoint != nd.path.mnt->mnt_root) { 664 if (nd.path.mnt->mnt_mountpoint != nd.path.mnt->mnt_root) {
663 if (follow_down(&nd.path.mnt, &nd.path.dentry)) { 665 if (follow_down(&nd.path.mnt, &nd.path.dentry)) {
664 struct inode *inode = nd.path.dentry->d_inode; 666 struct inode *inode = nd.path.dentry->d_inode;
665 param->arg2 = inode->i_sb->s_magic; 667 magic = inode->i_sb->s_magic;
666 } 668 }
667 } 669 }
668 } 670 }
669 671
672 param->ismountpoint.out.devid = devid;
673 param->ismountpoint.out.magic = magic;
674
670out_release: 675out_release:
671 path_put(&nd.path); 676 path_put(&nd.path);
672out: 677out:
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 4b6fb3f628c0..e3bd50776f9e 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -63,7 +63,7 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry)
63 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 63 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
64 64
65 /* This is an autofs submount, we can't expire it */ 65 /* This is an autofs submount, we can't expire it */
66 if (sbi->type == AUTOFS_TYPE_INDIRECT) 66 if (autofs_type_indirect(sbi->type))
67 goto done; 67 goto done;
68 68
69 /* 69 /*
@@ -490,7 +490,7 @@ int autofs4_expire_multi(struct super_block *sb, struct vfsmount *mnt,
490 if (arg && get_user(do_now, arg)) 490 if (arg && get_user(do_now, arg))
491 return -EFAULT; 491 return -EFAULT;
492 492
493 if (sbi->type & AUTOFS_TYPE_TRIGGER) 493 if (autofs_type_trigger(sbi->type))
494 dentry = autofs4_expire_direct(sb, mnt, sbi, do_now); 494 dentry = autofs4_expire_direct(sb, mnt, sbi, do_now);
495 else 495 else
496 dentry = autofs4_expire_indirect(sb, mnt, sbi, do_now); 496 dentry = autofs4_expire_indirect(sb, mnt, sbi, do_now);
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index cfc23e53b6f4..716e12b627b2 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -197,9 +197,9 @@ static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt)
197 seq_printf(m, ",minproto=%d", sbi->min_proto); 197 seq_printf(m, ",minproto=%d", sbi->min_proto);
198 seq_printf(m, ",maxproto=%d", sbi->max_proto); 198 seq_printf(m, ",maxproto=%d", sbi->max_proto);
199 199
200 if (sbi->type & AUTOFS_TYPE_OFFSET) 200 if (autofs_type_offset(sbi->type))
201 seq_printf(m, ",offset"); 201 seq_printf(m, ",offset");
202 else if (sbi->type & AUTOFS_TYPE_DIRECT) 202 else if (autofs_type_direct(sbi->type))
203 seq_printf(m, ",direct"); 203 seq_printf(m, ",direct");
204 else 204 else
205 seq_printf(m, ",indirect"); 205 seq_printf(m, ",indirect");
@@ -284,13 +284,13 @@ static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid,
284 *maxproto = option; 284 *maxproto = option;
285 break; 285 break;
286 case Opt_indirect: 286 case Opt_indirect:
287 *type = AUTOFS_TYPE_INDIRECT; 287 set_autofs_type_indirect(type);
288 break; 288 break;
289 case Opt_direct: 289 case Opt_direct:
290 *type = AUTOFS_TYPE_DIRECT; 290 set_autofs_type_direct(type);
291 break; 291 break;
292 case Opt_offset: 292 case Opt_offset:
293 *type = AUTOFS_TYPE_OFFSET; 293 set_autofs_type_offset(type);
294 break; 294 break;
295 default: 295 default:
296 return 1; 296 return 1;
@@ -338,7 +338,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
338 sbi->sb = s; 338 sbi->sb = s;
339 sbi->version = 0; 339 sbi->version = 0;
340 sbi->sub_version = 0; 340 sbi->sub_version = 0;
341 sbi->type = AUTOFS_TYPE_INDIRECT; 341 set_autofs_type_indirect(&sbi->type);
342 sbi->min_proto = 0; 342 sbi->min_proto = 0;
343 sbi->max_proto = 0; 343 sbi->max_proto = 0;
344 mutex_init(&sbi->wq_mutex); 344 mutex_init(&sbi->wq_mutex);
@@ -380,7 +380,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
380 } 380 }
381 381
382 root_inode->i_fop = &autofs4_root_operations; 382 root_inode->i_fop = &autofs4_root_operations;
383 root_inode->i_op = sbi->type & AUTOFS_TYPE_TRIGGER ? 383 root_inode->i_op = autofs_type_trigger(sbi->type) ?
384 &autofs4_direct_root_inode_operations : 384 &autofs4_direct_root_inode_operations :
385 &autofs4_indirect_root_inode_operations; 385 &autofs4_indirect_root_inode_operations;
386 386
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index e02cc8ae5eb3..eeb246845909 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -337,7 +337,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
337 * is very similar for indirect mounts except only dentrys 337 * is very similar for indirect mounts except only dentrys
338 * in the root of the autofs file system may be negative. 338 * in the root of the autofs file system may be negative.
339 */ 339 */
340 if (sbi->type & AUTOFS_TYPE_TRIGGER) 340 if (autofs_type_trigger(sbi->type))
341 return -ENOENT; 341 return -ENOENT;
342 else if (!IS_ROOT(dentry->d_parent)) 342 else if (!IS_ROOT(dentry->d_parent))
343 return -ENOENT; 343 return -ENOENT;
@@ -348,7 +348,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
348 return -ENOMEM; 348 return -ENOMEM;
349 349
350 /* If this is a direct mount request create a dummy name */ 350 /* If this is a direct mount request create a dummy name */
351 if (IS_ROOT(dentry) && sbi->type & AUTOFS_TYPE_TRIGGER) 351 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
352 qstr.len = sprintf(name, "%p", dentry); 352 qstr.len = sprintf(name, "%p", dentry);
353 else { 353 else {
354 qstr.len = autofs4_getpath(sbi, dentry, &name); 354 qstr.len = autofs4_getpath(sbi, dentry, &name);
@@ -406,11 +406,11 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
406 type = autofs_ptype_expire_multi; 406 type = autofs_ptype_expire_multi;
407 } else { 407 } else {
408 if (notify == NFY_MOUNT) 408 if (notify == NFY_MOUNT)
409 type = (sbi->type & AUTOFS_TYPE_TRIGGER) ? 409 type = autofs_type_trigger(sbi->type) ?
410 autofs_ptype_missing_direct : 410 autofs_ptype_missing_direct :
411 autofs_ptype_missing_indirect; 411 autofs_ptype_missing_indirect;
412 else 412 else
413 type = (sbi->type & AUTOFS_TYPE_TRIGGER) ? 413 type = autofs_type_trigger(sbi->type) ?
414 autofs_ptype_expire_direct : 414 autofs_ptype_expire_direct :
415 autofs_ptype_expire_indirect; 415 autofs_ptype_expire_indirect;
416 } 416 }