Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
90b9c37b
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
460
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
90b9c37b
编写于
4月 01, 2021
作者:
O
openharmony_ci
提交者:
Gitee
4月 01, 2021
浏览文件
操作
浏览文件
下载
差异文件
!107 Fix OHOS shell cannot ls a file
Merge pull request !107 from ysy4tc3/dev
上级
be5e5fdf
704f60f6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
78 addition
and
40 deletion
+78
-40
fs/vfs/operation/fs_other.c
fs/vfs/operation/fs_other.c
+78
-40
未找到文件。
fs/vfs/operation/fs_other.c
100755 → 100644
浏览文件 @
90b9c37b
...
...
@@ -513,16 +513,75 @@ static void PrintFileInfo(const struct stat *statInfo, const char *name)
PRINTK
(
"%c%s%s%s %-8lld u:%-5d g:%-5d %-10s
\n
"
,
dirFlag
,
str
[
0
],
str
[
1
],
str
[
UGO_NUMS
-
1
],
statInfo
->
st_size
,
statInfo
->
st_uid
,
statInfo
->
st_gid
,
name
);
}
void
ls
(
const
char
*
pathname
)
int
LsFile
(
const
char
*
path
)
{
struct
stat64
stat64_info
;
struct
stat
stat_info
;
struct
dirent
*
pdirent
=
NULL
;
char
*
path
=
NULL
;
struct
stat64
stat64Info
;
struct
stat
statInfo
;
if
(
stat64
(
path
,
&
stat64Info
)
==
0
)
{
PrintFileInfo64
(
&
stat64Info
,
path
);
}
else
if
(
stat
(
path
,
&
statInfo
)
==
0
)
{
PrintFileInfo
(
&
statInfo
,
path
);
}
else
{
return
-
1
;
}
return
0
;
}
int
LsDir
(
const
char
*
path
)
{
struct
stat
statInfo
=
{
0
};
struct
stat64
stat64Info
=
{
0
};
DIR
*
d
=
NULL
;
char
*
fullpath
=
NULL
;
char
*
fullpath_bak
=
NULL
;
struct
dirent
*
pdirent
=
NULL
;
d
=
opendir
(
path
);
if
(
d
==
NULL
)
{
return
-
1
;
}
PRINTK
(
"Directory %s:
\n
"
,
path
);
do
{
pdirent
=
readdir
(
d
);
if
(
pdirent
==
NULL
)
{
break
;
}
else
{
if
(
!
strcmp
(
pdirent
->
d_name
,
"."
)
||
!
strcmp
(
pdirent
->
d_name
,
".."
))
{
continue
;
}
(
void
)
memset_s
(
&
statInfo
,
sizeof
(
struct
stat
),
0
,
sizeof
(
struct
stat
));
(
void
)
memset_s
(
&
stat64Info
,
sizeof
(
struct
stat
),
0
,
sizeof
(
struct
stat
));
fullpath
=
ls_get_fullpath
(
path
,
pdirent
);
if
(
fullpath
==
NULL
)
{
(
void
)
closedir
(
d
);
return
-
1
;
}
fullpath_bak
=
fullpath
;
if
(
stat64
(
fullpath
,
&
stat64Info
)
==
0
)
{
PrintFileInfo64
(
&
stat64Info
,
pdirent
->
d_name
);
}
else
if
(
stat
(
fullpath
,
&
statInfo
)
==
0
)
{
PrintFileInfo
(
&
statInfo
,
pdirent
->
d_name
);
}
else
{
PRINTK
(
"BAD file: %s
\n
"
,
pdirent
->
d_name
);
}
free
(
fullpath_bak
);
}
}
while
(
1
);
(
void
)
closedir
(
d
);
return
0
;
}
void
ls
(
const
char
*
pathname
)
{
struct
stat
statInfo
=
{
0
};
char
*
path
=
NULL
;
int
ret
;
DIR
*
d
=
NULL
;
if
(
pathname
==
NULL
)
{
#ifdef VFS_USING_WORKDIR
...
...
@@ -548,44 +607,23 @@ void ls(const char *pathname)
}
}
/* list all directory and file*/
d
=
opendir
(
path
);
if
(
d
==
NULL
)
{
ret
=
stat
(
path
,
&
statInfo
);
if
(
ret
<
0
)
{
perror
(
"ls error"
);
}
else
{
PRINTK
(
"Directory %s:
\n
"
,
path
);
do
{
pdirent
=
readdir
(
d
);
if
(
pdirent
==
NULL
)
{
break
;
}
else
{
if
(
!
strcmp
(
pdirent
->
d_name
,
"."
)
||
!
strcmp
(
pdirent
->
d_name
,
".."
))
{
continue
;
}
(
void
)
memset_s
(
&
stat_info
,
sizeof
(
struct
stat
),
0
,
sizeof
(
struct
stat
));
fullpath
=
ls_get_fullpath
(
path
,
pdirent
);
if
(
fullpath
==
NULL
)
{
free
(
path
);
(
void
)
closedir
(
d
);
return
;
}
fullpath_bak
=
fullpath
;
if
(
stat64
(
fullpath
,
&
stat64_info
)
==
0
)
{
PrintFileInfo64
(
&
stat64_info
,
pdirent
->
d_name
);
}
else
if
(
stat
(
fullpath
,
&
stat_info
)
==
0
)
{
PrintFileInfo
(
&
stat_info
,
pdirent
->
d_name
);
}
else
{
PRINTK
(
"BAD file: %s
\n
"
,
pdirent
->
d_name
);
}
free
(
fullpath_bak
);
}
}
while
(
1
);
free
(
path
);
return
;
}
(
void
)
closedir
(
d
);
if
(
statInfo
.
st_mode
&
S_IFDIR
)
{
/* list all directory and file */
ret
=
LsDir
((
pathname
==
NULL
)
?
path
:
pathname
);
}
else
{
/* show the file infomation */
ret
=
LsFile
(
path
);
}
if
(
ret
<
0
)
{
perror
(
"ls error"
);
}
free
(
path
);
free
(
path
);
return
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录