Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate ZFSin controllers in device manager #33

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions cmd/os/windows/zfsinstaller/zfsinstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ printUsage() {
DWORD zfs_install(char *inf_path) {

DWORD error = 0;
bool IsServiceRunning = false;
// 128+4 If a reboot of the computer is necessary,
// ask the user for permission before rebooting.

Expand All @@ -445,8 +446,13 @@ DWORD zfs_install(char *inf_path) {
fprintf(stderr, "Installation failed, skip "
"starting the service\r\n");

if (!error)
error = installRootDevice(inf_path);
if (error == ERROR_SERVICE_ALREADY_RUNNING) {
IsServiceRunning = true;
error = 0;
}

if(!error)
error = installRootDevice(inf_path, IsServiceRunning);

if (!error)
perf_counters_install(inf_path);
Expand Down Expand Up @@ -580,6 +586,7 @@ startService(char *serviceName)
if (!StartServiceA(zfsServHdl, NULL, NULL)) {
if (GetLastError() == ERROR_SERVICE_ALREADY_RUNNING) {
fprintf(stderr, "Service is already running\n");
error = GetLastError();
} else {
fprintf(stderr, "StartServiceA failed, error %d\n",
GetLastError());
Expand Down Expand Up @@ -679,7 +686,7 @@ openDeviceInfo(char *inf, GUID *ClassGUID, char *ClassName, int namemax)


DWORD
installRootDevice(char *inf)
installRootDevice(char *inf, bool IsServiceRunning)
{
HDEVINFO DeviceInfoSet = INVALID_HANDLE_VALUE;
SP_DEVINFO_DATA DeviceInfoData;
Expand Down Expand Up @@ -721,12 +728,15 @@ installRootDevice(char *inf)
goto final;
}

// Transform the registry element into an actual devnode
// in the PnP HW tree.
if (!SetupDiCallClassInstaller(DIF_REGISTERDEVICE,
DeviceInfoSet,
&DeviceInfoData)) {
goto final;
// If service is running.
if (!IsServiceRunning) {
//Transform the registry element into an actual devnode
//in the PnP HW tree.
if (!SetupDiCallClassInstaller(DIF_REGISTERDEVICE,
DeviceInfoSet,
&DeviceInfoData)) {
goto final;
}
}

failcode = 0;
Expand Down
2 changes: 1 addition & 1 deletion cmd/os/windows/zfsinstaller/zfsinstaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ DWORD executeInfSection(const char *, char *);
DWORD startService(char *);
void printUsage();
DWORD send_zfs_ioc_unregister_fs();
DWORD installRootDevice(char *inf_path);
DWORD installRootDevice(char *inf_path, bool IsServiceRunning);
DWORD uninstallRootDevice(char *inf_path);