FAT: remove cur_part_nr
PATCH v4 1/3 FAT: remove cur_part_nr
From: Stephen Warren <[email protected]>
A future patch will implement the more standard filesystem API fat_set_blk_dev(). This API has no way to know which partition number the partition represents. Equally, future DM rework will make the concept of partition number harder to pass around.
So, simply remove cur_part_nr from fat.c; its only use is in a diagnostic printf, and the context where it's printed should make it obvious which partition is referred to anyway (since the partition ID would come from the user command-line that caused it).
---
v4: New patch: Dropped addition of part number of disk_partition_t, and replaced it with this patch.
--- fs/fat/fat.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
fs/fat/fat.c +2 -7
@@ -46,7 +46,6 @@ static void downcase(char *str) }static block_dev_desc_t *cur_dev; -static unsigned int cur_part_nr;static disk_partition_t cur_part_info;#define DOS_BOOT_MAGIC_OFFSET 0x1fe
@@ -77,10 +76,8 @@ int fat_register_device(block_dev_desc_t * dev_desc, int part_no) defined(CONFIG_SYSTEMACE) )/* Read the partition table, if present */ -if (!get_partition_info (dev_desc, part_no, &cur_part_info)) { +if (!get_partition_info (dev_desc, part_no, &cur_part_info)) cur_dev = dev_desc; - cur_part_nr = part_no; - }#endif /* Otherwise it might be a superfloppy (whole-disk FAT filesystem) */
@@ -92,7 +89,6 @@ int fat_register_device(block_dev_desc_t * dev_desc, int part_no) } cur_dev = dev_desc; - cur_part_nr =1 ; cur_part_info.start =0 ; cur_part_info.size = dev_desc->lba; cur_part_info.blksz = dev_desc->blksz;
@@ -1235,8 +1231,7 @@ int file_fat_detectfs(void) vol_label[11 ] ='\0' ; volinfo.fs_type[5 ] ='\0' ; -printf ("Partition %d: Filesystem: %s \"%s\"\n" , cur_part_nr, - volinfo.fs_type, vol_label); +printf ("Filesystem: %s \"%s\"\n" , volinfo.fs_type, vol_label);return 0 ; }
Signature · 1 line
1.7.0.4
PATCH v4 2/3 FAT: initialize all fields in cur_part_info, simplify init
From: Stephen Warren <[email protected]>
cur_part_info.{name,type} are strings. So, we don't need to memset() the entire thing, just put the NULL-termination in the first byte.
Add missing initialization of the bootable and uuid fields.
None of these fields are actually used by fat.c. However, since it stores the entire disk_partition_t, we should make sure that all fields are valid.
---
v4: No change (just rebased).
v3: New patch.
--- fs/fat/fat.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
fs/fat/fat.c +6 -2
@@ -92,8 +92,12 @@ int fat_register_device(block_dev_desc_t * dev_desc, int part_no) cur_part_info.start =0 ; cur_part_info.size = dev_desc->lba; cur_part_info.blksz = dev_desc->blksz; -memset (cur_part_info.name,0 ,sizeof (cur_part_info.name)); -memset (cur_part_info.type,0 ,sizeof (cur_part_info.type)); + cur_part_info.name[0 ] =0 ; + cur_part_info.type[0 ] =0 ; + cur_part_info.bootable =0 ; +#ifdef CONFIG_PARTITION_UUIDS + cur_part_info.uuid[0 ] =0 ; +#endif }/* Make sure it has a valid FAT header */
Signature · 1 line
1.7.0.4
PATCH v4 3/3 FAT: implement fat_set_blk_dev(), convert cmd_fat.c
In reply to Stephen WarrenFrom: Stephen Warren <[email protected]>
This makes the FAT filesystem API more consistent with other block-based filesystems. If in the future standard multi-filesystem commands such as "ls" or "load" are implemented, having FAT work the same way as other filesystems will be necessary.
Convert cmd_fat.c to the new API, so the code looks more like other files implementing the same commands for other filesystems.
---
v4: No change (just rebased).
v3: Rebase on new fat.c cleanup patch.
v2: Fix inverted test of get_partition_info() result in fat_register_device().
--- common/cmd_fat.c | 8 +++--- fs/fat/fat.c | 66 +++++++++++++++++++++++++---------------------------- include/fat.h | 1 + 3 files changed, 36 insertions(+), 39 deletions(-)
common/cmd_fat.c +4 -4
@@ -55,7 +55,7 @@ int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return 1 ; dev = dev_desc->dev; -if (fat_register_device (dev_desc,part)!=0 ) { +if (fat_set_blk_dev (dev_desc, &info) !=0 ) {printf ("\n** Unable to use %s %d:%d for fatload **\n" , argv[1 ], dev, part);return 1 ;
@@ -111,7 +111,7 @@ int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return 1 ; dev = dev_desc->dev; -if (fat_register_device (dev_desc,part)!=0 ) { +if (fat_set_blk_dev (dev_desc, &info) !=0 ) {printf ("\n** Unable to use %s %d:%d for fatls **\n" , argv[1 ], dev, part);return 1 ;
@@ -149,7 +149,7 @@ int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return 1 ; dev = dev_desc->dev; -if (fat_register_device (dev_desc,part)!=0 ) { +if (fat_set_blk_dev (dev_desc, &info) !=0 ) {printf ("\n** Unable to use %s %d:%d for fatinfo **\n" , argv[1 ], dev, part);return 1 ;
@@ -185,7 +185,7 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, dev = dev_desc->dev; -if (fat_register_device (dev_desc, part) !=0 ) { +if (fat_set_blk_dev (dev_desc, &info) !=0 ) {printf ("\n** Unable to use %s %d:%d for fatwrite **\n" , argv[1 ], dev, part);return 1 ;
fs/fat/fat.c +31 -35
81 lines not on this page · raw message
include/fat.h +1 -0
@@ -212,6 +212,7 @@ long file_fat_read_at(const char *filename, unsigned long pos, void *buffer, unsigned long maxsize);long file_fat_read (const char *filename,void *buffer,unsigned long maxsize);const char *file_getfsname (int idx); +int fat_set_blk_dev (block_dev_desc_t *rbdd,disk_partition_t *info);int fat_register_device (block_dev_desc_t *dev_desc,int part_no);int file_fat_write (const char *filename,void *buffer,unsigned long maxsize);
Signature · 1 line
1.7.0.4
PATCH v4 3/3 FAT: implement fat_set_blk_dev(), convert cmd_fat.c
Hi Stephen,
Quoted 13 lines · Stephen Warren
From: Stephen Warren <[email protected]>
This makes the FAT filesystem API more consistent with other block-based
filesystems. If in the future standard multi-filesystem commands such as
"ls" or "load" are implemented, having FAT work the same way as other filesystems will be necessary.Convert
cmd_fat.cto the new API, so the code looks more like other files
implementing the same commands for other filesystems.
Quoted 8 lines
Signed-off-by Stephen Warren <[email protected]>Reviewed-by Beno?t Th?baudeau <[email protected]>---
v4: No change (just rebased).
v3: Rebase on newfat.ccleanup patch.
v2: Fix inverted test ofget_partition_info()result infat_register_device().
---
[...]
I'm still fine with the V4 of this series:
Best regards,
Beno?t
PATCH v4 1/3 FAT: remove cur_part_nr
In reply to Stephen WarrenQuoted 12 lines · Stephen Warren
From: Stephen Warren <[email protected]>
A future patch will implement the more standard filesystem API
fat_set_blk_dev(). This API has no way to know which partition number the partition represents. Equally, future DM rework will make the concept of partition number harder to pass around.So, simply remove
cur_part_nrfromfat.c; its only use is in a diagnostic printf, and the context where it's printed should make it obvious which partition is referred to anyway (since the partition ID would come from the user command-line that caused it).
Quoted 4 lines
Signed-off-by Stephen Warren <[email protected]>---
v4: New patch: Dropped addition of part number ofdisk_partition_t, and replaced it with this patch.
For the series, applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121025/a4060009/attachment.pgp>