实现free指令+修复 mountfs的内存泄露问题(#394)

* 实现meminfo文件

* 成功实现free指令,添加了一些string有关函数,并进行一些无影响的小改动


* 解决内存泄露的问题:mountfs inode的wrap方法使用了Arc::into_raw而没有from_raw,导致inode始终无法释放

---------

Co-authored-by: LoGin <longjin@DragonOS.org>
Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
yuyi2439
2023-10-08 14:26:17 +08:00
committed by GitHub
parent afc95d5c25
commit 34e6d6c80f
16 changed files with 401 additions and 89 deletions

View File

@ -320,7 +320,7 @@ int shell_cmd_cat(int argc, char **argv)
char *file_path = get_target_filepath(argv[1], &path_len);
// 打开文件
int fd = open(file_path, 0);
int fd = open(file_path, O_RDONLY);
if (fd <= 0)
{
printf("ERROR: Cannot open file: %s, fd=%d\n", file_path, fd);
@ -593,13 +593,13 @@ int shell_cmd_free(int argc, char **argv)
printf("Mem:\t");
if (argc == 1) // 按照kb显示
{
printf("%ld\t%ld\t%ld\t%ld\t%ld\t%ld\t\n", mst.total >> 10, mst.used >> 10, mst.free >> 10, mst.shared >> 10,
mst.cache_used >> 10, mst.available >> 10);
printf("%ld\t%ld\t%ld\t%ld\t%ld\t%ld\t\n", mst.total, mst.used, mst.free, mst.shared,
mst.cache_used, mst.available);
}
else // 按照MB显示
{
printf("%ld\t%ld\t%ld\t%ld\t%ld\t%ld\t\n", mst.total >> 20, mst.used >> 20, mst.free >> 20, mst.shared >> 20,
mst.cache_used >> 20, mst.available >> 20);
printf("%ld\t%ld\t%ld\t%ld\t%ld\t%ld\t\n", mst.total >> 10, mst.used >> 10, mst.free >> 10, mst.shared >> 10,
mst.cache_used >> 10, mst.available >> 10);
}
done:;