Skip to content

Commit

Permalink
Merge pull request RT-Thread#3931 from enkiller/0926
Browse files Browse the repository at this point in the history
[add] DFS file system supports device types
  • Loading branch information
BernardXiong authored Sep 26, 2020
2 parents 8ffe242 + 50dc414 commit 3893176
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/dfs/filesystems/devfs/devfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down
1 change: 1 addition & 0 deletions components/dfs/include/dfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions components/dfs/src/dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3893176

Please sign in to comment.