Skip to content

Commit

Permalink
Start port of zed
Browse files Browse the repository at this point in the history
zed -d path/to/zed.d -p path/to/pid.txt -s path/to/zed.state -f

Passes through enough to query ZFS for events. There is no
zed_exec.c yet, so no scripts will currently execute.

TODO

Implement zed_exec.c to start scripts
Change Cmake to pull in PowerShell API

Signed-off-by: Jorgen Lundman <[email protected]>
  • Loading branch information
lundman committed Oct 28, 2024
1 parent f578243 commit b3778ea
Show file tree
Hide file tree
Showing 19 changed files with 773 additions and 10 deletions.
1 change: 1 addition & 0 deletions cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ add_subdirectory(os/windows/kstat)
add_subdirectory(os/windows/zfsinstaller)
add_subdirectory(raidz_test)
add_subdirectory(zinject)
add_subdirectory(zed)
35 changes: 35 additions & 0 deletions cmd/zed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

use_clang()

um_add_executable(zed
zed.c
zed_conf.c
zed_disk_event.c
zed_event.c
zed_file.c
zed_log.c
zed_strings.c
agents/fmd_api.c
agents/fmd_serd.c
agents/zfs_agents.c
agents/zfs_diagnosis.c
agents/zfs_mod.c
agents/zfs_retire.c
os/windows/zed_exec.c
os/windows/resource.rc
)
target_link_libraries(zed PRIVATE
# libnvpair
# libuutil
libzfs
# libzfs_core
libzpool
)

target_include_directories(zed PRIVATE "${CMAKE_SOURCE_DIR}/cmd/zed" "${CMAKE_SOURCE_DIR}/include")

install(TARGETS zed RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES $<TARGET_PDB_FILE:zed>
DESTINATION "${CMAKE_INSTALL_BINDIR}"
OPTIONAL
)
10 changes: 5 additions & 5 deletions cmd/zed/agents/fmd_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ fmd_serd_gc(fmd_hdl_t *hdl)
}

/* FMD Timers */

#if 0
static void
_timer_notify(union sigval sv)
{
Expand All @@ -584,7 +584,7 @@ _timer_notify(union sigval sv)
if (ops->fmdo_timeout != NULL)
ops->fmdo_timeout(hdl, ftp, ftp->ft_arg);
}

#endif
/*
* Install a new timer which will fire at least delta nanoseconds after the
* current time. After the timeout has expired, the module's fmdo_timeout
Expand All @@ -608,9 +608,9 @@ fmd_timer_install(fmd_hdl_t *hdl, void *arg, fmd_event_t *ep, hrtime_t delta)
its.it_interval.tv_nsec = its.it_value.tv_nsec;

sev.sigev_notify = SIGEV_THREAD;
sev.sigev_notify_function = _timer_notify;
sev.sigev_notify_attributes = NULL;
sev.sigev_value.sival_ptr = ftp;
// sev.sigev_notify_function = _timer_notify;
// sev.sigev_notify_attributes = NULL;
// sev.sigev_value.sival_ptr = ftp;
sev.sigev_signo = 0;

timer_create(CLOCK_REALTIME, &sev, &ftp->ft_tid);
Expand Down
15 changes: 15 additions & 0 deletions cmd/zed/os/windows/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// {{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by resource.rc
//

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
110 changes: 110 additions & 0 deletions cmd/zed/os/windows/resource.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// Microsoft Visual C++ generated resource script.
//
#include <windows.h>
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// English (India) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENN)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_INDIA
#pragma code_page(1252)

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "400904b0"
BEGIN
VALUE "CompanyName", "TODO: <Company name>"
VALUE "FileDescription", "zed.exe"
VALUE "FileVersion", "1.0.0.1"
VALUE "LegalCopyright", "Copyright (C) 2021"
VALUE "OriginalFilename", "resource.rc"
VALUE "ProductName", "zed.exe"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x4009, 1200
END
END

#endif // English (India) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Loading

0 comments on commit b3778ea

Please sign in to comment.