From 33e823ef654f4f79fb88599b7b8e09429f28afff Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Mon, 19 Oct 2009 22:09:01 +0200 Subject: [PATCH] Move fat_set_part_name() to src/common.c and rename it to set_part_name_chomp() --- src/common.c | 10 +++++++++- src/common.h | 1 + src/fat.c | 19 ++++--------------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/common.c b/src/common.c index 011560a9..f9603916 100644 --- a/src/common.c +++ b/src/common.c @@ -162,4 +162,12 @@ void set_part_name(partition_t *partition,const char *src,const int max_size) partition->fsname[i--]='\0'; } - +void set_part_name_chomp(partition_t *partition, const unsigned char *src, const int max_size) +{ + int i; + for(i=0;(ifsname[i]=src[i]; + partition->fsname[i--]='\0'; + for(;(i>=0) && (src[i]==' ');i--); + partition->fsname[i+1]='\0'; +} diff --git a/src/common.h b/src/common.h index 33ca1e28..8a76dcc7 100644 --- a/src/common.h +++ b/src/common.h @@ -374,6 +374,7 @@ struct my_data_struct void *MALLOC(size_t size); unsigned int up2power(const unsigned int number); void set_part_name(partition_t *partition,const char *src,const int max_size); +void set_part_name_chomp(partition_t *partition, const unsigned char *src, const int max_size); #ifndef BSD_MAXPARTITIONS #define BSD_MAXPARTITIONS 8 #endif diff --git a/src/fat.c b/src/fat.c index b6c09ff8..64b3b3db 100644 --- a/src/fat.c +++ b/src/fat.c @@ -47,7 +47,6 @@ extern const arch_fnct_t arch_i386; extern const arch_fnct_t arch_mac; static int set_FAT_info(disk_t *disk_car, const struct fat_boot_sector *fat_header, partition_t *partition); -static void fat_set_part_name(partition_t *partition,const unsigned char *src,const int max_size); static int fat32_set_part_name(disk_t *disk_car, partition_t *partition, const struct fat_boot_sector*fat_header); static int log_fat_info(const struct fat_boot_sector*fh1, const upart_type_t upart_type, const unsigned int sector_size); static int test_OS2MB(disk_t *disk_car,const struct fat_boot_sector *fat_header, partition_t *partition,const int verbose, const int dump_ind); @@ -75,16 +74,6 @@ static int is_fat32(const partition_t *partition); #define FAT16_BAD 0xFFF7 #define FAT16_EOC 0xFFF8 -static void fat_set_part_name(partition_t *partition,const unsigned char *src,const int max_size) -{ - int i; - for(i=0;(ifsname[i]=src[i]; - partition->fsname[i--]='\0'; - for(;(i>=0) && (src[i]==' ');i--); - partition->fsname[i+1]='\0'; -} - static int log_fat_info(const struct fat_boot_sector*fh1, const upart_type_t upart_type, const unsigned int sector_size) { log_info("sector_size %u\n", fat_sector_size(fh1)); @@ -215,7 +204,7 @@ static int set_FAT_info(disk_t *disk_car, const struct fat_boot_sector *fat_head snprintf(partition->info,sizeof(partition->info),"FAT12"); if(buffer[38]==0x29) /* BS_BootSig */ { - fat_set_part_name(partition,((const unsigned char*)fat_header)+FAT1X_PART_NAME,11); + set_part_name_chomp(partition,((const unsigned char*)fat_header)+FAT1X_PART_NAME,11); if(check_VFAT_volume_name(partition->fsname, 11)) partition->fsname[0]='\0'; } @@ -224,7 +213,7 @@ static int set_FAT_info(disk_t *disk_car, const struct fat_boot_sector *fat_head snprintf(partition->info,sizeof(partition->info),"FAT16"); if(buffer[38]==0x29) /* BS_BootSig */ { - fat_set_part_name(partition,((const unsigned char*)fat_header)+FAT1X_PART_NAME,11); + set_part_name_chomp(partition,((const unsigned char*)fat_header)+FAT1X_PART_NAME,11); if(check_VFAT_volume_name(partition->fsname, 11)) partition->fsname[0]='\0'; } @@ -843,7 +832,7 @@ static int fat32_set_part_name(disk_t *disk_car, partition_t *partition, const s { /* Test attribut volume name and check if the volume name is erased or not */ if(((buffer[i*0x20+0xB] & ATTR_EXT) !=ATTR_EXT) && ((buffer[i*0x20+0xB] & ATTR_VOLUME) !=0) && (buffer[i*0x20]!=0xE5)) { - fat_set_part_name(partition,&buffer[i*0x20],11); + set_part_name_chomp(partition,&buffer[i*0x20],11); if(check_VFAT_volume_name(partition->fsname, 11)) partition->fsname[0]='\0'; } @@ -858,7 +847,7 @@ static int fat32_set_part_name(disk_t *disk_car, partition_t *partition, const s if(partition->fsname[0]=='\0') { log_info("set_FAT_info: name from BS used\n"); - fat_set_part_name(partition,((const unsigned char*)fat_header)+FAT32_PART_NAME,11); + set_part_name_chomp(partition,((const unsigned char*)fat_header)+FAT32_PART_NAME,11); if(check_VFAT_volume_name(partition->fsname, 11)) partition->fsname[0]='\0'; }