aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-08-31 06:50:04 -0400
committerJens Axboe <axboe@nelson.home.kernel.dk>2006-09-30 14:52:30 -0400
commit188f83dfe0eeecd1427d0d255cc97dbf7ef6b4b7 (patch)
tree72a36a42e6b1f4693b4c39dc70d25241418dc228 /fs/fat
parent52a700c5675f399c07e6e57328291e57f13ef3bb (diff)
[PATCH] BLOCK: Move the msdos device ioctl compat stuff to the msdos driver [try #6]
Move the msdos device ioctl compat stuff from fs/compat_ioctl.c to the msdos driver so that the msdos header file doesn't need to be included. Signed-Off-By: David Howells <dhowells@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/fat')
-rw-r--r--fs/fat/dir.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 698b85bb1dd4..3e50a4166283 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -20,6 +20,7 @@
20#include <linux/dirent.h> 20#include <linux/dirent.h>
21#include <linux/smp_lock.h> 21#include <linux/smp_lock.h>
22#include <linux/buffer_head.h> 22#include <linux/buffer_head.h>
23#include <linux/compat.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24 25
25static inline loff_t fat_make_i_pos(struct super_block *sb, 26static inline loff_t fat_make_i_pos(struct super_block *sb,
@@ -741,10 +742,65 @@ static int fat_dir_ioctl(struct inode * inode, struct file * filp,
741 return ret; 742 return ret;
742} 743}
743 744
745#ifdef CONFIG_COMPAT
746#define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
747#define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
748
749static long fat_compat_put_dirent32(struct dirent *d,
750 struct compat_dirent __user *d32)
751{
752 if (!access_ok(VERIFY_WRITE, d32, sizeof(struct compat_dirent)))
753 return -EFAULT;
754
755 __put_user(d->d_ino, &d32->d_ino);
756 __put_user(d->d_off, &d32->d_off);
757 __put_user(d->d_reclen, &d32->d_reclen);
758 if (__copy_to_user(d32->d_name, d->d_name, d->d_reclen))
759 return -EFAULT;
760
761 return 0;
762}
763
764static long fat_compat_dir_ioctl(struct file *file, unsigned cmd,
765 unsigned long arg)
766{
767 struct compat_dirent __user *p = compat_ptr(arg);
768 int ret;
769 mm_segment_t oldfs = get_fs();
770 struct dirent d[2];
771
772 switch (cmd) {
773 case VFAT_IOCTL_READDIR_BOTH32:
774 cmd = VFAT_IOCTL_READDIR_BOTH;
775 break;
776 case VFAT_IOCTL_READDIR_SHORT32:
777 cmd = VFAT_IOCTL_READDIR_SHORT;
778 break;
779 default:
780 return -ENOIOCTLCMD;
781 }
782
783 set_fs(KERNEL_DS);
784 lock_kernel();
785 ret = fat_dir_ioctl(file->f_dentry->d_inode, file,
786 cmd, (unsigned long) &d);
787 unlock_kernel();
788 set_fs(oldfs);
789 if (ret >= 0) {
790 ret |= fat_compat_put_dirent32(&d[0], p);
791 ret |= fat_compat_put_dirent32(&d[1], p + 1);
792 }
793 return ret;
794}
795#endif /* CONFIG_COMPAT */
796
744const struct file_operations fat_dir_operations = { 797const struct file_operations fat_dir_operations = {
745 .read = generic_read_dir, 798 .read = generic_read_dir,
746 .readdir = fat_readdir, 799 .readdir = fat_readdir,
747 .ioctl = fat_dir_ioctl, 800 .ioctl = fat_dir_ioctl,
801#ifdef CONFIG_COMPAT
802 .compat_ioctl = fat_compat_dir_ioctl,
803#endif
748 .fsync = file_fsync, 804 .fsync = file_fsync,
749}; 805};
750 806