diff options
| -rw-r--r-- | fs/fat/dir.c | 28 | ||||
| -rw-r--r-- | fs/fat/fat.h | 4 | ||||
| -rw-r--r-- | fs/fat/file.c | 19 | ||||
| -rw-r--r-- | fs/fat/inode.c | 6 | 
4 files changed, 32 insertions, 25 deletions
| diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 530b4ca01510..ee42b9e0b16a 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/buffer_head.h> | 19 | #include <linux/buffer_head.h> | 
| 20 | #include <linux/compat.h> | 20 | #include <linux/compat.h> | 
| 21 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> | 
| 22 | #include <linux/kernel.h> | ||
| 22 | #include "fat.h" | 23 | #include "fat.h" | 
| 23 | 24 | ||
| 24 | /* | 25 | /* | 
| @@ -140,28 +141,22 @@ static int uni16_to_x8(unsigned char *ascii, const wchar_t *uni, int len, | |||
| 140 | { | 141 | { | 
| 141 | const wchar_t *ip; | 142 | const wchar_t *ip; | 
| 142 | wchar_t ec; | 143 | wchar_t ec; | 
| 143 | unsigned char *op, nc; | 144 | unsigned char *op; | 
| 144 | int charlen; | 145 | int charlen; | 
| 145 | int k; | ||
| 146 | 146 | ||
| 147 | ip = uni; | 147 | ip = uni; | 
| 148 | op = ascii; | 148 | op = ascii; | 
| 149 | 149 | ||
| 150 | while (*ip && ((len - NLS_MAX_CHARSET_SIZE) > 0)) { | 150 | while (*ip && ((len - NLS_MAX_CHARSET_SIZE) > 0)) { | 
| 151 | ec = *ip++; | 151 | ec = *ip++; | 
| 152 | if ( (charlen = nls->uni2char(ec, op, NLS_MAX_CHARSET_SIZE)) > 0) { | 152 | if ((charlen = nls->uni2char(ec, op, NLS_MAX_CHARSET_SIZE)) > 0) { | 
| 153 | op += charlen; | 153 | op += charlen; | 
| 154 | len -= charlen; | 154 | len -= charlen; | 
| 155 | } else { | 155 | } else { | 
| 156 | if (uni_xlate == 1) { | 156 | if (uni_xlate == 1) { | 
| 157 | *op = ':'; | 157 | *op++ = ':'; | 
| 158 | for (k = 4; k > 0; k--) { | 158 | op = pack_hex_byte(op, ec >> 8); | 
| 159 | nc = ec & 0xF; | 159 | op = pack_hex_byte(op, ec); | 
| 160 | op[k] = nc > 9 ? nc + ('a' - 10) | ||
| 161 | : nc + '0'; | ||
| 162 | ec >>= 4; | ||
| 163 | } | ||
| 164 | op += 5; | ||
| 165 | len -= 5; | 160 | len -= 5; | 
| 166 | } else { | 161 | } else { | 
| 167 | *op++ = '?'; | 162 | *op++ = '?'; | 
| @@ -758,9 +753,10 @@ static int fat_ioctl_readdir(struct inode *inode, struct file *filp, | |||
| 758 | return ret; | 753 | return ret; | 
| 759 | } | 754 | } | 
| 760 | 755 | ||
| 761 | static int fat_dir_ioctl(struct inode *inode, struct file *filp, | 756 | static long fat_dir_ioctl(struct file *filp, unsigned int cmd, | 
| 762 | unsigned int cmd, unsigned long arg) | 757 | unsigned long arg) | 
| 763 | { | 758 | { | 
| 759 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
| 764 | struct __fat_dirent __user *d1 = (struct __fat_dirent __user *)arg; | 760 | struct __fat_dirent __user *d1 = (struct __fat_dirent __user *)arg; | 
| 765 | int short_only, both; | 761 | int short_only, both; | 
| 766 | 762 | ||
| @@ -774,7 +770,7 @@ static int fat_dir_ioctl(struct inode *inode, struct file *filp, | |||
| 774 | both = 1; | 770 | both = 1; | 
| 775 | break; | 771 | break; | 
| 776 | default: | 772 | default: | 
| 777 | return fat_generic_ioctl(inode, filp, cmd, arg); | 773 | return fat_generic_ioctl(filp, cmd, arg); | 
| 778 | } | 774 | } | 
| 779 | 775 | ||
| 780 | if (!access_ok(VERIFY_WRITE, d1, sizeof(struct __fat_dirent[2]))) | 776 | if (!access_ok(VERIFY_WRITE, d1, sizeof(struct __fat_dirent[2]))) | 
| @@ -814,7 +810,7 @@ static long fat_compat_dir_ioctl(struct file *filp, unsigned cmd, | |||
| 814 | both = 1; | 810 | both = 1; | 
| 815 | break; | 811 | break; | 
| 816 | default: | 812 | default: | 
| 817 | return -ENOIOCTLCMD; | 813 | return fat_generic_ioctl(filp, cmd, (unsigned long)arg); | 
| 818 | } | 814 | } | 
| 819 | 815 | ||
| 820 | if (!access_ok(VERIFY_WRITE, d1, sizeof(struct compat_dirent[2]))) | 816 | if (!access_ok(VERIFY_WRITE, d1, sizeof(struct compat_dirent[2]))) | 
| @@ -836,7 +832,7 @@ const struct file_operations fat_dir_operations = { | |||
| 836 | .llseek = generic_file_llseek, | 832 | .llseek = generic_file_llseek, | 
| 837 | .read = generic_read_dir, | 833 | .read = generic_read_dir, | 
| 838 | .readdir = fat_readdir, | 834 | .readdir = fat_readdir, | 
| 839 | .ioctl = fat_dir_ioctl, | 835 | .unlocked_ioctl = fat_dir_ioctl, | 
| 840 | #ifdef CONFIG_COMPAT | 836 | #ifdef CONFIG_COMPAT | 
| 841 | .compat_ioctl = fat_compat_dir_ioctl, | 837 | .compat_ioctl = fat_compat_dir_ioctl, | 
| 842 | #endif | 838 | #endif | 
| diff --git a/fs/fat/fat.h b/fs/fat/fat.h index e6efdfa0f6db..eb821ee1a333 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h | |||
| @@ -298,8 +298,8 @@ extern int fat_free_clusters(struct inode *inode, int cluster); | |||
| 298 | extern int fat_count_free_clusters(struct super_block *sb); | 298 | extern int fat_count_free_clusters(struct super_block *sb); | 
| 299 | 299 | ||
| 300 | /* fat/file.c */ | 300 | /* fat/file.c */ | 
| 301 | extern int fat_generic_ioctl(struct inode *inode, struct file *filp, | 301 | extern long fat_generic_ioctl(struct file *filp, unsigned int cmd, | 
| 302 | unsigned int cmd, unsigned long arg); | 302 | unsigned long arg); | 
| 303 | extern const struct file_operations fat_file_operations; | 303 | extern const struct file_operations fat_file_operations; | 
| 304 | extern const struct inode_operations fat_file_inode_operations; | 304 | extern const struct inode_operations fat_file_inode_operations; | 
| 305 | extern int fat_setattr(struct dentry * dentry, struct iattr * attr); | 305 | extern int fat_setattr(struct dentry * dentry, struct iattr * attr); | 
| diff --git a/fs/fat/file.c b/fs/fat/file.c index e8c159de236b..a14c2f6a489e 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include <linux/capability.h> | 9 | #include <linux/capability.h> | 
| 10 | #include <linux/module.h> | 10 | #include <linux/module.h> | 
| 11 | #include <linux/compat.h> | ||
| 11 | #include <linux/mount.h> | 12 | #include <linux/mount.h> | 
| 12 | #include <linux/time.h> | 13 | #include <linux/time.h> | 
| 13 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> | 
| @@ -114,9 +115,9 @@ out: | |||
| 114 | return err; | 115 | return err; | 
| 115 | } | 116 | } | 
| 116 | 117 | ||
| 117 | int fat_generic_ioctl(struct inode *inode, struct file *filp, | 118 | long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 
| 118 | unsigned int cmd, unsigned long arg) | ||
| 119 | { | 119 | { | 
| 120 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
| 120 | u32 __user *user_attr = (u32 __user *)arg; | 121 | u32 __user *user_attr = (u32 __user *)arg; | 
| 121 | 122 | ||
| 122 | switch (cmd) { | 123 | switch (cmd) { | 
| @@ -129,6 +130,15 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp, | |||
| 129 | } | 130 | } | 
| 130 | } | 131 | } | 
| 131 | 132 | ||
| 133 | #ifdef CONFIG_COMPAT | ||
| 134 | static long fat_generic_compat_ioctl(struct file *filp, unsigned int cmd, | ||
| 135 | unsigned long arg) | ||
| 136 | |||
| 137 | { | ||
| 138 | return fat_generic_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); | ||
| 139 | } | ||
| 140 | #endif | ||
| 141 | |||
| 132 | static int fat_file_release(struct inode *inode, struct file *filp) | 142 | static int fat_file_release(struct inode *inode, struct file *filp) | 
| 133 | { | 143 | { | 
| 134 | if ((filp->f_mode & FMODE_WRITE) && | 144 | if ((filp->f_mode & FMODE_WRITE) && | 
| @@ -159,7 +169,10 @@ const struct file_operations fat_file_operations = { | |||
| 159 | .aio_write = generic_file_aio_write, | 169 | .aio_write = generic_file_aio_write, | 
| 160 | .mmap = generic_file_mmap, | 170 | .mmap = generic_file_mmap, | 
| 161 | .release = fat_file_release, | 171 | .release = fat_file_release, | 
| 162 | .ioctl = fat_generic_ioctl, | 172 | .unlocked_ioctl = fat_generic_ioctl, | 
| 173 | #ifdef CONFIG_COMPAT | ||
| 174 | .compat_ioctl = fat_generic_compat_ioctl, | ||
| 175 | #endif | ||
| 163 | .fsync = fat_file_fsync, | 176 | .fsync = fat_file_fsync, | 
| 164 | .splice_read = generic_file_splice_read, | 177 | .splice_read = generic_file_splice_read, | 
| 165 | }; | 178 | }; | 
| diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 0ce143bd7d56..c611818893b2 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
| @@ -1497,10 +1497,8 @@ out_fail: | |||
| 1497 | iput(fat_inode); | 1497 | iput(fat_inode); | 
| 1498 | if (root_inode) | 1498 | if (root_inode) | 
| 1499 | iput(root_inode); | 1499 | iput(root_inode); | 
| 1500 | if (sbi->nls_io) | 1500 | unload_nls(sbi->nls_io); | 
| 1501 | unload_nls(sbi->nls_io); | 1501 | unload_nls(sbi->nls_disk); | 
| 1502 | if (sbi->nls_disk) | ||
| 1503 | unload_nls(sbi->nls_disk); | ||
| 1504 | if (sbi->options.iocharset != fat_default_iocharset) | 1502 | if (sbi->options.iocharset != fat_default_iocharset) | 
| 1505 | kfree(sbi->options.iocharset); | 1503 | kfree(sbi->options.iocharset); | 
| 1506 | sb->s_fs_info = NULL; | 1504 | sb->s_fs_info = NULL; | 
