From ca835e568327ab634f7512219cb33031c0ad7de1 Mon Sep 17 00:00:00 2001 From: Christian Mauderer Date: Tue, 28 Nov 2017 16:42:00 +0100 Subject: 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. Update #3257. --- testsuites/fstests/fsdosfsname01/init.c | 45 ++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'testsuites/fstests') diff --git a/testsuites/fstests/fsdosfsname01/init.c b/testsuites/fstests/fsdosfsname01/init.c index b796dee40f..eb66323073 100644 --- a/testsuites/fstests/fsdosfsname01/init.c +++ b/testsuites/fstests/fsdosfsname01/init.c @@ -46,6 +46,7 @@ const char rtems_test_name[] = "FSDOSFSNAME 1"; #define RAMDISK_PATH "/dev/rda" #define BLOCK_NUM 47 #define BLOCK_SIZE 512 +#define VOLUME_LABEL "MyDisk" #define NUMBER_OF_DIRECTORIES 8 #define NUMBER_OF_FILES 13 @@ -78,7 +79,7 @@ static rtems_resource_snapshot before_mount; static const msdos_format_request_param_t rqdata = { .OEMName = "RTEMS", - .VolLabel = "RTEMSDisk", + .VolLabel = VOLUME_LABEL, .sectors_per_cluster = 2, .fat_num = 0, .files_per_root_dir = 0, @@ -1107,10 +1108,52 @@ static void test_full_8_3_name( void ) 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 ) { test_end_of_string_matches(); test_full_8_3_name(); + test_file_with_same_name_as_volume_label(); + test_dir_with_same_name_as_volume_label(); } /* -- cgit v1.2.3