Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/hirofumi/fatfs-2.6
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/hirofumi/fatfs-2.6:
  fat: Fix statfs->f_namelen
  fat: Replace all printk with fat_msg()
  fat: Add fat_msg() function for preformated FAT messages
  fat: Convert fat_fs_error to use %pV
  fat: Fix possible null deref in fat_cache_add()
  fat: use new setup() for ->dir_ops too
  • Loading branch information
torvalds committed May 24, 2011
2 parents f4e0bcf + f68e542 commit 343800e
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 80 deletions.
7 changes: 7 additions & 0 deletions fs/fat/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ static void fat_cache_add(struct inode *inode, struct fat_cache_id *new)
spin_unlock(&MSDOS_I(inode)->cache_lru_lock);

tmp = fat_cache_alloc(inode);
if (!tmp) {
spin_lock(&MSDOS_I(inode)->cache_lru_lock);
MSDOS_I(inode)->nr_caches--;
spin_unlock(&MSDOS_I(inode)->cache_lru_lock);
return;
}

spin_lock(&MSDOS_I(inode)->cache_lru_lock);
cache = fat_cache_merge(inode, new);
if (cache != NULL) {
Expand Down
32 changes: 17 additions & 15 deletions fs/fat/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static int fat__get_entry(struct inode *dir, loff_t *pos,

*bh = sb_bread(sb, phys);
if (*bh == NULL) {
printk(KERN_ERR "FAT: Directory bread(block %llu) failed\n",
fat_msg(sb, KERN_ERR, "Directory bread(block %llu) failed",
(llu)phys);
/* skip this block */
*pos = (iblock + 1) << sb->s_blocksize_bits;
Expand Down Expand Up @@ -136,9 +136,10 @@ static inline int fat_get_entry(struct inode *dir, loff_t *pos,
* but ignore that right now.
* Ahem... Stack smashing in ring 0 isn't fun. Fixed.
*/
static int uni16_to_x8(unsigned char *ascii, const wchar_t *uni, int len,
int uni_xlate, struct nls_table *nls)
static int uni16_to_x8(struct super_block *sb, unsigned char *ascii,
const wchar_t *uni, int len, struct nls_table *nls)
{
int uni_xlate = MSDOS_SB(sb)->options.unicode_xlate;
const wchar_t *ip;
wchar_t ec;
unsigned char *op;
Expand Down Expand Up @@ -166,23 +167,23 @@ static int uni16_to_x8(unsigned char *ascii, const wchar_t *uni, int len,
}

if (unlikely(*ip)) {
printk(KERN_WARNING "FAT: filename was truncated while "
"converting.");
fat_msg(sb, KERN_WARNING, "filename was truncated while "
"converting.");
}

*op = 0;
return (op - ascii);
}

static inline int fat_uni_to_x8(struct msdos_sb_info *sbi, const wchar_t *uni,
static inline int fat_uni_to_x8(struct super_block *sb, const wchar_t *uni,
unsigned char *buf, int size)
{
struct msdos_sb_info *sbi = MSDOS_SB(sb);
if (sbi->options.utf8)
return utf16s_to_utf8s(uni, FAT_MAX_UNI_CHARS,
UTF16_HOST_ENDIAN, buf, size);
else
return uni16_to_x8(buf, uni, size, sbi->options.unicode_xlate,
sbi->nls_io);
return uni16_to_x8(sb, buf, uni, size, sbi->nls_io);
}

static inline int
Expand Down Expand Up @@ -419,7 +420,7 @@ int fat_search_long(struct inode *inode, const unsigned char *name,

/* Compare shortname */
bufuname[last_u] = 0x0000;
len = fat_uni_to_x8(sbi, bufuname, bufname, sizeof(bufname));
len = fat_uni_to_x8(sb, bufuname, bufname, sizeof(bufname));
if (fat_name_match(sbi, name, name_len, bufname, len))
goto found;

Expand All @@ -428,7 +429,7 @@ int fat_search_long(struct inode *inode, const unsigned char *name,
int size = PATH_MAX - FAT_MAX_UNI_SIZE;

/* Compare longname */
len = fat_uni_to_x8(sbi, unicode, longname, size);
len = fat_uni_to_x8(sb, unicode, longname, size);
if (fat_name_match(sbi, name, name_len, longname, len))
goto found;
}
Expand Down Expand Up @@ -545,7 +546,7 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent,
if (nr_slots) {
void *longname = unicode + FAT_MAX_UNI_CHARS;
int size = PATH_MAX - FAT_MAX_UNI_SIZE;
int len = fat_uni_to_x8(sbi, unicode, longname, size);
int len = fat_uni_to_x8(sb, unicode, longname, size);

fill_name = longname;
fill_len = len;
Expand Down Expand Up @@ -621,7 +622,7 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent,

if (isvfat) {
bufuname[j] = 0x0000;
i = fat_uni_to_x8(sbi, bufuname, bufname, sizeof(bufname));
i = fat_uni_to_x8(sb, bufuname, bufname, sizeof(bufname));
}
if (nr_slots) {
/* hack for fat_ioctl_filldir() */
Expand Down Expand Up @@ -979,6 +980,7 @@ static int __fat_remove_entries(struct inode *dir, loff_t pos, int nr_slots)

int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo)
{
struct super_block *sb = dir->i_sb;
struct msdos_dir_entry *de;
struct buffer_head *bh;
int err = 0, nr_slots;
Expand Down Expand Up @@ -1013,8 +1015,8 @@ int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo)
*/
err = __fat_remove_entries(dir, sinfo->slot_off, nr_slots);
if (err) {
printk(KERN_WARNING
"FAT: Couldn't remove the long name slots\n");
fat_msg(sb, KERN_WARNING,
"Couldn't remove the long name slots");
}
}

Expand Down Expand Up @@ -1265,7 +1267,7 @@ int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
if (sbi->fat_bits != 32)
goto error;
} else if (MSDOS_I(dir)->i_start == 0) {
printk(KERN_ERR "FAT: Corrupted directory (i_pos %lld)\n",
fat_msg(sb, KERN_ERR, "Corrupted directory (i_pos %lld)",
MSDOS_I(dir)->i_pos);
err = -EIO;
goto error;
Expand Down
15 changes: 8 additions & 7 deletions fs/fat/fat.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,19 +319,20 @@ extern struct inode *fat_build_inode(struct super_block *sb,
struct msdos_dir_entry *de, loff_t i_pos);
extern int fat_sync_inode(struct inode *inode);
extern int fat_fill_super(struct super_block *sb, void *data, int silent,
const struct inode_operations *fs_dir_inode_ops,
int isvfat, void (*setup)(struct super_block *));
int isvfat, void (*setup)(struct super_block *));

extern int fat_flush_inodes(struct super_block *sb, struct inode *i1,
struct inode *i2);
/* fat/misc.c */
extern void
__fat_fs_error(struct super_block *s, int report, const char *fmt, ...)
__fat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
__attribute__ ((format (printf, 3, 4))) __cold;
#define fat_fs_error(sb, fmt, args...) \
__fat_fs_error(sb, 1, fmt , ## args)
#define fat_fs_error_ratelimit(sb, fmt, args...) \
__fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args)
void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...)
__attribute__ ((format (printf, 3, 4))) __cold;
#define fat_fs_error(s, fmt, args...) \
__fat_fs_error(s, 1, fmt , ## args)
#define fat_fs_error_ratelimit(s, fmt, args...) \
__fat_fs_error(s, __ratelimit(&MSDOS_SB(s)->ratelimit), fmt , ## args)
extern int fat_clusters_flush(struct super_block *sb);
extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster);
extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,
Expand Down
4 changes: 2 additions & 2 deletions fs/fat/fatent.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int fat12_ent_bread(struct super_block *sb, struct fat_entry *fatent,
err_brelse:
brelse(bhs[0]);
err:
printk(KERN_ERR "FAT: FAT read failed (blocknr %llu)\n", (llu)blocknr);
fat_msg(sb, KERN_ERR, "FAT read failed (blocknr %llu)", (llu)blocknr);
return -EIO;
}

Expand All @@ -108,7 +108,7 @@ static int fat_ent_bread(struct super_block *sb, struct fat_entry *fatent,
fatent->fat_inode = MSDOS_SB(sb)->fat_inode;
fatent->bhs[0] = sb_bread(sb, blocknr);
if (!fatent->bhs[0]) {
printk(KERN_ERR "FAT: FAT read failed (blocknr %llu)\n",
fat_msg(sb, KERN_ERR, "FAT read failed (blocknr %llu)",
(llu)blocknr);
return -EIO;
}
Expand Down
Loading

0 comments on commit 343800e

Please sign in to comment.