NTSTATUS SrvReadConfig( PLWIO_SRV_CONFIG pConfig ) { NTSTATUS ntStatus = STATUS_SUCCESS; LWIO_SRV_CONFIG srvConfig = {0}; PLWIO_CONFIG_REG pReg = NULL; BOOLEAN bUsePolicy = TRUE; ntStatus = SrvInitConfig(&srvConfig); BAIL_ON_NT_STATUS(ntStatus); ntStatus = LwIoOpenConfig( "Services\\lwio\\Parameters\\Drivers\\srv", "Policy\\Services\\lwio\\Parameters\\Drivers\\srv", &pReg); if (ntStatus) { LWIO_LOG_ERROR("Failed to access device configuration [error code: %u]", ntStatus); ntStatus = STATUS_DEVICE_CONFIGURATION_ERROR; } BAIL_ON_NT_STATUS(ntStatus); /* Ignore error as it may not exist; we can still use default. */ LwIoReadConfigBoolean( pReg, "BootstrapDefaultSharePath", bUsePolicy, &srvConfig.bBootstrapDefaultSharePath); /* Ignore error as it may not exist; we can still use default. */ LwIoReadConfigDword( pReg, "MonitorIntervalMinutes", bUsePolicy, LWIO_SRV_DEFAULT_MONITOR_INTERVAL_MINS_MIN, LWIO_SRV_DEFAULT_MONITOR_INTERVAL_MINS_MAX, &srvConfig.ulMonitorIntervalMinutes); ntStatus = SrvTransferConfigContents(&srvConfig, pConfig); BAIL_ON_NT_STATUS(ntStatus); cleanup: if (pReg) { LwIoCloseConfig(pReg); } SrvFreeConfigContents(&srvConfig); return ntStatus; error: goto cleanup; }
static NTSTATUS SrvInitialize( IO_DEVICE_HANDLE hDevice ) { NTSTATUS ntStatus = 0; INT iWorker = 0; memset(&gSMBSrvGlobals, 0, sizeof(gSMBSrvGlobals)); pthread_mutex_init(&gSMBSrvGlobals.mutex, NULL); gSMBSrvGlobals.pMutex = &gSMBSrvGlobals.mutex; ntStatus = SrvInitConfig(&gSMBSrvGlobals.config); BAIL_ON_NT_STATUS(ntStatus); ntStatus = SrvReadConfig(&gSMBSrvGlobals.config); BAIL_ON_NT_STATUS(ntStatus); ntStatus = SMBPacketCreateAllocator( gSMBSrvGlobals.config.ulMaxNumPackets, &gSMBSrvGlobals.hPacketAllocator); BAIL_ON_NT_STATUS(ntStatus); ntStatus = SrvProdConsInitContents( &gSMBSrvGlobals.workQueue, gSMBSrvGlobals.config.ulMaxNumWorkItemsInQueue, &SrvReleaseExecContextHandle); BAIL_ON_NT_STATUS(ntStatus); ntStatus = SrvShareInit(); BAIL_ON_NT_STATUS(ntStatus); ntStatus = SrvShareInitList(&gSMBSrvGlobals.shareList); BAIL_ON_NT_STATUS(ntStatus); ntStatus = SrvShareBootstrapNamedPipeRoot(&gSMBSrvGlobals.shareList); BAIL_ON_NT_STATUS(ntStatus); if (gSMBSrvGlobals.config.bBootstrapDefaultSharePath) { ntStatus = SrvShareBootstrapDiskRoot(&gSMBSrvGlobals.shareList); BAIL_ON_NT_STATUS(ntStatus); } ntStatus = SrvElementsInit(); BAIL_ON_NT_STATUS(ntStatus); ntStatus = SrvStatisticsInitialize(); BAIL_ON_NT_STATUS(ntStatus); ntStatus = SrvProtocolInit( &gSMBSrvGlobals.workQueue, gSMBSrvGlobals.hPacketAllocator, &gSMBSrvGlobals.shareList); BAIL_ON_NT_STATUS(ntStatus); ntStatus = SrvAllocateMemory( gSMBSrvGlobals.config.ulNumWorkers * sizeof(LWIO_SRV_WORKER), (PVOID*)&gSMBSrvGlobals.pWorkerArray); BAIL_ON_NT_STATUS(ntStatus); gSMBSrvGlobals.ulNumWorkers = gSMBSrvGlobals.config.ulNumWorkers; for (; iWorker < gSMBSrvGlobals.config.ulNumWorkers; iWorker++) { PLWIO_SRV_WORKER pWorker = &gSMBSrvGlobals.pWorkerArray[iWorker]; pWorker->workerId = iWorker + 1; ntStatus = SrvWorkerInit(pWorker); BAIL_ON_NT_STATUS(ntStatus); } gSMBSrvGlobals.hDevice = hDevice; error: return ntStatus; }