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

Function SysInterfaceConnect

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

//////////////////////// \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 ////////////////////////

Source from the content-addressed store, hash-verified

2339/// \return Handle ID of endpoint on success, negative error code on failure
2340/////////////////////////////
2341long 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

Callers

nothing calls this directly

Calls 9

GetCurrentProcessFunction · 0.85
strlenSafeFunction · 0.85
strncpyFunction · 0.85
strchrFunction · 0.85
WarningFunction · 0.85
ResolveServiceNameMethod · 0.80
ResolveInterfaceMethod · 0.80
ConnectMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected