From 76f45b3fb2783d1cab45a6ba08787c29dfa2c948 Mon Sep 17 00:00:00 2001 From: Kiita Date: Mon, 19 Jul 2021 19:20:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20toybox=E5=91=BD=E4=BB=A4=E5=8D=87?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【背景】liteos_a toybox 命令升级升级 【修改方案】 1、help命令列表不支持命令删除。 2、cp命令和mv命令拷贝文件失败和文件损坏等问题修复。 3、修复du命令统计nfs文件大小为0问题修复。 4、修复ls命令nfs文件时间打印信息有误问题。 5、更新命令不支持入参列表。 re #I41N2A Signed-off-by: yansira Change-Id: I5f5b82e33ba9193ae06e9547182d5b7bac0a3b44 --- apps/toybox/liteos_a_custom.config | 12 +++++++++--- fs/fat/os_adapt/fatfs.c | 3 +++ fs/jffs2/src/vfs_jffs2.c | 5 +++++ syscall/fs_syscall.c | 8 ++++---- syscall/los_syscall.h | 5 +++-- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/apps/toybox/liteos_a_custom.config b/apps/toybox/liteos_a_custom.config index 03dbae41..7628c2fa 100644 --- a/apps/toybox/liteos_a_custom.config +++ b/apps/toybox/liteos_a_custom.config @@ -1,7 +1,6 @@ -CONFIG_GETTY=y -CONFIG_MDEV=y -CONFIG_MDEV_CONF=y +# CONFIG_BASENAME is not set # CONFIG_CAL is not set +# CONFIG_CAT is not set # CONFIG_CATV is not set # CONFIG_CKSUM is not set # CONFIG_CRC32 is not set @@ -13,6 +12,7 @@ CONFIG_MDEV_CONF=y # CONFIG_CUT is not set # CONFIG_DF is not set # CONFIG_DIRNAME is not set +# CONFIG_ECHO is not set # CONFIG_ENV is not set # CONFIG_EXPAND is not set # CONFIG_FALSE is not set @@ -178,3 +178,9 @@ CONFIG_MDEV_CONF=y # CONFIG_SEQ is not set # CONFIG_SU is not set # CONFIG_SYNC is not set +# +# pending (see toys/pending/README) +# +# CONFIG_GETTY is not set +# CONFIG_MDEV is not set +# CONFIG_MDEV_CONF is not set diff --git a/fs/fat/os_adapt/fatfs.c b/fs/fat/os_adapt/fatfs.c index b6c02f02..8df522ab 100644 --- a/fs/fat/os_adapt/fatfs.c +++ b/fs/fat/os_adapt/fatfs.c @@ -1416,6 +1416,9 @@ int fatfs_stat(struct Vnode *vp, struct stat* sp) time = fattime_transfer(finfo->fdate, finfo->ftime); sp->st_mtime = time; + /* Adapt to kstat member "long tv_sec" */ + sp->__st_mtim32.tv_sec = (long)time; + unlock_fs(fs, FR_OK); return 0; } diff --git a/fs/jffs2/src/vfs_jffs2.c b/fs/jffs2/src/vfs_jffs2.c index 63cbf3c6..43922953 100644 --- a/fs/jffs2/src/vfs_jffs2.c +++ b/fs/jffs2/src/vfs_jffs2.c @@ -807,6 +807,11 @@ int VfsJffs2Stat(struct Vnode *pVnode, struct stat *buf) buf->st_mtime = node->i_mtime; buf->st_ctime = node->i_ctime; + /* Adapt to kstat member long tv_sec */ + buf->__st_atim32.tv_sec = (long)node->i_atime; + buf->__st_mtim32.tv_sec = (long)node->i_mtime; + buf->__st_ctim32.tv_sec = (long)node->i_ctime; + LOS_MuxUnlock(&g_jffs2FsLock); return 0; diff --git a/syscall/fs_syscall.c b/syscall/fs_syscall.c index b424b05b..c4f0af49 100644 --- a/syscall/fs_syscall.c +++ b/syscall/fs_syscall.c @@ -1206,7 +1206,7 @@ OUT: return ret; } -int SysStat(const char *path, struct stat *buf) +int SysStat(const char *path, struct kstat *buf) { int ret; char *pathRet = NULL; @@ -1225,7 +1225,7 @@ int SysStat(const char *path, struct stat *buf) goto OUT; } - ret = LOS_ArchCopyToUser(buf, &bufRet, sizeof(struct stat)); + ret = LOS_ArchCopyToUser(buf, &bufRet, sizeof(struct kstat)); if (ret != 0) { ret = -EFAULT; } @@ -1237,7 +1237,7 @@ OUT: return ret; } -int SysLstat(const char *path, struct stat *buffer) +int SysLstat(const char *path, struct kstat *buffer) { int ret; char *pathRet = NULL; @@ -1256,7 +1256,7 @@ int SysLstat(const char *path, struct stat *buffer) goto OUT; } - ret = LOS_ArchCopyToUser(buffer, &bufRet, sizeof(struct stat)); + ret = LOS_ArchCopyToUser(buffer, &bufRet, sizeof(struct kstat)); if (ret != 0) { ret = -EFAULT; } diff --git a/syscall/los_syscall.h b/syscall/los_syscall.h index 37429b88..1934673d 100644 --- a/syscall/los_syscall.h +++ b/syscall/los_syscall.h @@ -55,6 +55,7 @@ #include "time.h" #include "sys/time.h" #include "sys/stat.h" +#include "sys/kstat.h" #ifdef LOSCFG_FS_VFS #include "sys/socket.h" #include "dirent.h" @@ -252,8 +253,8 @@ extern int SysFtruncate(int fd, off_t length); extern int SysStatfs(const char *path, struct statfs *buf); extern int SysStatfs64(const char *path, size_t sz, struct statfs *buf); -extern int SysStat(const char *path, struct stat *buf); -extern int SysLstat(const char *path, struct stat *buffer); +extern int SysStat(const char *path, struct kstat *buf); +extern int SysLstat(const char *path, struct kstat *buffer); extern int SysFstat(int fildes, struct stat *buf); extern int SysStatx(int fd, const char *restrict path, int flag, unsigned mask, struct statx *restrict stx); extern int SysFsync(int fd); -- GitLab