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

Function lwp_channel_open

components/lwp/lwp_ipc.c:1081–1121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1079};
1080
1081int lwp_channel_open(int fdt_type, const char *name, int flags)
1082{
1083 int fd;
1084 rt_channel_t ch = RT_NULL;
1085 struct dfs_file *d;
1086
1087 fd = _chfd_alloc(fdt_type); /* allocate an IPC channel descriptor */
1088 if (fd == -1)
1089 {
1090 goto quit;
1091 }
1092
1093 d = lwp_fd_get(fdt_type, fd);
1094 d->vnode = (struct dfs_vnode *)rt_malloc(sizeof(struct dfs_vnode));
1095 if (!d->vnode)
1096 {
1097 _chfd_free(fd, fdt_type);
1098 fd = -1;
1099 goto quit;
1100 }
1101
1102 ch = rt_raw_channel_open(name, flags);
1103 if (ch)
1104 {
1105 /* initialize vnode */
1106 dfs_vnode_init(d->vnode, FT_USER, &channel_fops);
1107 d->flags = O_RDWR; /* set flags as read and write */
1108
1109 /* set socket to the data of dfs_file */
1110 d->vnode->data = (void *)ch;
1111 }
1112 else
1113 {
1114 rt_free(d->vnode);
1115 d->vnode = RT_NULL;
1116 _chfd_free(fd, fdt_type);
1117 fd = -1;
1118 }
1119quit:
1120 return fd;
1121}
1122
1123static rt_channel_t fd_2_channel(int fdt_type, int fd)
1124{

Callers 2

rt_channel_openFunction · 0.85
sys_channel_openFunction · 0.85

Calls 7

_chfd_allocFunction · 0.85
lwp_fd_getFunction · 0.85
rt_mallocFunction · 0.85
_chfd_freeFunction · 0.85
rt_raw_channel_openFunction · 0.85
rt_freeFunction · 0.85
dfs_vnode_initFunction · 0.50

Tested by

no test coverage detected