aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat/dir.c
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2012-10-09 10:03:21 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-10-09 10:04:25 -0400
commitffe315012510165ce82e4dd4767f0a5dba9edbf7 (patch)
treef601cd980af9d0ced5ca9aedecef4fa0d2ca0e15 /fs/fat/dir.c
parente2d3a35ee427aaba99b6c68a56609ce276c51270 (diff)
parent4a8e43feeac7996b8de2d5b2823e316917493df4 (diff)
Merge tag 'disintegrate-mtd-20121009' of git://git.infradead.org/users/dhowells/linux-headers
UAPI Disintegration 2012-10-09 Conflicts: MAINTAINERS arch/arm/configs/bcmring_defconfig arch/arm/mach-imx/clk-imx51-imx53.c drivers/mtd/nand/Kconfig drivers/mtd/nand/bcm_umi_nand.c drivers/mtd/nand/nand_bcm_umi.h drivers/mtd/nand/orion_nand.c
Diffstat (limited to 'fs/fat/dir.c')
-rw-r--r--fs/fat/dir.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index dc49ed2cbffa..bca6d0a1255e 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -18,7 +18,7 @@
18#include <linux/time.h> 18#include <linux/time.h>
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 <linux/uaccess.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include "fat.h" 23#include "fat.h"
24 24
@@ -123,7 +123,8 @@ static inline int fat_get_entry(struct inode *dir, loff_t *pos,
123{ 123{
124 /* Fast stuff first */ 124 /* Fast stuff first */
125 if (*bh && *de && 125 if (*bh && *de &&
126 (*de - (struct msdos_dir_entry *)(*bh)->b_data) < MSDOS_SB(dir->i_sb)->dir_per_block - 1) { 126 (*de - (struct msdos_dir_entry *)(*bh)->b_data) <
127 MSDOS_SB(dir->i_sb)->dir_per_block - 1) {
127 *pos += sizeof(struct msdos_dir_entry); 128 *pos += sizeof(struct msdos_dir_entry);
128 (*de)++; 129 (*de)++;
129 return 0; 130 return 0;
@@ -155,7 +156,8 @@ static int uni16_to_x8(struct super_block *sb, unsigned char *ascii,
155 156
156 while (*ip && ((len - NLS_MAX_CHARSET_SIZE) > 0)) { 157 while (*ip && ((len - NLS_MAX_CHARSET_SIZE) > 0)) {
157 ec = *ip++; 158 ec = *ip++;
158 if ((charlen = nls->uni2char(ec, op, NLS_MAX_CHARSET_SIZE)) > 0) { 159 charlen = nls->uni2char(ec, op, NLS_MAX_CHARSET_SIZE);
160 if (charlen > 0) {
159 op += charlen; 161 op += charlen;
160 len -= charlen; 162 len -= charlen;
161 } else { 163 } else {
@@ -172,12 +174,12 @@ static int uni16_to_x8(struct super_block *sb, unsigned char *ascii,
172 } 174 }
173 175
174 if (unlikely(*ip)) { 176 if (unlikely(*ip)) {
175 fat_msg(sb, KERN_WARNING, "filename was truncated while " 177 fat_msg(sb, KERN_WARNING,
176 "converting."); 178 "filename was truncated while converting.");
177 } 179 }
178 180
179 *op = 0; 181 *op = 0;
180 return (op - ascii); 182 return op - ascii;
181} 183}
182 184
183static inline int fat_uni_to_x8(struct super_block *sb, const wchar_t *uni, 185static inline int fat_uni_to_x8(struct super_block *sb, const wchar_t *uni,
@@ -205,7 +207,8 @@ fat_short2uni(struct nls_table *t, unsigned char *c, int clen, wchar_t *uni)
205} 207}
206 208
207static inline int 209static inline int
208fat_short2lower_uni(struct nls_table *t, unsigned char *c, int clen, wchar_t *uni) 210fat_short2lower_uni(struct nls_table *t, unsigned char *c,
211 int clen, wchar_t *uni)
209{ 212{
210 int charlen; 213 int charlen;
211 wchar_t wc; 214 wchar_t wc;
@@ -220,7 +223,8 @@ fat_short2lower_uni(struct nls_table *t, unsigned char *c, int clen, wchar_t *un
220 if (!nc) 223 if (!nc)
221 nc = *c; 224 nc = *c;
222 225
223 if ( (charlen = t->char2uni(&nc, 1, uni)) < 0) { 226 charlen = t->char2uni(&nc, 1, uni);
227 if (charlen < 0) {
224 *uni = 0x003f; /* a question mark */ 228 *uni = 0x003f; /* a question mark */
225 charlen = 1; 229 charlen = 1;
226 } 230 }
@@ -537,7 +541,6 @@ end_of_dir:
537 541
538 return err; 542 return err;
539} 543}
540
541EXPORT_SYMBOL_GPL(fat_search_long); 544EXPORT_SYMBOL_GPL(fat_search_long);
542 545
543struct fat_ioctl_filldir_callback { 546struct fat_ioctl_filldir_callback {
@@ -574,7 +577,8 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent,
574 /* Fake . and .. for the root directory. */ 577 /* Fake . and .. for the root directory. */
575 if (inode->i_ino == MSDOS_ROOT_INO) { 578 if (inode->i_ino == MSDOS_ROOT_INO) {
576 while (cpos < 2) { 579 while (cpos < 2) {
577 if (filldir(dirent, "..", cpos+1, cpos, MSDOS_ROOT_INO, DT_DIR) < 0) 580 if (filldir(dirent, "..", cpos+1, cpos,
581 MSDOS_ROOT_INO, DT_DIR) < 0)
578 goto out; 582 goto out;
579 cpos++; 583 cpos++;
580 filp->f_pos++; 584 filp->f_pos++;
@@ -872,25 +876,26 @@ static int fat_get_short_entry(struct inode *dir, loff_t *pos,
872} 876}
873 877
874/* 878/*
875 * The ".." entry can not provide the "struct fat_slot_info" informations 879 * The ".." entry can not provide the "struct fat_slot_info" information
876 * for inode. So, this function provide the some informations only. 880 * for inode, nor a usable i_pos. So, this function provides some information
881 * only.
882 *
883 * Since this function walks through the on-disk inodes within a directory,
884 * callers are responsible for taking any locks necessary to prevent the
885 * directory from changing.
877 */ 886 */
878int fat_get_dotdot_entry(struct inode *dir, struct buffer_head **bh, 887int fat_get_dotdot_entry(struct inode *dir, struct buffer_head **bh,
879 struct msdos_dir_entry **de, loff_t *i_pos) 888 struct msdos_dir_entry **de)
880{ 889{
881 loff_t offset; 890 loff_t offset = 0;
882 891
883 offset = 0; 892 *de = NULL;
884 *bh = NULL;
885 while (fat_get_short_entry(dir, &offset, bh, de) >= 0) { 893 while (fat_get_short_entry(dir, &offset, bh, de) >= 0) {
886 if (!strncmp((*de)->name, MSDOS_DOTDOT, MSDOS_NAME)) { 894 if (!strncmp((*de)->name, MSDOS_DOTDOT, MSDOS_NAME))
887 *i_pos = fat_make_i_pos(dir->i_sb, *bh, *de);
888 return 0; 895 return 0;
889 }
890 } 896 }
891 return -ENOENT; 897 return -ENOENT;
892} 898}
893
894EXPORT_SYMBOL_GPL(fat_get_dotdot_entry); 899EXPORT_SYMBOL_GPL(fat_get_dotdot_entry);
895 900
896/* See if directory is empty */ 901/* See if directory is empty */
@@ -913,7 +918,6 @@ int fat_dir_empty(struct inode *dir)
913 brelse(bh); 918 brelse(bh);
914 return result; 919 return result;
915} 920}
916
917EXPORT_SYMBOL_GPL(fat_dir_empty); 921EXPORT_SYMBOL_GPL(fat_dir_empty);
918 922
919/* 923/*
@@ -959,7 +963,6 @@ int fat_scan(struct inode *dir, const unsigned char *name,
959 } 963 }
960 return -ENOENT; 964 return -ENOENT;
961} 965}
962
963EXPORT_SYMBOL_GPL(fat_scan); 966EXPORT_SYMBOL_GPL(fat_scan);
964 967
965static int __fat_remove_entries(struct inode *dir, loff_t pos, int nr_slots) 968static int __fat_remove_entries(struct inode *dir, loff_t pos, int nr_slots)
@@ -1047,7 +1050,6 @@ int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo)
1047 1050
1048 return 0; 1051 return 0;
1049} 1052}
1050
1051EXPORT_SYMBOL_GPL(fat_remove_entries); 1053EXPORT_SYMBOL_GPL(fat_remove_entries);
1052 1054
1053static int fat_zeroed_cluster(struct inode *dir, sector_t blknr, int nr_used, 1055static int fat_zeroed_cluster(struct inode *dir, sector_t blknr, int nr_used,
@@ -1141,10 +1143,8 @@ int fat_alloc_new_dir(struct inode *dir, struct timespec *ts)
1141 de[0].ctime_cs = de[1].ctime_cs = 0; 1143 de[0].ctime_cs = de[1].ctime_cs = 0;
1142 de[0].adate = de[0].cdate = de[1].adate = de[1].cdate = 0; 1144 de[0].adate = de[0].cdate = de[1].adate = de[1].cdate = 0;
1143 } 1145 }
1144 de[0].start = cpu_to_le16(cluster); 1146 fat_set_start(&de[0], cluster);
1145 de[0].starthi = cpu_to_le16(cluster >> 16); 1147 fat_set_start(&de[1], MSDOS_I(dir)->i_logstart);
1146 de[1].start = cpu_to_le16(MSDOS_I(dir)->i_logstart);
1147 de[1].starthi = cpu_to_le16(MSDOS_I(dir)->i_logstart >> 16);
1148 de[0].size = de[1].size = 0; 1148 de[0].size = de[1].size = 0;
1149 memset(de + 2, 0, sb->s_blocksize - 2 * sizeof(*de)); 1149 memset(de + 2, 0, sb->s_blocksize - 2 * sizeof(*de));
1150 set_buffer_uptodate(bhs[0]); 1150 set_buffer_uptodate(bhs[0]);
@@ -1161,7 +1161,6 @@ error_free:
1161error: 1161error:
1162 return err; 1162 return err;
1163} 1163}
1164
1165EXPORT_SYMBOL_GPL(fat_alloc_new_dir); 1164EXPORT_SYMBOL_GPL(fat_alloc_new_dir);
1166 1165
1167static int fat_add_new_entries(struct inode *dir, void *slots, int nr_slots, 1166static int fat_add_new_entries(struct inode *dir, void *slots, int nr_slots,
@@ -1377,5 +1376,4 @@ error_remove:
1377 __fat_remove_entries(dir, pos, free_slots); 1376 __fat_remove_entries(dir, pos, free_slots);
1378 return err; 1377 return err;
1379} 1378}
1380
1381EXPORT_SYMBOL_GPL(fat_add_entries); 1379EXPORT_SYMBOL_GPL(fat_add_entries);