MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / SysCreateService

Function SysCreateService

Kernel/src/arch/x86_64/syscalls.cpp:2227–2248  ·  view source on GitHub ↗

//////////////////////// \brief SysCreateService (name) - Create a service Create a new service. Services are essentially named containers for interfaces, allowing one program to implement multiple interfaces under a service. \param name (const char*) Service name to be used, must be unique \return Handle ID on success, error code on failure ////////////////////////

Source from the content-addressed store, hash-verified

2225/// \return Handle ID on success, error code on failure
2226/////////////////////////////
2227long SysCreateService(regs64_t* r){
2228 process_t* currentProcess = Scheduler::GetCurrentProcess();
2229
2230 size_t nameLength;
2231 if(strlenSafe(reinterpret_cast<const char*>(SC_ARG0(r)), nameLength, currentProcess->addressSpace)){
2232 return -EFAULT;
2233 }
2234
2235 char name[nameLength + 1];
2236 strncpy(name, reinterpret_cast<const char*>(SC_ARG0(r)), nameLength);
2237 name[nameLength] = 0;
2238 for(auto& svc : ServiceFS::Instance()->services){
2239 if(strncmp(svc->GetName(), name, nameLength) == 0){
2240 return -EEXIST;
2241 }
2242 }
2243
2244 FancyRefPtr<Service> svc = ServiceFS::Instance()->CreateService(name);
2245 Handle& handle = Scheduler::RegisterHandle(currentProcess, static_pointer_cast<KernelObject, Service>(svc));
2246
2247 return handle.id;
2248}
2249
2250/////////////////////////////
2251/// \brief SysCreateInterface (service, name, msgSize) - Create a new interface

Callers

nothing calls this directly

Calls 6

GetCurrentProcessFunction · 0.85
strlenSafeFunction · 0.85
strncpyFunction · 0.85
strncmpFunction · 0.85
CreateServiceMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected