//////////////////////// \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 ////////////////////////
| 2225 | /// \return Handle ID on success, error code on failure |
| 2226 | ///////////////////////////// |
| 2227 | long 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 |
nothing calls this directly
no test coverage detected