Skip to content

Commit 52b499c

Browse files
dhowellsJens Axboe
authored andcommitted
[PATCH] BLOCK: Move the ReiserFS device ioctl compat stuff to the ReiserFS driver [try raspberrypi#6]
Move the ReiserFS device ioctl compat stuff from fs/compat_ioctl.c to the ReiserFS driver so that the ReiserFS header file doesn't need to be included. Signed-Off-By: David Howells <dhowells@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 3669567 commit 52b499c

5 files changed

Lines changed: 51 additions & 12 deletions

File tree

‎fs/compat_ioctl.c‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
#include <linux/pci.h>
6060
#include <linux/module.h>
6161
#include <linux/serial.h>
62-
#include <linux/reiserfs_fs.h>
6362
#include <linux/if_tun.h>
6463
#include <linux/ctype.h>
6564
#include <linux/ioctl32.h>
@@ -2014,16 +2013,6 @@ static int vfat_ioctl32(unsigned fd, unsigned cmd, unsigned long arg)
20142013
return ret;
20152014
}
20162015

2017-
#define REISERFS_IOC_UNPACK32 _IOW(0xCD,1,int)
2018-
2019-
static int reiserfs_ioctl32(unsigned fd, unsigned cmd, unsigned long ptr)
2020-
{
2021-
if (cmd == REISERFS_IOC_UNPACK32)
2022-
cmd = REISERFS_IOC_UNPACK;
2023-
2024-
return sys_ioctl(fd,cmd,ptr);
2025-
}
2026-
20272016
struct raw32_config_request
20282017
{
20292018
compat_int_t raw_minor;
@@ -2784,7 +2773,6 @@ HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64)
27842773
/* vfat */
27852774
HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
27862775
HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32)
2787-
HANDLE_IOCTL(REISERFS_IOC_UNPACK32, reiserfs_ioctl32)
27882776
/* Raw devices */
27892777
HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
27902778
HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)

‎fs/reiserfs/dir.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ const struct file_operations reiserfs_dir_operations = {
2222
.readdir = reiserfs_readdir,
2323
.fsync = reiserfs_dir_fsync,
2424
.ioctl = reiserfs_ioctl,
25+
#ifdef CONFIG_COMPAT
26+
.compat_ioctl = reiserfs_compat_ioctl,
27+
#endif
2528
};
2629

2730
static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry,

‎fs/reiserfs/file.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
33
*/
44

5+
#include <linux/config.h>
56
#include <linux/time.h>
67
#include <linux/reiserfs_fs.h>
78
#include <linux/reiserfs_acl.h>
@@ -1568,6 +1569,9 @@ const struct file_operations reiserfs_file_operations = {
15681569
.read = generic_file_read,
15691570
.write = reiserfs_file_write,
15701571
.ioctl = reiserfs_ioctl,
1572+
#ifdef CONFIG_COMPAT
1573+
.compat_ioctl = reiserfs_compat_ioctl,
1574+
#endif
15711575
.mmap = generic_file_mmap,
15721576
.release = reiserfs_file_release,
15731577
.fsync = reiserfs_sync_file,

‎fs/reiserfs/ioctl.c‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <asm/uaccess.h>
1010
#include <linux/pagemap.h>
1111
#include <linux/smp_lock.h>
12+
#include <linux/compat.h>
1213

1314
static int reiserfs_unpack(struct inode *inode, struct file *filp);
1415

@@ -94,6 +95,40 @@ int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
9495
}
9596
}
9697

98+
#ifdef CONFIG_COMPAT
99+
long reiserfs_compat_ioctl(struct file *file, unsigned int cmd,
100+
unsigned long arg)
101+
{
102+
struct inode *inode = file->f_dentry->d_inode;
103+
int ret;
104+
105+
/* These are just misnamed, they actually get/put from/to user an int */
106+
switch (cmd) {
107+
case REISERFS_IOC32_UNPACK:
108+
cmd = REISERFS_IOC_UNPACK;
109+
break;
110+
case REISERFS_IOC32_GETFLAGS:
111+
cmd = REISERFS_IOC_GETFLAGS;
112+
break;
113+
case REISERFS_IOC32_SETFLAGS:
114+
cmd = REISERFS_IOC_SETFLAGS;
115+
break;
116+
case REISERFS_IOC32_GETVERSION:
117+
cmd = REISERFS_IOC_GETVERSION;
118+
break;
119+
case REISERFS_IOC32_SETVERSION:
120+
cmd = REISERFS_IOC_SETVERSION;
121+
break;
122+
default:
123+
return -ENOIOCTLCMD;
124+
}
125+
lock_kernel();
126+
ret = reiserfs_ioctl(inode, file, cmd, (unsigned long) compat_ptr(arg));
127+
unlock_kernel();
128+
return ret;
129+
}
130+
#endif
131+
97132
/*
98133
** reiserfs_unpack
99134
** Function try to convert tail from direct item into indirect.

‎include/linux/reiserfs_fs.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,6 +2161,8 @@ __u32 r5_hash(const signed char *msg, int len);
21612161
/* prototypes from ioctl.c */
21622162
int reiserfs_ioctl(struct inode *inode, struct file *filp,
21632163
unsigned int cmd, unsigned long arg);
2164+
long reiserfs_compat_ioctl(struct file *filp,
2165+
unsigned int cmd, unsigned long arg);
21642166

21652167
/* ioctl's command */
21662168
#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long)
@@ -2171,6 +2173,13 @@ int reiserfs_ioctl(struct inode *inode, struct file *filp,
21712173
#define REISERFS_IOC_GETVERSION FS_IOC_GETVERSION
21722174
#define REISERFS_IOC_SETVERSION FS_IOC_SETVERSION
21732175

2176+
/* the 32 bit compat definitions with int argument */
2177+
#define REISERFS_IOC32_UNPACK _IOW(0xCD, 1, int)
2178+
#define REISERFS_IOC32_GETFLAGS FS_IOC32_GETFLAGS
2179+
#define REISERFS_IOC32_SETFLAGS FS_IOC32_SETFLAGS
2180+
#define REISERFS_IOC32_GETVERSION FS_IOC32_GETVERSION
2181+
#define REISERFS_IOC32_SETVERSION FS_IOC32_SETVERSION
2182+
21742183
/* Locking primitives */
21752184
/* Right now we are still falling back to (un)lock_kernel, but eventually that
21762185
would evolve into real per-fs locks */

0 commit comments

Comments
 (0)