Hi community,
for the partition manager I need some clarification. I've two primary partitions onto one SD card. To access both partitions, I've to setup two partition manager. Here's the code snipped that works:
// Install partition manager over SD card driver, acquire full disk space
result = _io_part_mgr_install ( hdCard, "pm:", 0 );
// error handling omitted here...
// Open partition manager
hdCardPart1 = fopen ( "pm:", NULL );
// error handling omitted here...
// Validate partition 1
param = 1;
result = _io_ioctl ( hdCardPart1, IO_IOCTL_VAL_PART, ¶m );
if ( result == MQX_OK )
{
// Install MFS over partition 1
result = _io_mfs_install ( hdCardPart1, "c:", param );
// error handling omitted here...
}
// Open file system
hd_1 = fopen ( "c:", NULL );
result = ferror ( hd_1 );
// error handling omitted here...
// Open partition manager
hdCardPart2 = fopen ( "pm:", NULL );
// error handling omitted here...
// Validate partition 2
param = 2;
result = _io_ioctl ( hdCardPart2, IO_IOCTL_VAL_PART, ¶m );
if ( result == MQX_OK )
{
// Install MFS over partition 2
result = _io_mfs_install ( hdCardPart2, "d:", param );
// error handling omitted here...
}
hd_2 = fopen ( "d:", NULL );
result = ferror ( hd_2 );
// error handling omitted here...
My question is, why two partition managers (hdCardPart1 and hdCardPart2) are needed?
That is to say, the following code snipped doesn't work:
// some code omitted here...
result = _io_mfs_install ( hdCardPart1, "c:", param );
// some code omitted here...
result = _io_mfs_install ( hdCardPart1, "d:", param ); // re-use the first partition manager for second partition -> not working
I use MQX 4.0.2.2 on MK60DN512.
TY
解決済! 解決策の投稿を見る。
It is that way, because this is correct way.
You can have file system
In second case, file system has to be installed on partition and file system doesn’t care what is below partition. Parameter partition_num will be removed in next MFS version (released probably in MQX 4.2 package).
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
It is that way, because this is correct way.
You can have file system
In second case, file system has to be installed on partition and file system doesn’t care what is below partition. Parameter partition_num will be removed in next MFS version (released probably in MQX 4.2 package).
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Fine. Would it be better to distinguish the string identifier? In other words, should
hdCardPart1 = fopen ( "pm1:", NULL );
hdCardPart2 = fopen ( "pm2:", NULL );
be used instead of
hdCardPart1 = fopen ( "pm:", NULL );
hdCardPart2 = fopen ( "pm:", NULL );
or doesn't matter?
In fact, you have two correct options how to select appropriate partition:
a)
// Install partition manager over SD card driver, acquire full disk space
result = _io_part_mgr_install ( hdCard, "pm:", 0 );
hdCardPart1 = fopen ( "pm:1", NULL );
hdCardPart2 = fopen ( "pm:2", NULL );
//pm:0 is whole device; pm:1, pm:2, pm:3, pm:4 are partitions
b)
// Install partition manager over SD card driver, acquire full disk space
result = _io_part_mgr_install ( hdCard, "pm:", 0 );
hdCardPart1 = fopen ( "pm:", NULL );
partition_number = 1;
error_code = ioctl(hdCardPart1, IO_IOCTL_SEL_PART, &partition_number);
hdCardPart2 = fopen ( "pm:", NULL );
partition_number = 2;
error_code = ioctl(hdCardPart2, IO_IOCTL_SEL_PART, &partition_number);
// partition_number=0 is whole device, 1, 2, 3, 4 are partitions
I hope it helps you.