ReactOS 0.4.15-dev-8191-gbc6c731
service.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SZAPPNAME   "nfsd"
 
#define SZSERVICENAME   "pnfs"
 
#define SZSERVICEDISPLAYNAME   "NFSv4.1 Client"
 
#define SZDEPENDENCIES   ""
 

Functions

VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv)
 
VOID ServiceStop ()
 
BOOL ReportStatusToSCMgr (DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint)
 
void AddToMessageLog (LPTSTR lpszMsg)
 

Macro Definition Documentation

◆ SZAPPNAME

#define SZAPPNAME   "nfsd"

Definition at line 65 of file service.h.

◆ SZDEPENDENCIES

#define SZDEPENDENCIES   ""

Definition at line 71 of file service.h.

◆ SZSERVICEDISPLAYNAME

#define SZSERVICEDISPLAYNAME   "NFSv4.1 Client"

Definition at line 69 of file service.h.

◆ SZSERVICENAME

#define SZSERVICENAME   "pnfs"

Definition at line 67 of file service.h.

Function Documentation

◆ AddToMessageLog()

void AddToMessageLog ( LPTSTR  lpszMsg)

Definition at line 289 of file service.c.

290{
291 TCHAR szMsg [(sizeof(SZSERVICENAME) / sizeof(TCHAR)) + 100 ];
292 HANDLE hEventSource;
293 LPTSTR lpszStrings[2];
294
295 if ( !bDebug )
296 {
298
299 // Use event logging to log the error.
300 //
301 hEventSource = RegisterEventSource(NULL, TEXT(SZSERVICENAME));
302
303#ifndef __REACTOS__
304 _stprintf_s(szMsg,(sizeof(SZSERVICENAME) / sizeof(TCHAR)) + 100, TEXT("%s error: %d"), TEXT(SZSERVICENAME), dwErr);
305#else
306 _sntprintf(szMsg,(sizeof(SZSERVICENAME) / sizeof(TCHAR)) + 100, TEXT("%s error: %d"), TEXT(SZSERVICENAME), dwErr);
307#endif
308 lpszStrings[0] = szMsg;
309 lpszStrings[1] = lpszMsg;
310
311 if (hEventSource != NULL)
312 {
313 ReportEvent(hEventSource, // handle of event source
314 EVENTLOG_ERROR_TYPE, // event type
315 0, // event category
316 0, // event ID
317 NULL, // current user's SID
318 2, // strings in lpszStrings
319 0, // no bytes of raw data
320 lpszStrings, // array of error strings
321 NULL); // no raw data
322
323 (VOID) DeregisterEventSource(hEventSource);
324 }
325 }
326}
#define VOID
Definition: acefi.h:82
BOOL bDebug
Definition: service.c:37
DWORD dwErr
Definition: service.c:36
#define NULL
Definition: types.h:112
BOOL WINAPI DeregisterEventSource(IN HANDLE hEventLog)
Definition: eventlog.c:473
#define TEXT(s)
Definition: k32.h:26
#define SZSERVICENAME
Definition: service.h:67
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ReportEvent
Definition: winbase.h:3899
#define RegisterEventSource
Definition: winbase.h:3894
#define EVENTLOG_ERROR_TYPE
Definition: winnt_old.h:2834
char TCHAR
Definition: xmlstorage.h:189
#define _sntprintf
Definition: xmlstorage.h:201
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by main(), and ReportStatusToSCMgr().

◆ ReportStatusToSCMgr()

BOOL ReportStatusToSCMgr ( DWORD  dwCurrentState,
DWORD  dwWin32ExitCode,
DWORD  dwWaitHint 
)

Definition at line 240 of file service.c.

