Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /*
0003  * Copyright 1997 Transmeta Corporation - All Rights Reserved
0004  * Copyright 1999-2000 Jeremy Fitzhardinge <jeremy@goop.org>
0005  * Copyright 2005-2006,2013,2017-2018 Ian Kent <raven@themaw.net>
0006  *
0007  * This file is part of the Linux kernel and is made available under
0008  * the terms of the GNU General Public License, version 2, or at your
0009  * option, any later version, incorporated herein by reference.
0010  *
0011  * ----------------------------------------------------------------------- */
0012 
0013 #ifndef _UAPI_LINUX_AUTO_FS_H
0014 #define _UAPI_LINUX_AUTO_FS_H
0015 
0016 #include <linux/types.h>
0017 #include <linux/limits.h>
0018 #ifndef __KERNEL__
0019 #include <sys/ioctl.h>
0020 #endif /* __KERNEL__ */
0021 
0022 #define AUTOFS_PROTO_VERSION        5
0023 #define AUTOFS_MIN_PROTO_VERSION    3
0024 #define AUTOFS_MAX_PROTO_VERSION    5
0025 
0026 #define AUTOFS_PROTO_SUBVERSION     5
0027 
0028 /*
0029  * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed
0030  * back to the kernel via ioctl from userspace. On architectures where 32- and
0031  * 64-bit userspace binaries can be executed it's important that the size of
0032  * autofs_wqt_t stays constant between 32- and 64-bit Linux kernels so that we
0033  * do not break the binary ABI interface by changing the structure size.
0034  */
0035 #if defined(__ia64__) || defined(__alpha__) /* pure 64bit architectures */
0036 typedef unsigned long autofs_wqt_t;
0037 #else
0038 typedef unsigned int autofs_wqt_t;
0039 #endif
0040 
0041 /* Packet types */
0042 #define autofs_ptype_missing    0   /* Missing entry (mount request) */
0043 #define autofs_ptype_expire 1   /* Expire entry (umount request) */
0044 
0045 struct autofs_packet_hdr {
0046     int proto_version;      /* Protocol version */
0047     int type;           /* Type of packet */
0048 };
0049 
0050 struct autofs_packet_missing {
0051     struct autofs_packet_hdr hdr;
0052     autofs_wqt_t wait_queue_token;
0053     int len;
0054     char name[NAME_MAX+1];
0055 };  
0056 
0057 /* v3 expire (via ioctl) */
0058 struct autofs_packet_expire {
0059     struct autofs_packet_hdr hdr;
0060     int len;
0061     char name[NAME_MAX+1];
0062 };
0063 
0064 #define AUTOFS_IOCTL 0x93
0065 
0066 enum {
0067     AUTOFS_IOC_READY_CMD = 0x60,
0068     AUTOFS_IOC_FAIL_CMD,
0069     AUTOFS_IOC_CATATONIC_CMD,
0070     AUTOFS_IOC_PROTOVER_CMD,
0071     AUTOFS_IOC_SETTIMEOUT_CMD,
0072     AUTOFS_IOC_EXPIRE_CMD,
0073 };
0074 
0075 #define AUTOFS_IOC_READY        _IO(AUTOFS_IOCTL, AUTOFS_IOC_READY_CMD)
0076 #define AUTOFS_IOC_FAIL         _IO(AUTOFS_IOCTL, AUTOFS_IOC_FAIL_CMD)
0077 #define AUTOFS_IOC_CATATONIC    _IO(AUTOFS_IOCTL, AUTOFS_IOC_CATATONIC_CMD)
0078 #define AUTOFS_IOC_PROTOVER     _IOR(AUTOFS_IOCTL, \
0079                      AUTOFS_IOC_PROTOVER_CMD, int)
0080 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(AUTOFS_IOCTL, \
0081                       AUTOFS_IOC_SETTIMEOUT_CMD, \
0082                       compat_ulong_t)
0083 #define AUTOFS_IOC_SETTIMEOUT   _IOWR(AUTOFS_IOCTL, \
0084                       AUTOFS_IOC_SETTIMEOUT_CMD, \
0085                       unsigned long)
0086 #define AUTOFS_IOC_EXPIRE       _IOR(AUTOFS_IOCTL, \
0087                      AUTOFS_IOC_EXPIRE_CMD, \
0088                      struct autofs_packet_expire)
0089 
0090 /* autofs version 4 and later definitions */
0091 
0092 /* Mask for expire behaviour */
0093 #define AUTOFS_EXP_NORMAL       0x00
0094 #define AUTOFS_EXP_IMMEDIATE        0x01
0095 #define AUTOFS_EXP_LEAVES       0x02
0096 #define AUTOFS_EXP_FORCED       0x04
0097 
0098 #define AUTOFS_TYPE_ANY         0U
0099 #define AUTOFS_TYPE_INDIRECT        1U
0100 #define AUTOFS_TYPE_DIRECT      2U
0101 #define AUTOFS_TYPE_OFFSET      4U
0102 
0103 static inline void set_autofs_type_indirect(unsigned int *type)
0104 {
0105     *type = AUTOFS_TYPE_INDIRECT;
0106 }
0107 
0108 static inline unsigned int autofs_type_indirect(unsigned int type)
0109 {
0110     return (type == AUTOFS_TYPE_INDIRECT);
0111 }
0112 
0113 static inline void set_autofs_type_direct(unsigned int *type)
0114 {
0115     *type = AUTOFS_TYPE_DIRECT;
0116 }
0117 
0118 static inline unsigned int autofs_type_direct(unsigned int type)
0119 {
0120     return (type == AUTOFS_TYPE_DIRECT);
0121 }
0122 
0123 static inline void set_autofs_type_offset(unsigned int *type)
0124 {
0125     *type = AUTOFS_TYPE_OFFSET;
0126 }
0127 
0128 static inline unsigned int autofs_type_offset(unsigned int type)
0129 {
0130     return (type == AUTOFS_TYPE_OFFSET);
0131 }
0132 
0133 static inline unsigned int autofs_type_trigger(unsigned int type)
0134 {
0135     return (type == AUTOFS_TYPE_DIRECT || type == AUTOFS_TYPE_OFFSET);
0136 }
0137 
0138 /*
0139  * This isn't really a type as we use it to say "no type set" to
0140  * indicate we want to search for "any" mount in the
0141  * autofs_dev_ioctl_ismountpoint() device ioctl function.
0142  */
0143 static inline void set_autofs_type_any(unsigned int *type)
0144 {
0145     *type = AUTOFS_TYPE_ANY;
0146 }
0147 
0148 static inline unsigned int autofs_type_any(unsigned int type)
0149 {
0150     return (type == AUTOFS_TYPE_ANY);
0151 }
0152 
0153 /* Daemon notification packet types */
0154 enum autofs_notify {
0155     NFY_NONE,
0156     NFY_MOUNT,
0157     NFY_EXPIRE
0158 };
0159 
0160 /* Kernel protocol version 4 packet types */
0161 
0162 /* Expire entry (umount request) */
0163 #define autofs_ptype_expire_multi   2
0164 
0165 /* Kernel protocol version 5 packet types */
0166 
0167 /* Indirect mount missing and expire requests. */
0168 #define autofs_ptype_missing_indirect   3
0169 #define autofs_ptype_expire_indirect    4
0170 
0171 /* Direct mount missing and expire requests */
0172 #define autofs_ptype_missing_direct 5
0173 #define autofs_ptype_expire_direct  6
0174 
0175 /* v4 multi expire (via pipe) */
0176 struct autofs_packet_expire_multi {
0177     struct autofs_packet_hdr hdr;
0178     autofs_wqt_t wait_queue_token;
0179     int len;
0180     char name[NAME_MAX+1];
0181 };
0182 
0183 union autofs_packet_union {
0184     struct autofs_packet_hdr hdr;
0185     struct autofs_packet_missing missing;
0186     struct autofs_packet_expire expire;
0187     struct autofs_packet_expire_multi expire_multi;
0188 };
0189 
0190 /* autofs v5 common packet struct */
0191 struct autofs_v5_packet {
0192     struct autofs_packet_hdr hdr;
0193     autofs_wqt_t wait_queue_token;
0194     __u32 dev;
0195     __u64 ino;
0196     __u32 uid;
0197     __u32 gid;
0198     __u32 pid;
0199     __u32 tgid;
0200     __u32 len;
0201     char name[NAME_MAX+1];
0202 };
0203 
0204 typedef struct autofs_v5_packet autofs_packet_missing_indirect_t;
0205 typedef struct autofs_v5_packet autofs_packet_expire_indirect_t;
0206 typedef struct autofs_v5_packet autofs_packet_missing_direct_t;
0207 typedef struct autofs_v5_packet autofs_packet_expire_direct_t;
0208 
0209 union autofs_v5_packet_union {
0210     struct autofs_packet_hdr hdr;
0211     struct autofs_v5_packet v5_packet;
0212     autofs_packet_missing_indirect_t missing_indirect;
0213     autofs_packet_expire_indirect_t expire_indirect;
0214     autofs_packet_missing_direct_t missing_direct;
0215     autofs_packet_expire_direct_t expire_direct;
0216 };
0217 
0218 enum {
0219     AUTOFS_IOC_EXPIRE_MULTI_CMD = 0x66, /* AUTOFS_IOC_EXPIRE_CMD + 1 */
0220     AUTOFS_IOC_PROTOSUBVER_CMD,
0221     AUTOFS_IOC_ASKUMOUNT_CMD = 0x70, /* AUTOFS_DEV_IOCTL_VERSION_CMD - 1 */
0222 };
0223 
0224 #define AUTOFS_IOC_EXPIRE_MULTI     _IOW(AUTOFS_IOCTL, \
0225                          AUTOFS_IOC_EXPIRE_MULTI_CMD, int)
0226 #define AUTOFS_IOC_PROTOSUBVER      _IOR(AUTOFS_IOCTL, \
0227                          AUTOFS_IOC_PROTOSUBVER_CMD, int)
0228 #define AUTOFS_IOC_ASKUMOUNT        _IOR(AUTOFS_IOCTL, \
0229                          AUTOFS_IOC_ASKUMOUNT_CMD, int)
0230 
0231 #endif /* _UAPI_LINUX_AUTO_FS_H */