mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 23:23:13 +00:00
dosfs: Fix files with same name as volume name.
Take care that a file in the root directory with the same name as the volume name can be found. Close #3257.
This commit is contained in:
committed by
Sebastian Huber
parent
c139a70597
commit
004a63efef
@@ -1585,7 +1585,8 @@ msdos_find_file_in_directory (
|
|||||||
printf ("MSFS:[9.2] checksum, entry_matched:%i, lfn_entry:%i, lfn_checksum:%02x/%02x\n",
|
printf ("MSFS:[9.2] checksum, entry_matched:%i, lfn_entry:%i, lfn_checksum:%02x/%02x\n",
|
||||||
entry_matched, lfn_entry, lfn_checksum, msdos_lfn_checksum(entry));
|
entry_matched, lfn_entry, lfn_checksum, msdos_lfn_checksum(entry));
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else if ((*MSDOS_DIR_ATTR(entry) & MSDOS_ATTR_VOLUME_ID)
|
||||||
|
== 0) {
|
||||||
bytes_in_entry = MSDOS_SHORT_NAME_LEN + 1;
|
bytes_in_entry = MSDOS_SHORT_NAME_LEN + 1;
|
||||||
bytes_in_entry = msdos_short_entry_to_utf8_name (
|
bytes_in_entry = msdos_short_entry_to_utf8_name (
|
||||||
converter,
|
converter,
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const char rtems_test_name[] = "FSDOSFSNAME 1";
|
|||||||
#define RAMDISK_PATH "/dev/rda"
|
#define RAMDISK_PATH "/dev/rda"
|
||||||
#define BLOCK_NUM 47
|
#define BLOCK_NUM 47
|
||||||
#define BLOCK_SIZE 512
|
#define BLOCK_SIZE 512
|
||||||
|
#define VOLUME_LABEL "MyDisk"
|
||||||
|
|
||||||
#define NUMBER_OF_DIRECTORIES 8
|
#define NUMBER_OF_DIRECTORIES 8
|
||||||
#define NUMBER_OF_FILES 13
|
#define NUMBER_OF_FILES 13
|
||||||
@@ -78,7 +79,7 @@ static rtems_resource_snapshot before_mount;
|
|||||||
|
|
||||||
static const msdos_format_request_param_t rqdata = {
|
static const msdos_format_request_param_t rqdata = {
|
||||||
.OEMName = "RTEMS",
|
.OEMName = "RTEMS",
|
||||||
.VolLabel = "RTEMSDisk",
|
.VolLabel = VOLUME_LABEL,
|
||||||
.sectors_per_cluster = 2,
|
.sectors_per_cluster = 2,
|
||||||
.fat_num = 0,
|
.fat_num = 0,
|
||||||
.files_per_root_dir = 0,
|
.files_per_root_dir = 0,
|
||||||
@@ -1107,10 +1108,52 @@ static void test_full_8_3_name( void )
|
|||||||
rtems_test_assert( rc == 0 );
|
rtems_test_assert( rc == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_dir_with_same_name_as_volume_label( void )
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
DIR *dirp;
|
||||||
|
|
||||||
|
rc = mkdir( MOUNT_DIR "/" VOLUME_LABEL, S_IRWXU | S_IRWXG | S_IRWXO );
|
||||||
|
rtems_test_assert( rc == 0 );
|
||||||
|
|
||||||
|
dirp = opendir( MOUNT_DIR "/" VOLUME_LABEL );
|
||||||
|
rtems_test_assert( NULL != dirp );
|
||||||
|
|
||||||
|
rc = closedir( dirp );
|
||||||
|
rtems_test_assert( rc == 0 );
|
||||||
|
|
||||||
|
rc = unlink( MOUNT_DIR "/" VOLUME_LABEL );
|
||||||
|
rtems_test_assert( rc == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_file_with_same_name_as_volume_label( void )
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = open( MOUNT_DIR "/" VOLUME_LABEL, O_RDWR | O_CREAT,
|
||||||
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
|
||||||
|
rtems_test_assert( fd >= 0 );
|
||||||
|
|
||||||
|
rc = close( fd );
|
||||||
|
rtems_test_assert( rc == 0 );
|
||||||
|
|
||||||
|
fd = open( MOUNT_DIR "/" VOLUME_LABEL, O_RDWR );
|
||||||
|
rtems_test_assert( fd >= 0 );
|
||||||
|
|
||||||
|
rc = close( fd );
|
||||||
|
rtems_test_assert( rc == 0 );
|
||||||
|
|
||||||
|
rc = unlink( MOUNT_DIR "/" VOLUME_LABEL );
|
||||||
|
rtems_test_assert( rc == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
static void test_special_cases( void )
|
static void test_special_cases( void )
|
||||||
{
|
{
|
||||||
test_end_of_string_matches();
|
test_end_of_string_matches();
|
||||||
test_full_8_3_name();
|
test_full_8_3_name();
|
||||||
|
test_file_with_same_name_as_volume_label();
|
||||||
|
test_dir_with_same_name_as_volume_label();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user