243{
244 static DWORD dwCheckPoint = 1;
245 BOOL fResult = TRUE;
246
247
248 if ( !bDebug ) // when debugging we don't report to the SCM
249 {
250 if (dwCurrentState == SERVICE_START_PENDING)
252 else
254
255 ssStatus.dwCurrentState = dwCurrentState;
256 ssStatus.dwWin32ExitCode = dwWin32ExitCode;
257 ssStatus.dwWaitHint = dwWaitHint;
258
259 if ( ( dwCurrentState == SERVICE_RUNNING ) ||
260 ( dwCurrentState == SERVICE_STOPPED ) )
262 else
263 ssStatus.dwCheckPoint = dwCheckPoint++;
264
265
266 // Report the status of the service to the service control manager.
268 if (!fResult)
269 AddToMessageLog(TEXT("SetServiceStatus"));
270 }
271 return fResult;
272}
SERVICE_STATUS ssStatus
Definition: service.c:34
VOID AddToMessageLog(LPTSTR lpszMsg)
Definition: service.c:289
SERVICE_STATUS_HANDLE sshStatusHandle
Definition: service.c:35
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:997
DWORD dwWin32ExitCode
Definition: winsvc.h:102
DWORD dwControlsAccepted
Definition: winsvc.h:101
DWORD dwWaitHint
Definition: winsvc.h:105
DWORD dwCurrentState
Definition: winsvc.h:100
DWORD dwCheckPoint
Definition: winsvc.h:104
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
#define SERVICE_START_PENDING
Definition: winsvc.h:22
#define SERVICE_RUNNING
Definition: winsvc.h:24

Referenced by open_log_files(), service_ctrl(), service_main(), and ServiceStart().

◆ ServiceStart()

VOID ServiceStart ( DWORD  dwArgc,
LPTSTR lpszArgv 
)

Definition at line 381 of file nfs41_daemon.c.

