MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sys_channel_open

Function sys_channel_open

components/lwp/lwp_syscall.c:4065–4094  ·  view source on GitHub ↗

* @brief Opens a communication channel. * * This system call is used to open a communication channel with a specified name and set of flags. * The channel allows for inter-process or inter-thread communication, depending on the underlying system. * The `name` parameter specifies the name of the channel, while the `flags` parameter allows * configuration of the channel's behavior (e.g., read/w

Source from the content-addressed store, hash-verified

4063 * as improper configuration might lead to access issues, data loss, or undefined behavior.
4064 */
4065sysret_t sys_channel_open(const char *name, int flags)
4066{
4067 rt_size_t ret = 0;
4068 char *kname = RT_NULL;
4069 int len = 0;
4070
4071 len = lwp_user_strlen(name);
4072 if (len <= 0)
4073 {
4074 return -EFAULT;
4075 }
4076
4077 kname = (char *)kmem_get(len + 1);
4078 if (!kname)
4079 {
4080 return -ENOMEM;
4081 }
4082
4083 if (lwp_get_from_user(kname, (void *)name, len + 1) != (len + 1))
4084 {
4085 kmem_put(kname);
4086 return -EFAULT;
4087 }
4088
4089 ret = lwp_channel_open(FDT_TYPE_LWP, kname, flags);
4090
4091 kmem_put(kname);
4092
4093 return ret;
4094}
4095
4096/**
4097 * @brief Closes an open communication channel.

Callers

nothing calls this directly

Calls 5

lwp_user_strlenFunction · 0.85
kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
kmem_putFunction · 0.85
lwp_channel_openFunction · 0.85

Tested by

no test coverage detected