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

autofs4: make autofs type usage explicit

- the type assigned at mount when no type is given is changed
from 0 to AUTOFS_TYPE_INDIRECT. This was done because 0 and
AUTOFS_TYPE_INDIRECT were being treated implicitly as the same
type.

- previously, an offset mount had it's type set to
AUTOFS_TYPE_DIRECT|AUTOFS_TYPE_OFFSET but the mount control
re-implementation needs to be able distinguish all three types.
So this was changed to make the type setting explicit.

- a type AUTOFS_TYPE_ANY was added for use by the re-implementation
when checking if a given path is a mountpoint. It's not really a
type as we use this to ask if a given path is a mountpoint in the
autofs_dev_ioctl_ismountpoint() function.

- functions to set and test the autofs mount types have been added to
improve readability and make the type usage explicit.

- the mount type is used from user space for the mount control
re-implementtion so, for consistency, all the definitions have
been moved to the user space include file include/linux/auto_fs4.h.

Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ian Kent and committed by
Linus Torvalds
a92daf6b 41cfef2e

+73 -21
-2
fs/autofs4/autofs_i.h
··· 25 25 #define AUTOFS_DEV_IOCTL_IOC_FIRST (AUTOFS_DEV_IOCTL_VERSION) 26 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 28 #include <linux/kernel.h> 31 29 #include <linux/slab.h> 32 30 #include <linux/time.h>
+2 -2
fs/autofs4/dev-ioctl.c
··· 532 532 how = param->expire.how; 533 533 mnt = fp->f_path.mnt; 534 534 535 - if (sbi->type & AUTOFS_TYPE_TRIGGER) 535 + if (autofs_type_trigger(sbi->type)) 536 536 dentry = autofs4_expire_direct(sbi->sb, mnt, sbi, how); 537 537 else 538 538 dentry = autofs4_expire_indirect(sbi->sb, mnt, sbi, how); ··· 615 615 param->ismountpoint.out.magic = magic = 0; 616 616 617 617 if (!fp || param->ioctlfd == -1) { 618 - if (type == AUTOFS_TYPE_ANY) { 618 + if (autofs_type_any(type)) { 619 619 struct super_block *sb; 620 620 621 621 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
+2 -2
fs/autofs4/expire.c
··· 63 63 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 64 64 65 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 67 goto done; 68 68 69 69 /* ··· 490 490 if (arg && get_user(do_now, arg)) 491 491 return -EFAULT; 492 492 493 - if (sbi->type & AUTOFS_TYPE_TRIGGER) 493 + if (autofs_type_trigger(sbi->type)) 494 494 dentry = autofs4_expire_direct(sb, mnt, sbi, do_now); 495 495 else 496 496 dentry = autofs4_expire_indirect(sb, mnt, sbi, do_now);
+7 -7
fs/autofs4/inode.c
··· 197 197 seq_printf(m, ",minproto=%d", sbi->min_proto); 198 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 201 seq_printf(m, ",offset"); 202 - else if (sbi->type & AUTOFS_TYPE_DIRECT) 202 + else if (autofs_type_direct(sbi->type)) 203 203 seq_printf(m, ",direct"); 204 204 else 205 205 seq_printf(m, ",indirect"); ··· 284 284 *maxproto = option; 285 285 break; 286 286 case Opt_indirect: 287 - *type = AUTOFS_TYPE_INDIRECT; 287 + set_autofs_type_indirect(type); 288 288 break; 289 289 case Opt_direct: 290 - *type = AUTOFS_TYPE_DIRECT; 290 + set_autofs_type_direct(type); 291 291 break; 292 292 case Opt_offset: 293 - *type = AUTOFS_TYPE_OFFSET; 293 + set_autofs_type_offset(type); 294 294 break; 295 295 default: 296 296 return 1; ··· 338 338 sbi->sb = s; 339 339 sbi->version = 0; 340 340 sbi->sub_version = 0; 341 - sbi->type = AUTOFS_TYPE_INDIRECT; 341 + set_autofs_type_indirect(&sbi->type); 342 342 sbi->min_proto = 0; 343 343 sbi->max_proto = 0; 344 344 mutex_init(&sbi->wq_mutex); ··· 380 380 } 381 381 382 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 384 &autofs4_direct_root_inode_operations : 385 385 &autofs4_indirect_root_inode_operations; 386 386
+4 -4
fs/autofs4/waitq.c
··· 337 337 * is very similar for indirect mounts except only dentrys 338 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 341 return -ENOENT; 342 342 else if (!IS_ROOT(dentry->d_parent)) 343 343 return -ENOENT; ··· 348 348 return -ENOMEM; 349 349 350 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 352 qstr.len = sprintf(name, "%p", dentry); 353 353 else { 354 354 qstr.len = autofs4_getpath(sbi, dentry, &name); ··· 406 406 type = autofs_ptype_expire_multi; 407 407 } else { 408 408 if (notify == NFY_MOUNT) 409 - type = (sbi->type & AUTOFS_TYPE_TRIGGER) ? 409 + type = autofs_type_trigger(sbi->type) ? 410 410 autofs_ptype_missing_direct : 411 411 autofs_ptype_missing_indirect; 412 412 else 413 - type = (sbi->type & AUTOFS_TYPE_TRIGGER) ? 413 + type = autofs_type_trigger(sbi->type) ? 414 414 autofs_ptype_expire_direct : 415 415 autofs_ptype_expire_indirect; 416 416 }
+58 -4
include/linux/auto_fs4.h
··· 29 29 #define AUTOFS_EXP_IMMEDIATE 1 30 30 #define AUTOFS_EXP_LEAVES 2 31 31 32 - #define AUTOFS_TYPE_ANY 0x0000 33 - #define AUTOFS_TYPE_INDIRECT 0x0001 34 - #define AUTOFS_TYPE_DIRECT 0x0002 35 - #define AUTOFS_TYPE_OFFSET 0x0004 32 + #define AUTOFS_TYPE_ANY 0U 33 + #define AUTOFS_TYPE_INDIRECT 1U 34 + #define AUTOFS_TYPE_DIRECT 2U 35 + #define AUTOFS_TYPE_OFFSET 4U 36 + 37 + static inline void set_autofs_type_indirect(unsigned int *type) 38 + { 39 + *type = AUTOFS_TYPE_INDIRECT; 40 + return; 41 + } 42 + 43 + static inline unsigned int autofs_type_indirect(unsigned int type) 44 + { 45 + return (type == AUTOFS_TYPE_INDIRECT); 46 + } 47 + 48 + static inline void set_autofs_type_direct(unsigned int *type) 49 + { 50 + *type = AUTOFS_TYPE_DIRECT; 51 + return; 52 + } 53 + 54 + static inline unsigned int autofs_type_direct(unsigned int type) 55 + { 56 + return (type == AUTOFS_TYPE_DIRECT); 57 + } 58 + 59 + static inline void set_autofs_type_offset(unsigned int *type) 60 + { 61 + *type = AUTOFS_TYPE_OFFSET; 62 + return; 63 + } 64 + 65 + static inline unsigned int autofs_type_offset(unsigned int type) 66 + { 67 + return (type == AUTOFS_TYPE_OFFSET); 68 + } 69 + 70 + static inline unsigned int autofs_type_trigger(unsigned int type) 71 + { 72 + return (type == AUTOFS_TYPE_DIRECT || type == AUTOFS_TYPE_OFFSET); 73 + } 74 + 75 + /* 76 + * This isn't really a type as we use it to say "no type set" to 77 + * indicate we want to search for "any" mount in the 78 + * autofs_dev_ioctl_ismountpoint() device ioctl function. 79 + */ 80 + static inline void set_autofs_type_any(unsigned int *type) 81 + { 82 + *type = AUTOFS_TYPE_ANY; 83 + return; 84 + } 85 + 86 + static inline unsigned int autofs_type_any(unsigned int type) 87 + { 88 + return (type == AUTOFS_TYPE_ANY); 89 + } 36 90 37 91 /* Daemon notification packet types */ 38 92 enum autofs_notify {