Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (c) 2004 Silicon Graphics, Inc. All Rights Reserved. | |
3 | * | |
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. | |
7 | * | |
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. | |
11 | * | |
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. | |
18 | * | |
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. | |
22 | * | |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | |
24 | * Mountain View, CA 94043, or: | |
25 | * | |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | |
31 | */ | |
32 | ||
33 | #include <linux/config.h> | |
34 | #include <linux/compat.h> | |
35 | #include <linux/init.h> | |
36 | #include <linux/ioctl.h> | |
37 | #include <linux/ioctl32.h> | |
38 | #include <linux/syscalls.h> | |
39 | #include <linux/types.h> | |
40 | #include <linux/fs.h> | |
41 | #include <asm/uaccess.h> | |
42 | ||
43 | #include "xfs.h" | |
44 | #include "xfs_types.h" | |
45 | #include "xfs_fs.h" | |
46 | #include "xfs_vfs.h" | |
47 | #include "xfs_vnode.h" | |
48 | #include "xfs_dfrag.h" | |
49 | ||
50 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) | |
51 | #define BROKEN_X86_ALIGNMENT | |
52 | #else | |
53 | ||
54 | typedef struct xfs_fsop_bulkreq32 { | |
55 | compat_uptr_t lastip; /* last inode # pointer */ | |
56 | __s32 icount; /* count of entries in buffer */ | |
57 | compat_uptr_t ubuffer; /* user buffer for inode desc. */ | |
58 | __s32 ocount; /* output count pointer */ | |
59 | } xfs_fsop_bulkreq32_t; | |
60 | ||
61 | static unsigned long | |
62 | xfs_ioctl32_bulkstat(unsigned long arg) | |
63 | { | |
64 | xfs_fsop_bulkreq32_t __user *p32 = (void __user *)arg; | |
65 | xfs_fsop_bulkreq_t __user *p = compat_alloc_user_space(sizeof(*p)); | |
66 | u32 addr; | |
67 | ||
68 | if (get_user(addr, &p32->lastip) || | |
69 | put_user(compat_ptr(addr), &p->lastip) || | |
70 | copy_in_user(&p->icount, &p32->icount, sizeof(s32)) || | |
71 | get_user(addr, &p32->ubuffer) || | |
72 | put_user(compat_ptr(addr), &p->ubuffer) || | |
73 | get_user(addr, &p32->ocount) || | |
74 | put_user(compat_ptr(addr), &p->ocount)) | |
75 | return -EFAULT; | |
76 | ||
77 | return (unsigned long)p; | |
78 | } | |
79 | #endif | |
80 | ||
81 | static long | |
82 | __xfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg) | |
83 | { | |
84 | int error; | |
85 | struct inode *inode = f->f_dentry->d_inode; | |
86 | vnode_t *vp = LINVFS_GET_VP(inode); | |
87 | ||
88 | switch (cmd) { | |
89 | case XFS_IOC_DIOINFO: | |
90 | case XFS_IOC_FSGEOMETRY_V1: | |
91 | case XFS_IOC_FSGEOMETRY: | |
92 | case XFS_IOC_GETVERSION: | |
93 | case XFS_IOC_GETXFLAGS: | |
94 | case XFS_IOC_SETXFLAGS: | |
95 | case XFS_IOC_FSGETXATTR: | |
96 | case XFS_IOC_FSSETXATTR: | |
97 | case XFS_IOC_FSGETXATTRA: | |
98 | case XFS_IOC_FSSETDM: | |
99 | case XFS_IOC_GETBMAP: | |
100 | case XFS_IOC_GETBMAPA: | |
101 | case XFS_IOC_GETBMAPX: | |
102 | /* not handled | |
103 | case XFS_IOC_FD_TO_HANDLE: | |
104 | case XFS_IOC_PATH_TO_HANDLE: | |
105 | case XFS_IOC_PATH_TO_HANDLE: | |
106 | case XFS_IOC_PATH_TO_FSHANDLE: | |
107 | case XFS_IOC_OPEN_BY_HANDLE: | |
108 | case XFS_IOC_FSSETDM_BY_HANDLE: | |
109 | case XFS_IOC_READLINK_BY_HANDLE: | |
110 | case XFS_IOC_ATTRLIST_BY_HANDLE: | |
111 | case XFS_IOC_ATTRMULTI_BY_HANDLE: | |
112 | */ | |
113 | case XFS_IOC_FSCOUNTS: | |
114 | case XFS_IOC_SET_RESBLKS: | |
115 | case XFS_IOC_GET_RESBLKS: | |
116 | case XFS_IOC_FSGROWFSDATA: | |
117 | case XFS_IOC_FSGROWFSLOG: | |
118 | case XFS_IOC_FSGROWFSRT: | |
119 | case XFS_IOC_FREEZE: | |
120 | case XFS_IOC_THAW: | |
121 | case XFS_IOC_GOINGDOWN: | |
122 | case XFS_IOC_ERROR_INJECTION: | |
123 | case XFS_IOC_ERROR_CLEARALL: | |
124 | break; | |
125 | ||
126 | #ifndef BROKEN_X86_ALIGNMENT | |
127 | /* xfs_flock_t and xfs_bstat_t have wrong u32 vs u64 alignment */ | |
128 | case XFS_IOC_ALLOCSP: | |
129 | case XFS_IOC_FREESP: | |
130 | case XFS_IOC_RESVSP: | |
131 | case XFS_IOC_UNRESVSP: | |
132 | case XFS_IOC_ALLOCSP64: | |
133 | case XFS_IOC_FREESP64: | |
134 | case XFS_IOC_RESVSP64: | |
135 | case XFS_IOC_UNRESVSP64: | |
136 | case XFS_IOC_SWAPEXT: | |
137 | break; | |
138 | ||
139 | case XFS_IOC_FSBULKSTAT_SINGLE: | |
140 | case XFS_IOC_FSBULKSTAT: | |
141 | case XFS_IOC_FSINUMBERS: | |
142 | arg = xfs_ioctl32_bulkstat(arg); | |
143 | break; | |
144 | #endif | |
145 | default: | |
146 | return -ENOIOCTLCMD; | |
147 | } | |
148 | ||
149 | VOP_IOCTL(vp, inode, f, mode, cmd, (void __user *)arg, error); | |
150 | VMODIFY(vp); | |
151 | ||
152 | return error; | |
153 | } | |
154 | ||
155 | long xfs_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg) | |
156 | { | |
157 | return __xfs_compat_ioctl(0, f, cmd, arg); | |
158 | } | |
159 | ||
160 | long xfs_compat_invis_ioctl(struct file *f, unsigned cmd, unsigned long arg) | |
161 | { | |
162 | return __xfs_compat_ioctl(IO_INVIS, f, cmd, arg); | |
163 | } |