Merge pull request #1573 from enkiller/dev

[components][dfs] list_fd 打印信息更加友好
This commit is contained in:
Bernard Xiong 2018-06-26 15:20:27 +08:00 committed by GitHub
commit 355e9f29fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 9 deletions

View File

@ -522,23 +522,30 @@ int list_fd(void)
if (!fd_table) return -1; if (!fd_table) return -1;
rt_enter_critical(); rt_enter_critical();
rt_kprintf("fd type ref magic path\n");
rt_kprintf("-- ------ --- ----- ------\n");
for (index = 0; index < fd_table->maxfd; index ++) for (index = 0; index < fd_table->maxfd; index ++)
{ {
struct dfs_fd *fd = fd_table->fds[index]; struct dfs_fd *fd = fd_table->fds[index];
if (fd->fops) if (fd->fops)
{ {
rt_kprintf("--fd: %d--", index); rt_kprintf("%2d ", index);
if (fd->type == FT_DIRECTORY) rt_kprintf("[dir]\n"); if (fd->type == FT_DIRECTORY) rt_kprintf("%-7.7s ", "dir");
if (fd->type == FT_REGULAR) rt_kprintf("[file]\n"); else if (fd->type == FT_REGULAR) rt_kprintf("%-7.7s ", "file");
if (fd->type == FT_SOCKET) rt_kprintf("[socket]\n"); else if (fd->type == FT_SOCKET) rt_kprintf("%-7.7s ", "socket");
if (fd->type == FT_USER) rt_kprintf("[user]\n"); else if (fd->type == FT_USER) rt_kprintf("%-7.7s ", "user");
rt_kprintf("refcount=%d\n", fd->ref_count); else rt_kprintf("%-8.8s ", "unknown");
rt_kprintf("magic=0x%04x\n", fd->magic); rt_kprintf("%3d ", fd->ref_count);
rt_kprintf("%04x ", fd->magic);
if (fd->path) if (fd->path)
{ {
rt_kprintf("path: %s\n", fd->path); rt_kprintf("%s\n", fd->path);
}
else
{
rt_kprintf("\n");
} }
} }
} }