[add] DFS file system supports device types

This commit is contained in:
tangyuxin 2020-09-26 09:55:58 +08:00
parent 8ffe242228
commit 50dc41468e
3 changed files with 4 additions and 0 deletions

View File

@ -186,6 +186,7 @@ int dfs_device_fs_open(struct dfs_fd *file)
result = file->fops->open(file);
if (result == RT_EOK || result == -RT_ENOSYS)
{
file->type = FT_DEVICE;
return 0;
}
}
@ -197,6 +198,7 @@ int dfs_device_fs_open(struct dfs_fd *file)
if (result == RT_EOK || result == -RT_ENOSYS)
{
file->data = device;
file->type = FT_DEVICE;
return RT_EOK;
}
}

View File

@ -55,6 +55,7 @@
#define FT_SOCKET 1 /* socket file */
#define FT_DIRECTORY 2 /* directory */
#define FT_USER 3 /* user defined */
#define FT_DEVICE 4 /* device */
/* File flags */
#define DFS_F_OPEN 0x01000000

View File

@ -542,6 +542,7 @@ int list_fd(void)
else if (fd->type == FT_REGULAR) rt_kprintf("%-7.7s ", "file");
else if (fd->type == FT_SOCKET) rt_kprintf("%-7.7s ", "socket");
else if (fd->type == FT_USER) rt_kprintf("%-7.7s ", "user");
else if (fd->type == FT_DEVICE) rt_kprintf("%-7.7s ", "device");
else rt_kprintf("%-8.8s ", "unknown");
rt_kprintf("%3d ", fd->ref_count);
rt_kprintf("%04x ", fd->magic);