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

autofs4: improve parameter usage

The parameter usage in the device node ioctl code uses arg1 and arg2 as
parameter names. This patch redefines the parameter names to reflect what
they actually are in an effort to make the code more readable.

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
730c9eec f70f582f

+100 -29
+29 -25
fs/autofs4/dev-ioctl.c
··· 180 180 struct autofs_sb_info *sbi, 181 181 struct autofs_dev_ioctl *param) 182 182 { 183 - param->arg1 = sbi->version; 183 + param->protover.version = sbi->version; 184 184 return 0; 185 185 } 186 186 ··· 189 189 struct autofs_sb_info *sbi, 190 190 struct autofs_dev_ioctl *param) 191 191 { 192 - param->arg1 = sbi->sub_version; 192 + param->protosubver.sub_version = sbi->sub_version; 193 193 return 0; 194 194 } 195 195 ··· 335 335 int err, fd; 336 336 337 337 /* param->path has already been checked */ 338 - if (!param->arg1) 338 + if (!param->openmount.devid) 339 339 return -EINVAL; 340 340 341 341 param->ioctlfd = -1; 342 342 343 343 path = param->path; 344 - devid = param->arg1; 344 + devid = param->openmount.devid; 345 345 346 346 err = 0; 347 347 fd = autofs_dev_ioctl_open_mountpoint(path, devid); ··· 373 373 { 374 374 autofs_wqt_t token; 375 375 376 - token = (autofs_wqt_t) param->arg1; 376 + token = (autofs_wqt_t) param->ready.token; 377 377 return autofs4_wait_release(sbi, token, 0); 378 378 } 379 379 ··· 388 388 autofs_wqt_t token; 389 389 int status; 390 390 391 - token = (autofs_wqt_t) param->arg1; 392 - status = param->arg2 ? param->arg2 : -ENOENT; 391 + token = (autofs_wqt_t) param->fail.token; 392 + status = param->fail.status ? param->fail.status : -ENOENT; 393 393 return autofs4_wait_release(sbi, token, status); 394 394 } 395 395 ··· 412 412 int pipefd; 413 413 int err = 0; 414 414 415 - if (param->arg1 == -1) 415 + if (param->setpipefd.pipefd == -1) 416 416 return -EINVAL; 417 417 418 - pipefd = param->arg1; 418 + pipefd = param->setpipefd.pipefd; 419 419 420 420 mutex_lock(&sbi->wq_mutex); 421 421 if (!sbi->catatonic) { ··· 457 457 { 458 458 unsigned long timeout; 459 459 460 - timeout = param->arg1; 461 - param->arg1 = sbi->exp_timeout / HZ; 460 + timeout = param->timeout.timeout; 461 + param->timeout.timeout = sbi->exp_timeout / HZ; 462 462 sbi->exp_timeout = timeout * HZ; 463 463 return 0; 464 464 } ··· 489 489 path = param->path; 490 490 devid = sbi->sb->s_dev; 491 491 492 - param->arg1 = param->arg2 = -1; 492 + param->requester.uid = param->requester.gid = -1; 493 493 494 494 /* Get nameidata of the parent directory */ 495 495 err = path_lookup(path, LOOKUP_PARENT, &nd); ··· 505 505 err = 0; 506 506 autofs4_expire_wait(nd.path.dentry); 507 507 spin_lock(&sbi->fs_lock); 508 - param->arg1 = ino->uid; 509 - param->arg2 = ino->gid; 508 + param->requester.uid = ino->uid; 509 + param->requester.gid = ino->gid; 510 510 spin_unlock(&sbi->fs_lock); 511 511 } 512 512 ··· 529 529 int err = -EAGAIN; 530 530 int how; 531 531 532 - how = param->arg1; 532 + how = param->expire.how; 533 533 mnt = fp->f_path.mnt; 534 534 535 535 if (sbi->type & AUTOFS_TYPE_TRIGGER) ··· 565 565 struct autofs_sb_info *sbi, 566 566 struct autofs_dev_ioctl *param) 567 567 { 568 - param->arg1 = 0; 568 + param->askumount.may_umount = 0; 569 569 if (may_umount(fp->f_path.mnt)) 570 - param->arg1 = 1; 570 + param->askumount.may_umount = 1; 571 571 return 0; 572 572 } 573 573 ··· 600 600 struct nameidata nd; 601 601 const char *path; 602 602 unsigned int type; 603 + unsigned int devid, magic; 603 604 int err = -ENOENT; 604 605 605 606 if (param->size <= sizeof(*param)) { ··· 609 608 } 610 609 611 610 path = param->path; 612 - type = param->arg1; 611 + type = param->ismountpoint.in.type; 613 612 614 - param->arg1 = 0; 615 - param->arg2 = 0; 613 + param->ismountpoint.out.devid = devid = 0; 614 + param->ismountpoint.out.magic = magic = 0; 616 615 617 616 if (!fp || param->ioctlfd == -1) { 618 617 if (type == AUTOFS_TYPE_ANY) { ··· 623 622 goto out; 624 623 625 624 sb = nd.path.dentry->d_sb; 626 - param->arg1 = new_encode_dev(sb->s_dev); 625 + devid = new_encode_dev(sb->s_dev); 627 626 } else { 628 627 struct autofs_info *ino; 629 628 ··· 636 635 goto out_release; 637 636 638 637 ino = autofs4_dentry_ino(nd.path.dentry); 639 - param->arg1 = autofs4_get_dev(ino->sbi); 638 + devid = autofs4_get_dev(ino->sbi); 640 639 } 641 640 642 641 err = 0; 643 642 if (nd.path.dentry->d_inode && 644 643 nd.path.mnt->mnt_root == nd.path.dentry) { 645 644 err = 1; 646 - param->arg2 = nd.path.dentry->d_inode->i_sb->s_magic; 645 + magic = nd.path.dentry->d_inode->i_sb->s_magic; 647 646 } 648 647 } else { 649 648 dev_t devid = new_encode_dev(sbi->sb->s_dev); ··· 656 655 if (err) 657 656 goto out_release; 658 657 659 - param->arg1 = autofs4_get_dev(sbi); 658 + devid = autofs4_get_dev(sbi); 660 659 661 660 err = have_submounts(nd.path.dentry); 662 661 663 662 if (nd.path.mnt->mnt_mountpoint != nd.path.mnt->mnt_root) { 664 663 if (follow_down(&nd.path.mnt, &nd.path.dentry)) { 665 664 struct inode *inode = nd.path.dentry->d_inode; 666 - param->arg2 = inode->i_sb->s_magic; 665 + magic = inode->i_sb->s_magic; 667 666 } 668 667 } 669 668 } 669 + 670 + param->ismountpoint.out.devid = devid; 671 + param->ismountpoint.out.magic = magic; 670 672 671 673 out_release: 672 674 path_put(&nd.path);
+71 -4
include/linux/auto_dev-ioctl.h
··· 10 10 #ifndef _LINUX_AUTO_DEV_IOCTL_H 11 11 #define _LINUX_AUTO_DEV_IOCTL_H 12 12 13 + #include <linux/string.h> 13 14 #include <linux/types.h> 14 15 15 16 #define AUTOFS_DEVICE_NAME "autofs" ··· 26 25 * An ioctl interface for autofs mount point control. 27 26 */ 28 27 28 + struct args_protover { 29 + __u32 version; 30 + }; 31 + 32 + struct args_protosubver { 33 + __u32 sub_version; 34 + }; 35 + 36 + struct args_openmount { 37 + __u32 devid; 38 + }; 39 + 40 + struct args_ready { 41 + __u32 token; 42 + }; 43 + 44 + struct args_fail { 45 + __u32 token; 46 + __s32 status; 47 + }; 48 + 49 + struct args_setpipefd { 50 + __s32 pipefd; 51 + }; 52 + 53 + struct args_timeout { 54 + __u64 timeout; 55 + }; 56 + 57 + struct args_requester { 58 + __u32 uid; 59 + __u32 gid; 60 + }; 61 + 62 + struct args_expire { 63 + __u32 how; 64 + }; 65 + 66 + struct args_askumount { 67 + __u32 may_umount; 68 + }; 69 + 70 + struct args_ismountpoint { 71 + union { 72 + struct args_in { 73 + __u32 type; 74 + } in; 75 + struct args_out { 76 + __u32 devid; 77 + __u32 magic; 78 + } out; 79 + }; 80 + }; 81 + 29 82 /* 30 83 * All the ioctls use this structure. 31 84 * When sending a path size must account for the total length ··· 94 39 * including this struct */ 95 40 __s32 ioctlfd; /* automount command fd */ 96 41 97 - __u32 arg1; /* Command parameters */ 98 - __u32 arg2; 42 + /* Command parameters */ 43 + 44 + union { 45 + struct args_protover protover; 46 + struct args_protosubver protosubver; 47 + struct args_openmount openmount; 48 + struct args_ready ready; 49 + struct args_fail fail; 50 + struct args_setpipefd setpipefd; 51 + struct args_timeout timeout; 52 + struct args_requester requester; 53 + struct args_expire expire; 54 + struct args_askumount askumount; 55 + struct args_ismountpoint ismountpoint; 56 + }; 99 57 100 58 char path[0]; 101 59 }; 102 60 103 61 static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl *in) 104 62 { 63 + memset(in, 0, sizeof(struct autofs_dev_ioctl)); 105 64 in->ver_major = AUTOFS_DEV_IOCTL_VERSION_MAJOR; 106 65 in->ver_minor = AUTOFS_DEV_IOCTL_VERSION_MINOR; 107 66 in->size = sizeof(struct autofs_dev_ioctl); 108 67 in->ioctlfd = -1; 109 - in->arg1 = 0; 110 - in->arg2 = 0; 111 68 return; 112 69 } 113 70