提交 2dc24da8 编写于 作者: Y yinjiaming

fix: 内核告警清理

【背景】
内核代码经代码扫描工具发现存在一些关于代码格式的告警,
现经修改解除掉告警.

【修改方案】
修改了代码中格式不规范的地方,修改的点有:
1.代码中一行过长
2.没有合理的添加空格和空行
3.没有按照规范进行缩进
4.括号的格式没有按照规范
5.注释的格式不对以及存在魔数字
6.函数的声明与定义的格式不一致
并更新了修改文件的版权头时间

【影响】
对现有的产品编译不会有影响。

re #I5H6F5
Signed-off-by: Nyinjiaming <yinjiaming@huawei.com>
Change-Id: Ie46b5b3238fd88c25f99542b8ccd138b956c6458
上级 6302c5f7
...@@ -478,7 +478,6 @@ static int PthreadGetCputime(clockid_t clockID, struct timespec *ats) ...@@ -478,7 +478,6 @@ static int PthreadGetCputime(clockid_t clockID, struct timespec *ats)
uint64_t runtime; uint64_t runtime;
UINT32 intSave; UINT32 intSave;
UINT32 tid = GetTidFromClockID(clockID); UINT32 tid = GetTidFromClockID(clockID);
if (OS_TID_CHECK_INVALID(tid)) { if (OS_TID_CHECK_INVALID(tid)) {
return -EINVAL; return -EINVAL;
} }
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
extern "C"{ extern "C" {
#endif #endif
#endif /* __cplusplus */ #endif /* __cplusplus */
......
...@@ -343,7 +343,8 @@ static FRESULT init_cluster(DIR_FILE *pdfp, DIR *dp_new, FATFS *fs, int type, co ...@@ -343,7 +343,8 @@ static FRESULT init_cluster(DIR_FILE *pdfp, DIR *dp_new, FATFS *fs, int type, co
return FR_OK; return FR_OK;
} }
static int fatfs_create_obj(struct Vnode *parent, const char *name, int mode, struct Vnode **vpp, BYTE type, const char *target) static int fatfs_create_obj(struct Vnode *parent, const char *name, int mode, struct Vnode **vpp,
BYTE type, const char *target)
{ {
struct Vnode *vp = NULL; struct Vnode *vp = NULL;
FATFS *fs = (FATFS *)parent->originMount->data; FATFS *fs = (FATFS *)parent->originMount->data;
......
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
...@@ -244,7 +244,8 @@ extern int chattr(const char *pathname, struct IATTR *attr); ...@@ -244,7 +244,8 @@ extern int chattr(const char *pathname, struct IATTR *attr);
* *
* @retval #0 On success. * @retval #0 On success.
* @retval #-1 On failure with errno set. * @retval #-1 On failure with errno set.
* @retval CONTINE_NUTTX_FCNTL doesn't support some cmds in VfsFcntl, needs to continue going through Nuttx vfs operation.</li> * @retval CONTINE_NUTTX_FCNTL doesn't support some cmds in VfsFcntl, needs to continue going through
* Nuttx vfs operation.</li>
* *
* @par Dependency: * @par Dependency:
* <ul><li>fs.h</li></ul> * <ul><li>fs.h</li></ul>
......
/* /*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2021-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
...@@ -682,7 +682,6 @@ int VfsJffs2Rmdir(struct Vnode *parentVnode, struct Vnode *targetVnode, const ch ...@@ -682,7 +682,6 @@ int VfsJffs2Rmdir(struct Vnode *parentVnode, struct Vnode *targetVnode, const ch
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER); LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
ret = jffs2_rmdir(parentInode, targetInode, (const unsigned char *)path); ret = jffs2_rmdir(parentInode, targetInode, (const unsigned char *)path);
if (ret == 0) { if (ret == 0) {
(void)jffs2_iput(targetInode); (void)jffs2_iput(targetInode);
} }
...@@ -809,7 +808,6 @@ int VfsJffs2Unlink(struct Vnode *parentVnode, struct Vnode *targetVnode, const c ...@@ -809,7 +808,6 @@ int VfsJffs2Unlink(struct Vnode *parentVnode, struct Vnode *targetVnode, const c
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER); LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
ret = jffs2_unlink(parentInode, targetInode, (const unsigned char *)path); ret = jffs2_unlink(parentInode, targetInode, (const unsigned char *)path);
if (ret == 0) { if (ret == 0) {
(void)jffs2_iput(targetInode); (void)jffs2_iput(targetInode);
} }
......
/* /*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2021-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
...@@ -154,7 +154,8 @@ static int FsCacheInfoFill(struct SeqBuf *buf, void *arg) ...@@ -154,7 +154,8 @@ static int FsCacheInfoFill(struct SeqBuf *buf, void *arg)
VnodeHold(); VnodeHold();
LosBufPrintf(buf, "\n=================================================================\n"); LosBufPrintf(buf, "\n=================================================================\n");
LosBufPrintf(buf, "VnodeAddr ParentAddr DataAddr VnodeOps Hash Ref Type Gid Uid Mode\n"); LosBufPrintf(buf,
"VnodeAddr ParentAddr DataAddr VnodeOps Hash Ref Type Gid Uid Mode\n");
vnodeVirtual = VnodeListProcess(buf, GetVnodeVirtualList()); vnodeVirtual = VnodeListProcess(buf, GetVnodeVirtualList());
vnodeFree = VnodeListProcess(buf, GetVnodeFreeList()); vnodeFree = VnodeListProcess(buf, GetVnodeFreeList());
vnodeActive = VnodeListProcess(buf, GetVnodeActiveList()); vnodeActive = VnodeListProcess(buf, GetVnodeActiveList());
......
...@@ -62,8 +62,8 @@ int OsShellCmdWriteProc(int argc, char **argv) ...@@ -62,8 +62,8 @@ int OsShellCmdWriteProc(int argc, char **argv)
if (argc == WRITEPROC_ARGC) { if (argc == WRITEPROC_ARGC) {
value = argv[0]; value = argv[0];
path = argv[2]; path = argv[2]; // 2: index of path
len = strlen(value) + 1; /* +1:add the \0 */ len = strlen(value) + 1; /* + 1:add the \0 */
if (strncmp(argv[1], ">>", strlen(">>")) == 0) { if (strncmp(argv[1], ">>", strlen(">>")) == 0) {
if ((realpath(path, realPath) == NULL) || (strncmp(realPath, rootProcDir, strlen(rootProcDir)) != 0)) { if ((realpath(path, realPath) == NULL) || (strncmp(realPath, rootProcDir, strlen(rootProcDir)) != 0)) {
PRINT_ERR("No such file or directory\n"); PRINT_ERR("No such file or directory\n");
......
/* /*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2021-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
...@@ -304,7 +304,7 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout ...@@ -304,7 +304,7 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout
int pollSize; int pollSize;
epHead = EpollGetDataBuff(epfd); epHead = EpollGetDataBuff(epfd);
if (epHead== NULL) { if (epHead == NULL) {
set_errno(EBADF); set_errno(EBADF);
return -1; return -1;
} }
......
...@@ -225,7 +225,6 @@ static char *vfs_normalize_fullpath(const char *directory, const char *filename, ...@@ -225,7 +225,6 @@ static char *vfs_normalize_fullpath(const char *directory, const char *filename,
/* it's a absolute path, use it directly */ /* it's a absolute path, use it directly */
fullpath = strdup(filename); /* copy string */ fullpath = strdup(filename); /* copy string */
if (fullpath == NULL) { if (fullpath == NULL) {
*pathname = NULL; *pathname = NULL;
set_errno(ENOMEM); set_errno(ENOMEM);
...@@ -258,8 +257,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn ...@@ -258,8 +257,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn
} }
#ifdef VFS_USING_WORKDIR #ifdef VFS_USING_WORKDIR
if (directory == NULL) if (directory == NULL) {
{
spin_lock_irqsave(&curr->files->workdir_lock, lock_flags); spin_lock_irqsave(&curr->files->workdir_lock, lock_flags);
directory = curr->files->workdir; directory = curr->files->workdir;
} }
...@@ -275,8 +273,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn ...@@ -275,8 +273,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn
if ((filename[0] != '/') && (strlen(directory) + namelen + 2 > TEMP_PATH_MAX)) { if ((filename[0] != '/') && (strlen(directory) + namelen + 2 > TEMP_PATH_MAX)) {
#ifdef VFS_USING_WORKDIR #ifdef VFS_USING_WORKDIR
if (dir_flags == TRUE) if (dir_flags == TRUE) {
{
spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags); spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags);
} }
#endif #endif
...@@ -285,8 +282,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn ...@@ -285,8 +282,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn
fullpath = vfs_normalize_fullpath(directory, filename, pathname, namelen); fullpath = vfs_normalize_fullpath(directory, filename, pathname, namelen);
#ifdef VFS_USING_WORKDIR #ifdef VFS_USING_WORKDIR
if (dir_flags == TRUE) if (dir_flags == TRUE) {
{
spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags); spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags);
} }
#endif #endif
...@@ -308,7 +304,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn ...@@ -308,7 +304,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn
int vfs_normalize_pathat(int dirfd, const char *filename, char **pathname) int vfs_normalize_pathat(int dirfd, const char *filename, char **pathname)
{ {
/* Get path by dirfd*/ /* Get path by dirfd */
char *relativeoldpath = NULL; char *relativeoldpath = NULL;
char *fullpath = NULL; char *fullpath = NULL;
int ret = 0; int ret = 0;
......
...@@ -155,7 +155,6 @@ int chdir(const char *path) ...@@ -155,7 +155,6 @@ int chdir(const char *path)
char *fullpath_bak = NULL; char *fullpath_bak = NULL;
struct stat statBuff; struct stat statBuff;
if (!path) { if (!path) {
set_errno(EFAULT); set_errno(EFAULT);
return -1; return -1;
......
...@@ -57,7 +57,6 @@ int utime(const char *path, const struct utimbuf *ptimes) ...@@ -57,7 +57,6 @@ int utime(const char *path, const struct utimbuf *ptimes)
/* Sanity checks */ /* Sanity checks */
if (path == NULL) { if (path == NULL) {
ret = -EINVAL; ret = -EINVAL;
goto errout; goto errout;
......
...@@ -53,8 +53,7 @@ ...@@ -53,8 +53,7 @@
#include <ctype.h> #include <ctype.h>
#include "fs/fs_operation.h" #include "fs/fs_operation.h"
typedef enum typedef enum {
{
RM_RECURSIVER, RM_RECURSIVER,
RM_FILE, RM_FILE,
RM_DIR, RM_DIR,
...@@ -63,15 +62,12 @@ typedef enum ...@@ -63,15 +62,12 @@ typedef enum
} wildcard_type; } wildcard_type;
#define ERROR_OUT_IF(condition, message_function, handler) \ #define ERROR_OUT_IF(condition, message_function, handler) \
do \ do { \
{ \ if (condition) { \
if (condition) \
{ \
message_function; \ message_function; \
handler; \ handler; \
} \ } \
} \ } while (0)
while (0)
static inline void set_err(int errcode, const char *err_message) static inline void set_err(int errcode, const char *err_message)
{ {
...@@ -85,13 +81,11 @@ int osShellCmdDoChdir(const char *path) ...@@ -85,13 +81,11 @@ int osShellCmdDoChdir(const char *path)
char *fullpath_bak = NULL; char *fullpath_bak = NULL;
int ret; int ret;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
if (path == NULL) if (path == NULL) {
{
LOS_TaskLock(); LOS_TaskLock();
PRINTK("%s\n", shell_working_directory); PRINTK("%s\n", shell_working_directory);
LOS_TaskUnlock(); LOS_TaskUnlock();
...@@ -106,8 +100,7 @@ int osShellCmdDoChdir(const char *path) ...@@ -106,8 +100,7 @@ int osShellCmdDoChdir(const char *path)
fullpath_bak = fullpath; fullpath_bak = fullpath;
ret = chdir(fullpath); ret = chdir(fullpath);
if (ret < 0) if (ret < 0) {
{
free(fullpath_bak); free(fullpath_bak);
perror("cd"); perror("cd");
return -1; return -1;
...@@ -117,8 +110,7 @@ int osShellCmdDoChdir(const char *path) ...@@ -117,8 +110,7 @@ int osShellCmdDoChdir(const char *path)
LOS_TaskLock(); LOS_TaskLock();
ret = strncpy_s(shell_working_directory, PATH_MAX, fullpath, strlen(fullpath)); ret = strncpy_s(shell_working_directory, PATH_MAX, fullpath, strlen(fullpath));
if (ret != EOK) if (ret != EOK) {
{
free(fullpath_bak); free(fullpath_bak);
LOS_TaskUnlock(); LOS_TaskUnlock();
return -1; return -1;
...@@ -137,15 +129,13 @@ int osShellCmdLs(int argc, const char **argv) ...@@ -137,15 +129,13 @@ int osShellCmdLs(int argc, const char **argv)
const char *filename = NULL; const char *filename = NULL;
int ret; int ret;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
ERROR_OUT_IF(argc > 1, PRINTK("ls or ls [DIRECTORY]\n"), return -1); ERROR_OUT_IF(argc > 1, PRINTK("ls or ls [DIRECTORY]\n"), return -1);
if (argc == 0) if (argc == 0) {
{
ls(shell_working_directory); ls(shell_working_directory);
return 0; return 0;
} }
...@@ -162,8 +152,7 @@ int osShellCmdLs(int argc, const char **argv) ...@@ -162,8 +152,7 @@ int osShellCmdLs(int argc, const char **argv)
int osShellCmdCd(int argc, const char **argv) int osShellCmdCd(int argc, const char **argv)
{ {
if (argc == 0) if (argc == 0) {
{
(void)osShellCmdDoChdir("/"); (void)osShellCmdDoChdir("/");
return 0; return 0;
} }
...@@ -189,35 +178,28 @@ int osShellCmdDoCatShow(UINTPTR arg) ...@@ -189,35 +178,28 @@ int osShellCmdDoCatShow(UINTPTR arg)
(void)pthread_mutex_lock(&g_mutex_cat); (void)pthread_mutex_lock(&g_mutex_cat);
ini = fopen(fullpath, "r"); ini = fopen(fullpath, "r");
if (ini == NULL) if (ini == NULL) {
{
ret = -1; ret = -1;
perror("cat error"); perror("cat error");
goto out; goto out;
} }
do do {
{
(void)memset_s(buf, sizeof(buf), 0, CAT_BUF_SIZE); (void)memset_s(buf, sizeof(buf), 0, CAT_BUF_SIZE);
size = fread(buf, 1, CAT_BUF_SIZE, ini); size = fread(buf, 1, CAT_BUF_SIZE, ini);
if ((int)size < 0) if ((int)size < 0) {
{
ret = -1; ret = -1;
perror("cat error"); perror("cat error");
goto out_with_fclose; goto out_with_fclose;
} }
for (toWrite = size, written = 0; toWrite > 0;) for (toWrite = size, written = 0; toWrite > 0;) {
{
cnt = write(1, buf + written, toWrite); cnt = write(1, buf + written, toWrite);
if (cnt == 0) if (cnt == 0) {
{
/* avoid task-starvation */ /* avoid task-starvation */
(void)LOS_TaskDelay(1); (void)LOS_TaskDelay(1);
continue; continue;
} } else if (cnt < 0) {
else if (cnt < 0)
{
perror("cat write error"); perror("cat write error");
break; break;
} }
...@@ -244,8 +226,7 @@ int osShellCmdCat(int argc, const char **argv) ...@@ -244,8 +226,7 @@ int osShellCmdCat(int argc, const char **argv)
struct Vnode *vnode = NULL; struct Vnode *vnode = NULL;
TSK_INIT_PARAM_S init_param; TSK_INIT_PARAM_S init_param;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
...@@ -256,16 +237,14 @@ int osShellCmdCat(int argc, const char **argv) ...@@ -256,16 +237,14 @@ int osShellCmdCat(int argc, const char **argv)
VnodeHold(); VnodeHold();
ret = VnodeLookup(fullpath, &vnode, O_RDONLY); ret = VnodeLookup(fullpath, &vnode, O_RDONLY);
if (ret != LOS_OK) if (ret != LOS_OK) {
{
set_errno(-ret); set_errno(-ret);
perror("cat error"); perror("cat error");
VnodeDrop(); VnodeDrop();
free(fullpath); free(fullpath);
return -1; return -1;
} }
if (vnode->type != VNODE_TYPE_REG) if (vnode->type != VNODE_TYPE_REG) {
{
set_errno(EINVAL); set_errno(EINVAL);
perror("cat error"); perror("cat error");
VnodeDrop(); VnodeDrop();
...@@ -283,9 +262,7 @@ int osShellCmdCat(int argc, const char **argv) ...@@ -283,9 +262,7 @@ int osShellCmdCat(int argc, const char **argv)
init_param.processID = 2; /* 2: kProcess */ init_param.processID = 2; /* 2: kProcess */
ret = (int)LOS_TaskCreate(&ca_task, &init_param); ret = (int)LOS_TaskCreate(&ca_task, &init_param);
if (ret != LOS_OK) {
if (ret != LOS_OK)
{
free(fullpath); free(fullpath);
} }
...@@ -330,42 +307,34 @@ int osShellCmdMount(int argc, const char **argv) ...@@ -330,42 +307,34 @@ int osShellCmdMount(int argc, const char **argv)
char *filessystemtype = NULL; char *filessystemtype = NULL;
unsigned long mountfalgs; unsigned long mountfalgs;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
ERROR_OUT_IF(argc < 3, print_mount_usage(), return OS_FAIL); ERROR_OUT_IF(argc < 3, print_mount_usage(), return OS_FAIL);
if (strncmp(argv[0], "-t", 2) == 0 || strncmp(argv[0], "-o", 2) == 0) if (strncmp(argv[0], "-t", 2) == 0 || strncmp(argv[0], "-o", 2) == 0) // 2: length of "-t"
{
if (argc < 4)
{ {
if (argc < 4) { // 4: required number of parameters
PRINTK("mount -t/-o [DEVICE] [PATH] [NAME]\n"); PRINTK("mount -t/-o [DEVICE] [PATH] [NAME]\n");
return -1; return -1;
} }
filename = argv[2]; filename = argv[2]; // 2: index of file path
ret = vfs_normalize_path(shell_working_directory, filename, &fullpath); ret = vfs_normalize_path(shell_working_directory, filename, &fullpath);
ERROR_OUT_IF(ret < 0, set_err(-ret, "mount error"), return -1); ERROR_OUT_IF(ret < 0, set_err(-ret, "mount error"), return -1);
if (strncmp(argv[3], "nfs", 3) == 0) if (strncmp(argv[3], "nfs", 3) == 0) { // 3: index of fs type
{ if (argc <= 6) { // 6: arguments include uid or gid
if (argc <= 6)
{
uid = ((argc >= 5) && (argv[4] != NULL)) ? (unsigned int)strtoul(argv[4], (char **)NULL, 0) : 0; uid = ((argc >= 5) && (argv[4] != NULL)) ? (unsigned int)strtoul(argv[4], (char **)NULL, 0) : 0;
gid = ((argc == 6) && (argv[5] != NULL)) ? (unsigned int)strtoul(argv[5], (char **)NULL, 0) : 0; gid = ((argc == 6) && (argv[5] != NULL)) ? (unsigned int)strtoul(argv[5], (char **)NULL, 0) : 0;
if (nfs_mount_ref != NULL) if (nfs_mount_ref != NULL) {
{
ret = nfs_mount_ref(argv[1], fullpath, uid, gid); ret = nfs_mount_ref(argv[1], fullpath, uid, gid);
if (ret != LOS_OK) if (ret != LOS_OK) {
{
PRINTK("mount -t [DEVICE] [PATH] [NAME]\n"); PRINTK("mount -t [DEVICE] [PATH] [NAME]\n");
} }
} } else {
else
{
PRINTK("can't find nfs_mount\n"); PRINTK("can't find nfs_mount\n");
} }
free(fullpath); free(fullpath);
...@@ -373,50 +342,36 @@ int osShellCmdMount(int argc, const char **argv) ...@@ -373,50 +342,36 @@ int osShellCmdMount(int argc, const char **argv)
} }
} }
filessystemtype = (argc >= 4) ? (char *)argv[3] : NULL; /* 3: fs type */ filessystemtype = (argc >= 4) ? (char *)argv[3] : NULL; /* 4: specify fs type, 3: fs type */
mountfalgs = (argc >= 5) ? get_mountflags((const char *)argv[4]) : 0; /* 4: usr option */ mountfalgs = (argc >= 5) ? get_mountflags((const char *)argv[4]) : 0; /* 4: usr option */
data = (argc >= 6) ? (char *)argv[5] : NULL; /* 5: usr option data */ data = (argc >= 6) ? (char *)argv[5] : NULL; /* 5: usr option data */
if (strcmp(argv[1], "0") == 0) if (strcmp(argv[1], "0") == 0) {
{
ret = mount((const char *)NULL, fullpath, filessystemtype, mountfalgs, data); ret = mount((const char *)NULL, fullpath, filessystemtype, mountfalgs, data);
} } else {
else
{
ret = mount(argv[1], fullpath, filessystemtype, mountfalgs, data); /* 3: fs type */ ret = mount(argv[1], fullpath, filessystemtype, mountfalgs, data); /* 3: fs type */
} }
if (ret != LOS_OK) if (ret != LOS_OK) {
{
perror("mount error"); perror("mount error");
} } else {
else
{
PRINTK("mount ok\n"); PRINTK("mount ok\n");
} }
} } else {
else
{
filename = argv[1]; filename = argv[1];
ret = vfs_normalize_path(shell_working_directory, filename, &fullpath); ret = vfs_normalize_path(shell_working_directory, filename, &fullpath);
ERROR_OUT_IF(ret < 0, set_err(-ret, "mount error"), return -1); ERROR_OUT_IF(ret < 0, set_err(-ret, "mount error"), return -1);
if (strncmp(argv[2], "nfs", 3) == 0) if (strncmp(argv[2], "nfs", 3) == 0) { // 2: index of fs type, 3: length of "nfs"
{ if (argc <= 5) { // 5: arguments include gid and uid
if (argc <= 5)
{
uid = ((argc >= 4) && (argv[3] != NULL)) ? (unsigned int)strtoul(argv[3], (char **)NULL, 0) : 0; uid = ((argc >= 4) && (argv[3] != NULL)) ? (unsigned int)strtoul(argv[3], (char **)NULL, 0) : 0;
gid = ((argc == 5) && (argv[4] != NULL)) ? (unsigned int)strtoul(argv[4], (char **)NULL, 0) : 0; gid = ((argc == 5) && (argv[4] != NULL)) ? (unsigned int)strtoul(argv[4], (char **)NULL, 0) : 0;
if (nfs_mount_ref != NULL) if (nfs_mount_ref != NULL) {
{
ret = nfs_mount_ref(argv[0], fullpath, uid, gid); ret = nfs_mount_ref(argv[0], fullpath, uid, gid);
if (ret != LOS_OK) if (ret != LOS_OK) {
{
PRINTK("mount [DEVICE] [PATH] [NAME]\n"); PRINTK("mount [DEVICE] [PATH] [NAME]\n");
} }
} } else {
else
{
PRINTK("can't find nfs_mount\n"); PRINTK("can't find nfs_mount\n");
} }
free(fullpath); free(fullpath);
...@@ -431,20 +386,14 @@ int osShellCmdMount(int argc, const char **argv) ...@@ -431,20 +386,14 @@ int osShellCmdMount(int argc, const char **argv)
mountfalgs = (argc >= 4) ? get_mountflags((const char *)argv[3]) : 0; /* 3: usr option */ mountfalgs = (argc >= 4) ? get_mountflags((const char *)argv[3]) : 0; /* 3: usr option */
data = (argc >= 5) ? (char *)argv[4] : NULL; /* 4: usr option data */ data = (argc >= 5) ? (char *)argv[4] : NULL; /* 4: usr option data */
if (strcmp(argv[0], "0") == 0) if (strcmp(argv[0], "0") == 0) {
{
ret = mount((const char *)NULL, fullpath, argv[2], mountfalgs, data); ret = mount((const char *)NULL, fullpath, argv[2], mountfalgs, data);
} } else {
else
{
ret = mount(argv[0], fullpath, argv[2], mountfalgs, data); /* 2: fs type */ ret = mount(argv[0], fullpath, argv[2], mountfalgs, data); /* 2: fs type */
} }
if (ret != LOS_OK) if (ret != LOS_OK) {
{
perror("mount error"); perror("mount error");
} } else {
else
{
PRINTK("mount ok\n"); PRINTK("mount ok\n");
} }
} }
...@@ -462,8 +411,7 @@ int osShellCmdUmount(int argc, const char **argv) ...@@ -462,8 +411,7 @@ int osShellCmdUmount(int argc, const char **argv)
int cmp_num; int cmp_num;
char *work_path = NULL; char *work_path = NULL;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
work_path = shell_working_directory; work_path = shell_working_directory;
...@@ -477,11 +425,9 @@ int osShellCmdUmount(int argc, const char **argv) ...@@ -477,11 +425,9 @@ int osShellCmdUmount(int argc, const char **argv)
target_path = fullpath; target_path = fullpath;
cmp_num = strlen(fullpath); cmp_num = strlen(fullpath);
ret = strncmp(work_path, target_path, cmp_num); ret = strncmp(work_path, target_path, cmp_num);
if (ret == 0) if (ret == 0) {
{
work_path += cmp_num; work_path += cmp_num;
if (*work_path == '/' || *work_path == '\0') if (*work_path == '/' || *work_path == '\0') {
{
set_errno(EBUSY); set_errno(EBUSY);
perror("umount error"); perror("umount error");
free(fullpath); free(fullpath);
...@@ -491,8 +437,7 @@ int osShellCmdUmount(int argc, const char **argv) ...@@ -491,8 +437,7 @@ int osShellCmdUmount(int argc, const char **argv)
ret = umount(fullpath); ret = umount(fullpath);
free(fullpath); free(fullpath);
if (ret != LOS_OK) if (ret != LOS_OK) {
{
perror("umount error"); perror("umount error");
return 0; return 0;
} }
...@@ -507,8 +452,7 @@ int osShellCmdMkdir(int argc, const char **argv) ...@@ -507,8 +452,7 @@ int osShellCmdMkdir(int argc, const char **argv)
char *fullpath = NULL; char *fullpath = NULL;
const char *filename = NULL; const char *filename = NULL;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
...@@ -519,8 +463,7 @@ int osShellCmdMkdir(int argc, const char **argv) ...@@ -519,8 +463,7 @@ int osShellCmdMkdir(int argc, const char **argv)
ERROR_OUT_IF(ret < 0, set_err(-ret, "mkdir error"), return -1); ERROR_OUT_IF(ret < 0, set_err(-ret, "mkdir error"), return -1);
ret = mkdir(fullpath, S_IRWXU | S_IRWXG | S_IRWXO); ret = mkdir(fullpath, S_IRWXU | S_IRWXG | S_IRWXO);
if (ret == -1) if (ret == -1) {
{
perror("mkdir error"); perror("mkdir error");
} }
free(fullpath); free(fullpath);
...@@ -532,23 +475,20 @@ int osShellCmdPwd(int argc, const char **argv) ...@@ -532,23 +475,20 @@ int osShellCmdPwd(int argc, const char **argv)
char buf[SHOW_MAX_LEN] = {0}; char buf[SHOW_MAX_LEN] = {0};
DIR *dir = NULL; DIR *dir = NULL;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
ERROR_OUT_IF(argc > 0, PRINTK("\nUsage: pwd\n"), return -1); ERROR_OUT_IF(argc > 0, PRINTK("\nUsage: pwd\n"), return -1);
dir = opendir(shell_working_directory); dir = opendir(shell_working_directory);
if (dir == NULL) if (dir == NULL) {
{
perror("pwd error"); perror("pwd error");
return -1; return -1;
} }
LOS_TaskLock(); LOS_TaskLock();
if (strncpy_s(buf, SHOW_MAX_LEN, shell_working_directory, SHOW_MAX_LEN - 1) != EOK) if (strncpy_s(buf, SHOW_MAX_LEN, shell_working_directory, SHOW_MAX_LEN - 1) != EOK) {
{
LOS_TaskUnlock(); LOS_TaskUnlock();
PRINTK("pwd error: strncpy_s error!\n"); PRINTK("pwd error: strncpy_s error!\n");
(void)closedir(dir); (void)closedir(dir);
...@@ -578,8 +518,7 @@ int osShellCmdStatfs(int argc, const char **argv) ...@@ -578,8 +518,7 @@ int osShellCmdStatfs(int argc, const char **argv)
char *fullpath = NULL; char *fullpath = NULL;
const char *filename = NULL; const char *filename = NULL;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
...@@ -594,8 +533,7 @@ int osShellCmdStatfs(int argc, const char **argv) ...@@ -594,8 +533,7 @@ int osShellCmdStatfs(int argc, const char **argv)
result = statfs(fullpath, &sfs); result = statfs(fullpath, &sfs);
free(fullpath); free(fullpath);
if (result != 0 || sfs.f_type == 0) if (result != 0 || sfs.f_type == 0) {
{
PRINTK("statfs failed! Invalid argument!\n"); PRINTK("statfs failed! Invalid argument!\n");
print_statfs_usage(); print_statfs_usage();
return -1; return -1;
...@@ -619,8 +557,7 @@ int osShellCmdTouch(int argc, const char **argv) ...@@ -619,8 +557,7 @@ int osShellCmdTouch(int argc, const char **argv)
char *fullpath = NULL; char *fullpath = NULL;
const char *filename = NULL; const char *filename = NULL;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
...@@ -632,8 +569,7 @@ int osShellCmdTouch(int argc, const char **argv) ...@@ -632,8 +569,7 @@ int osShellCmdTouch(int argc, const char **argv)
fd = open(fullpath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); fd = open(fullpath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
free(fullpath); free(fullpath);
if (fd == -1) if (fd == -1) {
{
perror("touch error"); perror("touch error");
return -1; return -1;
} }
...@@ -660,14 +596,12 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename ...@@ -660,14 +596,12 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename
struct stat stat_buf; struct stat stat_buf;
mode_t src_mode; mode_t src_mode;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
buf = (char *)malloc(CP_BUF_SIZE); buf = (char *)malloc(CP_BUF_SIZE);
if (buf == NULL) if (buf == NULL) {
{
PRINTK("cp error: Out of memory!\n"); PRINTK("cp error: Out of memory!\n");
return -1; return -1;
} }
...@@ -675,8 +609,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename ...@@ -675,8 +609,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename
/* Get source fullpath. */ /* Get source fullpath. */
ret = vfs_normalize_path(shell_working_directory, src_filepath, &src_fullpath); ret = vfs_normalize_path(shell_working_directory, src_filepath, &src_fullpath);
if (ret < 0) if (ret < 0) {
{
set_errno(-ret); set_errno(-ret);
PRINTK("cp error: %s\n", strerror(errno)); PRINTK("cp error: %s\n", strerror(errno));
free(buf); free(buf);
...@@ -686,16 +619,14 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename ...@@ -686,16 +619,14 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename
/* Is source path exist? */ /* Is source path exist? */
ret = stat(src_fullpath, &stat_buf); ret = stat(src_fullpath, &stat_buf);
if (ret == -1) if (ret == -1) {
{
PRINTK("cp %s error: %s\n", src_fullpath, strerror(errno)); PRINTK("cp %s error: %s\n", src_fullpath, strerror(errno));
goto errout_with_srcpath; goto errout_with_srcpath;
} }
src_mode = stat_buf.st_mode; src_mode = stat_buf.st_mode;
/* Is source path a directory? */ /* Is source path a directory? */
if (S_ISDIR(stat_buf.st_mode)) if (S_ISDIR(stat_buf.st_mode)) {
{
PRINTK("cp %s error: Source file can't be a directory.\n", src_fullpath); PRINTK("cp %s error: Source file can't be a directory.\n", src_fullpath);
goto errout_with_srcpath; goto errout_with_srcpath;
} }
...@@ -703,8 +634,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename ...@@ -703,8 +634,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename
/* Get dest fullpath. */ /* Get dest fullpath. */
dst_fullpath = strdup(dst_filename); dst_fullpath = strdup(dst_filename);
if (dst_fullpath == NULL) if (dst_fullpath == NULL) {
{
PRINTK("cp error: Out of memory.\n"); PRINTK("cp error: Out of memory.\n");
goto errout_with_srcpath; goto errout_with_srcpath;
} }
...@@ -712,20 +642,16 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename ...@@ -712,20 +642,16 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename
/* Is dest path exist? */ /* Is dest path exist? */
ret = stat(dst_fullpath, &stat_buf); ret = stat(dst_fullpath, &stat_buf);
if (ret == 0) if (ret == 0) {
{
/* Is dest path a directory? */ /* Is dest path a directory? */
if (S_ISDIR(stat_buf.st_mode)) if (S_ISDIR(stat_buf.st_mode)) {
{
/* Get source file name without '/'. */ /* Get source file name without '/'. */
src_filename = src_filepath; src_filename = src_filepath;
while (1) while (1) {
{
filename = strchr(src_filename, '/'); filename = strchr(src_filename, '/');
if (filename == NULL) if (filename == NULL) {
{
break; break;
} }
src_filename = filename + 1; src_filename = filename + 1;
...@@ -734,8 +660,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename ...@@ -734,8 +660,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename
/* Add the source file after dest path. */ /* Add the source file after dest path. */
ret = vfs_normalize_path(dst_fullpath, src_filename, &dst_filepath); ret = vfs_normalize_path(dst_fullpath, src_filename, &dst_filepath);
if (ret < 0) if (ret < 0) {
{
set_errno(-ret); set_errno(-ret);
PRINTK("cp error. %s.\n", strerror(errno)); PRINTK("cp error. %s.\n", strerror(errno));
goto errout_with_path; goto errout_with_path;
...@@ -747,8 +672,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename ...@@ -747,8 +672,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename
/* Is dest file same as source file? */ /* Is dest file same as source file? */
if (strcmp(src_fullpath, dst_fullpath) == 0) if (strcmp(src_fullpath, dst_fullpath) == 0) {
{
PRINTK("cp error: '%s' and '%s' are the same file\n", src_fullpath, dst_fullpath); PRINTK("cp error: '%s' and '%s' are the same file\n", src_fullpath, dst_fullpath);
goto errout_with_path; goto errout_with_path;
} }
...@@ -757,36 +681,30 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename ...@@ -757,36 +681,30 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename
(void)pthread_mutex_lock(&g_mutex_cp); (void)pthread_mutex_lock(&g_mutex_cp);
src_fd = open(src_fullpath, O_RDONLY); src_fd = open(src_fullpath, O_RDONLY);
if (src_fd < 0) if (src_fd < 0) {
{
PRINTK("cp error: can't open %s. %s.\n", src_fullpath, strerror(errno)); PRINTK("cp error: can't open %s. %s.\n", src_fullpath, strerror(errno));
goto errout_with_mutex; goto errout_with_mutex;
} }
dst_fd = open(dst_fullpath, O_CREAT | O_WRONLY | O_TRUNC, src_mode); dst_fd = open(dst_fullpath, O_CREAT | O_WRONLY | O_TRUNC, src_mode);
if (dst_fd < 0) if (dst_fd < 0) {
{
PRINTK("cp error: can't create %s. %s.\n", dst_fullpath, strerror(errno)); PRINTK("cp error: can't create %s. %s.\n", dst_fullpath, strerror(errno));
goto errout_with_srcfd; goto errout_with_srcfd;
} }
do do {
{
(void)memset_s(buf, CP_BUF_SIZE, 0, CP_BUF_SIZE); (void)memset_s(buf, CP_BUF_SIZE, 0, CP_BUF_SIZE);
r_size = read(src_fd, buf, CP_BUF_SIZE); r_size = read(src_fd, buf, CP_BUF_SIZE);
if (r_size < 0) if (r_size < 0) {
{
PRINTK("cp %s %s failed. %s.\n", src_fullpath, dst_fullpath, strerror(errno)); PRINTK("cp %s %s failed. %s.\n", src_fullpath, dst_fullpath, strerror(errno));
goto errout_with_fd; goto errout_with_fd;
} }
w_size = write(dst_fd, buf, r_size); w_size = write(dst_fd, buf, r_size);
if (w_size != r_size) if (w_size != r_size) {
{
PRINTK("cp %s %s failed. %s.\n", src_fullpath, dst_fullpath, strerror(errno)); PRINTK("cp %s %s failed. %s.\n", src_fullpath, dst_fullpath, strerror(errno));
goto errout_with_fd; goto errout_with_fd;
} }
} } while (r_size == CP_BUF_SIZE);
while (r_size == CP_BUF_SIZE);
/* Release resource. */ /* Release resource. */
...@@ -825,46 +743,37 @@ static int os_shell_cmd_do_rmdir(const char *pathname) ...@@ -825,46 +743,37 @@ static int os_shell_cmd_do_rmdir(const char *pathname)
int ret; int ret;
(void)memset_s(&stat_info, sizeof(stat_info), 0, sizeof(struct stat)); (void)memset_s(&stat_info, sizeof(stat_info), 0, sizeof(struct stat));
if (stat(pathname, &stat_info) != 0) if (stat(pathname, &stat_info) != 0) {
{
return -1; return -1;
} }
if (S_ISREG(stat_info.st_mode) || S_ISLNK(stat_info.st_mode)) if (S_ISREG(stat_info.st_mode) || S_ISLNK(stat_info.st_mode)) {
{
return remove(pathname); return remove(pathname);
} }
d = opendir(pathname); d = opendir(pathname);
if (d == NULL) if (d == NULL) {
{
return -1; return -1;
} }
while (1) while (1) {
{
dirent = readdir(d); dirent = readdir(d);
if (dirent == NULL) if (dirent == NULL) {
{
break; break;
} }
if (strcmp(dirent->d_name, "..") && strcmp(dirent->d_name, ".")) if (strcmp(dirent->d_name, "..") && strcmp(dirent->d_name, ".")) {
{
size_t fullpath_buf_size = strlen(pathname) + strlen(dirent->d_name) + SEPARATOR_EOF_LEN; size_t fullpath_buf_size = strlen(pathname) + strlen(dirent->d_name) + SEPARATOR_EOF_LEN;
if (fullpath_buf_size <= 0) if (fullpath_buf_size <= 0) {
{
PRINTK("buffer size is invalid!\n"); PRINTK("buffer size is invalid!\n");
(void)closedir(d); (void)closedir(d);
return -1; return -1;
} }
fullpath = (char *)malloc(fullpath_buf_size); fullpath = (char *)malloc(fullpath_buf_size);
if (fullpath == NULL) if (fullpath == NULL) {
{
PRINTK("malloc failure!\n"); PRINTK("malloc failure!\n");
(void)closedir(d); (void)closedir(d);
return -1; return -1;
} }
ret = snprintf_s(fullpath, fullpath_buf_size, fullpath_buf_size - 1, "%s/%s", pathname, dirent->d_name); ret = snprintf_s(fullpath, fullpath_buf_size, fullpath_buf_size - 1, "%s/%s", pathname, dirent->d_name);
if (ret < 0) if (ret < 0) {
{
PRINTK("name is too long!\n"); PRINTK("name is too long!\n");
free(fullpath); free(fullpath);
(void)closedir(d); (void)closedir(d);
...@@ -884,55 +793,42 @@ static int os_wildcard_match(const char *src, const char *filename) ...@@ -884,55 +793,42 @@ static int os_wildcard_match(const char *src, const char *filename)
{ {
int ret; int ret;
if (*src != '\0') if (*src != '\0') {
{ if (*filename == '*') {
if (*filename == '*') while ((*filename == '*') || (*filename == '?')) {
{
while ((*filename == '*') || (*filename == '?'))
{
filename++; filename++;
} }
if (*filename == '\0') if (*filename == '\0') {
{
return 0; return 0;
} }
while (*src != '\0' && !(*src == *filename)) while (*src != '\0' && !(*src == *filename)) {
{
src++; src++;
} }
if (*src == '\0') if (*src == '\0') {
{
return -1; return -1;
} }
ret = os_wildcard_match(src, filename); ret = os_wildcard_match(src, filename);
while ((ret != 0) && (*(++src) != '\0')) while ((ret != 0) && (*(++src) != '\0')) {
{ if (*src == *filename) {
if (*src == *filename)
{
ret = os_wildcard_match(src, filename); ret = os_wildcard_match(src, filename);
} }
} }
return ret; return ret;
} } else {
else if ((*src == *filename) || (*filename == '?')) {
{
if ((*src == *filename) || (*filename == '?'))
{
return os_wildcard_match(++src, ++filename); return os_wildcard_match(++src, ++filename);
} }
return -1; return -1;
} }
} }
while (*filename != '\0') while (*filename != '\0') {
{ if (*filename != '*') {
if (*filename != '*')
{
return -1; return -1;
} }
filename++; filename++;
...@@ -944,10 +840,8 @@ static int os_wildcard_match(const char *src, const char *filename) ...@@ -944,10 +840,8 @@ static int os_wildcard_match(const char *src, const char *filename)
static int os_is_containers_wildcard(const char *filename) static int os_is_containers_wildcard(const char *filename)
{ {
while (*filename != '\0') while (*filename != '\0') {
{ if ((*filename == '*') || (*filename == '?')) {
if ((*filename == '*') || (*filename == '?'))
{
return 1; return 1;
} }
filename++; filename++;
...@@ -961,8 +855,7 @@ static int os_wildcard_delete_file_or_dir(const char *fullpath, wildcard_type ma ...@@ -961,8 +855,7 @@ static int os_wildcard_delete_file_or_dir(const char *fullpath, wildcard_type ma
{ {
int ret; int ret;
switch (mark) switch (mark) {
{
case RM_RECURSIVER: case RM_RECURSIVER:
ret = os_shell_cmd_do_rmdir(fullpath); ret = os_shell_cmd_do_rmdir(fullpath);
break; break;
...@@ -975,8 +868,7 @@ static int os_wildcard_delete_file_or_dir(const char *fullpath, wildcard_type ma ...@@ -975,8 +868,7 @@ static int os_wildcard_delete_file_or_dir(const char *fullpath, wildcard_type ma
default: default:
return VFS_ERROR; return VFS_ERROR;
} }
if (ret == -1) if (ret == -1) {
{
PRINTK("%s ", fullpath); PRINTK("%s ", fullpath);
perror("rm/rmdir error!"); perror("rm/rmdir error!");
return ret; return ret;
...@@ -995,24 +887,18 @@ static char* os_wildcard_split_path(char *fullpath, char **handle, char **wait) ...@@ -995,24 +887,18 @@ static char* os_wildcard_split_path(char *fullpath, char **handle, char **wait)
int b = 0; int b = 0;
int len = strlen(fullpath); int len = strlen(fullpath);
for (n = 0; n < len; n++) for (n = 0; n < len; n++) {
{ if (fullpath[n] == '/') {
if (fullpath[n] == '/') if (b != 0) {
{
if (b != 0)
{
fullpath[n] = '\0'; fullpath[n] = '\0';
*wait = fullpath + n + 1; *wait = fullpath + n + 1;
break; break;
} }
a = n; a = n;
} } else if (fullpath[n] == '*' || fullpath[n] == '?') {
else if (fullpath[n] == '*' || fullpath[n] == '?')
{
b = n; b = n;
fullpath[a] = '\0'; fullpath[a] = '\0';
if (a == 0) if (a == 0) {
{
*handle = fullpath + a + 1; *handle = fullpath + a + 1;
continue; continue;
} }
...@@ -1039,112 +925,82 @@ static int os_wildcard_extract_directory(char *fullpath, void *dst, wildcard_typ ...@@ -1039,112 +925,82 @@ static int os_wildcard_extract_directory(char *fullpath, void *dst, wildcard_typ
f = os_wildcard_split_path(fullpath, &s, &t); f = os_wildcard_split_path(fullpath, &s, &t);
if (s == NULL) if (s == NULL) {
{ if (mark == CP_FILE) {
if (mark == CP_FILE)
{
ret = os_shell_cmd_do_cp(fullpath, dst); ret = os_shell_cmd_do_cp(fullpath, dst);
} } else if (mark == CP_COUNT) {
else if (mark == CP_COUNT)
{
ret = stat(fullpath, &stat_buf); ret = stat(fullpath, &stat_buf);
if (ret == 0 && (S_ISREG(stat_buf.st_mode) || S_ISLNK(stat_buf.st_mode))) if (ret == 0 && (S_ISREG(stat_buf.st_mode) || S_ISLNK(stat_buf.st_mode))) {
{
(*(int *)dst)++; (*(int *)dst)++;
} }
} } else {
else
{
ret = os_wildcard_delete_file_or_dir(fullpath, mark); ret = os_wildcard_delete_file_or_dir(fullpath, mark);
} }
return ret; return ret;
} }
d = (*f == '\0') ? opendir("/") : opendir(f); d = (*f == '\0') ? opendir("/") : opendir(f);
if (d == NULL) {
if (d == NULL)
{
perror("opendir error"); perror("opendir error");
return VFS_ERROR; return VFS_ERROR;
} }
while (1) while (1) {
{
dirent = readdir(d); dirent = readdir(d);
if (dirent == NULL) if (dirent == NULL) {
{
break; break;
} }
ret = strcpy_s(src, PATH_MAX, f); ret = strcpy_s(src, PATH_MAX, f);
if (ret != EOK) if (ret != EOK) {
{
goto closedir_out; goto closedir_out;
} }
ret = os_wildcard_match(dirent->d_name, s); ret = os_wildcard_match(dirent->d_name, s);
if (ret == 0) if (ret == 0) {
{
ret = strcat_s(src, sizeof(src), separator); ret = strcat_s(src, sizeof(src), separator);
if (ret != EOK) if (ret != EOK) {
{
goto closedir_out; goto closedir_out;
} }
ret = strcat_s(src, sizeof(src), dirent->d_name); ret = strcat_s(src, sizeof(src), dirent->d_name);
if (ret != EOK) if (ret != EOK) {
{
goto closedir_out; goto closedir_out;
} }
if (t == NULL) if (t == NULL) {
{ if (mark == CP_FILE) {
if (mark == CP_FILE)
{
ret = os_shell_cmd_do_cp(src, dst); ret = os_shell_cmd_do_cp(src, dst);
} } else if (mark == CP_COUNT) {
else if (mark == CP_COUNT)
{
ret = stat(src, &stat_buf); ret = stat(src, &stat_buf);
if (ret == 0 && (S_ISREG(stat_buf.st_mode) || S_ISLNK(stat_buf.st_mode))) if (ret == 0 && (S_ISREG(stat_buf.st_mode) || S_ISLNK(stat_buf.st_mode))) {
{
(*(int *)dst)++; (*(int *)dst)++;
if ((*(int *)dst) > 1) if ((*(int *)dst) > 1) {
{
break; break;
} }
} }
} } else {
else
{
ret = os_wildcard_delete_file_or_dir(src, mark); ret = os_wildcard_delete_file_or_dir(src, mark);
if (ret == 0) if (ret == 0) {
{
deleteFlag = 1; deleteFlag = 1;
} }
} }
} } else {
else
{
ret = strcat_s(src, sizeof(src), separator); ret = strcat_s(src, sizeof(src), separator);
if (ret != EOK) if (ret != EOK) {
{
goto closedir_out; goto closedir_out;
} }
ret = strcat_s(src, sizeof(src), t); ret = strcat_s(src, sizeof(src), t);
if (ret != EOK) if (ret != EOK) {
{
goto closedir_out; goto closedir_out;
} }
ret = os_wildcard_extract_directory(src, dst, mark); ret = os_wildcard_extract_directory(src, dst, mark);
if (mark == CP_COUNT && (*(int *)dst) > 1) if (mark == CP_COUNT && (*(int *)dst) > 1) {
{
break; break;
} }
} }
} }
} }
(void)closedir(d); (void)closedir(d);
if (deleteFlag == 1) if (deleteFlag == 1) {
{
ret = 0; ret = 0;
} }
return ret; return ret;
...@@ -1163,8 +1019,7 @@ int osShellCmdCp(int argc, const char **argv) ...@@ -1163,8 +1019,7 @@ int osShellCmdCp(int argc, const char **argv)
struct stat stat_buf; struct stat stat_buf;
int count = 0; int count = 0;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
...@@ -1176,15 +1031,13 @@ int osShellCmdCp(int argc, const char **argv) ...@@ -1176,15 +1031,13 @@ int osShellCmdCp(int argc, const char **argv)
/* Get source fullpath. */ /* Get source fullpath. */
ret = vfs_normalize_path(shell_working_directory, src, &src_fullpath); ret = vfs_normalize_path(shell_working_directory, src, &src_fullpath);
if (ret < 0) if (ret < 0) {
{
set_errno(-ret); set_errno(-ret);
PRINTK("cp error:%s\n", strerror(errno)); PRINTK("cp error:%s\n", strerror(errno));
return -1; return -1;
} }
if (src[strlen(src) - 1] == '/') if (src[strlen(src) - 1] == '/') {
{
PRINTK("cp %s error: Source file can't be a directory.\n", src); PRINTK("cp %s error: Source file can't be a directory.\n", src);
goto errout_with_srcpath; goto errout_with_srcpath;
} }
...@@ -1192,8 +1045,7 @@ int osShellCmdCp(int argc, const char **argv) ...@@ -1192,8 +1045,7 @@ int osShellCmdCp(int argc, const char **argv)
/* Get dest fullpath. */ /* Get dest fullpath. */
ret = vfs_normalize_path(shell_working_directory, dst, &dst_fullpath); ret = vfs_normalize_path(shell_working_directory, dst, &dst_fullpath);
if (ret < 0) if (ret < 0) {
{
set_errno(-ret); set_errno(-ret);
PRINTK("cp error: can't open %s. %s\n", dst, strerror(errno)); PRINTK("cp error: can't open %s. %s\n", dst, strerror(errno));
goto errout_with_srcpath; goto errout_with_srcpath;
...@@ -1202,47 +1054,36 @@ int osShellCmdCp(int argc, const char **argv) ...@@ -1202,47 +1054,36 @@ int osShellCmdCp(int argc, const char **argv)
/* Is dest path exist? */ /* Is dest path exist? */
ret = stat(dst_fullpath, &stat_buf); ret = stat(dst_fullpath, &stat_buf);
if (ret < 0) if (ret < 0) {
{
/* Is dest path a directory? */ /* Is dest path a directory? */
if (dst[strlen(dst) - 1] == '/') if (dst[strlen(dst) - 1] == '/') {
{
PRINTK("cp error: %s, %s.\n", dst_fullpath, strerror(errno)); PRINTK("cp error: %s, %s.\n", dst_fullpath, strerror(errno));
goto errout_with_path; goto errout_with_path;
} }
} } else {
else if ((S_ISREG(stat_buf.st_mode) || S_ISLNK(stat_buf.st_mode)) && dst[strlen(dst) - 1] == '/') {
{
if ((S_ISREG(stat_buf.st_mode) || S_ISLNK(stat_buf.st_mode)) && dst[strlen(dst) - 1] == '/')
{
PRINTK("cp error: %s is not a directory.\n", dst_fullpath); PRINTK("cp error: %s is not a directory.\n", dst_fullpath);
goto errout_with_path; goto errout_with_path;
} }
} }
if (os_is_containers_wildcard(src_fullpath)) if (os_is_containers_wildcard(src_fullpath)) {
{ if (ret < 0 || S_ISREG(stat_buf.st_mode) || S_ISLNK(stat_buf.st_mode)) {
if (ret < 0 || S_ISREG(stat_buf.st_mode) || S_ISLNK(stat_buf.st_mode))
{
char *src_copy = strdup(src_fullpath); char *src_copy = strdup(src_fullpath);
if (src_copy == NULL) if (src_copy == NULL) {
{
PRINTK("cp error : Out of memory.\n"); PRINTK("cp error : Out of memory.\n");
goto errout_with_path; goto errout_with_path;
} }
(void)os_wildcard_extract_directory(src_copy, &count, CP_COUNT); (void)os_wildcard_extract_directory(src_copy, &count, CP_COUNT);
free(src_copy); free(src_copy);
if (count > 1) if (count > 1) {
{
PRINTK("cp error : %s is not a directory.\n", dst_fullpath); PRINTK("cp error : %s is not a directory.\n", dst_fullpath);
goto errout_with_path; goto errout_with_path;
} }
} }
ret = os_wildcard_extract_directory(src_fullpath, dst_fullpath, CP_FILE); ret = os_wildcard_extract_directory(src_fullpath, dst_fullpath, CP_FILE);
} } else {
else
{
ret = os_shell_cmd_do_cp(src_fullpath, dst_fullpath); ret = os_shell_cmd_do_cp(src_fullpath, dst_fullpath);
} }
free(dst_fullpath); free(dst_fullpath);
...@@ -1267,47 +1108,36 @@ int osShellCmdRm(int argc, const char **argv) ...@@ -1267,47 +1108,36 @@ int osShellCmdRm(int argc, const char **argv)
char *fullpath = NULL; char *fullpath = NULL;
const char *filename = NULL; const char *filename = NULL;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
ERROR_OUT_IF(argc != 1 && argc != 2, print_rm_usage(), return -1); ERROR_OUT_IF(argc != 1 && argc != 2, print_rm_usage(), return -1);
if (argc == 2) if (argc == 2) { // 2: arguments include "-r" or "-R"
{
ERROR_OUT_IF(strcmp(argv[0], "-r") != 0 && strcmp(argv[0], "-R") != 0, print_rm_usage(), return -1); ERROR_OUT_IF(strcmp(argv[0], "-r") != 0 && strcmp(argv[0], "-R") != 0, print_rm_usage(), return -1);
filename = argv[1]; filename = argv[1];
ret = vfs_normalize_path(shell_working_directory, filename, &fullpath); ret = vfs_normalize_path(shell_working_directory, filename, &fullpath);
ERROR_OUT_IF(ret < 0, set_err(-ret, "rm error"), return -1); ERROR_OUT_IF(ret < 0, set_err(-ret, "rm error"), return -1);
if (os_is_containers_wildcard(fullpath)) if (os_is_containers_wildcard(fullpath)) {
{
ret = os_wildcard_extract_directory(fullpath, NULL, RM_RECURSIVER); ret = os_wildcard_extract_directory(fullpath, NULL, RM_RECURSIVER);
} } else {
else
{
ret = os_shell_cmd_do_rmdir(fullpath); ret = os_shell_cmd_do_rmdir(fullpath);
} }
} } else {
else
{
filename = argv[0]; filename = argv[0];
ret = vfs_normalize_path(shell_working_directory, filename, &fullpath); ret = vfs_normalize_path(shell_working_directory, filename, &fullpath);
ERROR_OUT_IF(ret < 0, set_err(-ret, "rm error"), return -1); ERROR_OUT_IF(ret < 0, set_err(-ret, "rm error"), return -1);
if (os_is_containers_wildcard(fullpath)) if (os_is_containers_wildcard(fullpath)) {
{
ret = os_wildcard_extract_directory(fullpath, NULL, RM_FILE); ret = os_wildcard_extract_directory(fullpath, NULL, RM_FILE);
} } else {
else
{
ret = unlink(fullpath); ret = unlink(fullpath);
} }
} }
if (ret == -1) if (ret == -1) {
{
perror("rm error"); perror("rm error");
} }
free(fullpath); free(fullpath);
...@@ -1320,8 +1150,7 @@ int osShellCmdRmdir(int argc, const char **argv) ...@@ -1320,8 +1150,7 @@ int osShellCmdRmdir(int argc, const char **argv)
char *fullpath = NULL; char *fullpath = NULL;
const char *filename = NULL; const char *filename = NULL;
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
...@@ -1331,16 +1160,12 @@ int osShellCmdRmdir(int argc, const char **argv) ...@@ -1331,16 +1160,12 @@ int osShellCmdRmdir(int argc, const char **argv)
ret = vfs_normalize_path(shell_working_directory, filename, &fullpath); ret = vfs_normalize_path(shell_working_directory, filename, &fullpath);
ERROR_OUT_IF(ret < 0, set_err(-ret, "rmdir error"), return -1); ERROR_OUT_IF(ret < 0, set_err(-ret, "rmdir error"), return -1);
if (os_is_containers_wildcard(fullpath)) if (os_is_containers_wildcard(fullpath)) {
{
ret = os_wildcard_extract_directory(fullpath, NULL, RM_DIR); ret = os_wildcard_extract_directory(fullpath, NULL, RM_DIR);
} } else {
else
{
ret = rmdir(fullpath); ret = rmdir(fullpath);
} }
if (ret == -1) if (ret == -1) {
{
PRINTK("rmdir %s failed. Error: %s.\n", fullpath, strerror(errno)); PRINTK("rmdir %s failed. Error: %s.\n", fullpath, strerror(errno));
} }
free(fullpath); free(fullpath);
...@@ -1368,20 +1193,16 @@ int osShellCmdLsfd(int argc, const char **argv) ...@@ -1368,20 +1193,16 @@ int osShellCmdLsfd(int argc, const char **argv)
int checkNum(const char *arg) int checkNum(const char *arg)
{ {
int i = 0; int i = 0;
if (arg == NULL) if (arg == NULL) {
{
return -1; return -1;
} }
if (arg[0] == '-') if (arg[0] == '-') {
{
/* exclude the '-' */ /* exclude the '-' */
i = 1; i = 1;
} }
for (; arg[i] != 0; i++) for (; arg[i] != 0; i++) {
{ if (!isdigit(arg[i])) {
if (!isdigit(arg[i]))
{
return -1; return -1;
} }
} }
...@@ -1394,15 +1215,12 @@ int osShellCmdSu(int argc, const char **argv) ...@@ -1394,15 +1215,12 @@ int osShellCmdSu(int argc, const char **argv)
int su_uid; int su_uid;
int su_gid; int su_gid;
if (argc == 0) if (argc == 0) {
{
/* for su root */ /* for su root */
su_uid = 0; su_uid = 0;
su_gid = 0; su_gid = 0;
} } else {
else
{
ERROR_OUT_IF((argc != 2), PRINTK("su [uid_num] [gid_num]\n"), return -1); ERROR_OUT_IF((argc != 2), PRINTK("su [uid_num] [gid_num]\n"), return -1);
ERROR_OUT_IF((checkNum(argv[0]) != 0) || (checkNum(argv[1]) != 0), /* check argv is digit */ ERROR_OUT_IF((checkNum(argv[0]) != 0) || (checkNum(argv[1]) != 0), /* check argv is digit */
PRINTK("check uid_num and gid_num is digit\n"), return -1); PRINTK("check uid_num and gid_num is digit\n"), return -1);
...@@ -1435,14 +1253,10 @@ int osShellCmdChmod(int argc, const char **argv) ...@@ -1435,14 +1253,10 @@ int osShellCmdChmod(int argc, const char **argv)
ERROR_OUT_IF((argc != 2), PRINTK("Usage: chmod <MODE> [FILE]\n"), return -1); ERROR_OUT_IF((argc != 2), PRINTK("Usage: chmod <MODE> [FILE]\n"), return -1);
p = argv[0]; p = argv[0];
while (p[i]) while (p[i]) {
{ if ((p[i] <= '7') && (p[i] >= '0')) {
if ((p[i] <= '7') && (p[i] >= '0'))
{
mode = ((uint)mode << MODE_BIT) | (uint)(p[i] - '0'); mode = ((uint)mode << MODE_BIT) | (uint)(p[i] - '0');
} } else {
else
{
PRINTK("check the input <MODE>\n"); PRINTK("check the input <MODE>\n");
return -1; return -1;
} }
...@@ -1451,8 +1265,7 @@ int osShellCmdChmod(int argc, const char **argv) ...@@ -1451,8 +1265,7 @@ int osShellCmdChmod(int argc, const char **argv)
filename = argv[1]; filename = argv[1];
shell_working_directory = OsShellGetWorkingDirectory(); shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
ret = vfs_normalize_path(shell_working_directory, filename, &fullpath); ret = vfs_normalize_path(shell_working_directory, filename, &fullpath);
...@@ -1461,8 +1274,7 @@ int osShellCmdChmod(int argc, const char **argv) ...@@ -1461,8 +1274,7 @@ int osShellCmdChmod(int argc, const char **argv)
attr.attr_chg_mode = mode; attr.attr_chg_mode = mode;
attr.attr_chg_valid = CHG_MODE; /* change mode */ attr.attr_chg_valid = CHG_MODE; /* change mode */
ret = chattr(fullpath, &attr); ret = chattr(fullpath, &attr);
if (ret < 0) if (ret < 0) {
{
free(fullpath); free(fullpath);
PRINTK("chmod error! %s\n", strerror(errno)); PRINTK("chmod error! %s\n", strerror(errno));
return ret; return ret;
...@@ -1483,14 +1295,12 @@ int osShellCmdChown(int argc, const char **argv) ...@@ -1483,14 +1295,12 @@ int osShellCmdChown(int argc, const char **argv)
attr.attr_chg_valid = 0; attr.attr_chg_valid = 0;
ERROR_OUT_IF(((argc != 2) && (argc != 3)), PRINTK("Usage: chown [OWNER] [GROUP] FILE\n"), return -1); ERROR_OUT_IF(((argc != 2) && (argc != 3)), PRINTK("Usage: chown [OWNER] [GROUP] FILE\n"), return -1);
if (argc == 2) if (argc == 2) { // 2: chown owner of file
{
ERROR_OUT_IF((checkNum(argv[0]) != 0), PRINTK("check OWNER is digit\n"), return -1); ERROR_OUT_IF((checkNum(argv[0]) != 0), PRINTK("check OWNER is digit\n"), return -1);
owner = atoi(argv[0]); owner = atoi(argv[0]);
filename = argv[1]; filename = argv[1];
} }
if (argc == 3) if (argc == 3) { // 3: chown both owner and group
{
ERROR_OUT_IF((checkNum(argv[0]) != 0), PRINTK("check OWNER is digit\n"), return -1); ERROR_OUT_IF((checkNum(argv[0]) != 0), PRINTK("check OWNER is digit\n"), return -1);
ERROR_OUT_IF((checkNum(argv[1]) != 0), PRINTK("check GROUP is digit\n"), return -1); ERROR_OUT_IF((checkNum(argv[1]) != 0), PRINTK("check GROUP is digit\n"), return -1);
owner = atoi(argv[0]); owner = atoi(argv[0]);
...@@ -1498,28 +1308,24 @@ int osShellCmdChown(int argc, const char **argv) ...@@ -1498,28 +1308,24 @@ int osShellCmdChown(int argc, const char **argv)
filename = argv[2]; filename = argv[2];
} }
if (group != -1) if (group != -1) {
{
attr.attr_chg_gid = group; attr.attr_chg_gid = group;
attr.attr_chg_valid |= CHG_GID; attr.attr_chg_valid |= CHG_GID;
} }
if (owner != -1) if (owner != -1) {
{
attr.attr_chg_uid = owner; attr.attr_chg_uid = owner;
attr.attr_chg_valid |= CHG_UID; attr.attr_chg_valid |= CHG_UID;
} }
char *shell_working_directory = OsShellGetWorkingDirectory(); char *shell_working_directory = OsShellGetWorkingDirectory();
if (shell_working_directory == NULL) if (shell_working_directory == NULL) {
{
return -1; return -1;
} }
ret = vfs_normalize_path(shell_working_directory, filename, &fullpath); ret = vfs_normalize_path(shell_working_directory, filename, &fullpath);
ERROR_OUT_IF(ret < 0, set_err(-ret, "chown error\n"), return -1); ERROR_OUT_IF(ret < 0, set_err(-ret, "chown error\n"), return -1);
ret = chattr(fullpath, &attr); ret = chattr(fullpath, &attr);
if (ret < 0) if (ret < 0) {
{
free(fullpath); free(fullpath);
PRINTK("chown error! %s\n", strerror(errno)); PRINTK("chown error! %s\n", strerror(errno));
return ret; return ret;
......
/* /*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2021-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
...@@ -239,7 +239,7 @@ BOOL VnodeInUseIter(const struct Mount *mount) ...@@ -239,7 +239,7 @@ BOOL VnodeInUseIter(const struct Mount *mount)
return FALSE; return FALSE;
} }
int VnodeHold() int VnodeHold(void)
{ {
int ret = LOS_MuxLock(&g_vnodeMux, LOS_WAIT_FOREVER); int ret = LOS_MuxLock(&g_vnodeMux, LOS_WAIT_FOREVER);
if (ret != LOS_OK) { if (ret != LOS_OK) {
...@@ -248,7 +248,7 @@ int VnodeHold() ...@@ -248,7 +248,7 @@ int VnodeHold()
return ret; return ret;
} }
int VnodeDrop() int VnodeDrop(void)
{ {
int ret = LOS_MuxUnlock(&g_vnodeMux); int ret = LOS_MuxUnlock(&g_vnodeMux);
if (ret != LOS_OK) { if (ret != LOS_OK) {
...@@ -583,7 +583,7 @@ int VnodeCreate(struct Vnode *parent, const char *name, int mode, struct Vnode * ...@@ -583,7 +583,7 @@ int VnodeCreate(struct Vnode *parent, const char *name, int mode, struct Vnode *
return 0; return 0;
} }
int VnodeDevInit() int VnodeDevInit(void)
{ {
struct Vnode *devNode = NULL; struct Vnode *devNode = NULL;
struct Mount *devMount = NULL; struct Mount *devMount = NULL;
...@@ -616,7 +616,7 @@ int VnodeGetattr(struct Vnode *vnode, struct stat *buf) ...@@ -616,7 +616,7 @@ int VnodeGetattr(struct Vnode *vnode, struct stat *buf)
return LOS_OK; return LOS_OK;
} }
struct Vnode *VnodeGetRoot() struct Vnode *VnodeGetRoot(void)
{ {
return g_rootVnode; return g_rootVnode;
} }
...@@ -697,7 +697,7 @@ LIST_HEAD* GetVnodeActiveList() ...@@ -697,7 +697,7 @@ LIST_HEAD* GetVnodeActiveList()
return &g_vnodeActiveList; return &g_vnodeActiveList;
} }
int VnodeClearCache() int VnodeClearCache(void)
{ {
struct Vnode *item = NULL; struct Vnode *item = NULL;
struct Vnode *nextItem = NULL; struct Vnode *nextItem = NULL;
......
...@@ -50,8 +50,8 @@ extern "C" { ...@@ -50,8 +50,8 @@ extern "C" {
* Rwlock object. * Rwlock object.
*/ */
typedef struct OsRwlock { typedef struct OsRwlock {
INT32 magic:24; /**< Magic number */ INT32 magic : 24; /**< Magic number */
INT32 rwCount:8; /**< Times of locking the rwlock, rwCount > 0 when rwkick is read mode, rwCount < 0 INT32 rwCount : 8; /**< Times of locking the rwlock, rwCount > 0 when rwkick is read mode, rwCount < 0
when the rwlock is write mode, rwCount = 0 when the lock is free. */ when the rwlock is write mode, rwCount = 0 when the lock is free. */
VOID *writeOwner; /**< The current write thread that is locking the rwlock */ VOID *writeOwner; /**< The current write thread that is locking the rwlock */
LOS_DL_LIST readList; /**< Read waiting list */ LOS_DL_LIST readList; /**< Read waiting list */
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
#define ip_addr_set_val(dest, src) do { \ #define ip_addr_set_val(dest, src) do { \
IP_SET_TYPE_VAL(*dest, IP_GET_TYPE(src)); \ IP_SET_TYPE_VAL(*dest, IP_GET_TYPE(src)); \
if(IP_IS_V6_VAL(*(src))) { \ if (IP_IS_V6_VAL(*(src))) { \
ip6_addr_set(ip_2_ip6(dest), ip_2_ip6(src)); \ ip6_addr_set(ip_2_ip6(dest), ip_2_ip6(src)); \
} else { \ } else { \
ip4_addr_set(ip_2_ip4(dest), ip_2_ip4(src)); \ ip4_addr_set(ip_2_ip4(dest), ip_2_ip4(src)); \
......
...@@ -1076,7 +1076,7 @@ u32_t lwip_ifconfig(int argc, const char **argv) ...@@ -1076,7 +1076,7 @@ u32_t lwip_ifconfig(int argc, const char **argv)
ifconfig_cmd.cb_print_buf[PRINT_BUF_LEN - 1] = '\0'; ifconfig_cmd.cb_print_buf[PRINT_BUF_LEN - 1] = '\0';
PRINTK("%s", ifconfig_cmd.cb_print_buf); PRINTK("%s", ifconfig_cmd.cb_print_buf);
#if LWIP_ARP && LWIP_ENABLE_IP_CONFLICT_SIGNAL #if LWIP_ARP && LWIP_ENABLE_IP_CONFLICT_SIGNAL
/* Pend 2 seconds for waiting the arp reply if the ip is already in use.*/ /* Pend 2 seconds for waiting the arp reply if the ip is already in use. */
if ((ifconfig_cmd.option & IFCONFIG_OPTION_SET_IP) && IP_IS_V4_VAL((ifconfig_cmd.ip_addr))) { if ((ifconfig_cmd.option & IFCONFIG_OPTION_SET_IP) && IP_IS_V4_VAL((ifconfig_cmd.ip_addr))) {
err = (err_t)sys_arch_sem_wait(&ip_conflict_detect, DUP_ARP_DETECT_TIME); err = (err_t)sys_arch_sem_wait(&ip_conflict_detect, DUP_ARP_DETECT_TIME);
is_ip_conflict_signal = 0; is_ip_conflict_signal = 0;
...@@ -1106,7 +1106,7 @@ u32_t lwip_ifconfig(int argc, const char **argv) ...@@ -1106,7 +1106,7 @@ u32_t lwip_ifconfig(int argc, const char **argv)
#endif /* LWIP_ARP && LWIP_ENABLE_IP_CONFLICT_SIGNAL */ #endif /* LWIP_ARP && LWIP_ENABLE_IP_CONFLICT_SIGNAL */
#if LWIP_IPV6 #if LWIP_IPV6
if ((ifconfig_cmd.option & IFCONFIG_OPTION_SET_IP) && IP_IS_V6_VAL(ifconfig_cmd.ip_addr)) { if ((ifconfig_cmd.option & IFCONFIG_OPTION_SET_IP) && IP_IS_V6_VAL(ifconfig_cmd.ip_addr)) {
/* Pend 2 seconds for waiting the arp reply if the ip is already in use.*/ /* Pend 2 seconds for waiting the arp reply if the ip is already in use. */
retval = sys_arch_sem_wait(&dup_addr_detect, DUP_ARP_DETECT_TIME); retval = sys_arch_sem_wait(&dup_addr_detect, DUP_ARP_DETECT_TIME);
is_dup_detect_initialized = 0; is_dup_detect_initialized = 0;
sys_sem_free(&dup_addr_detect); sys_sem_free(&dup_addr_detect);
...@@ -1191,7 +1191,6 @@ void lwip_arp_show_internal(struct netif *netif, char *printf_buf, unsigned int ...@@ -1191,7 +1191,6 @@ void lwip_arp_show_internal(struct netif *netif, char *printf_buf, unsigned int
|| (state == ETHARP_STATE_STATIC) || (state == ETHARP_STATE_STATIC)
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
) && arp_table[i].netif) { ) && arp_table[i].netif) {
if (strcmp(netif_get_name(netif), netif_get_name(arp_table[i].netif)) != 0) { if (strcmp(netif_get_name(netif), netif_get_name(arp_table[i].netif)) != 0) {
continue; continue;
} }
...@@ -1305,7 +1304,7 @@ void lwip_arp_internal(void *arg) ...@@ -1305,7 +1304,7 @@ void lwip_arp_internal(void *arg)
for (netif = netif_list; netif != NULL; netif = netif->next) { for (netif = netif_list; netif != NULL; netif = netif->next) {
ret = etharp_delete_arp_entry(netif, &ipaddr); ret = etharp_delete_arp_entry(netif, &ipaddr);
if (ret == ERR_OK) { if (ret == ERR_OK) {
/*only can del success one time*/ /* only can del success one time */
break; break;
} }
} }
...@@ -1387,7 +1386,7 @@ u32_t lwip_arp(int argc, const char **argv) ...@@ -1387,7 +1386,7 @@ u32_t lwip_arp(int argc, const char **argv)
goto arp_error; goto arp_error;
} }
i += 2; i += 2;
argc -= 2; argc -= 2; // 2: number of used parameters
} else if (strcmp("-d", argv[i]) == 0 && (argc > 1)) { } else if (strcmp("-d", argv[i]) == 0 && (argc > 1)) {
/* arp delete */ /* arp delete */
arp_cmd.option = ARP_OPTION_DEL; arp_cmd.option = ARP_OPTION_DEL;
...@@ -1399,8 +1398,8 @@ u32_t lwip_arp(int argc, const char **argv) ...@@ -1399,8 +1398,8 @@ u32_t lwip_arp(int argc, const char **argv)
} }
i += 2; i += 2;
argc -= 2; argc -= 2; // 2: number of used parameters
} else if (strcmp("-s", argv[i]) == 0 && (argc > 2)) { } else if (strcmp("-s", argv[i]) == 0 && (argc > 2)) { // 2: require more than 2 parameters
/* arp add */ /* arp add */
char *digit = NULL; char *digit = NULL;
u32_t macaddrlen = strlen(argv[i + 2]) + 1; u32_t macaddrlen = strlen(argv[i + 2]) + 1;
...@@ -1418,7 +1417,7 @@ u32_t lwip_arp(int argc, const char **argv) ...@@ -1418,7 +1417,7 @@ u32_t lwip_arp(int argc, const char **argv)
goto arp_error; goto arp_error;
} }
/*cannot add an arp entry of 127.*.*.* */ /* cannot add an arp entry of 127.*.*.* */
if ((arp_cmd.ipaddr & (u32_t)0x0000007fUL) == (u32_t)0x0000007fUL) { if ((arp_cmd.ipaddr & (u32_t)0x0000007fUL) == (u32_t)0x0000007fUL) {
PRINTK("IP address is not correct!\n"); PRINTK("IP address is not correct!\n");
goto arp_error; goto arp_error;
...@@ -1452,7 +1451,7 @@ u32_t lwip_arp(int argc, const char **argv) ...@@ -1452,7 +1451,7 @@ u32_t lwip_arp(int argc, const char **argv)
} }
i += 3; i += 3;
argc -= 3; argc -= 3; // 3: number of used parameters
} else { } else {
goto arp_error; goto arp_error;
} }
...@@ -1727,7 +1726,7 @@ LWIP_STATIC int osPingFunc(u32_t destip, u32_t cnt, u32_t interval, u32_t data_l ...@@ -1727,7 +1726,7 @@ LWIP_STATIC int osPingFunc(u32_t destip, u32_t cnt, u32_t interval, u32_t data_l
break; break;
} }
intrvl -= 1000; intrvl -= 1000;
sys_msleep(1000); sys_msleep(1000); // 1000: delay 1 s
if (ping_kill == 1) if (ping_kill == 1)
break; break;
} while (intrvl > 0); } while (intrvl > 0);
...@@ -1819,7 +1818,7 @@ u32_t osShellPing(int argc, const char **argv) ...@@ -1819,7 +1818,7 @@ u32_t osShellPing(int argc, const char **argv)
count = ret; count = ret;
count_set = 1; count_set = 1;
i += 2; i += 2;
argc -= 2; argc -= 2; // 2: nuber of arguments that has been checked
} else if (strcmp("-t", argv[i]) == 0) { } else if (strcmp("-t", argv[i]) == 0) {
count = 0; /* ping forerver */ count = 0; /* ping forerver */
count_set = 1; count_set = 1;
...@@ -1834,7 +1833,7 @@ u32_t osShellPing(int argc, const char **argv) ...@@ -1834,7 +1833,7 @@ u32_t osShellPing(int argc, const char **argv)
interval = ret; interval = ret;
i += 2; i += 2;
argc -= 2; argc -= 2; // 2:number of arguments that has been checked
} else if (strcmp("-l", argv[i]) == 0 && (argc > 1)) { } else if (strcmp("-l", argv[i]) == 0 && (argc > 1)) {
ret = atoi(argv[i + 1]); ret = atoi(argv[i + 1]);
if (ret < 0 || ret > (int)(LWIP_MAX_UDP_RAW_SEND_SIZE - sizeof(struct icmp_echo_hdr))) { if (ret < 0 || ret > (int)(LWIP_MAX_UDP_RAW_SEND_SIZE - sizeof(struct icmp_echo_hdr))) {
...@@ -1844,7 +1843,7 @@ u32_t osShellPing(int argc, const char **argv) ...@@ -1844,7 +1843,7 @@ u32_t osShellPing(int argc, const char **argv)
} }
data_len = ret; data_len = ret;
i += 2; i += 2;
argc -= 2; argc -= 2; // 2: number of elements has been checked
} else if (strcmp("-k", argv[i]) == 0) { } else if (strcmp("-k", argv[i]) == 0) {
if (ping_taskid > 0) { if (ping_taskid > 0) {
ping_kill = 1; /* stop the current ping task */ ping_kill = 1; /* stop the current ping task */
...@@ -1896,7 +1895,7 @@ u32_t osShellPing(int argc, const char **argv) ...@@ -1896,7 +1895,7 @@ u32_t osShellPing(int argc, const char **argv)
stPingTask.auwArgs[0] = dst_ipaddr.addr; /* network order */ stPingTask.auwArgs[0] = dst_ipaddr.addr; /* network order */
stPingTask.auwArgs[1] = count; stPingTask.auwArgs[1] = count;
stPingTask.auwArgs[2] = interval; stPingTask.auwArgs[2] = interval;
stPingTask.auwArgs[3] = data_len; stPingTask.auwArgs[3] = data_len; // 3: index of data length
ret = LOS_TaskCreate((UINT32 *)(&ping_taskid), &stPingTask); ret = LOS_TaskCreate((UINT32 *)(&ping_taskid), &stPingTask);
if (ret != LOS_OK) { if (ret != LOS_OK) {
PRINTK("ping_task create failed 0x%08x.\n", ret); PRINTK("ping_task create failed 0x%08x.\n", ret);
...@@ -1923,7 +1922,7 @@ ping_error: ...@@ -1923,7 +1922,7 @@ ping_error:
SHELLCMD_ENTRY(ping_shellcmd, CMD_TYPE_EX, "ping", XARGS, (CmdCallBackFunc)osShellPing); SHELLCMD_ENTRY(ping_shellcmd, CMD_TYPE_EX, "ping", XARGS, (CmdCallBackFunc)osShellPing);
#endif /* LOSCFG_SHELL */ #endif /* LOSCFG_SHELL */
#else /* LWIP_EXT_POLL_SUPPORT*/ #else /* LWIP_EXT_POLL_SUPPORT */
u32_t osShellPing(int argc, const char **argv) u32_t osShellPing(int argc, const char **argv)
{ {
...@@ -2076,7 +2075,7 @@ FAILURE: ...@@ -2076,7 +2075,7 @@ FAILURE:
SHELLCMD_ENTRY(ping_shellcmd, CMD_TYPE_EX, "ping", XARGS, (CmdCallBackFunc)osShellPing); SHELLCMD_ENTRY(ping_shellcmd, CMD_TYPE_EX, "ping", XARGS, (CmdCallBackFunc)osShellPing);
#endif /* LOSCFG_SHELL */ #endif /* LOSCFG_SHELL */
#endif /* LWIP_EXT_POLL_SUPPORT*/ #endif /* LWIP_EXT_POLL_SUPPORT */
#if LWIP_IPV6 #if LWIP_IPV6
u32_t osShellPing6(int argc, const char **argv) u32_t osShellPing6(int argc, const char **argv)
...@@ -2311,6 +2310,7 @@ REDUCE_SELECT_TIME: ...@@ -2311,6 +2310,7 @@ REDUCE_SELECT_TIME:
PRINTK("--- %s ping statistics ---\n", argv[ping6_params.host_index]); PRINTK("--- %s ping statistics ---\n", argv[ping6_params.host_index]);
PRINTK("%d packets transmitted, %d received, %.2f%% packet loss, time %dms\n", PRINTK("%d packets transmitted, %d received, %.2f%% packet loss, time %dms\n",
nsent, nrecieve, (float)(((float)(nsent - nrecieve)) * ((float)(100)) / ((float)(nsent))), nsent, nrecieve, (float)(((float)(nsent - nrecieve)) * ((float)(100)) / ((float)(nsent))),
/* 1000: convert seconds to milliseconds, 1000000: convert nanoseconds to milliseconds */
((last.tv_sec - first.tv_sec) * 1000 + (last.tv_nsec - first.tv_nsec) / 1000000)); ((last.tv_sec - first.tv_sec) * 1000 + (last.tv_nsec - first.tv_nsec) / 1000000));
if (nrecieve) { if (nrecieve) {
/* Display rtt stats only if at least one packet is received */ /* Display rtt stats only if at least one packet is received */
...@@ -2629,7 +2629,7 @@ usage: ...@@ -2629,7 +2629,7 @@ usage:
SHELLCMD_ENTRY(ntpdate_shellcmd, CMD_TYPE_EX, "ntpdate", XARGS, (CmdCallBackFunc)osShellNtpdate); SHELLCMD_ENTRY(ntpdate_shellcmd, CMD_TYPE_EX, "ntpdate", XARGS, (CmdCallBackFunc)osShellNtpdate);
#endif /* LOSCFG_SHELL_CMD_DEBUG */ #endif /* LOSCFG_SHELL_CMD_DEBUG */
#endif /* LWIP_SNTP*/ #endif /* LWIP_SNTP */
#if LWIP_DNS #if LWIP_DNS
u32_t osShellDns(int argc, const char **argv) u32_t osShellDns(int argc, const char **argv)
...@@ -2866,7 +2866,7 @@ int netstat_tcp_recvq(struct tcp_pcb *tpcb) ...@@ -2866,7 +2866,7 @@ int netstat_tcp_recvq(struct tcp_pcb *tpcb)
case NETCONN_UDP_IPV6: case NETCONN_UDP_IPV6:
#endif #endif
case NETCONN_UDP: case NETCONN_UDP:
SYS_ARCH_GET(((unsigned int)conn->recv_avail /*+ conn->lrcv_left*/), retVal); SYS_ARCH_GET(((unsigned int)conn->recv_avail), retVal); // + conn->lrcv_left
break; break;
default: default:
retVal = 0; /* ur... very ugly, damn DHCP DNS and SNTP */ retVal = 0; /* ur... very ugly, damn DHCP DNS and SNTP */
...@@ -2992,7 +2992,7 @@ int netstat_netconn_recvq(const struct netconn *conn) ...@@ -2992,7 +2992,7 @@ int netstat_netconn_recvq(const struct netconn *conn)
case NETCONN_PKT_RAW: case NETCONN_PKT_RAW:
#endif #endif
case NETCONN_UDP: case NETCONN_UDP:
SYS_ARCH_GET(((unsigned int)conn->recv_avail /*+ conn->lrcv_left*/), retVal); SYS_ARCH_GET(((unsigned int)conn->recv_avail), retVal); // + conn->lrcv_left
break; break;
default: default:
retVal = 0; /* ur... very ugly, damn DHCP DNS and SNTP */ retVal = 0; /* ur... very ugly, damn DHCP DNS and SNTP */
...@@ -3271,10 +3271,10 @@ void netstat_internal(void *ctx) ...@@ -3271,10 +3271,10 @@ void netstat_internal(void *ctx)
recvQlen = netstat_netconn_recvq(rpcb->recv_arg); recvQlen = netstat_netconn_recvq(rpcb->recv_arg);
sendQlen = netstat_netconn_sendq(rpcb->recv_arg); sendQlen = netstat_netconn_sendq(rpcb->recv_arg);
proto = rpcb->protocol;//raw_proto; proto = rpcb->protocol; // raw_proto;
iRet = snprintf_s((char *)(entry_buf + entry_buf_offset), entry_buf_len, entry_buf_len - 1, iRet = snprintf_s((char *)(entry_buf + entry_buf_offset), entry_buf_len, entry_buf_len - 1,
"%-8s%-12d%-12d%-20s%-20s%-16u%-16d\n", "%-8s%-12d%-12d%-20s%-20s%-16u%-16d\n",
"raw", recvQlen, sendQlen, local_ip_port, remote_ip_port, proto, /*rpcb->hdrincl*/0); "raw", recvQlen, sendQlen, local_ip_port, remote_ip_port, proto, 0); // rpcb->hdrincl
if ((iRet <= 0) || ((u32_t)(iRet) >= entry_buf_len)) { if ((iRet <= 0) || ((u32_t)(iRet) >= entry_buf_len)) {
goto out; goto out;
} }
...@@ -3297,7 +3297,8 @@ void netstat_internal(void *ctx) ...@@ -3297,7 +3297,8 @@ void netstat_internal(void *ctx)
sendQlen = netstat_netconn_sendq(rpcb->recv_arg); sendQlen = netstat_netconn_sendq(rpcb->recv_arg);
for (netif = netif_list; netif != NULL; netif = netif->next) { for (netif = netif_list; netif != NULL; netif = netif->next) {
if (netif_get_index(netif)/*netif->ifindex*/ == rpcb->netif_idx/*index*/) { /* netif->ifindex and index */
if (netif_get_index(netif) == rpcb->netif_idx) {
(void)snprintf_s((char *)netif_name, IFNAMSIZ, IFNAMSIZ - 1, "%s", netif_get_name(netif)); (void)snprintf_s((char *)netif_name, IFNAMSIZ, IFNAMSIZ - 1, "%s", netif_get_name(netif));
break; break;
} }
...@@ -3307,7 +3308,7 @@ void netstat_internal(void *ctx) ...@@ -3307,7 +3308,7 @@ void netstat_internal(void *ctx)
(void)snprintf_s((char *)netif_name, IFNAMSIZ, IFNAMSIZ - 1, "%s", "None"); (void)snprintf_s((char *)netif_name, IFNAMSIZ, IFNAMSIZ - 1, "%s", "None");
} }
proto = rpcb->protocol;//ntohs(rpcb->proto.eth_proto); proto = rpcb->protocol; // ntohs(rpcb->proto.eth_proto);
iRet = snprintf_s((char *)(entry_buf + entry_buf_offset), entry_buf_len, entry_buf_len - 1, iRet = snprintf_s((char *)(entry_buf + entry_buf_offset), entry_buf_len, entry_buf_len - 1,
"%-12s%-12d%-12d%-16x%-12s\n", "pkt-raw", recvQlen, sendQlen, proto, netif_name); "%-12s%-12d%-12d%-16x%-12s\n", "pkt-raw", recvQlen, sendQlen, proto, netif_name);
...@@ -3884,4 +3885,4 @@ SHELLCMD_ENTRY(reboot_shellcmd, CMD_TYPE_EX, "reboot", XARGS, (CmdCallBackFunc)o ...@@ -3884,4 +3885,4 @@ SHELLCMD_ENTRY(reboot_shellcmd, CMD_TYPE_EX, "reboot", XARGS, (CmdCallBackFunc)o
#endif /* LOSCFG_SHELL_CMD_DEBUG */ #endif /* LOSCFG_SHELL_CMD_DEBUG */
#endif #endif
#endif //LWIP_ENABLE_LOS_SHELL_CMD #endif // LWIP_ENABLE_LOS_SHELL_CMD
...@@ -412,7 +412,7 @@ int ip6addr_aton(const char *cp, ip6_addr_t *addr) ...@@ -412,7 +412,7 @@ int ip6addr_aton(const char *cp, ip6_addr_t *addr)
int squash_pos = ipv6_blocks; int squash_pos = ipv6_blocks;
int i; int i;
const char *s = cp; const char *s = cp;
const char *ss = cp-1; const char *ss = cp - 1;
for (; ; s++) { for (; ; s++) {
if (current_block_index >= ipv6_blocks) { if (current_block_index >= ipv6_blocks) {
......
...@@ -803,12 +803,10 @@ static u8_t lwip_ioctl_internal_SIOCSIFHWADDR(struct ifreq *ifr) ...@@ -803,12 +803,10 @@ static u8_t lwip_ioctl_internal_SIOCSIFHWADDR(struct ifreq *ifr)
} }
#endif #endif
else { else {
/* bring netif down to clear all Neighbor Cache Entry */ /* bring netif down to clear all Neighbor Cache Entry */
(void)netif_set_down(netif); (void)netif_set_down(netif);
ret = netif_set_hwaddr(netif, (const unsigned char *)ifr->ifr_hwaddr.sa_data, netif->hwaddr_len); ret = netif_set_hwaddr(netif, (const unsigned char *)ifr->ifr_hwaddr.sa_data, netif->hwaddr_len);
if (ret != ERR_OK) { if (ret != ERR_OK) {
(void)netif_set_up(netif); (void)netif_set_up(netif);
return err_to_errno(ret); return err_to_errno(ret);
...@@ -979,7 +977,6 @@ static u8_t lwip_ioctl_internal_SIOCGIFFLAGS(struct ifreq *ifr) ...@@ -979,7 +977,6 @@ static u8_t lwip_ioctl_internal_SIOCGIFFLAGS(struct ifreq *ifr)
#endif /* LWIP_IGMP || LWIP_IPV6_MLD */ #endif /* LWIP_IGMP || LWIP_IPV6_MLD */
#if LWIP_DHCP #if LWIP_DHCP
//if ((netif->flags & NETIF_FLAG_DHCP) != 0) {
if (dhcp_supplied_address(netif)) { if (dhcp_supplied_address(netif)) {
ifr->ifr_flags = (short)((unsigned short)ifr->ifr_flags | IFF_DYNAMIC); ifr->ifr_flags = (short)((unsigned short)ifr->ifr_flags | IFF_DYNAMIC);
} else { } else {
...@@ -1090,7 +1087,6 @@ static u8_t lwip_ioctl_internal_SIOCSIFNAME(struct ifreq *ifr) ...@@ -1090,7 +1087,6 @@ static u8_t lwip_ioctl_internal_SIOCSIFNAME(struct ifreq *ifr)
#endif #endif
netif = netif_find(ifr->ifr_name); netif = netif_find(ifr->ifr_name);
if (netif == NULL) { if (netif == NULL) {
return ENODEV; return ENODEV;
} else if (netif->link_layer_type == LOOPBACK_IF) { } else if (netif->link_layer_type == LOOPBACK_IF) {
...@@ -1165,7 +1161,6 @@ static u8_t lwip_ioctl_internal_SIOCGIFMTU(struct ifreq *ifr) ...@@ -1165,7 +1161,6 @@ static u8_t lwip_ioctl_internal_SIOCGIFMTU(struct ifreq *ifr)
/* get netif hw addr */ /* get netif hw addr */
netif = netif_find(ifr->ifr_name); netif = netif_find(ifr->ifr_name);
if (netif == NULL) { if (netif == NULL) {
return ENODEV; return ENODEV;
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册