dfsv2 code tidy. (#8374)

This commit is contained in:
geniusgogo
2023-12-16 18:06:47 +08:00
committed by GitHub
parent 4658267117
commit 6b22a0a2b7
8 changed files with 201 additions and 275 deletions

View File

@@ -115,12 +115,11 @@ int dfs_fdtable_drop_fd(struct dfs_fdtable *fdtab, int fd);
#ifdef DFS_USING_POSIX
/* FD APIs */
int fdt_fd_new(struct dfs_fdtable *fdt);
struct dfs_file *fdt_fd_get(struct dfs_fdtable* fdt, int fd);
struct dfs_file *fdt_get_file(struct dfs_fdtable* fdt, int fd);
void fdt_fd_release(struct dfs_fdtable* fdt, int fd);
int fd_new(void);
int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_file *file);
int fdt_fd_associate_file(struct dfs_fdtable *fdt, int fd, struct dfs_file *file);
struct dfs_file *fd_get(int fd);
int fd_get_fd_index(struct dfs_file *file);
void fd_release(int fd);
void fd_init(struct dfs_file *fd);

File diff suppressed because it is too large Load Diff

View File

@@ -9,6 +9,10 @@
* 2023-10-23 Shell fix synchronization of data to icache
*/
#define DBG_TAG "dfs.pcache"
#define DBG_LVL DBG_WARNING
#include <rtdbg.h>
#include "dfs_pcache.h"
#include "dfs_dentry.h"
#include "dfs_mnt.h"
@@ -20,10 +24,6 @@
#ifdef RT_USING_PAGECACHE
#define DBG_TAG "dfs.pcache"
#define DBG_LVL DBG_WARNING
#include <rtdbg.h>
#ifndef RT_PAGECACHE_COUNT
#define RT_PAGECACHE_COUNT 4096
#endif

View File

@@ -402,93 +402,3 @@ void dfs_seq_pad(struct dfs_seq_file *seq, char c)
dfs_seq_putc(seq, c);
}
}
#if 1
/* test demo */
static char *txt[4] = {
"text1",
"text2",
"text3",
"text4",
};
static void *seq_test_start(struct dfs_seq_file *seq, off_t *index)
{
off_t i = *index; // seq->index
if (i >= 0 && i < 4)
{
return txt[i];
}
return RT_NULL;
}
static void seq_test_stop(struct dfs_seq_file *seq, void *data)
{
}
static void *seq_test_next(struct dfs_seq_file *seq, void *data, off_t *index)
{
off_t i = *index + 1; // seq->index
*index = i;
if (i >= 0 && i < 4)
{
return txt[i];
}
return RT_NULL;
}
static int seq_test_show(struct dfs_seq_file *seq, void *data)
{
const char *text = (const char *)data;
dfs_seq_setwidth(seq, 20);
dfs_seq_puts(seq, "puts ");
dfs_seq_putc(seq, 'c');
dfs_seq_write(seq, " write", 6);
dfs_seq_printf(seq, " %s", text);
dfs_seq_pad(seq, 0);
return 0;
}
static const struct dfs_seq_ops _test_ops = {
.start = seq_test_start,
.stop = seq_test_stop,
.next = seq_test_next,
.show = seq_test_show,
};
static int dfs_seq_test(int argc, char **argv)
{
struct dfs_file file = {0};
int ret = dfs_seq_open(&file, &_test_ops);
if (ret == 0)
{
char buf[256] = {0};
off_t pos = (argc > 1) ? atoi(argv[1]) : 0;
ssize_t len = (argc > 2) ? atoi(argv[2]) : 255;
if (len > 255)
{
len = 255;
rt_kprintf("buf len is %d, max read is 255\n", 256, len);
}
len = dfs_seq_read(&file, buf, len, &pos);
buf[len] = '\0';
rt_kprintf("show: \"%s\" len: %d\n", buf, len);
dfs_seq_release(&file);
}
return 0;
}
MSH_CMD_EXPORT_ALIAS(dfs_seq_test, seq_test, seq_test[pos][read_len]);
#endif

View File

@@ -1089,11 +1089,11 @@ static void lwp_copy_stdio_fdt(struct rt_lwp *lwp)
{
lwp_fdt->maxfd = 4;
d = fd_get(0);
fd_associate(lwp_fdt, 0, d);
fdt_fd_associate_file(lwp_fdt, 0, d);
d = fd_get(1);
fd_associate(lwp_fdt, 1, d);
fdt_fd_associate_file(lwp_fdt, 1, d);
d = fd_get(2);
fd_associate(lwp_fdt, 2, d);
fdt_fd_associate_file(lwp_fdt, 2, d);
}
return;

View File

@@ -961,7 +961,7 @@ static struct dfs_file *lwp_fd_get(int fdt_type, int fd)
{
fdt = dfs_fdtable_get();
}
return fdt_fd_get(fdt, fd);
return fdt_get_file(fdt, fd);
}
static void lwp_fd_release(int fdt_type, int fd)

View File

@@ -2049,7 +2049,7 @@ static int lwp_copy_files(struct rt_lwp *dst, struct rt_lwp *src)
/* dup files */
for (i = 0; i < src_fdt->maxfd; i++)
{
d_s = fdt_fd_get(src_fdt, i);
d_s = fdt_get_file(src_fdt, i);
if (d_s)
{
dst_fdt->fds[i] = d_s;

View File

@@ -3,3 +3,4 @@ CONFIG_UTEST_MEMHEAP_TC=y
# dependencies
CONFIG_RT_USING_SMART=y
CONFIG_RT_USING_MEMHEAP=y
CONFIG_RT_USING_DFS_V2=y