From ee8c49876a6c680467ecc3aa41dfbbed6004dc85 Mon Sep 17 00:00:00 2001 From: Elizabeth Ashurov Date: Thu, 19 Jun 2025 19:43:09 +0300 Subject: [PATCH] RHEL-95788: Fix- support CLI argument for VirtioFsSvc service When creating a VirtioFsSvc service using sc create, command-line arguments appear to be ignored. To work around this, when argc <= 1, we can manually parse the full command line using GetCommandLineW and CommandLineToArgvW, restoring proper argc/argv behavior. Signed-off-by: Elizabeth Ashurov --- viofs/svc/virtiofs.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/viofs/svc/virtiofs.cpp b/viofs/svc/virtiofs.cpp index 78f88000..dbca4bf7 100644 --- a/viofs/svc/virtiofs.cpp +++ b/viofs/svc/virtiofs.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -2759,11 +2760,29 @@ static NTSTATUS SvcStart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv) VIRTFS *VirtFs; NTSTATUS Status{STATUS_SUCCESS}; DWORD Error; + PWSTR *finalArgv = argv; + int finalArgc = argc; + bool shouldFreeFinalArgv = false; - if (argc > 1) + if (argc <= 1) { - Status = ParseArgs(argc, - argv, + LPWSTR fullCommandLine = GetCommandLineW(); + finalArgv = CommandLineToArgvW(fullCommandLine, &finalArgc); + if (finalArgv) + { + shouldFreeFinalArgv = true; + } + else + { + finalArgv = argv; + finalArgc = argc; + } + } + + if (finalArgc > 1) + { + Status = ParseArgs(finalArgc, + finalArgv, DebugFlags, DebugLogFile, CaseInsensitive, @@ -2771,6 +2790,11 @@ static NTSTATUS SvcStart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv) MountPoint, Tag, Owner); + + if (shouldFreeFinalArgv) + { + LocalFree(finalArgv); + } } else {