~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to fs/fat/inode.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
236
236
        .readpages      = fat_readpages,
237
237
        .writepage      = fat_writepage,
238
238
        .writepages     = fat_writepages,
239
 
        .sync_page      = block_sync_page,
240
239
        .write_begin    = fat_write_begin,
241
240
        .write_end      = fat_write_end,
242
241
        .direct_IO      = fat_direct_IO,
582
581
        buf->f_bavail = sbi->free_clusters;
583
582
        buf->f_fsid.val[0] = (u32)id;
584
583
        buf->f_fsid.val[1] = (u32)(id >> 32);
585
 
        buf->f_namelen = sbi->options.isvfat ? FAT_LFN_LEN : 12;
 
584
        buf->f_namelen =
 
585
                (sbi->options.isvfat ? FAT_LFN_LEN : 12) * NLS_MAX_CHARSET_SIZE;
586
586
 
587
587
        return 0;
588
588
}
620
620
 
621
621
        bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits);
622
622
        if (!bh) {
623
 
                printk(KERN_ERR "FAT: unable to read inode block "
624
 
                       "for updating (i_pos %lld)\n", i_pos);
 
623
                fat_msg(sb, KERN_ERR, "unable to read inode block "
 
624
                       "for updating (i_pos %lld)", i_pos);
625
625
                return -EIO;
626
626
        }
627
627
        spin_lock(&sbi->inode_hash_lock);
757
757
        struct inode *inode =  de->d_inode;
758
758
        u32 ipos_h, ipos_m, ipos_l;
759
759
 
760
 
        if (len < 5)
 
760
        if (len < 5) {
 
761
                *lenp = 5;
761
762
                return 255; /* no room */
 
763
        }
762
764
 
763
765
        ipos_h = MSDOS_I(inode)->i_pos >> 8;
764
766
        ipos_m = (MSDOS_I(inode)->i_pos & 0xf0) << 24;
975
977
        {Opt_err, NULL}
976
978
};
977
979
 
978
 
static int parse_options(char *options, int is_vfat, int silent, int *debug,
979
 
                         struct fat_mount_options *opts)
 
980
static int parse_options(struct super_block *sb, char *options, int is_vfat,
 
981
                         int silent, int *debug, struct fat_mount_options *opts)
980
982
{
981
983
        char *p;
982
984
        substring_t args[MAX_OPT_ARGS];
1167
1169
 
1168
1170
                /* obsolete mount options */
1169
1171
                case Opt_obsolate:
1170
 
                        printk(KERN_INFO "FAT: \"%s\" option is obsolete, "
1171
 
                               "not supported now\n", p);
 
1172
                        fat_msg(sb, KERN_INFO, "\"%s\" option is obsolete, "
 
1173
                               "not supported now", p);
1172
1174
                        break;
1173
1175
                /* unknown option */
1174
1176
                default:
1175
1177
                        if (!silent) {
1176
 
                                printk(KERN_ERR
1177
 
                                       "FAT: Unrecognized mount option \"%s\" "
1178
 
                                       "or missing value\n", p);
 
1178
                                fat_msg(sb, KERN_ERR,
 
1179
                                       "Unrecognized mount option \"%s\" "
 
1180
                                       "or missing value", p);
1179
1181
                        }
1180
1182
                        return -EINVAL;
1181
1183
                }
1184
1186
out:
1185
1187
        /* UTF-8 doesn't provide FAT semantics */
