From e03370f6ef4c13286c0c5aaead710cf195cd2cd7 Mon Sep 17 00:00:00 2001 From: mucor Date: Thu, 6 May 2021 19:41:57 +0800 Subject: [PATCH] fix:telnet not work add open in console dev init process Change-Id: Ibf9801462d6de231001f094d4e75f01cad50da1f --- kernel/common/console.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kernel/common/console.c b/kernel/common/console.c index 3c929b57..8459d9cc 100644 --- a/kernel/common/console.c +++ b/kernel/common/console.c @@ -1005,6 +1005,7 @@ STATIC INT32 OsConsoleDevInit(CONSOLE_CB *consoleCB, const CHAR *deviceName) INT32 ret; struct file *filep = NULL; struct Vnode *vnode = NULL; + struct file_operations_vfs *devOps = NULL; /* allocate memory for filep,in order to unchange the value of filep */ filep = (struct file *)LOS_MemAlloc(m_aucSysMem0, sizeof(struct file)); @@ -1040,6 +1041,13 @@ STATIC INT32 OsConsoleDevInit(CONSOLE_CB *consoleCB, const CHAR *deviceName) * Use filep to connect console and uart, we can find uart driver function throught filep. * now we can operate /dev/console to operate /dev/ttyS0 through filep. */ + devOps = (struct file_operations_vfs *)((struct drv_data*)vnode->data)->ops; + if (devOps != NULL && devOps->open != NULL) { + (VOID)devOps->open(filep); + } else { + ret = ENOSYS; + goto ERROUT; + } ret = register_driver(consoleCB->name, &g_consoleDevOps, DEFFILEMODE, filep); if (ret != LOS_OK) { @@ -1204,7 +1212,7 @@ STATIC CONSOLE_CB *OsConsoleCreate(UINT32 consoleID, const CHAR *deviceName) ret = OsConsoleDevInit(consoleCB, deviceName); if (ret != LOS_OK) { - PRINT_ERR("console OsConsoleDevInitlloc error. %d\n", ret); + PRINT_ERR("console OsConsoleDevInit error. %d\n", ret); goto ERR_WITH_SEM; } -- GitLab