New prototype for test_MD() and test_MD_be()

This commit is contained in:
Christophe Grenier 2016-01-23 10:17:11 +01:00
parent 286e35eee9
commit b46e852db4

116
src/md.c
View file

@ -35,10 +35,10 @@
#include "md.h"
#include "fnctdsk.h"
#include "log.h"
static int test_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t *partition, const int dump_ind);
static int test_MD_be(disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t *partition, const int dump_ind);
static int set_MD_info(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose);
static int set_MD_info_be(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose);
static int test_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, const partition_t *partition, const int dump_ind);
static int test_MD_be(disk_t *disk_car, const struct mdp_superblock_s *sb, const partition_t *partition, const int dump_ind);
static void set_MD_info(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose);
static void set_MD_info_be(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose);
int check_MD(disk_t *disk_car, partition_t *partition, const int verbose)
{
@ -241,11 +241,12 @@ int recover_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t
return 1;
}
static int set_MD_info(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose)
static void set_MD_info(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose)
{
if(le32(sb->major_version)==0)
{
unsigned int i;
partition->upart_type=UP_MD;
sprintf(partition->fsname,"md%u",(unsigned int)le32(sb->md_minor));
sprintf(partition->info,"md %u.%u.%u L.Endian Raid %u: devices",
(unsigned int)le32(sb->major_version),
@ -257,7 +258,7 @@ static int set_MD_info(const struct mdp_superblock_s *sb, partition_t *partition
if(le32(sb->disks[i].major)!=0 && le32(sb->disks[i].minor)!=0)
{
if(strlen(partition->info)<sizeof(partition->info)-26)
{
{
sprintf(&partition->info[strlen(partition->info)]," %u(%u,%u)",
(unsigned int)le32(sb->disks[i].number),
(unsigned int)le32(sb->disks[i].major),
@ -272,6 +273,7 @@ static int set_MD_info(const struct mdp_superblock_s *sb, partition_t *partition
else
{
const struct mdp_superblock_1 *sb1=(const struct mdp_superblock_1 *)sb;
partition->upart_type=UP_MD1;
set_part_name(partition,sb1->set_name,32);
sprintf(partition->info,"md %u.x L.Endian Raid %u - Array Slot : %lu",
(unsigned int)le32(sb1->major_version),
@ -301,14 +303,14 @@ static int set_MD_info(const struct mdp_superblock_s *sb, partition_t *partition
}
if(verbose>0)
log_info("%s %s\n", partition->fsname, partition->info);
return 0;
}
static int set_MD_info_be(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose)
static void set_MD_info_be(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose)
{
if(be32(sb->major_version)==0)
{
unsigned int i;
partition->upart_type=UP_MD;
sprintf(partition->fsname,"md%u",(unsigned int)be32(sb->md_minor));
sprintf(partition->info,"md %u.%u.%u B.Endian Raid %u: devices",
(unsigned int)be32(sb->major_version),
@ -320,7 +322,7 @@ static int set_MD_info_be(const struct mdp_superblock_s *sb, partition_t *partit
if(be32(sb->disks[i].major)!=0 && be32(sb->disks[i].minor)!=0)
{
if(strlen(partition->info)<sizeof(partition->info)-26)
{
{
sprintf(&partition->info[strlen(partition->info)]," %u(%u,%u)",
(unsigned int)be32(sb->disks[i].number),
(unsigned int)be32(sb->disks[i].major),
@ -335,6 +337,7 @@ static int set_MD_info_be(const struct mdp_superblock_s *sb, partition_t *partit
else
{
const struct mdp_superblock_1 *sb1=(const struct mdp_superblock_1 *)sb;
partition->upart_type=UP_MD1;
set_part_name(partition,sb1->set_name,32);
sprintf(partition->info,"md %u.x B.Endian Raid %u - Array Slot : %lu",
(unsigned int)be32(sb1->major_version),
@ -364,67 +367,52 @@ static int set_MD_info_be(const struct mdp_superblock_s *sb, partition_t *partit
}
if(verbose>0)
log_info("%s %s\n", partition->fsname, partition->info);
}
static int test_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, const partition_t *partition, const int dump_ind)
{
if(le32(sb->md_magic)!=(unsigned int)MD_SB_MAGIC)
return 1;
log_info("\nRaid magic value at %u/%u/%u\n",
offset2cylinder(disk_car,partition->part_offset),
offset2head(disk_car,partition->part_offset),
offset2sector(disk_car,partition->part_offset));
log_info("Raid apparent size: %llu sectors\n", (long long unsigned)(sb->size<<1));
if(le32(sb->major_version)==0)
{
/* chunk_size may be 0 */
log_info("Raid chunk size: %llu bytes\n", (long long unsigned)le32(sb->chunk_size));
}
if(le32(sb->major_version)>1)
return 1;
if(dump_ind!=0)
{
/* There is a little offset ... */
dump_log(sb,DEFAULT_SECTOR_SIZE);
}
return 0;
}
static int test_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t *partition, const int dump_ind)
static int test_MD_be(disk_t *disk_car, const struct mdp_superblock_s *sb, const partition_t *partition, const int dump_ind)
{
if(le32(sb->md_magic)==(unsigned int)MD_SB_MAGIC)
if(be32(sb->md_magic)!=(unsigned int)MD_SB_MAGIC)
return 1;
log_info("\nRaid magic value at %u/%u/%u\n",
offset2cylinder(disk_car,partition->part_offset),
offset2head(disk_car,partition->part_offset),
offset2sector(disk_car,partition->part_offset));
log_info("Raid apparent size: %llu sectors\n", (long long unsigned)(sb->size<<1));
if(be32(sb->major_version)==0)
{
log_info("\nRaid magic value at %u/%u/%u\n",
offset2cylinder(disk_car,partition->part_offset),
offset2head(disk_car,partition->part_offset),
offset2sector(disk_car,partition->part_offset));
log_info("Raid apparent size: %llu sectors\n",(long long unsigned)(sb->size<<1));
if(le32(sb->major_version)==0)
{
log_info("Raid chunk size: %llu bytes\n",(long long unsigned)le32(sb->chunk_size));
/* chunk_size may be 0 */
partition->upart_type=UP_MD;
}
else if(le32(sb->major_version)==1)
{
partition->upart_type=UP_MD1;
}
else
return 1;
if(dump_ind!=0)
{
/* There is a little offset ... */
dump_log(sb,DEFAULT_SECTOR_SIZE);
}
return 0;
/* chunk_size may be 0 */
log_info("Raid chunk size: %llu bytes\n",(long long unsigned)be32(sb->chunk_size));
}
return 1;
}
static int test_MD_be(disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t *partition, const int dump_ind)
{
if(be32(sb->md_magic)==(unsigned int)MD_SB_MAGIC)
if(be32(sb->major_version)>1)
return 1;
if(dump_ind!=0)
{
log_info("\nRaid magic value at %u/%u/%u\n",
offset2cylinder(disk_car,partition->part_offset),
offset2head(disk_car,partition->part_offset),
offset2sector(disk_car,partition->part_offset));
log_info("Raid apparent size: %llu sectors\n",(long long unsigned)(sb->size<<1));
if(be32(sb->major_version)==0)
{
log_info("Raid chunk size: %llu bytes\n",(long long unsigned)be32(sb->chunk_size));
/* chunk_size may be 0 */
partition->upart_type=UP_MD;
}
else if(be32(sb->major_version)==1)
{
partition->upart_type=UP_MD1;
}
else
return 1;
if(dump_ind!=0)
{
/* There is a little offset ... */
dump_log(sb,DEFAULT_SECTOR_SIZE);
}
return 0;
/* There is a little offset ... */
dump_log(sb,DEFAULT_SECTOR_SIZE);
}
return 1;
return 0;
}