1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Copyright 1997 Transmeta Corporation - All Rights Reserved
4*4882a593Smuzhiyun * Copyright 1999-2000 Jeremy Fitzhardinge <jeremy@goop.org>
5*4882a593Smuzhiyun * Copyright 2005-2006,2013,2017-2018 Ian Kent <raven@themaw.net>
6*4882a593Smuzhiyun *
7*4882a593Smuzhiyun * This file is part of the Linux kernel and is made available under
8*4882a593Smuzhiyun * the terms of the GNU General Public License, version 2, or at your
9*4882a593Smuzhiyun * option, any later version, incorporated herein by reference.
10*4882a593Smuzhiyun *
11*4882a593Smuzhiyun * ----------------------------------------------------------------------- */
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun #ifndef _UAPI_LINUX_AUTO_FS_H
14*4882a593Smuzhiyun #define _UAPI_LINUX_AUTO_FS_H
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun #include <linux/types.h>
17*4882a593Smuzhiyun #include <linux/limits.h>
18*4882a593Smuzhiyun #ifndef __KERNEL__
19*4882a593Smuzhiyun #include <sys/ioctl.h>
20*4882a593Smuzhiyun #endif /* __KERNEL__ */
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun #define AUTOFS_PROTO_VERSION 5
23*4882a593Smuzhiyun #define AUTOFS_MIN_PROTO_VERSION 3
24*4882a593Smuzhiyun #define AUTOFS_MAX_PROTO_VERSION 5
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun #define AUTOFS_PROTO_SUBVERSION 5
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun /*
29*4882a593Smuzhiyun * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed
30*4882a593Smuzhiyun * back to the kernel via ioctl from userspace. On architectures where 32- and
31*4882a593Smuzhiyun * 64-bit userspace binaries can be executed it's important that the size of
32*4882a593Smuzhiyun * autofs_wqt_t stays constant between 32- and 64-bit Linux kernels so that we
33*4882a593Smuzhiyun * do not break the binary ABI interface by changing the structure size.
34*4882a593Smuzhiyun */
35*4882a593Smuzhiyun #if defined(__ia64__) || defined(__alpha__) /* pure 64bit architectures */
36*4882a593Smuzhiyun typedef unsigned long autofs_wqt_t;
37*4882a593Smuzhiyun #else
38*4882a593Smuzhiyun typedef unsigned int autofs_wqt_t;
39*4882a593Smuzhiyun #endif
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun /* Packet types */
42*4882a593Smuzhiyun #define autofs_ptype_missing 0 /* Missing entry (mount request) */
43*4882a593Smuzhiyun #define autofs_ptype_expire 1 /* Expire entry (umount request) */
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun struct autofs_packet_hdr {
46*4882a593Smuzhiyun int proto_version; /* Protocol version */
47*4882a593Smuzhiyun int type; /* Type of packet */
48*4882a593Smuzhiyun };
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun struct autofs_packet_missing {
51*4882a593Smuzhiyun struct autofs_packet_hdr hdr;
52*4882a593Smuzhiyun autofs_wqt_t wait_queue_token;
53*4882a593Smuzhiyun int len;
54*4882a593Smuzhiyun char name[NAME_MAX+1];
55*4882a593Smuzhiyun };
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun /* v3 expire (via ioctl) */
58*4882a593Smuzhiyun struct autofs_packet_expire {
59*4882a593Smuzhiyun struct autofs_packet_hdr hdr;
60*4882a593Smuzhiyun int len;
61*4882a593Smuzhiyun char name[NAME_MAX+1];
62*4882a593Smuzhiyun };
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun #define AUTOFS_IOCTL 0x93
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun enum {
67*4882a593Smuzhiyun AUTOFS_IOC_READY_CMD = 0x60,
68*4882a593Smuzhiyun AUTOFS_IOC_FAIL_CMD,
69*4882a593Smuzhiyun AUTOFS_IOC_CATATONIC_CMD,
70*4882a593Smuzhiyun AUTOFS_IOC_PROTOVER_CMD,
71*4882a593Smuzhiyun AUTOFS_IOC_SETTIMEOUT_CMD,
72*4882a593Smuzhiyun AUTOFS_IOC_EXPIRE_CMD,
73*4882a593Smuzhiyun };
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun #define AUTOFS_IOC_READY _IO(AUTOFS_IOCTL, AUTOFS_IOC_READY_CMD)
76*4882a593Smuzhiyun #define AUTOFS_IOC_FAIL _IO(AUTOFS_IOCTL, AUTOFS_IOC_FAIL_CMD)
77*4882a593Smuzhiyun #define AUTOFS_IOC_CATATONIC _IO(AUTOFS_IOCTL, AUTOFS_IOC_CATATONIC_CMD)
78*4882a593Smuzhiyun #define AUTOFS_IOC_PROTOVER _IOR(AUTOFS_IOCTL, \
79*4882a593Smuzhiyun AUTOFS_IOC_PROTOVER_CMD, int)
80*4882a593Smuzhiyun #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(AUTOFS_IOCTL, \
81*4882a593Smuzhiyun AUTOFS_IOC_SETTIMEOUT_CMD, \
82*4882a593Smuzhiyun compat_ulong_t)
83*4882a593Smuzhiyun #define AUTOFS_IOC_SETTIMEOUT _IOWR(AUTOFS_IOCTL, \
84*4882a593Smuzhiyun AUTOFS_IOC_SETTIMEOUT_CMD, \
85*4882a593Smuzhiyun unsigned long)
86*4882a593Smuzhiyun #define AUTOFS_IOC_EXPIRE _IOR(AUTOFS_IOCTL, \
87*4882a593Smuzhiyun AUTOFS_IOC_EXPIRE_CMD, \
88*4882a593Smuzhiyun struct autofs_packet_expire)
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun /* autofs version 4 and later definitions */
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun /* Mask for expire behaviour */
93*4882a593Smuzhiyun #define AUTOFS_EXP_NORMAL 0x00
94*4882a593Smuzhiyun #define AUTOFS_EXP_IMMEDIATE 0x01
95*4882a593Smuzhiyun #define AUTOFS_EXP_LEAVES 0x02
96*4882a593Smuzhiyun #define AUTOFS_EXP_FORCED 0x04
97*4882a593Smuzhiyun
98*4882a593Smuzhiyun #define AUTOFS_TYPE_ANY 0U
99*4882a593Smuzhiyun #define AUTOFS_TYPE_INDIRECT 1U
100*4882a593Smuzhiyun #define AUTOFS_TYPE_DIRECT 2U
101*4882a593Smuzhiyun #define AUTOFS_TYPE_OFFSET 4U
102*4882a593Smuzhiyun
set_autofs_type_indirect(unsigned int * type)103*4882a593Smuzhiyun static inline void set_autofs_type_indirect(unsigned int *type)
104*4882a593Smuzhiyun {
105*4882a593Smuzhiyun *type = AUTOFS_TYPE_INDIRECT;
106*4882a593Smuzhiyun }
107*4882a593Smuzhiyun
autofs_type_indirect(unsigned int type)108*4882a593Smuzhiyun static inline unsigned int autofs_type_indirect(unsigned int type)
109*4882a593Smuzhiyun {
110*4882a593Smuzhiyun return (type == AUTOFS_TYPE_INDIRECT);
111*4882a593Smuzhiyun }
112*4882a593Smuzhiyun
set_autofs_type_direct(unsigned int * type)113*4882a593Smuzhiyun static inline void set_autofs_type_direct(unsigned int *type)
114*4882a593Smuzhiyun {
115*4882a593Smuzhiyun *type = AUTOFS_TYPE_DIRECT;
116*4882a593Smuzhiyun }
117*4882a593Smuzhiyun
autofs_type_direct(unsigned int type)118*4882a593Smuzhiyun static inline unsigned int autofs_type_direct(unsigned int type)
119*4882a593Smuzhiyun {
120*4882a593Smuzhiyun return (type == AUTOFS_TYPE_DIRECT);
121*4882a593Smuzhiyun }
122*4882a593Smuzhiyun
set_autofs_type_offset(unsigned int * type)123*4882a593Smuzhiyun static inline void set_autofs_type_offset(unsigned int *type)
124*4882a593Smuzhiyun {
125*4882a593Smuzhiyun *type = AUTOFS_TYPE_OFFSET;
126*4882a593Smuzhiyun }
127*4882a593Smuzhiyun
autofs_type_offset(unsigned int type)128*4882a593Smuzhiyun static inline unsigned int autofs_type_offset(unsigned int type)
129*4882a593Smuzhiyun {
130*4882a593Smuzhiyun return (type == AUTOFS_TYPE_OFFSET);
131*4882a593Smuzhiyun }
132*4882a593Smuzhiyun
autofs_type_trigger(unsigned int type)133*4882a593Smuzhiyun static inline unsigned int autofs_type_trigger(unsigned int type)
134*4882a593Smuzhiyun {
135*4882a593Smuzhiyun return (type == AUTOFS_TYPE_DIRECT || type == AUTOFS_TYPE_OFFSET);
136*4882a593Smuzhiyun }
137*4882a593Smuzhiyun
138*4882a593Smuzhiyun /*
139*4882a593Smuzhiyun * This isn't really a type as we use it to say "no type set" to
140*4882a593Smuzhiyun * indicate we want to search for "any" mount in the
141*4882a593Smuzhiyun * autofs_dev_ioctl_ismountpoint() device ioctl function.
142*4882a593Smuzhiyun */
set_autofs_type_any(unsigned int * type)143*4882a593Smuzhiyun static inline void set_autofs_type_any(unsigned int *type)
144*4882a593Smuzhiyun {
145*4882a593Smuzhiyun *type = AUTOFS_TYPE_ANY;
146*4882a593Smuzhiyun }
147*4882a593Smuzhiyun
autofs_type_any(unsigned int type)148*4882a593Smuzhiyun static inline unsigned int autofs_type_any(unsigned int type)
149*4882a593Smuzhiyun {
150*4882a593Smuzhiyun return (type == AUTOFS_TYPE_ANY);
151*4882a593Smuzhiyun }
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun /* Daemon notification packet types */
154*4882a593Smuzhiyun enum autofs_notify {
155*4882a593Smuzhiyun NFY_NONE,
156*4882a593Smuzhiyun NFY_MOUNT,
157*4882a593Smuzhiyun NFY_EXPIRE
158*4882a593Smuzhiyun };
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun /* Kernel protocol version 4 packet types */
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun /* Expire entry (umount request) */
163*4882a593Smuzhiyun #define autofs_ptype_expire_multi 2
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun /* Kernel protocol version 5 packet types */
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun /* Indirect mount missing and expire requests. */
168*4882a593Smuzhiyun #define autofs_ptype_missing_indirect 3
169*4882a593Smuzhiyun #define autofs_ptype_expire_indirect 4
170*4882a593Smuzhiyun
171*4882a593Smuzhiyun /* Direct mount missing and expire requests */
172*4882a593Smuzhiyun #define autofs_ptype_missing_direct 5
173*4882a593Smuzhiyun #define autofs_ptype_expire_direct 6
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun /* v4 multi expire (via pipe) */
176*4882a593Smuzhiyun struct autofs_packet_expire_multi {
177*4882a593Smuzhiyun struct autofs_packet_hdr hdr;
178*4882a593Smuzhiyun autofs_wqt_t wait_queue_token;
179*4882a593Smuzhiyun int len;
180*4882a593Smuzhiyun char name[NAME_MAX+1];
181*4882a593Smuzhiyun };
182*4882a593Smuzhiyun
183*4882a593Smuzhiyun union autofs_packet_union {
184*4882a593Smuzhiyun struct autofs_packet_hdr hdr;
185*4882a593Smuzhiyun struct autofs_packet_missing missing;
186*4882a593Smuzhiyun struct autofs_packet_expire expire;
187*4882a593Smuzhiyun struct autofs_packet_expire_multi expire_multi;
188*4882a593Smuzhiyun };
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun /* autofs v5 common packet struct */
191*4882a593Smuzhiyun struct autofs_v5_packet {
192*4882a593Smuzhiyun struct autofs_packet_hdr hdr;
193*4882a593Smuzhiyun autofs_wqt_t wait_queue_token;
194*4882a593Smuzhiyun __u32 dev;
195*4882a593Smuzhiyun __u64 ino;
196*4882a593Smuzhiyun __u32 uid;
197*4882a593Smuzhiyun __u32 gid;
198*4882a593Smuzhiyun __u32 pid;
199*4882a593Smuzhiyun __u32 tgid;
200*4882a593Smuzhiyun __u32 len;
201*4882a593Smuzhiyun char name[NAME_MAX+1];
202*4882a593Smuzhiyun };
203*4882a593Smuzhiyun
204*4882a593Smuzhiyun typedef struct autofs_v5_packet autofs_packet_missing_indirect_t;
205*4882a593Smuzhiyun typedef struct autofs_v5_packet autofs_packet_expire_indirect_t;
206*4882a593Smuzhiyun typedef struct autofs_v5_packet autofs_packet_missing_direct_t;
207*4882a593Smuzhiyun typedef struct autofs_v5_packet autofs_packet_expire_direct_t;
208*4882a593Smuzhiyun
209*4882a593Smuzhiyun union autofs_v5_packet_union {
210*4882a593Smuzhiyun struct autofs_packet_hdr hdr;
211*4882a593Smuzhiyun struct autofs_v5_packet v5_packet;
212*4882a593Smuzhiyun autofs_packet_missing_indirect_t missing_indirect;
213*4882a593Smuzhiyun autofs_packet_expire_indirect_t expire_indirect;
214*4882a593Smuzhiyun autofs_packet_missing_direct_t missing_direct;
215*4882a593Smuzhiyun autofs_packet_expire_direct_t expire_direct;
216*4882a593Smuzhiyun };
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun enum {
219*4882a593Smuzhiyun AUTOFS_IOC_EXPIRE_MULTI_CMD = 0x66, /* AUTOFS_IOC_EXPIRE_CMD + 1 */
220*4882a593Smuzhiyun AUTOFS_IOC_PROTOSUBVER_CMD,
221*4882a593Smuzhiyun AUTOFS_IOC_ASKUMOUNT_CMD = 0x70, /* AUTOFS_DEV_IOCTL_VERSION_CMD - 1 */
222*4882a593Smuzhiyun };
223*4882a593Smuzhiyun
224*4882a593Smuzhiyun #define AUTOFS_IOC_EXPIRE_MULTI _IOW(AUTOFS_IOCTL, \
225*4882a593Smuzhiyun AUTOFS_IOC_EXPIRE_MULTI_CMD, int)
226*4882a593Smuzhiyun #define AUTOFS_IOC_PROTOSUBVER _IOR(AUTOFS_IOCTL, \
227*4882a593Smuzhiyun AUTOFS_IOC_PROTOSUBVER_CMD, int)
228*4882a593Smuzhiyun #define AUTOFS_IOC_ASKUMOUNT _IOR(AUTOFS_IOCTL, \
229*4882a593Smuzhiyun AUTOFS_IOC_ASKUMOUNT_CMD, int)
230*4882a593Smuzhiyun
231*4882a593Smuzhiyun #endif /* _UAPI_LINUX_AUTO_FS_H */
232