-#ifndef CONFIG_FAT_DEFAULT_IOCHARSET
-/* if user don't select VFAT, this is undefined. */
-#define CONFIG_FAT_DEFAULT_IOCHARSET ""
-#endif
-
-static int fat_default_codepage = CONFIG_FAT_DEFAULT_CODEPAGE;
-static char fat_default_iocharset[] = CONFIG_FAT_DEFAULT_IOCHARSET;
-
/*
* New FAT inode stuff. We do the following:
* a) i_ino is constant and has nothing with on-disk location.
/*
* New FAT inode stuff. We do the following:
* a) i_ino is constant and has nothing with on-disk location.
- if (sbi->options.iocharset != fat_default_iocharset) {
+ /*
+ * Note: the iocharset option might have been specified
+ * without enabling nls_io, so check for it here.
+ */
+ if (sbi->options.iocharset) {
seq_printf(m, ",gid=%u", opts->fs_gid);
seq_printf(m, ",fmask=%04o", opts->fs_fmask);
seq_printf(m, ",dmask=%04o", opts->fs_dmask);
seq_printf(m, ",gid=%u", opts->fs_gid);
seq_printf(m, ",fmask=%04o", opts->fs_fmask);
seq_printf(m, ",dmask=%04o", opts->fs_dmask);
seq_printf(m, ",codepage=%s", sbi->nls_disk->charset);
if (isvfat) {
seq_printf(m, ",codepage=%s", sbi->nls_disk->charset);
if (isvfat) {
seq_printf(m, ",iocharset=%s", sbi->nls_io->charset);
switch (opts->shortname) {
seq_printf(m, ",iocharset=%s", sbi->nls_io->charset);
switch (opts->shortname) {
opts->isvfat = is_vfat;
opts->fs_uid = current->uid;
opts->fs_gid = current->gid;
opts->fs_fmask = opts->fs_dmask = current->fs->umask;
opts->isvfat = is_vfat;
opts->fs_uid = current->uid;
opts->fs_gid = current->gid;
opts->fs_fmask = opts->fs_dmask = current->fs->umask;
- if (opts->iocharset != fat_default_iocharset)
- kfree(opts->iocharset);
- iocharset = match_strdup(&args[0]);
- if (!iocharset)
- return -ENOMEM;
- opts->iocharset = iocharset;
+ kfree(opts->iocharset);
+ opts->iocharset = match_strdup(&args[0]);
+ if (!opts->iocharset)
+ return 0;
default:
printk(KERN_ERR "FAT: Unrecognized mount option \"%s\" "
"or missing value\n", p);
default:
printk(KERN_ERR "FAT: Unrecognized mount option \"%s\" "
"or missing value\n", p);
- /* UTF8 doesn't provide FAT semantics */
- if (!strcmp(opts->iocharset, "utf8")) {
- printk(KERN_ERR "FAT: utf8 is not a recommended IO charset"
- " for FAT filesystems, filesystem will be case sensitive!\n");
- }
struct msdos_sb_info *sbi;
u16 logical_sector_size;
u32 total_sectors, total_clusters, fat_clusters, rootdir_sectors;
struct msdos_sb_info *sbi;
u16 logical_sector_size;
u32 total_sectors, total_clusters, fat_clusters, rootdir_sectors;
- error = parse_options(data, isvfat, &debug, &sbi->options);
- if (error)
+ error = -EINVAL;
+ if (!parse_options(data, isvfat, &debug, &sbi->options))
-
- /*
- * Earlier we checked here that b->secs_track and b->head are nonzero,
- * but it turns out valid FAT filesystems can have zero there.
- */
-
+ if (!b->secs_track) {
+ if (!silent)
+ printk(KERN_ERR "FAT: bogus sectors-per-track value\n");
+ brelse(bh);
+ goto out_invalid;
+ }
+ if (!b->heads) {
+ if (!silent)
+ printk(KERN_ERR "FAT: bogus number-of-heads value\n");
+ brelse(bh);
+ goto out_invalid;
+ }
- sprintf(buf, "cp%d", sbi->options.codepage);
+ cp = sbi->options.codepage ? sbi->options.codepage : 437;
+ sprintf(buf, "cp%d", cp);
- printk(KERN_ERR "FAT: codepage %s not found\n", buf);
- goto out_fail;
+ /* Fail only if explicit charset specified */
+ if (sbi->options.codepage != 0) {
+ printk(KERN_ERR "FAT: codepage %s not found\n", buf);
+ goto out_fail;
+ }
+ sbi->options.codepage = 0; /* already 0?? */
+ sbi->nls_disk = load_nls_default();
- sbi->nls_io = load_nls(sbi->options.iocharset);
- if (!sbi->nls_io) {
- printk(KERN_ERR "FAT: IO charset %s not found\n",
- sbi->options.iocharset);
- goto out_fail;
- }
+ if (sbi->options.iocharset != NULL) {
+ sbi->nls_io = load_nls(sbi->options.iocharset);
+ if (!sbi->nls_io) {
+ printk(KERN_ERR
+ "FAT: IO charset %s not found\n",
+ sbi->options.iocharset);
+ goto out_fail;
+ }
+ } else
+ sbi->nls_io = load_nls_default();