Christopher Ferris | 2598113 | 2017-11-14 16:53:49 -0800 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 2 | /* |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 3 | * Copyright 1999-2000 Jeremy Fitzhardinge <jeremy@goop.org> |
| 4 | * |
| 5 | * This file is part of the Linux kernel and is made available under |
| 6 | * the terms of the GNU General Public License, version 2, or at your |
| 7 | * option, any later version, incorporated herein by reference. |
| 8 | */ |
| 9 | |
| 10 | #ifndef _LINUX_AUTO_FS4_H |
| 11 | #define _LINUX_AUTO_FS4_H |
| 12 | |
| 13 | /* Include common v3 definitions */ |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/auto_fs.h> |
| 16 | |
| 17 | /* autofs v4 definitions */ |
| 18 | #undef AUTOFS_PROTO_VERSION |
| 19 | #undef AUTOFS_MIN_PROTO_VERSION |
| 20 | #undef AUTOFS_MAX_PROTO_VERSION |
| 21 | |
| 22 | #define AUTOFS_PROTO_VERSION 5 |
| 23 | #define AUTOFS_MIN_PROTO_VERSION 3 |
| 24 | #define AUTOFS_MAX_PROTO_VERSION 5 |
| 25 | |
| 26 | #define AUTOFS_PROTO_SUBVERSION 2 |
| 27 | |
| 28 | /* Mask for expire behaviour */ |
| 29 | #define AUTOFS_EXP_IMMEDIATE 1 |
| 30 | #define AUTOFS_EXP_LEAVES 2 |
| 31 | |
| 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; |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | static inline unsigned int autofs_type_indirect(unsigned int type) |
| 43 | { |
| 44 | return (type == AUTOFS_TYPE_INDIRECT); |
| 45 | } |
| 46 | |
| 47 | static inline void set_autofs_type_direct(unsigned int *type) |
| 48 | { |
| 49 | *type = AUTOFS_TYPE_DIRECT; |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | static inline unsigned int autofs_type_direct(unsigned int type) |
| 53 | { |
| 54 | return (type == AUTOFS_TYPE_DIRECT); |
| 55 | } |
| 56 | |
| 57 | static inline void set_autofs_type_offset(unsigned int *type) |
| 58 | { |
| 59 | *type = AUTOFS_TYPE_OFFSET; |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | static inline unsigned int autofs_type_offset(unsigned int type) |
| 63 | { |
| 64 | return (type == AUTOFS_TYPE_OFFSET); |
| 65 | } |
| 66 | |
| 67 | static inline unsigned int autofs_type_trigger(unsigned int type) |
| 68 | { |
| 69 | return (type == AUTOFS_TYPE_DIRECT || type == AUTOFS_TYPE_OFFSET); |
| 70 | } |
| 71 | |
| 72 | /* |
| 73 | * This isn't really a type as we use it to say "no type set" to |
| 74 | * indicate we want to search for "any" mount in the |
| 75 | * autofs_dev_ioctl_ismountpoint() device ioctl function. |
| 76 | */ |
| 77 | static inline void set_autofs_type_any(unsigned int *type) |
| 78 | { |
| 79 | *type = AUTOFS_TYPE_ANY; |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | static inline unsigned int autofs_type_any(unsigned int type) |
| 83 | { |
| 84 | return (type == AUTOFS_TYPE_ANY); |
| 85 | } |
| 86 | |
| 87 | /* Daemon notification packet types */ |
| 88 | enum autofs_notify { |
| 89 | NFY_NONE, |
| 90 | NFY_MOUNT, |
| 91 | NFY_EXPIRE |
| 92 | }; |
| 93 | |
| 94 | /* Kernel protocol version 4 packet types */ |
| 95 | |
| 96 | /* Expire entry (umount request) */ |
| 97 | #define autofs_ptype_expire_multi 2 |
| 98 | |
| 99 | /* Kernel protocol version 5 packet types */ |
| 100 | |
| 101 | /* Indirect mount missing and expire requests. */ |
| 102 | #define autofs_ptype_missing_indirect 3 |
| 103 | #define autofs_ptype_expire_indirect 4 |
| 104 | |
| 105 | /* Direct mount missing and expire requests */ |
| 106 | #define autofs_ptype_missing_direct 5 |
| 107 | #define autofs_ptype_expire_direct 6 |
| 108 | |
| 109 | /* v4 multi expire (via pipe) */ |
| 110 | struct autofs_packet_expire_multi { |
| 111 | struct autofs_packet_hdr hdr; |
Christopher Ferris | ccfaccd | 2016-08-24 12:11:31 -0700 | [diff] [blame] | 112 | autofs_wqt_t wait_queue_token; |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 113 | int len; |
| 114 | char name[NAME_MAX+1]; |
| 115 | }; |
| 116 | |
| 117 | union autofs_packet_union { |
| 118 | struct autofs_packet_hdr hdr; |
| 119 | struct autofs_packet_missing missing; |
| 120 | struct autofs_packet_expire expire; |
| 121 | struct autofs_packet_expire_multi expire_multi; |
| 122 | }; |
| 123 | |
| 124 | /* autofs v5 common packet struct */ |
| 125 | struct autofs_v5_packet { |
| 126 | struct autofs_packet_hdr hdr; |
| 127 | autofs_wqt_t wait_queue_token; |
| 128 | __u32 dev; |
| 129 | __u64 ino; |
| 130 | __u32 uid; |
| 131 | __u32 gid; |
| 132 | __u32 pid; |
| 133 | __u32 tgid; |
| 134 | __u32 len; |
| 135 | char name[NAME_MAX+1]; |
| 136 | }; |
| 137 | |
| 138 | typedef struct autofs_v5_packet autofs_packet_missing_indirect_t; |
| 139 | typedef struct autofs_v5_packet autofs_packet_expire_indirect_t; |
| 140 | typedef struct autofs_v5_packet autofs_packet_missing_direct_t; |
| 141 | typedef struct autofs_v5_packet autofs_packet_expire_direct_t; |
| 142 | |
| 143 | union autofs_v5_packet_union { |
| 144 | struct autofs_packet_hdr hdr; |
| 145 | struct autofs_v5_packet v5_packet; |
| 146 | autofs_packet_missing_indirect_t missing_indirect; |
| 147 | autofs_packet_expire_indirect_t expire_indirect; |
| 148 | autofs_packet_missing_direct_t missing_direct; |
| 149 | autofs_packet_expire_direct_t expire_direct; |
| 150 | }; |
| 151 | |
Christopher Ferris | 0543f74 | 2017-07-26 13:09:46 -0700 | [diff] [blame] | 152 | enum { |
| 153 | AUTOFS_IOC_EXPIRE_MULTI_CMD = 0x66, /* AUTOFS_IOC_EXPIRE_CMD + 1 */ |
| 154 | AUTOFS_IOC_PROTOSUBVER_CMD, |
| 155 | AUTOFS_IOC_ASKUMOUNT_CMD = 0x70, /* AUTOFS_DEV_IOCTL_VERSION_CMD - 1 */ |
| 156 | }; |
| 157 | |
| 158 | #define AUTOFS_IOC_EXPIRE_MULTI _IOW(AUTOFS_IOCTL, AUTOFS_IOC_EXPIRE_MULTI_CMD, int) |
Christopher Ferris | 0543f74 | 2017-07-26 13:09:46 -0700 | [diff] [blame] | 159 | #define AUTOFS_IOC_PROTOSUBVER _IOR(AUTOFS_IOCTL, AUTOFS_IOC_PROTOSUBVER_CMD, int) |
| 160 | #define AUTOFS_IOC_ASKUMOUNT _IOR(AUTOFS_IOCTL, AUTOFS_IOC_ASKUMOUNT_CMD, int) |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 161 | |
| 162 | #endif /* _LINUX_AUTO_FS4_H */ |