diff options
author | Christian Mauderer <Christian.Mauderer@embedded-brains.de> | 2017-11-28 16:42:00 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-12-05 08:00:34 +0100 |
commit | ca835e568327ab634f7512219cb33031c0ad7de1 (patch) | |
tree | acbbe55f3c9228a75368ecf3abb84b04c9810987 /testsuites/fstests | |
parent | ada: Check C and POSIX types (diff) | |
download | rtems-ca835e568327ab634f7512219cb33031c0ad7de1.tar.bz2 |
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.
Diffstat (limited to 'testsuites/fstests')
-rw-r--r-- | testsuites/fstests/fsdosfsname01/init.c | 45 |
1 files changed, 44 insertions, 1 deletions
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(); } /* |