Index: usr.sbin/makefs/cd9660.c =================================================================== --- usr.sbin/makefs/cd9660.c +++ usr.sbin/makefs/cd9660.c @@ -1638,14 +1638,15 @@ * File version number (5 characters, 1-32767) * 1 <= Sum of File name and File name extension <= 30 */ + int maxlen = is_file ? 30 : 31; int namelen = 0; int extlen = 0; int found_ext = 0; char *orignewname = newname; - while (*oldname != '\0' && namelen + extlen < 30) { + while (*oldname != '\0' && namelen + extlen < maxlen) { /* Handle period first, as it is special */ - if (*oldname == '.') { + if (*oldname == '.' && is_file) { if (found_ext) { if (diskStructure->allow_multidot) { *newname++ = '.'; Index: usr.sbin/makefs/tests/makefs_cd9660_tests.sh =================================================================== --- usr.sbin/makefs/tests/makefs_cd9660_tests.sh +++ usr.sbin/makefs/tests/makefs_cd9660_tests.sh @@ -374,6 +374,34 @@ common_cleanup } +atf_test_case duplicate_names cleanup +duplicate_names_head() +{ + atf_set "descr" "Ensure shortened directory names must be unique (PR283238)" +} +duplicate_names_body() +{ + create_test_dirs + + dir_prefix="this_directory_name_is_31_chars" + + mkdir -p $TEST_INPUTS_DIR/${dir_prefix}1 + mkdir -p $TEST_INPUTS_DIR/${dir_prefix}2 + mkdir -p $TEST_INPUTS_DIR/${dir_prefix}3 + + atf_check -e empty -o empty -s exit:0 \ + $MAKEFS -o rockridge $TEST_IMAGE $TEST_INPUTS_DIR + + check_cd9660_support + mount_image -r + + atf_check_equal $(ls -1 $TEST_MOUNT_DIR | sort | uniq | wc -l) 3 +} +duplicate_names_cleanup() +{ + common_cleanup +} + atf_init_test_cases() { atf_add_test_case D_flag @@ -392,4 +420,6 @@ atf_add_test_case o_flag_publisher atf_add_test_case o_flag_rockridge atf_add_test_case o_flag_rockridge_dev_nodes + + atf_add_test_case duplicate_names } Index: usr.sbin/makefs/tests/makefs_tests_common.sh =================================================================== --- usr.sbin/makefs/tests/makefs_tests_common.sh +++ usr.sbin/makefs/tests/makefs_tests_common.sh @@ -138,6 +138,6 @@ atf_check -e empty -o save:$TEST_MD_DEVICE_FILE -s exit:0 \ mdconfig -a -f $TEST_IMAGE atf_check -e empty -o empty -s exit:0 \ - $MOUNT /dev/$(cat $TEST_MD_DEVICE_FILE) $TEST_MOUNT_DIR + $MOUNT ${1} /dev/$(cat $TEST_MD_DEVICE_FILE) $TEST_MOUNT_DIR }