The current hash function can cause collisions in some applications, as described in https://gitlab.winehq.org/wine/wine/-/merge_requests/4244.
But we can't just change the hash function without breaking existing prefixes. (https://gitlab.winehq.org/wine/wine/-/merge_requests/4244#note_50530)
Windows has a registry key to disable the creation of new 8.3 Filenames, these changes should mimic this feature.
From: Pedro Nishiyama nishiyama.v3@gmail.com
--- dlls/ntdll/unix/file.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index 98e50082904..30e8f554298 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -240,6 +240,8 @@ static unsigned int dir_data_cache_size; static BOOL show_dot_files; static mode_t start_umask;
+static BOOL disable_8dot3_filenames; + /* at some point we may want to allow Winelib apps to set this */ static const BOOL is_case_sensitive = FALSE;
@@ -1510,7 +1512,7 @@ static BOOL append_entry( struct dir_data *data, const char *long_name, else /* generate a short name if necessary */ { short_len = 0; - if (!is_legal_8dot3_name( long_nameW, long_len )) + if (!is_legal_8dot3_name( long_nameW, long_len ) && !disable_8dot3_filenames) short_len = hash_short_file_name( long_nameW, long_len, short_nameW ); } short_nameW[short_len] = 0; @@ -3013,6 +3015,7 @@ void init_files(void) if (!open_hkcu_key( "Software\Wine", &key )) { static WCHAR showdotfilesW[] = {'S','h','o','w','D','o','t','F','i','l','e','s',0}; + static WCHAR disable8dot3filenamesW[] = {'D','i','s','a','b','l','e','8','d','o','t','3','F','i','l','e','n','a','m','e','s',0}; char tmp[80]; DWORD dummy; UNICODE_STRING nameW; @@ -3023,6 +3026,14 @@ void init_files(void) WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data; show_dot_files = IS_OPTION_TRUE( str[0] ); } + + init_unicode_string( &nameW, disable8dot3filenamesW ); + if (!NtQueryValueKey( key, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy )) + { + WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data; + disable_8dot3_filenames = IS_OPTION_TRUE( str[0] ); + } + NtClose( key ); } }
From: Pedro Nishiyama nishiyama.v3@gmail.com
--- programs/winecfg/driveui.c | 18 ++++++++++++++++-- programs/winecfg/resource.h | 1 + programs/winecfg/winecfg.rc | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/programs/winecfg/driveui.c b/programs/winecfg/driveui.c index e21c99a6697..d12b948d6b3 100644 --- a/programs/winecfg/driveui.c +++ b/programs/winecfg/driveui.c @@ -254,7 +254,7 @@ static int fill_drives_list(HWND dialog) return count; }
-static void on_options_click(HWND dialog) +static void on_show_dot_files_click(HWND dialog) { if (IsDlgButtonChecked(dialog, IDC_SHOW_DOT_FILES) == BST_CHECKED) set_reg_key(config_key, L"", L"ShowDotFiles", L"Y"); @@ -264,6 +264,16 @@ static void on_options_click(HWND dialog) SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0); }
+static void on_disable_8dot3_filenames_click(HWND dialog) +{ + if (IsDlgButtonChecked(dialog, IDC_DISABLE_8DOT3_FILENAMES) == BST_CHECKED) + set_reg_key(config_key, L"", L"Disable8dot3Filenames", L"Y"); + else + set_reg_key(config_key, L"", L"Disable8dot3Filenames", L"N"); + + SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0); +} + static INT_PTR CALLBACK drivechoose_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static int i, sel; @@ -648,6 +658,8 @@ static void load_drive_options(HWND dialog) { if (!wcscmp(get_reg_key(config_key, L"", L"ShowDotFiles", L"N"), L"Y")) CheckDlgButton(dialog, IDC_SHOW_DOT_FILES, BST_CHECKED); + if (!wcscmp(get_reg_key(config_key, L"", L"Disable8dot3Filenames", L"N"), L"Y")) + CheckDlgButton(dialog, IDC_DISABLE_8DOT3_FILENAMES, BST_CHECKED); }
INT_PTR CALLBACK @@ -700,7 +712,9 @@ DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam) switch (LOWORD(wParam)) { case IDC_SHOW_DOT_FILES: - on_options_click(dialog); + on_show_dot_files_click(dialog); + case IDC_DISABLE_8DOT3_FILENAMES: + on_disable_8dot3_filenames_click(dialog); break; } break; diff --git a/programs/winecfg/resource.h b/programs/winecfg/resource.h index cd7eaaf711e..55a8479f2a5 100644 --- a/programs/winecfg/resource.h +++ b/programs/winecfg/resource.h @@ -106,6 +106,7 @@ #define IDC_BUTTON_SHOW_HIDE_ADVANCED 1076 #define IDC_STATIC_TYPE 1077 #define IDC_SHOW_DOT_FILES 1080 +#define IDC_DISABLE_8DOT3_FILENAMES 1081
#define IDS_DRIVE_UNKNOWN 8200 #define IDS_DRIVE_FIXED 8201 diff --git a/programs/winecfg/winecfg.rc b/programs/winecfg/winecfg.rc index 779a2f900e3..be819bd774f 100644 --- a/programs/winecfg/winecfg.rc +++ b/programs/winecfg/winecfg.rc @@ -258,7 +258,8 @@ BEGIN LTEXT "S&erial:",IDC_STATIC_SERIAL,15,183,42,12 EDITTEXT IDC_EDIT_SERIAL,59,180,78,13,ES_AUTOHSCROLL | WS_TABSTOP
- CONTROL "&Show dot files",IDC_SHOW_DOT_FILES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,205,230,10 + CONTROL "&Show dot files",IDC_SHOW_DOT_FILES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,205,110,10 + CONTROL "&Disable 8.3 filenames",IDC_DISABLE_8DOT3_FILENAMES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,120,205,110,10 END
IDD_AUDIOCFG DIALOG 0, 0, 260, 220
This merge request was closed by Pedro Nishiyama.