This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / fs / xfs / linux-2.6 / xfs_ioctl32.c
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 <asm/uaccess.h>
41
42 #include "xfs_types.h"
43 #include "xfs_fs.h"
44 #include "xfs_dfrag.h"
45
46 #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
47 #define BROKEN_X86_ALIGNMENT
48 #else
49
50 typedef struct xfs_fsop_bulkreq32 {
51         compat_uptr_t   lastip;         /* last inode # pointer         */
52         __s32           icount;         /* count of entries in buffer   */
53         compat_uptr_t   ubuffer;        /* user buffer for inode desc.  */
54         __s32           ocount;         /* output count pointer         */
55 } xfs_fsop_bulkreq32_t;
56
57 static int
58 xfs_ioctl32_bulkstat(
59         unsigned int            fd,
60         unsigned int            cmd,
61         unsigned long           arg,
62         struct file *           file)
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 sys_ioctl(fd, cmd, (unsigned long)p);
78 }
79 #endif
80
81 struct ioctl_trans xfs_ioctl32_trans[] = {
82         { XFS_IOC_DIOINFO, },
83         { XFS_IOC_FSGEOMETRY_V1, },
84         { XFS_IOC_FSGEOMETRY, },
85         { XFS_IOC_GETVERSION, },
86         { XFS_IOC_GETXFLAGS, },
87         { XFS_IOC_SETXFLAGS, },
88         { XFS_IOC_FSGETXATTR, },
89         { XFS_IOC_FSSETXATTR, },
90         { XFS_IOC_FSGETXATTRA, },
91         { XFS_IOC_FSSETDM, },
92         { XFS_IOC_GETBMAP, },
93         { XFS_IOC_GETBMAPA, },
94         { XFS_IOC_GETBMAPX, },
95 /* not handled
96         { XFS_IOC_FD_TO_HANDLE, },
97         { XFS_IOC_PATH_TO_HANDLE, },
98         { XFS_IOC_PATH_TO_HANDLE, },
99         { XFS_IOC_PATH_TO_FSHANDLE, },
100         { XFS_IOC_OPEN_BY_HANDLE, },
101         { XFS_IOC_FSSETDM_BY_HANDLE, },
102         { XFS_IOC_READLINK_BY_HANDLE, },
103         { XFS_IOC_ATTRLIST_BY_HANDLE, },
104         { XFS_IOC_ATTRMULTI_BY_HANDLE, },
105 */
106         { XFS_IOC_FSCOUNTS, NULL, },
107         { XFS_IOC_SET_RESBLKS, NULL, },
108         { XFS_IOC_GET_RESBLKS, NULL, },
109         { XFS_IOC_FSGROWFSDATA, NULL, },
110         { XFS_IOC_FSGROWFSLOG, NULL, },
111         { XFS_IOC_FSGROWFSRT, NULL, },
112         { XFS_IOC_FREEZE, NULL, },
113         { XFS_IOC_THAW, NULL, },
114         { XFS_IOC_GOINGDOWN, NULL, },
115         { XFS_IOC_ERROR_INJECTION, NULL, },
116         { XFS_IOC_ERROR_CLEARALL, NULL, },
117 #ifndef BROKEN_X86_ALIGNMENT
118         /* xfs_flock_t and xfs_bstat_t have wrong u32 vs u64 alignment */
119         { XFS_IOC_ALLOCSP, },
120         { XFS_IOC_FREESP, },
121         { XFS_IOC_RESVSP, },
122         { XFS_IOC_UNRESVSP, },
123         { XFS_IOC_ALLOCSP64, },
124         { XFS_IOC_FREESP64, },
125         { XFS_IOC_RESVSP64, },
126         { XFS_IOC_UNRESVSP64, },
127         { XFS_IOC_SWAPEXT, },
128         { XFS_IOC_FSBULKSTAT_SINGLE, xfs_ioctl32_bulkstat },
129         { XFS_IOC_FSBULKSTAT, xfs_ioctl32_bulkstat},
130         { XFS_IOC_FSINUMBERS, xfs_ioctl32_bulkstat},
131 #endif
132         { 0, },
133 };
134
135 int __init
136 xfs_ioctl32_init(void)
137 {
138         int error, i;
139
140         for (i = 0; xfs_ioctl32_trans[i].cmd != 0; i++) {
141                 error = register_ioctl32_conversion(xfs_ioctl32_trans[i].cmd,
142                                 xfs_ioctl32_trans[i].handler);
143                 if (error)
144                         goto fail;
145         }
146
147         return 0;
148
149  fail:
150         while (--i)
151                 unregister_ioctl32_conversion(xfs_ioctl32_trans[i].cmd);
152         return error;
153 }
154
155 void
156 xfs_ioctl32_exit(void)
157 {
158         int i;
159
160         for (i = 0; xfs_ioctl32_trans[i].cmd != 0; i++)
161                 unregister_ioctl32_conversion(xfs_ioctl32_trans[i].cmd);
162 }