//////////////////////// \brief SysInterfaceConnect (path) - Open a connection to an interface Open a new connection on an interface and return a new MessageEndpoint \param interface (const char*) Path of interface in format servicename/interfacename (e.g. lemon.lemonwm/wm) \return Handle ID of endpoint on success, negative error code on failure ////////////////////////
| 2339 | /// \return Handle ID of endpoint on success, negative error code on failure |
| 2340 | ///////////////////////////// |
| 2341 | long SysInterfaceConnect(regs64_t* r){ |
| 2342 | process_t* currentProcess = Scheduler::GetCurrentProcess(); |
| 2343 | |
| 2344 | size_t sz = 0; |
| 2345 | if(strlenSafe(reinterpret_cast<const char*>(SC_ARG0(r)), sz, currentProcess->addressSpace)){ |
| 2346 | return -EFAULT; |
| 2347 | } |
| 2348 | |
| 2349 | char path[sz + 1]; |
| 2350 | strncpy(path, reinterpret_cast<const char*>(SC_ARG0(r)), sz); |
| 2351 | path[sz] = 0; |
| 2352 | |
| 2353 | if(!strchr(path, '/')){ // Interface name given by '/' separator |
| 2354 | Log::Warning("SysInterfaceConnect: No interface name given!"); |
| 2355 | return -EINVAL; |
| 2356 | } |
| 2357 | |
| 2358 | FancyRefPtr<MessageInterface> interface; |
| 2359 | { |
| 2360 | FancyRefPtr<Service> svc; |
| 2361 | if(ServiceFS::Instance()->ResolveServiceName(svc, path)){ |
| 2362 | return -ENOENT; // No such service |
| 2363 | } |
| 2364 | |
| 2365 | if(svc->ResolveInterface(interface, strchr(path, '/') + 1)){ |
| 2366 | return -ENOENT; // No such interface |
| 2367 | } |
| 2368 | } |
| 2369 | |
| 2370 | FancyRefPtr<MessageEndpoint> endp = interface->Connect(); |
| 2371 | if(!endp.get()){ |
| 2372 | return -EINVAL; // Some error connecting, interface destroyed? |
| 2373 | } |
| 2374 | |
| 2375 | Handle& handle = Scheduler::RegisterHandle(currentProcess, static_pointer_cast<KernelObject>(endp)); |
| 2376 | |
| 2377 | return handle.id; |
| 2378 | } |
| 2379 | |
| 2380 | ///////////////////////////// |
| 2381 | /// \brief SysEndpointQueue (endpoint, id, size, data) - Queue a message on an endpoint |
nothing calls this directly
no test coverage detected