blob: d28fa824284aaf8198ad50404e86f4793bb70892 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Nathan Scott7b718762005-11-02 14:58:39 +11003 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
Nathan Scott7b718762005-11-02 14:58:39 +11006#ifndef __XFS_IOCTL32_H__
7#define __XFS_IOCTL32_H__
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
sandeen@sandeen.netffae2632008-11-25 21:20:07 -06009#include <linux/compat.h>
10
sandeen@sandeen.netffae2632008-11-25 21:20:07 -060011/*
12 * on 32-bit arches, ioctl argument structures may have different sizes
13 * and/or alignment. We define compat structures which match the
14 * 32-bit sizes/alignments here, and their associated ioctl numbers.
15 *
16 * xfs_ioctl32.c contains routines to copy these structures in and out.
17 */
18
19/* stock kernel-level ioctls we support */
20#define XFS_IOC_GETXFLAGS_32 FS_IOC32_GETFLAGS
21#define XFS_IOC_SETXFLAGS_32 FS_IOC32_SETFLAGS
22#define XFS_IOC_GETVERSION_32 FS_IOC32_GETVERSION
23
24/*
25 * On intel, even if sizes match, alignment and/or padding may differ.
26 */
27#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
28#define BROKEN_X86_ALIGNMENT
29#define __compat_packed __attribute__((packed))
30#else
31#define __compat_packed
32#endif
33
34typedef struct compat_xfs_bstime {
35 compat_time_t tv_sec; /* seconds */
36 __s32 tv_nsec; /* and nanoseconds */
37} compat_xfs_bstime_t;
38
39typedef struct compat_xfs_bstat {
40 __u64 bs_ino; /* inode number */
41 __u16 bs_mode; /* type and mode */
42 __u16 bs_nlink; /* number of links */
43 __u32 bs_uid; /* user id */
44 __u32 bs_gid; /* group id */
45 __u32 bs_rdev; /* device value */
46 __s32 bs_blksize; /* block size */
47 __s64 bs_size; /* file size */
48 compat_xfs_bstime_t bs_atime; /* access time */
49 compat_xfs_bstime_t bs_mtime; /* modify time */
50 compat_xfs_bstime_t bs_ctime; /* inode change time */
51 int64_t bs_blocks; /* number of blocks */
52 __u32 bs_xflags; /* extended flags */
53 __s32 bs_extsize; /* extent size */
54 __s32 bs_extents; /* number of extents */
55 __u32 bs_gen; /* generation count */
Arkadiusz Mi?kiewicz67430992010-09-26 06:10:18 +000056 __u16 bs_projid_lo; /* lower part of project id */
57#define bs_projid bs_projid_lo /* (previously just bs_projid) */
Dave Chinnerb1d6cc02014-10-02 09:17:58 +100058 __u16 bs_forkoff; /* inode fork offset in bytes */
Arkadiusz Mi?kiewicz67430992010-09-26 06:10:18 +000059 __u16 bs_projid_hi; /* high part of project id */
Dave Chinnerb1d6cc02014-10-02 09:17:58 +100060 unsigned char bs_pad[10]; /* pad space, unused */
sandeen@sandeen.netffae2632008-11-25 21:20:07 -060061 __u32 bs_dmevmask; /* DMIG event mask */
62 __u16 bs_dmstate; /* DMIG state info */
63 __u16 bs_aextents; /* attribute number of extents */
64} __compat_packed compat_xfs_bstat_t;
65
66typedef struct compat_xfs_fsop_bulkreq {
67 compat_uptr_t lastip; /* last inode # pointer */
68 __s32 icount; /* count of entries in buffer */
69 compat_uptr_t ubuffer; /* user buffer for inode desc. */
70 compat_uptr_t ocount; /* output count pointer */
71} compat_xfs_fsop_bulkreq_t;
72
73#define XFS_IOC_FSBULKSTAT_32 \
74 _IOWR('X', 101, struct compat_xfs_fsop_bulkreq)
75#define XFS_IOC_FSBULKSTAT_SINGLE_32 \
76 _IOWR('X', 102, struct compat_xfs_fsop_bulkreq)
77#define XFS_IOC_FSINUMBERS_32 \
78 _IOWR('X', 103, struct compat_xfs_fsop_bulkreq)
79
80typedef struct compat_xfs_fsop_handlereq {
81 __u32 fd; /* fd for FD_TO_HANDLE */
82 compat_uptr_t path; /* user pathname */
83 __u32 oflags; /* open flags */
84 compat_uptr_t ihandle; /* user supplied handle */
85 __u32 ihandlen; /* user supplied length */
86 compat_uptr_t ohandle; /* user buffer for handle */
87 compat_uptr_t ohandlen; /* user buffer length */
88} compat_xfs_fsop_handlereq_t;
89
90#define XFS_IOC_PATH_TO_FSHANDLE_32 \
91 _IOWR('X', 104, struct compat_xfs_fsop_handlereq)
92#define XFS_IOC_PATH_TO_HANDLE_32 \
93 _IOWR('X', 105, struct compat_xfs_fsop_handlereq)
94#define XFS_IOC_FD_TO_HANDLE_32 \
95 _IOWR('X', 106, struct compat_xfs_fsop_handlereq)
96#define XFS_IOC_OPEN_BY_HANDLE_32 \
97 _IOWR('X', 107, struct compat_xfs_fsop_handlereq)
98#define XFS_IOC_READLINK_BY_HANDLE_32 \
99 _IOWR('X', 108, struct compat_xfs_fsop_handlereq)
100
sandeen@sandeen.nete94fc4a2008-11-25 21:20:09 -0600101/* The bstat field in the swapext struct needs translation */
102typedef struct compat_xfs_swapext {
Darrick J. Wongc8ce5402017-06-16 11:00:05 -0700103 int64_t sx_version; /* version */
104 int64_t sx_fdtarget; /* fd of target file */
105 int64_t sx_fdtmp; /* fd of tmp file */
sandeen@sandeen.nete94fc4a2008-11-25 21:20:09 -0600106 xfs_off_t sx_offset; /* offset into file */
107 xfs_off_t sx_length; /* leng from offset */
108 char sx_pad[16]; /* pad space, unused */
109 compat_xfs_bstat_t sx_stat; /* stat of target b4 copy */
110} __compat_packed compat_xfs_swapext_t;
111
112#define XFS_IOC_SWAPEXT_32 _IOWR('X', 109, struct compat_xfs_swapext)
113
sandeen@sandeen.netebeecd22008-11-25 21:20:14 -0600114typedef struct compat_xfs_fsop_attrlist_handlereq {
115 struct compat_xfs_fsop_handlereq hreq; /* handle interface structure */
116 struct xfs_attrlist_cursor pos; /* opaque cookie, list offset */
117 __u32 flags; /* which namespace to use */
118 __u32 buflen; /* length of buffer supplied */
119 compat_uptr_t buffer; /* returned names */
120} __compat_packed compat_xfs_fsop_attrlist_handlereq_t;
121
122/* Note: actually this is read/write */
123#define XFS_IOC_ATTRLIST_BY_HANDLE_32 \
124 _IOW('X', 122, struct compat_xfs_fsop_attrlist_handlereq)
125
sandeen@sandeen.net28750972008-11-25 21:20:15 -0600126/* am_opcodes defined in xfs_fs.h */
127typedef struct compat_xfs_attr_multiop {
128 __u32 am_opcode;
129 __s32 am_error;
130 compat_uptr_t am_attrname;
131 compat_uptr_t am_attrvalue;
132 __u32 am_length;
133 __u32 am_flags;
134} compat_xfs_attr_multiop_t;
135
136typedef struct compat_xfs_fsop_attrmulti_handlereq {
137 struct compat_xfs_fsop_handlereq hreq; /* handle interface structure */
138 __u32 opcount;/* count of following multiop */
139 /* ptr to compat_xfs_attr_multiop */
140 compat_uptr_t ops; /* attr_multi data */
141} compat_xfs_fsop_attrmulti_handlereq_t;
142
143#define XFS_IOC_ATTRMULTI_BY_HANDLE_32 \
144 _IOW('X', 123, struct compat_xfs_fsop_attrmulti_handlereq)
145
sandeen@sandeen.net710d62a2008-11-25 21:20:16 -0600146typedef struct compat_xfs_fsop_setdm_handlereq {
147 struct compat_xfs_fsop_handlereq hreq; /* handle information */
148 /* ptr to struct fsdmidata */
149 compat_uptr_t data; /* DMAPI data */
150} compat_xfs_fsop_setdm_handlereq_t;
151
152#define XFS_IOC_FSSETDM_BY_HANDLE_32 \
153 _IOW('X', 121, struct compat_xfs_fsop_setdm_handlereq)
154
sandeen@sandeen.netffae2632008-11-25 21:20:07 -0600155#ifdef BROKEN_X86_ALIGNMENT
156/* on ia32 l_start is on a 32-bit boundary */
157typedef struct compat_xfs_flock64 {
158 __s16 l_type;
159 __s16 l_whence;
160 __s64 l_start __attribute__((packed));
161 /* len == 0 means until end of file */
162 __s64 l_len __attribute__((packed));
163 __s32 l_sysid;
164 __u32 l_pid;
165 __s32 l_pad[4]; /* reserve area */
166} compat_xfs_flock64_t;
167
168#define XFS_IOC_ALLOCSP_32 _IOW('X', 10, struct compat_xfs_flock64)
169#define XFS_IOC_FREESP_32 _IOW('X', 11, struct compat_xfs_flock64)
170#define XFS_IOC_ALLOCSP64_32 _IOW('X', 36, struct compat_xfs_flock64)
171#define XFS_IOC_FREESP64_32 _IOW('X', 37, struct compat_xfs_flock64)
172#define XFS_IOC_RESVSP_32 _IOW('X', 40, struct compat_xfs_flock64)
173#define XFS_IOC_UNRESVSP_32 _IOW('X', 41, struct compat_xfs_flock64)
174#define XFS_IOC_RESVSP64_32 _IOW('X', 42, struct compat_xfs_flock64)
175#define XFS_IOC_UNRESVSP64_32 _IOW('X', 43, struct compat_xfs_flock64)
Christoph Hellwig8c1fdd02011-04-21 13:21:03 +0000176#define XFS_IOC_ZERO_RANGE_32 _IOW('X', 57, struct compat_xfs_flock64)
sandeen@sandeen.netffae2632008-11-25 21:20:07 -0600177
178typedef struct compat_xfs_fsop_geom_v1 {
179 __u32 blocksize; /* filesystem (data) block size */
180 __u32 rtextsize; /* realtime extent size */
181 __u32 agblocks; /* fsblocks in an AG */
182 __u32 agcount; /* number of allocation groups */
183 __u32 logblocks; /* fsblocks in the log */
184 __u32 sectsize; /* (data) sector size, bytes */
185 __u32 inodesize; /* inode size in bytes */
186 __u32 imaxpct; /* max allowed inode space(%) */
187 __u64 datablocks; /* fsblocks in data subvolume */
188 __u64 rtblocks; /* fsblocks in realtime subvol */
189 __u64 rtextents; /* rt extents in realtime subvol*/
190 __u64 logstart; /* starting fsblock of the log */
191 unsigned char uuid[16]; /* unique id of the filesystem */
192 __u32 sunit; /* stripe unit, fsblocks */
193 __u32 swidth; /* stripe width, fsblocks */
194 __s32 version; /* structure version */
195 __u32 flags; /* superblock version flags */
196 __u32 logsectsize; /* log sector size, bytes */
197 __u32 rtsectsize; /* realtime sector size, bytes */
198 __u32 dirblocksize; /* directory block size, bytes */
199} __attribute__((packed)) compat_xfs_fsop_geom_v1_t;
200
201#define XFS_IOC_FSGEOMETRY_V1_32 \
202 _IOR('X', 100, struct compat_xfs_fsop_geom_v1)
203
204typedef struct compat_xfs_inogrp {
205 __u64 xi_startino; /* starting inode number */
206 __s32 xi_alloccount; /* # bits set in allocmask */
207 __u64 xi_allocmask; /* mask of allocated inodes */
208} __attribute__((packed)) compat_xfs_inogrp_t;
209
sandeen@sandeen.net471d5912008-11-25 21:20:10 -0600210/* These growfs input structures have padding on the end, so must translate */
211typedef struct compat_xfs_growfs_data {
212 __u64 newblocks; /* new data subvol size, fsblocks */
213 __u32 imaxpct; /* new inode space percentage limit */
214} __attribute__((packed)) compat_xfs_growfs_data_t;
215
216typedef struct compat_xfs_growfs_rt {
217 __u64 newblocks; /* new realtime size, fsblocks */
218 __u32 extsize; /* new realtime extent size, fsblocks */
219} __attribute__((packed)) compat_xfs_growfs_rt_t;
220
221#define XFS_IOC_FSGROWFSDATA_32 _IOW('X', 110, struct compat_xfs_growfs_data)
222#define XFS_IOC_FSGROWFSRT_32 _IOW('X', 112, struct compat_xfs_growfs_rt)
223
sandeen@sandeen.netffae2632008-11-25 21:20:07 -0600224#endif /* BROKEN_X86_ALIGNMENT */
225
Nathan Scott7b718762005-11-02 14:58:39 +1100226#endif /* __XFS_IOCTL32_H__ */