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

Function lwp_ptmx_init

components/lwp/terminal/tty_ptmx.c:279–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277};
278
279rt_err_t lwp_ptmx_init(rt_device_t ptmx_device, const char *root_path)
280{
281 char *device_name;
282 int root_len;
283 const char *dev_rel_path;
284 rt_err_t rc;
285
286 root_len = strlen(root_path);
287 dev_rel_path = "/ptmx";
288 device_name = rt_malloc(root_len + sizeof("/ptmx"));
289
290 if (device_name)
291 {
292 /* Register device */
293 sprintf(device_name, "%s%s", root_path, dev_rel_path);
294 rt_device_register(ptmx_device, device_name, 0);
295
296 /* Setup fops */
297 ptmx_device->fops = &ptm_fops;
298
299 rt_free(device_name);
300
301 rc = RT_EOK;
302 }
303 else
304 {
305 rc = -RT_ENOMEM;
306 }
307
308 return rc;
309}
310
311/* system level ptmx */
312static struct rt_device sysptmx;

Callers 1

ptyfs_ops_mountFunction · 0.85

Calls 3

rt_mallocFunction · 0.85
rt_device_registerFunction · 0.85
rt_freeFunction · 0.85

Tested by

no test coverage detected