383{
384 DWORD status = 0, len;
385 // handle to our drivers
386 HANDLE pipe;
388 nfs41_idmapper *idmapper = NULL;
389 int i;
390 nfsd_args cmd_args;
391
392 if (!check_for_files())
393 exit(0);
394 if (!parse_cmdlineargs(argc, argv, &cmd_args))
395 exit(0);
398
399#ifdef __REACTOS__
400 /* Start the kernel part */
401 {
403 if (hSvcMan)
404 {
405 HANDLE hSvc = OpenService(hSvcMan, "nfs41_driver", SERVICE_ALL_ACCESS);
406 if (hSvc)
407 {
408 SERVICE_STATUS SvcSt;
409 QueryServiceStatus(hSvc, &SvcSt);
410 if (SvcSt.dwCurrentState != SERVICE_RUNNING)
411 {
412 if (StartService(hSvc, 0, NULL))
413 {
414 dprintf(1, "NFS41 driver started\n");
415 }
416 else
417 {
418 eprintf("Driver failed to start: %d\n", GetLastError());
419 }
420 }
421 else
422 {
423 eprintf("Driver in state: %x\n", SvcSt.dwCurrentState);
424 }
425
426 CloseServiceHandle(hSvc);
427 }
428 else
429 {
430 eprintf("Failed to open service: %d\n", GetLastError());
431 }
432
433 CloseServiceHandle(hSvcMan);
434 }
435 else
436 {
437 eprintf("Failed to open service manager: %d\n", GetLastError());
438 }
439 }
440#endif
441
442#ifdef _DEBUG
443 /* dump memory leaks to stderr on exit; this requires the debug heap,
444 /* available only when built in debug mode under visual studio -cbodley */
447#pragma warning (push)
448#pragma warning (disable : 4306) /* conversion from 'int' to '_HFILE' of greater size */
450#pragma warning (pop)
451 dprintf(1, "debug mode. dumping memory leaks to stderr on exit.\n");
452#endif
453 /* acquire and store in global memory current dns domain name.
454 * needed for acls */
455 if (getdomainname())
456 exit(0);
457
459
460 if (cmd_args.ldap_enable) {
461 status = nfs41_idmap_create(&idmapper);
462 if (status) {
463 eprintf("id mapping initialization failed with %d\n", status);
464 goto out_logs;
465 }
466 }
467
469 dprintf(1, "NFS41 Daemon starting: version %d\n", NFS41D_VERSION);
470
473 0, NULL);
474 if (pipe == INVALID_HANDLE_VALUE)
475 {
476 eprintf("Unable to open upcall pipe %d\n", GetLastError());
477 goto out_idmap;
478 }
479
480 dprintf(1, "starting nfs41 mini redirector\n");
482 &NFS41D_VERSION, sizeof(DWORD), NULL, 0, (LPDWORD)&len, NULL);
483 if (!status) {
484 eprintf("IOCTL_NFS41_START failed with %d\n",
485 GetLastError());
486 goto out_pipe;
487 }
488
489#ifndef STANDALONE_NFSD
491 if (stop_event == NULL)
492 goto out_pipe;
493#endif
494
495 for (i = 0; i < MAX_NUM_THREADS; i++) {
497 idmapper, 0, &tids[i].tid);
498 if (tids[i].handle == INVALID_HANDLE_VALUE) {
500 eprintf("_beginthreadex failed %d\n", status);
501 goto out_pipe;
502 }
503 }
504#ifndef STANDALONE_NFSD
505 // report the status to the service control manager.
507 goto out_pipe;
509#else
510 //This can be changed to waiting on an array of handles and using waitformultipleobjects
511 dprintf(1, "Parent waiting for children threads\n");
512 for (i = 0; i < MAX_NUM_THREADS; i++)
514#endif
515 dprintf(1, "Parent woke up!!!!\n");
516
517out_pipe:
518 CloseHandle(pipe);
519out_idmap:
520 if (idmapper) nfs41_idmap_free(idmapper);
521out_logs:
522#ifndef STANDALONE_NFSD
524#endif
525 return;
526}
static int argc
Definition: ServiceArgs.c:12
BOOL ReportStatusToSCMgr(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint)
Definition: service.c:240
#define _CRTDBG_MODE_FILE
Definition: crtdbg.h:24
#define _CRTDBG_LEAK_CHECK_DF
Definition: crtdbg.h:52
#define _CrtSetReportMode(t, f)
Definition: crtdbg.h:129
#define _CRT_WARN
Definition: crtdbg.h:19
#define _CRTDBG_FILE_STDERR
Definition: crtdbg.h:32
#define _CrtSetDbgFlag(f)
Definition: crtdbg.h:245
#define _CRTDBG_ALLOC_MEM_DF
Definition: crtdbg.h:47
#define _CrtSetReportFile(t, f)
Definition: crtdbg.h:130
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
void open_log_files()
Definition: daemon_debug.c:40
void set_debug_level(int level)
Definition: daemon_debug.c:35
void close_log_files()
Definition: daemon_debug.c:59
#define NO_ERROR
Definition: dderror.h:5
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define INFINITE
Definition: serial.h:102
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int nfs41_idmap_create(struct idmap_context **context_out)
Definition: idmap.c:805
void nfs41_idmap_free(struct idmap_context *context)
Definition: idmap.c:867
static TfClientId tid
#define argv
Definition: mplay32.c:18
void nfs41_server_list_init()
Definition: nfs41_server.c:48
#define MAX_NUM_THREADS
Definition: nfs41_daemon.c:41
static unsigned int WINAPI thread_main(void *args)
Definition: nfs41_daemon.c:84
HANDLE stop_event
Definition: nfs41_daemon.c:55
static bool_t check_for_files()
Definition: nfs41_daemon.c:168
DWORD NFS41D_VERSION
Definition: nfs41_daemon.c:42
static int getdomainname()
Definition: nfs41_daemon.c:290
static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out)
Definition: nfs41_daemon.c:206
#define IOCTL_NFS41_START
Definition: nfs41_driver.h:43
#define NFS41_USER_DEVICE_NAME_A
Definition: nfs41_driver.h:28
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
#define dprintf
Definition: regdump.c:33
BOOL WINAPI QueryServiceStatus(SC_HANDLE hService, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:2845
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
#define exit(n)
Definition: config.h:202
bool_t ldap_enable
Definition: nfs41_daemon.c:164
Definition: ps.c:97
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
PVOID HANDLE
Definition: typedefs.h:73
uint32_t * LPDWORD
Definition: typedefs.h:59
#define CreateEvent
Definition: winbase.h:3748
#define CreateFile
Definition: winbase.h:3749
#define OpenSCManager
Definition: winsvc.h:575
#define SERVICE_ALL_ACCESS
Definition: winsvc.h:62
#define StartService
Definition: winsvc.h:585
#define SC_MANAGER_ALL_ACCESS
Definition: winsvc.h:13
#define OpenService
Definition: winsvc.h:576

Referenced by CmdDebugService(), and service_main().

◆ ServiceStop()

VOID ServiceStop ( )

Definition at line 156 of file nfs41_daemon.c.

157{
158 if (stop_event)
160}
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733

Referenced by ControlHandler(), and service_ctrl().