fat: get partition size from current partition rather than next partition info
authorDonggeun Kim <dg77.kim@samsung.com>
Mon, 27 Dec 2010 06:32:45 +0000 (15:32 +0900)
committerDonggeun Kim <dg77.kim@samsung.com>
Mon, 27 Dec 2010 06:32:45 +0000 (15:32 +0900)
Signed-off-by: Donggeun Kim <dg77.kim@samsung.com>
fs/fat/fat.c
fs/fat/fat_write.c

index 77d8693..11bc254 100644 (file)
@@ -45,7 +45,7 @@ static void downcase (char *str)
 static block_dev_desc_t *cur_dev = NULL;
 
 static unsigned long part_offset = 0;
-static unsigned long next_part_offset = 0;
+static unsigned long part_size = 0;
 
 static int cur_part = 1;
 
@@ -100,9 +100,7 @@ int fat_register_device (block_dev_desc_t * dev_desc, int part_no)
        if (!get_partition_info(dev_desc, part_no, &info)) {
                part_offset = info.start;
                cur_part = part_no;
-
-               if (!get_partition_info(dev_desc, part_no + 1, &info))
-                       next_part_offset = info.start;
+               part_size = info.size;
        } else if ((strncmp((char *)&buffer[DOS_FS_TYPE_OFFSET], "FAT", 3) == 0) ||
                   (strncmp((char *)&buffer[DOS_FS32_TYPE_OFFSET], "FAT32", 5) == 0)) {
                /* ok, we assume we are on a PBR only */
index e2537b1..55ebeb5 100644 (file)
@@ -1159,7 +1159,7 @@ static int do_fat_write (const char *filename, void *buffer,
 
        total_sector = bs.total_sect;
        if (total_sector == 0) {
-               total_sector = next_part_offset - part_offset;
+               total_sector = part_size;
        }
 
        root_cluster = bs.root_cluster;
@@ -1331,7 +1331,7 @@ void file_fat_table (void)
 
        total_sector = bs.total_sect;
        if (total_sector == 0) {
-               total_sector = next_part_offset - part_offset;
+               total_sector = part_size;
        }
 
        if (mydata->fatsize == 32)
@@ -1474,7 +1474,7 @@ int mkfs_vfat (block_dev_desc_t *dev_desc, int part_no)
 
        if (!get_partition_info(dev_desc, part_no, &info)) {
                volume_size_bytes = info.size * info.blksz;
-               volume_size_sect = volume_size_bytes / bytes_per_sect;
+               volume_size_sect = info.size;
 
                total_sector = volume_size_sect;
        } else {