Added patch for fsutil.exe hardlink command.

This commit is contained in:
Sebastian Lackner 2016-04-01 01:56:01 +02:00
parent 8bed2773c4
commit 29b8c10db6
3 changed files with 295 additions and 0 deletions

View File

@ -0,0 +1,274 @@
From fe2b318c4d9cee458cc4db4d41c028a8b783282d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 1 Apr 2016 01:29:51 +0200
Subject: fsutil: Add fsutil program with support for creating hard links.
---
configure.ac | 1 +
programs/fsutil/Makefile.in | 8 +++
programs/fsutil/fsutil.rc | 34 ++++++++++
programs/fsutil/main.c | 151 ++++++++++++++++++++++++++++++++++++++++++++
programs/fsutil/resources.h | 25 ++++++++
5 files changed, 219 insertions(+)
create mode 100644 programs/fsutil/Makefile.in
create mode 100644 programs/fsutil/fsutil.rc
create mode 100644 programs/fsutil/main.c
create mode 100644 programs/fsutil/resources.h
diff --git a/configure.ac b/configure.ac
index 20478df..8cd1f4a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3459,6 +3459,7 @@ WINE_CONFIG_PROGRAM(expand,,[install])
WINE_CONFIG_PROGRAM(explorer,,[clean,install])
WINE_CONFIG_PROGRAM(extrac32,,[install])
WINE_CONFIG_PROGRAM(findstr,,[install])
+WINE_CONFIG_PROGRAM(fsutil,,[clean,install])
WINE_CONFIG_PROGRAM(hh,,[install])
WINE_CONFIG_PROGRAM(hostname,,[clean,install])
WINE_CONFIG_PROGRAM(icacls,,[install])
diff --git a/programs/fsutil/Makefile.in b/programs/fsutil/Makefile.in
new file mode 100644
index 0000000..7433695
--- /dev/null
+++ b/programs/fsutil/Makefile.in
@@ -0,0 +1,8 @@
+MODULE = fsutil.exe
+APPMODE = -mconsole -municode
+IMPORTS = user32
+
+C_SRCS = \
+ main.c
+
+RC_SRCS = fsutil.rc
diff --git a/programs/fsutil/fsutil.rc b/programs/fsutil/fsutil.rc
new file mode 100644
index 0000000..593f817
--- /dev/null
+++ b/programs/fsutil/fsutil.rc
@@ -0,0 +1,34 @@
+/*
+ * FSUTIL.EXE - Wine-compatible fsutil program
+ *
+ * Copyright 2016 Michael Müller
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "resources.h"
+
+#pragma makedep po
+
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+STRINGTABLE
+{
+ STRING_USAGE, "---- Commands Supported ----\n\nhardlink Hardlink management\n\n"
+ STRING_UNSUPPORTED_CMD, "%1 is an unsupported command\n"
+ STRING_UNSUPPORTED_PARAM, "%1 is an unsupported parameter\n"
+ STRING_HARDLINK_USAGE, "---- Hardlink - Commands Supported ----\n\ncreate Create a hardlink.\n\n"
+ STRING_HARDLINK_CREATE_USAGE, "Syntax: fsutil hardlink create old new\n\n"
+}
diff --git a/programs/fsutil/main.c b/programs/fsutil/main.c
new file mode 100644
index 0000000..ff58dd4
--- /dev/null
+++ b/programs/fsutil/main.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2016 Michael Müller
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <windows.h>
+#include <wine/unicode.h>
+#include <wine/debug.h>
+
+#include "resources.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(fsutil);
+
+static void output_write(const WCHAR *str, DWORD wlen)
+{
+ DWORD count, ret;
+
+ ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, wlen, &count, NULL);
+ if (!ret)
+ {
+ DWORD len;
+ char *msgA;
+
+ /* On Windows WriteConsoleW() fails if the output is redirected. So fall
+ * back to WriteFile(), assuming the console encoding is still the right
+ * one in that case.
+ */
+ len = WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, NULL, 0, NULL, NULL);
+ msgA = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
+ if (!msgA) return;
+
+ WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, msgA, len, NULL, NULL);
+ WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), msgA, len, &count, FALSE);
+ HeapFree(GetProcessHeap(), 0, msgA);
+ }
+}
+
+static int output_vprintf(const WCHAR* fmt, __ms_va_list va_args)
+{
+ WCHAR str[8192];
+ int len;
+
+ SetLastError(NO_ERROR);
+ len = FormatMessageW(FORMAT_MESSAGE_FROM_STRING, fmt, 0, 0, str,
+ sizeof(str)/sizeof(*str), &va_args);
+ if (len == 0 && GetLastError() != NO_ERROR)
+ WINE_FIXME("Could not format string: le=%u, fmt=%s\n", GetLastError(), wine_dbgstr_w(fmt));
+ else
+ output_write(str, len);
+ return 0;
+}
+
+static int __cdecl output_string(int msg, ...)
+{
+ WCHAR fmt[8192];
+ __ms_va_list arguments;
+
+ LoadStringW(GetModuleHandleW(NULL), msg, fmt, sizeof(fmt)/sizeof(fmt[0]));
+ __ms_va_start(arguments, msg);
+ output_vprintf(fmt, arguments);
+ __ms_va_end(arguments);
+ return 0;
+}
+
+static BOOL output_error_string(DWORD error)
+{
+ LPWSTR pBuffer;
+ if (FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+ NULL, error, 0, (LPWSTR)&pBuffer, 0, NULL))
+ {
+ output_write(pBuffer, lstrlenW(pBuffer));
+ LocalFree(pBuffer);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static int create_hardlink(int argc, WCHAR *argv[])
+{
+ if (argc != 5)
+ {
+ output_string(STRING_HARDLINK_CREATE_USAGE);
+ return 1;
+ }
+
+ if (CreateHardLinkW(argv[3], argv[4], NULL))
+ return 0;
+
+ output_error_string(GetLastError());
+ return 1;
+}
+
+static int hardlink(int argc, WCHAR *argv[])
+{
+ static const WCHAR createW[]={'c','r','e','a','t','e',0};
+ int ret;
+
+ if (argc > 2)
+ {
+ if (!strcmpiW(argv[2], createW))
+ return create_hardlink(argc, argv);
+ else
+ {
+ FIXME("unsupported parameter %s\n", debugstr_w(argv[2]));
+ output_string(STRING_UNSUPPORTED_PARAM, argv[2]);
+ ret = 1;
+ }
+ }
+
+ output_string(STRING_HARDLINK_USAGE);
+ return ret;
+}
+
+int wmain(int argc, WCHAR *argv[])
+{
+ static const WCHAR hardlinkW[]={'h','a','r','d','l','i','n','k',0};
+ int i, ret = 0;
+
+ for (i = 0; i < argc; i++)
+ WINE_TRACE(" %s", wine_dbgstr_w(argv[i]));
+ WINE_TRACE("\n");
+
+ if (argc > 1)
+ {
+ if (!strcmpiW(argv[1], hardlinkW))
+ return hardlink(argc, argv);
+ else
+ {
+ FIXME("unsupported command %s\n", debugstr_w(argv[1]));
+ output_string(STRING_UNSUPPORTED_CMD, argv[1]);
+ ret = 1;
+ }
+ }
+
+ output_string(STRING_USAGE);
+ return ret;
+}
diff --git a/programs/fsutil/resources.h b/programs/fsutil/resources.h
new file mode 100644
index 0000000..b85826a
--- /dev/null
+++ b/programs/fsutil/resources.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016 Michael Müller
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <windef.h>
+
+#define STRING_USAGE 101
+#define STRING_UNSUPPORTED_CMD 102
+#define STRING_UNSUPPORTED_PARAM 103
+#define STRING_HARDLINK_USAGE 104
+#define STRING_HARDLINK_CREATE_USAGE 105
--
2.7.1

View File

@ -0,0 +1 @@
Fixes: [22749] Add stub for fsutil.exe hardlink command

View File

@ -146,6 +146,7 @@ patch_enable_all ()
enable_dxva2_Video_Decoder="$1"
enable_explorer_Video_Registry_Key="$1"
enable_fonts_Missing_Fonts="$1"
enable_fsutil_Stub_Program="$1"
enable_gdi32_Lazy_Font_Initialization="$1"
enable_gdi32_MultiMonitor="$1"
enable_gdi32_Path_Metafile="$1"
@ -614,6 +615,9 @@ patch_enable ()
fonts-Missing_Fonts)
enable_fonts_Missing_Fonts="$2"
;;
fsutil-Stub_Program)
enable_fsutil_Stub_Program="$2"
;;
gdi32-Lazy_Font_Initialization)
enable_gdi32_Lazy_Font_Initialization="$2"
;;
@ -3710,6 +3714,22 @@ if test "$enable_fonts_Missing_Fonts" -eq 1; then
) >> "$patchlist"
fi
# Patchset fsutil-Stub_Program
# |
# | This patchset fixes the following Wine bugs:
# | * [#22749] Add stub for fsutil.exe hardlink command
# |
# | Modified files:
# | * configure.ac, programs/fsutil/Makefile.in, programs/fsutil/fsutil.rc, programs/fsutil/main.c,
# | programs/fsutil/resources.h
# |
if test "$enable_fsutil_Stub_Program" -eq 1; then
patch_apply fsutil-Stub_Program/0001-fsutil-Add-fsutil-program-with-support-for-creating-.patch
(
echo '+ { "Michael Müller", "fsutil: Add fsutil program with support for creating hard links.", 1 },';
) >> "$patchlist"
fi
# Patchset gdi32-Lazy_Font_Initialization
# |
# | Modified files: