aboutsummaryrefslogtreecommitdiffstats
path: root/fs/compat_ioctl.c
diff options
context:
space:
mode:
authorPetr Vandrovec <petr@vandrovec.name>2006-10-01 02:27:55 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-01 03:39:23 -0400
commit54f67f631dfc25ca7a8b19200e34013abc974337 (patch)
tree96c481c2723e1f5f626110c9a7f1c4a07b9ee056 /fs/compat_ioctl.c
parent89bbc03c01f68e627a2b120963f136e2815f0d84 (diff)
[PATCH] Move ncpfs 32bit compat ioctl to ncpfs
The ncp specific compat ioctls are clearly local to one file system, so the code can better live there. This version of the patch moves everything into the generic ioctl handler and uses it for both 32 and 64 bit calls. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Petr Vandrovec <petr@vandrovec.name> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/compat_ioctl.c')
-rw-r--r--fs/compat_ioctl.c198
1 files changed, 0 insertions, 198 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 64b34533edea..27ca1aa30562 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -60,7 +60,6 @@
60#include <linux/ctype.h> 60#include <linux/ctype.h>
61#include <linux/ioctl32.h> 61#include <linux/ioctl32.h>
62#include <linux/syscalls.h> 62#include <linux/syscalls.h>
63#include <linux/ncp_fs.h>
64#include <linux/i2c.h> 63#include <linux/i2c.h>
65#include <linux/i2c-dev.h> 64#include <linux/i2c-dev.h>
66#include <linux/wireless.h> 65#include <linux/wireless.h>
@@ -2348,193 +2347,6 @@ static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2348 } 2347 }
2349} 2348}
2350 2349
2351#if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
2352struct ncp_ioctl_request_32 {
2353 u32 function;
2354 u32 size;
2355 compat_caddr_t data;
2356};
2357
2358struct ncp_fs_info_v2_32 {
2359 s32 version;
2360 u32 mounted_uid;
2361 u32 connection;
2362 u32 buffer_size;
2363
2364 u32 volume_number;
2365 u32 directory_id;
2366
2367 u32 dummy1;
2368 u32 dummy2;
2369 u32 dummy3;
2370};
2371
2372struct ncp_objectname_ioctl_32
2373{
2374 s32 auth_type;
2375 u32 object_name_len;
2376 compat_caddr_t object_name; /* an userspace data, in most cases user name */
2377};
2378
2379struct ncp_privatedata_ioctl_32
2380{
2381 u32 len;
2382 compat_caddr_t data; /* ~1000 for NDS */
2383};
2384
2385#define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32)
2386#define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32)
2387#define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32)
2388#define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32)
2389#define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32)
2390#define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32)
2391#define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32)
2392
2393static int do_ncp_ncprequest(unsigned int fd, unsigned int cmd, unsigned long arg)
2394{
2395 struct ncp_ioctl_request_32 n32;
2396 struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p));
2397
2398 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) ||
2399 put_user(n32.function, &p->function) ||
2400 put_user(n32.size, &p->size) ||
2401 put_user(compat_ptr(n32.data), &p->data))
2402 return -EFAULT;
2403
2404 return sys_ioctl(fd, NCP_IOC_NCPREQUEST, (unsigned long)p);
2405}
2406
2407static int do_ncp_getmountuid2(unsigned int fd, unsigned int cmd, unsigned long arg)
2408{
2409 mm_segment_t old_fs = get_fs();
2410 __kernel_uid_t kuid;
2411 int err;
2412
2413 cmd = NCP_IOC_GETMOUNTUID2;
2414
2415 set_fs(KERNEL_DS);
2416 err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
2417 set_fs(old_fs);
2418
2419 if (!err)
2420 err = put_user(kuid,
2421 (unsigned int __user *) compat_ptr(arg));
2422
2423 return err;
2424}
2425
2426static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg)
2427{
2428 mm_segment_t old_fs = get_fs();
2429 struct ncp_fs_info_v2_32 n32;
2430 struct ncp_fs_info_v2 n;
2431 int err;
2432
2433 if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)))
2434 return -EFAULT;
2435 if (n32.version != NCP_GET_FS_INFO_VERSION_V2)
2436 return -EINVAL;
2437 n.version = NCP_GET_FS_INFO_VERSION_V2;
2438
2439 set_fs(KERNEL_DS);
2440 err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n);
2441 set_fs(old_fs);
2442
2443 if (!err) {
2444 n32.version = n.version;
2445 n32.mounted_uid = n.mounted_uid;
2446 n32.connection = n.connection;
2447 n32.buffer_size = n.buffer_size;
2448 n32.volume_number = n.volume_number;
2449 n32.directory_id = n.directory_id;
2450 n32.dummy1 = n.dummy1;
2451 n32.dummy2 = n.dummy2;
2452 n32.dummy3 = n.dummy3;
2453 err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0;
2454 }
2455 return err;
2456}
2457
2458static int do_ncp_getobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2459{
2460 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2461 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2462 s32 auth_type;
2463 u32 name_len;
2464 int err;
2465
2466 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2467 put_user(n32.object_name_len, &p->object_name_len) ||
2468 put_user(compat_ptr(n32.object_name), &p->object_name))
2469 return -EFAULT;
2470
2471 err = sys_ioctl(fd, NCP_IOC_GETOBJECTNAME, (unsigned long)p);
2472 if (err)
2473 return err;
2474
2475 if (get_user(auth_type, &p->auth_type) ||
2476 put_user(auth_type, &p32->auth_type) ||
2477 get_user(name_len, &p->object_name_len) ||
2478 put_user(name_len, &p32->object_name_len))
2479 return -EFAULT;
2480
2481 return 0;
2482}
2483
2484static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
2485{
2486 struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2487 struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
2488
2489 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2490 put_user(n32.auth_type, &p->auth_type) ||
2491 put_user(n32.object_name_len, &p->object_name_len) ||
2492 put_user(compat_ptr(n32.object_name), &p->object_name))
2493 return -EFAULT;
2494
2495 return sys_ioctl(fd, NCP_IOC_SETOBJECTNAME, (unsigned long)p);
2496}
2497
2498static int do_ncp_getprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2499{
2500 struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg);
2501 struct ncp_privatedata_ioctl __user *p =
2502 compat_alloc_user_space(sizeof(*p));
2503 u32 len;
2504 int err;
2505
2506 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2507 put_user(n32.len, &p->len) ||
2508 put_user(compat_ptr(n32.data), &p->data))
2509 return -EFAULT;
2510
2511 err = sys_ioctl(fd, NCP_IOC_GETPRIVATEDATA, (unsigned long)p);
2512 if (err)
2513 return err;
2514
2515 if (get_user(len, &p->len) ||
2516 put_user(len, &p32->len))
2517 return -EFAULT;
2518
2519 return 0;
2520}
2521
2522static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
2523{
2524 struct ncp_privatedata_ioctl_32 n32;
2525 struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg);
2526 struct ncp_privatedata_ioctl __user *p =
2527 compat_alloc_user_space(sizeof(*p));
2528
2529 if (copy_from_user(&n32, p32, sizeof(n32)) ||
2530 put_user(n32.len, &p->len) ||
2531 put_user(compat_ptr(n32.data), &p->data))
2532 return -EFAULT;
2533
2534 return sys_ioctl(fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)p);
2535}
2536#endif
2537
2538static int 2350static int
2539lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg) 2351lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
2540{ 2352{
@@ -2748,16 +2560,6 @@ HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl)
2748HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl) 2560HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
2749HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl) 2561HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl)
2750 2562
2751#if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
2752HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
2753HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2)
2754HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2)
2755HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname)
2756HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname)
2757HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
2758HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
2759#endif
2760
2761/* dvb */ 2563/* dvb */
2762HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event) 2564HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
2763HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture) 2565HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)