1186
1188
        if (!strcmp(opts->iocharset, "utf8")) {
1187
 
                printk(KERN_ERR "FAT: utf8 is not a recommended IO charset"
 
1189
                fat_msg(sb, KERN_ERR, "utf8 is not a recommended IO charset"
1188
1190
                       " for FAT filesystems, filesystem will be "
1189
1191
                       "case sensitive!\n");
1190
1192
        }
1237
1239
/*
1238
1240
 * Read the super block of an MS-DOS FS.
1239
1241
 */
1240
 
int fat_fill_super(struct super_block *sb, void *data, int silent,
1241
 
                   const struct inode_operations *fs_dir_inode_ops, int isvfat,
 
1242
int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
1242
1243
                   void (*setup)(struct super_block *))
1243
1244
{
1244
1245
        struct inode *root_inode = NULL, *fat_inode = NULL;
1267
1268
        sb->s_magic = MSDOS_SUPER_MAGIC;
1268
1269
        sb->s_op = &fat_sops;
1269
1270
        sb->s_export_op = &fat_export_ops;
1270
 
        sbi->dir_ops = fs_dir_inode_ops;
1271
1271
        ratelimit_state_init(&sbi->ratelimit, DEFAULT_RATELIMIT_INTERVAL,
1272
1272
                             DEFAULT_RATELIMIT_BURST);
1273
1273
 
1274
 
        error = parse_options(data, isvfat, silent, &debug, &sbi->options);
 
1274
        error = parse_options(sb, data, isvfat, silent, &debug, &sbi->options);
1275
1275
        if (error)
1276
1276
                goto out_fail;
1277
1277
 
1281
1281
        sb_min_blocksize(sb, 512);
1282
1282
        bh = sb_bread(sb, 0);
1283
1283
        if (bh == NULL) {
1284
 
                printk(KERN_ERR "FAT: unable to read boot sector\n");
 
1284
                fat_msg(sb, KERN_ERR, "unable to read boot sector");
1285
1285
                goto out_fail;
1286
1286
        }
1287
1287
 
1288
1288
        b = (struct fat_boot_sector *) bh->b_data;
1289
1289
        if (!b->reserved) {
1290
1290
                if (!silent)
1291
 
                        printk(KERN_ERR "FAT: bogus number of reserved sectors\n");
 
1291
                        fat_msg(sb, KERN_ERR, "bogus number of reserved sectors");
1292
1292
                brelse(bh);
1293
1293
                goto out_invalid;
1294
1294
        }
1295
1295
        if (!b->fats) {
1296
1296
                if (!silent)
1297
 
                        printk(KERN_ERR "FAT: bogus number of FAT structure\n");
 
1297
                        fat_msg(sb, KERN_ERR, "bogus number of FAT structure");
1298
1298
                brelse(bh);
1299
1299
                goto out_invalid;
1300
1300
        }
1307
1307
        media = b->media;
1308
1308
        if (!fat_valid_media(media)) {
1309
1309
                if (!silent)
1310
 
                        printk(KERN_ERR "FAT: invalid media value (0x%02x)\n",
 
1310
                        fat_msg(sb, KERN_ERR, "invalid media value (0x%02x)",
1311
1311
                               media);
1312
1312
                brelse(bh);
1313
1313
                goto out_invalid;
1317
1317
            || (logical_sector_size < 512)
1318
1318
            || (logical_sector_size > 4096)) {
1319
1319
                if (!silent)
1320
 
                        printk(KERN_ERR "FAT: bogus logical sector size %u\n",
 
1320
                        fat_msg(sb, KERN_ERR, "bogus logical sector size %u",
1321
1321
                               logical_sector_size);
1322
1322
                brelse(bh);
1323
1323
                goto out_invalid;
1325
1325
        sbi->sec_per_clus = b->sec_per_clus;
1326
1326
        if (!is_power_of_2(sbi->sec_per_clus)) {
1327
1327
                if (!silent)
1328
 
                        printk(KERN_ERR "FAT: bogus sectors per cluster %u\n",
 
1328
                        fat_msg(sb, KERN_ERR, "bogus sectors per cluster %u",
1329
1329
                               sbi->sec_per_clus);
1330
1330
                brelse(bh);
1331
1331
                goto out_invalid;
1332
1332
        }
1333
1333
 
1334
1334
        if (logical_sector_size < sb->s_blocksize) {
1335
 
                printk(KERN_ERR "FAT: logical sector size too small for device"
1336
 
                       " (logical sector size = %u)\n", logical_sector_size);
 
1335
                fat_msg(sb, KERN_ERR, "logical sector size too small for device"
 
1336
                       " (logical sector size = %u)", logical_sector_size);
1337
1337
                brelse(bh);
1338
1338
                goto out_fail;
1339
1339
        }
1341
1341
                brelse(bh);
1342
1342
 
1343
1343
                if (!sb_set_blocksize(sb, logical_sector_size)) {
1344
 
                        printk(KERN_ERR "FAT: unable to set blocksize %u\n",
 
1344
                        fat_msg(sb, KERN_ERR, "unable to set blocksize %u",
1345
1345
                               logical_sector_size);
1346
1346
                        goto out_fail;
1347
1347
                }
1348
1348
                bh = sb_bread(sb, 0);
1349
1349
                if (bh == NULL) {
1350
 
                        printk(KERN_ERR "FAT: unable to read boot sector"
1351
 
                               " (logical sector size = %lu)\n",
 
1350
                        fat_msg(sb, KERN_ERR, "unable to read boot sector"
 
1351
                               " (logical sector size = %lu)",
1352
1352
                               sb->s_blocksize);
1353
1353
                        goto out_fail;
1354
1354
                }
1384
1384
 
1385
1385
                fsinfo_bh = sb_bread(sb, sbi->fsinfo_sector);
1386
1386
                if (fsinfo_bh == NULL) {
1387
 
                        printk(KERN_ERR "FAT: bread failed, FSINFO block"
1388
 
                               " (sector = %lu)\n", sbi->fsinfo_sector);
 
1387
                        fat_msg(sb, KERN_ERR, "bread failed, FSINFO block"
 
1388
                               " (sector = %lu)", sbi->fsinfo_sector);
1389
1389
                        brelse(bh);
1390
1390
                        goto out_fail;
1391
1391
                }
1392
1392
 
1393
1393
                fsinfo = (struct fat_boot_fsinfo *)fsinfo_bh->b_data;
1394
1394
                if (!IS_FSINFO(fsinfo)) {
1395
 
                        printk(KERN_WARNING "FAT: Invalid FSINFO signature: "
1396
 
                               "0x%08x, 0x%08x (sector = %lu)\n",
 
1395
                        fat_msg(sb, KERN_WARNING, "Invalid FSINFO signature: "
 
1396
                               "0x%08x, 0x%08x (sector = %lu)",
1397
1397
                               le32_to_cpu(fsinfo->signature1),
1398
1398
                               le32_to_cpu(fsinfo->signature2),
1399
1399
                               sbi->fsinfo_sector);
1414
1414
        sbi->dir_entries = get_unaligned_le16(&b->dir_entries);
1415
1415
        if (sbi->dir_entries & (sbi->dir_per_block - 1)) {
1416
1416
                if (!silent)
1417
 
                        printk(KERN_ERR "FAT: bogus directroy-entries per block"
1418
 
                               " (%u)\n", sbi->dir_entries);
 
1417
                        fat_msg(sb, KERN_ERR, "bogus directroy-entries per block"
 
1418
                               " (%u)", sbi->dir_entries);
1419
1419
                brelse(bh);
1420
1420
                goto out_invalid;
1421
1421
        }
1437
1437
        total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT);
1438
1438
        if (total_clusters > MAX_FAT(sb)) {
1439
1439
                if (!silent)
1440
 
                        printk(KERN_ERR "FAT: count of clusters too big (%u)\n",
 
1440
                        fat_msg(sb, KERN_ERR, "count of clusters too big (%u)",
1441
1441
                               total_clusters);
1442
1442
                brelse(bh);
1443
1443
                goto out_invalid;
1470
1470
        sprintf(buf, "cp%d", sbi->options.codepage);
1471
1471
        sbi->nls_disk = load_nls(buf);
1472
1472
        if (!sbi->nls_disk) {
1473
 
                printk(KERN_ERR "FAT: codepage %s not found\n", buf);
 
1473
                fat_msg(sb, KERN_ERR, "codepage %s not found", buf);
1474
1474
                goto out_fail;
1475
1475
        }
1476
1476
 
1478
1478
        if (sbi->options.isvfat) {
1479
1479
                sbi->nls_io = load_nls(sbi->options.iocharset);
1480
1480
                if (!sbi->nls_io) {
1481
 
                        printk(KERN_ERR "FAT: IO charset %s not found\n",
 
1481
                        fat_msg(sb, KERN_ERR, "IO charset %s not found",
1482
1482
                               sbi->options.iocharset);
1483
1483
                        goto out_fail;
1484
1484
                }
1502
1502
        insert_inode_hash(root_inode);
1503
1503
        sb->s_root = d_alloc_root(root_inode);
1504
1504
        if (!sb->s_root) {
1505
 
                printk(KERN_ERR "FAT: get root inode failed\n");
 
1505
                fat_msg(sb, KERN_ERR, "get root inode failed");
1506
1506
                goto out_fail;
1507
1507
        }
1508
1508
 
1511
1511
out_invalid:
1512
1512
        error = -EINVAL;
1513
1513
        if (!silent)
1514
 
                printk(KERN_INFO "VFS: Can't find a valid FAT filesystem"
1515
 
                       " on dev %s.\n", sb->s_id);
 
1514
                fat_msg(sb, KERN_INFO, "Can't find a valid FAT filesystem");
1516
1515
 
1517
1516
out_fail:
1518
1517
        if (fat_inode)