From 5730097296283354082fc597a9421252aedc6b1c Mon Sep 17 00:00:00 2001 From: Shell Date: Mon, 15 Apr 2024 18:24:19 +0800 Subject: [PATCH] [smart] fixup devfs porting layer of terminal (#8797) Signed-off-by: Shell --- components/lwp/lwp.c | 4 ++-- components/lwp/terminal/freebsd/tty_pts.c | 4 ++-- components/lwp/terminal/tty_ptmx.c | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/components/lwp/lwp.c b/components/lwp/lwp.c index f923c91817..87629cc890 100644 --- a/components/lwp/lwp.c +++ b/components/lwp/lwp.c @@ -176,7 +176,7 @@ static int lwp_startup(void) else { rt_lwp_t p = lwp_from_pid_locked(1); - p->sig_protected = 0; + p->sig_protected = 1; error = 0; } @@ -186,7 +186,7 @@ static int lwp_startup(void) if (error) { - LOG_E("%s: init program not found\n" + LOG_D("%s: init program not found\n" "Switching to legacy mode...", __func__); } return error; diff --git a/components/lwp/terminal/freebsd/tty_pts.c b/components/lwp/terminal/freebsd/tty_pts.c index 2c75ff3009..d25e668d86 100644 --- a/components/lwp/terminal/freebsd/tty_pts.c +++ b/components/lwp/terminal/freebsd/tty_pts.c @@ -803,13 +803,13 @@ int pts_alloc(int fflags, struct rt_thread *td, struct dfs_file *ptm_file) #else rootpath = ptyfs_get_rootpath(ptmx_device); RT_ASSERT(rootpath[strlen(rootpath) - 1] != '/'); - snprintf(name_buf, DIRENT_NAME_MAX, "%s/%u", rootpath, psc->pts_unit); + snprintf(name_buf, DIRENT_NAME_MAX, "%s/%d", rootpath, psc->pts_unit); /* setup the pts */ lwp_tty_register(tp, name_buf); /* now this file operating on new pty */ - ptm_file->vnode->data = tp; + ptm_file->data = tp; #endif return 0; diff --git a/components/lwp/terminal/tty_ptmx.c b/components/lwp/terminal/tty_ptmx.c index 4158292251..8daebc099a 100644 --- a/components/lwp/terminal/tty_ptmx.c +++ b/components/lwp/terminal/tty_ptmx.c @@ -60,7 +60,7 @@ static int ptm_fops_close(struct dfs_file *file) lwp_tty_t tp; rt_device_t device; - if (file->vnode && file->vnode->data) + if (file->data) { if (file->vnode->ref_count != 1) { @@ -68,7 +68,7 @@ static int ptm_fops_close(struct dfs_file *file) } else { - device = (rt_device_t)file->vnode->data; + device = (rt_device_t)file->data; tp = rt_container_of(device, struct lwp_tty, parent); rc = bsd_ptsdev_methods.fo_close(tp, rt_thread_self()); } @@ -92,9 +92,9 @@ static ssize_t ptm_fops_read(struct dfs_file *file, void *buf, size_t count, struct lwp_tty *tp; int oflags = file->flags; - if (file->vnode && file->vnode->data) + if (file->data) { - device = (rt_device_t)file->vnode->data; + device = (rt_device_t)file->data; tp = rt_container_of(device, struct lwp_tty, parent); /* setup uio parameters */ @@ -133,9 +133,9 @@ static ssize_t ptm_fops_write(struct dfs_file *file, const void *buf, struct lwp_tty *tp; int oflags = file->flags; - if (file->vnode && file->vnode->data) + if (file->data) { - device = (rt_device_t)file->vnode->data; + device = (rt_device_t)file->data; tp = rt_container_of(device, struct lwp_tty, parent); /* setup uio parameters */ @@ -172,9 +172,9 @@ static int ptm_fops_ioctl(struct dfs_file *file, int cmd, void *arg) rt_device_t device; rt_ubase_t cmd_normal = (unsigned int)cmd; - if (file->vnode && file->vnode->data) + if (file->data) { - device = (rt_device_t)file->vnode->data; + device = (rt_device_t)file->data; tp = rt_container_of(device, struct lwp_tty, parent); switch (cmd_normal) @@ -239,9 +239,9 @@ static int ptm_fops_poll(struct dfs_file *file, struct rt_pollreq *req) rt_device_t device; struct lwp_tty *tp; - if (file->vnode && file->vnode->data) + if (file->data) { - device = (rt_device_t)file->vnode->data; + device = (rt_device_t)file->data; tp = rt_container_of(device, struct lwp_tty, parent); rc = bsd_ptsdev_methods.fo_poll(tp, req, 0, rt_thread_self());