2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
38 #ifdef HAVE_XFS_LIBXFS_H
39 #include <xfs/libxfs.h>
46 #ifdef HAVE_ATTR_ATTRIBUTES_H
47 #include <attr/attributes.h>
50 #ifdef HAVE_SYS_TYPES_H
51 #include <sys/types.h>
54 #ifdef HAVE_SYS_STAT_H
58 #ifdef HAVE_SYS_STATVFS_H
59 #include <sys/statvfs.h>
62 #ifdef HAVE_SYS_TIME_H
66 #ifdef HAVE_SYS_IOCTL_H
67 #include <sys/ioctl.h>
70 #ifdef HAVE_SYS_WAIT_H
98 #ifdef HAVE_SYS_FCNTL_H
103 #include <sys/time.h>
107 #include <sys/wait.h>
114 #ifdef HAVE_SYS_PARAM_H
115 #include <sys/param.h>
118 #ifdef HAVE_SYS_ATTRIBUTES_H
119 #include <sys/attributes.h>
134 #ifdef HAVE_STRINGS_H
138 #ifdef HAVE_SYS_SYSSGI_H
139 #include <sys/syssgi.h>
142 #ifdef HAVE_SYS_UUID_H
143 #include <sys/uuid.h>
146 #ifdef HAVE_SYS_FS_XFS_FSOPS_H
147 #include <sys/fs/xfs_fsops.h>
150 #ifdef HAVE_SYS_FS_XFS_ITABLE_H
151 #include <sys/fs/xfs_itable.h>
154 #ifdef HAVE_BSTRING_H
158 #ifdef HAVE_SYS_PARAM_H
159 #include <sys/param.h>
165 #define xfs_flock64 flock64
166 #define xfs_flock64_t struct flock64
168 #define XFS_IOC_DIOINFO F_DIOINFO
169 #define XFS_IOC_FSGETXATTR F_FSGETXATTR
170 #define XFS_IOC_FSSETXATTR F_FSSETXATTR
171 #define XFS_IOC_ALLOCSP64 F_ALLOCSP64
172 #define XFS_IOC_FREESP64 F_FREESP64
173 #define XFS_IOC_GETBMAP F_GETBMAP
174 #define XFS_IOC_FSSETDM F_FSSETDM
175 #define XFS_IOC_RESVSP F_RESVSP
176 #define XFS_IOC_UNRESVSP F_UNRESVSP
177 #define XFS_IOC_RESVSP64 F_RESVSP64
178 #define XFS_IOC_UNRESVSP64 F_UNRESVSP64
179 #define XFS_IOC_GETBMAPA F_GETBMAPA
180 #define XFS_IOC_FSGETXATTRA F_FSGETXATTRA
181 #define XFS_IOC_GETBMAPX F_GETBMAPX
183 #define XFS_IOC_FSGEOMETRY_V1 XFS_FS_GEOMETRY_V1
184 #define XFS_IOC_FSBULKSTAT SGI_FS_BULKSTAT
185 #define XFS_IOC_FSBULKSTAT_SINGLE SGI_FS_BULKSTAT_SINGLE
186 #define XFS_IOC_FSINUMBERS /* TODO */
187 #define XFS_IOC_PATH_TO_FSHANDLE /* TODO */
188 #define XFS_IOC_PATH_TO_HANDLE /* TODO */
189 #define XFS_IOC_FD_TO_HANDLE /* TODO */
190 #define XFS_IOC_OPEN_BY_HANDLE /* TODO */
191 #define XFS_IOC_READLINK_BY_HANDLE /* TODO */
192 #define XFS_IOC_SWAPEXT /* TODO */
193 #define XFS_IOC_FSGROWFSDATA XFS_GROWFS_DATA
194 #define XFS_IOC_FSGROWFSLOG XFS_GROWFS_LOG
195 #define XFS_IOC_FSGROWFSRT XFS_GROWFS_RT
196 #define XFS_IOC_FSCOUNTS XFS_FS_COUNTS
197 #define XFS_IOC_SET_RESBLKS XFS_SET_RESBLKS
198 #define XFS_IOC_GET_RESBLKS XFS_GET_RESBLKS
199 #define XFS_IOC_ERROR_INJECTION SGI_XFS_INJECT_ERROR
200 #define XFS_IOC_ERROR_CLEARALL SGI_XFS_CLEARALL_ERROR
201 #define XFS_IOC_FREEZE XFS_FS_FREEZE
202 #define XFS_IOC_THAW XFS_FS_THAW
203 #define XFS_IOC_FSSETDM_BY_HANDLE /* TODO */
204 #define XFS_IOC_ATTRLIST_BY_HANDLE /* TODO */
205 #define XFS_IOC_ATTRMULTI_BY_HANDLE /* TODO */
206 #define XFS_IOC_FSGEOMETRY XFS_FS_GEOMETRY
207 #define XFS_IOC_GOINGDOWN XFS_FS_GOINGDOWN
209 typedef struct xfs_error_injection {
212 } xfs_error_injection_t;
215 typedef struct xfs_fsop_bulkreq {
218 xfs_bstat_t *ubuffer;
220 } xfs_fsop_bulkreq_t;
222 static __inline__ int
223 xfsctl(char* path, int fd, int cmd, void* arg) {
224 if (cmd >= 0 && cmd < XFS_FSOPS_COUNT) {
226 * We have a problem in that xfsctl takes 1 arg but
227 * some sgi xfs ops take an input arg and/or an output arg
228 * So have to special case the ops to decide if xfsctl arg
229 * is an input or an output argument.
231 if (cmd == XFS_FS_GOINGDOWN) {
233 return syssgi(SGI_XFS_FSOPERATIONS, fd, cmd, arg, 0);
236 return syssgi(SGI_XFS_FSOPERATIONS, fd, cmd, 0, arg);
238 } else if (cmd == SGI_FS_BULKSTAT)
239 return syssgi(SGI_FS_BULKSTAT, fd,
240 ((xfs_fsop_bulkreq_t*)arg)->lastip,
241 ((xfs_fsop_bulkreq_t*)arg)->icount,
242 ((xfs_fsop_bulkreq_t*)arg)->ubuffer,
243 ((xfs_fsop_bulkreq_t*)arg)->ocount);
244 else if (cmd == SGI_FS_BULKSTAT_SINGLE)
245 return syssgi(SGI_FS_BULKSTAT_SINGLE, fd,
246 ((xfs_fsop_bulkreq_t*)arg)->lastip,
247 ((xfs_fsop_bulkreq_t*)arg)->ubuffer);
248 else if (cmd == SGI_XFS_INJECT_ERROR)
249 return syssgi(SGI_XFS_INJECT_ERROR,
250 ((xfs_error_injection_t*)arg)->errtag, fd);
251 else if (cmd == SGI_XFS_CLEARALL_ERROR)
252 return syssgi(SGI_XFS_CLEARALL_ERROR, fd);
254 return fcntl(fd, cmd, arg);