diff options
| author | Bernard Xiong <[email protected]> | 2021-03-02 15:00:43 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-03-02 15:00:43 +0800 |
| commit | 2c12493ff342ea9ba808311c3f6835eba31a8d3e (patch) | |
| tree | b1e1dfbeaead7c08ab8d7d0f34066154c125841b /components/dfs | |
| parent | 5f17cf9204e501d971cd28486e0a7193d2f1fae4 (diff) | |
| parent | 19871ac32e41590b1f3e3742d9ab023dc3147ba0 (diff) | |
Merge pull request #4404 from KyleChenjh/lts-v3.1.x
[Update] Sync from v4.0.3
Diffstat (limited to 'components/dfs')
| -rw-r--r-- | components/dfs/filesystems/devfs/devfs.c | 4 | ||||
| -rw-r--r-- | components/dfs/filesystems/jffs2/src/gcthread.c | 28 | ||||
| -rw-r--r-- | components/dfs/filesystems/romfs/dfs_romfs.c | 2 | ||||
| -rw-r--r-- | components/dfs/filesystems/uffs/src/example/flash-interface-example.c | 8 | ||||
| -rw-r--r-- | components/dfs/filesystems/uffs/uffs_nandif.c | 4 | ||||
| -rw-r--r-- | components/dfs/include/dfs.h | 1 | ||||
| -rw-r--r-- | components/dfs/src/dfs.c | 1 | ||||
| -rw-r--r-- | components/dfs/src/dfs_file.c | 2 | ||||
| -rw-r--r-- | components/dfs/src/dfs_fs.c | 4 | ||||
| -rw-r--r-- | components/dfs/src/poll.c | 18 |
10 files changed, 57 insertions, 15 deletions
diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c index 936b074ce1..e457f18727 100644 --- a/components/dfs/filesystems/devfs/devfs.c +++ b/components/dfs/filesystems/devfs/devfs.c @@ -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; } } @@ -324,7 +326,7 @@ static const struct dfs_filesystem_ops _device_fs = int devfs_init(void) { - /* register rom file system */ + /* register device file system */ dfs_register(&_device_fs); return 0; diff --git a/components/dfs/filesystems/jffs2/src/gcthread.c b/components/dfs/filesystems/jffs2/src/gcthread.c index 4005ec4788..ab66e1878e 100644 --- a/components/dfs/filesystems/jffs2/src/gcthread.c +++ b/components/dfs/filesystems/jffs2/src/gcthread.c @@ -187,7 +187,8 @@ jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c) { struct super_block *sb=OFNI_BS_2SFFJ(c); cyg_mtab_entry *mte; - rt_uint32_t e; + rt_uint32_t e; + rt_err_t result; //RT_ASSERT(sb->s_gc_thread_handle); @@ -198,10 +199,20 @@ jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c) D1(printk("jffs2_stop_garbage_collect_thread wait\n")); - rt_event_recv(&sb->s_gc_thread_flags, + result = rt_event_recv(&sb->s_gc_thread_flags, GC_THREAD_FLAG_HAS_EXIT, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, RT_WAITING_FOREVER, &e); + if (result == -RT_ETIMEOUT) + { + LOG_E("wait completed timeout"); + return; + } + else if (result == -RT_ERROR) + { + LOG_E("event received error"); + return; + } // Kill and free the resources ... this is safe due to the flag // from the thread. @@ -218,15 +229,26 @@ jffs2_garbage_collect_thread(unsigned long data) struct super_block *sb=OFNI_BS_2SFFJ(c); cyg_mtab_entry *mte; rt_uint32_t flag = 0; + rt_err_t result; D1(printk("jffs2_garbage_collect_thread START\n")); while(1) { - rt_event_recv(&sb->s_gc_thread_flags, + result = rt_event_recv(&sb->s_gc_thread_flags, GC_THREAD_FLAG_TRIG | GC_THREAD_FLAG_STOP, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, cyg_current_time() + CYGNUM_JFFS2_GS_THREAD_TICKS, &flag); + if (result == -RT_ETIMEOUT) + { + LOG_E("wait completed timeout"); + continue; + } + else if (result == -RT_ERROR) + { + LOG_E("event received error"); + continue; + } if (flag & GC_THREAD_FLAG_STOP) break; diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c index dcc34e5830..17dbee52f5 100644 --- a/components/dfs/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/filesystems/romfs/dfs_romfs.c @@ -62,7 +62,7 @@ struct romfs_dirent *dfs_romfs_lookup(struct romfs_dirent *root_dirent, const ch return root_dirent; } - /* goto root directy entries */ + /* goto root directory entries */ dirent = (struct romfs_dirent *)root_dirent->data; dirent_size = root_dirent->size; diff --git a/components/dfs/filesystems/uffs/src/example/flash-interface-example.c b/components/dfs/filesystems/uffs/src/example/flash-interface-example.c index 9a6e008262..ff26beb281 100644 --- a/components/dfs/filesystems/uffs/src/example/flash-interface-example.c +++ b/components/dfs/filesystems/uffs/src/example/flash-interface-example.c @@ -292,11 +292,11 @@ static uffs_FlashOps g_my_nand_ops = { nand_init_flash, // InitFlash() nand_release_flash, // ReleaseFlash() nand_read_page, // ReadPage() - NULL, // ReadPageWithLayout + NULL, // ReadPageWithLayout nand_write_page, // WritePage() - NULL, // WirtePageWithLayout - NULL, // IsBadBlock(), let UFFS take care of it. - NULL, // MarkBadBlock(), let UFFS take care of it. + NULL, // WritePageWithLayout + NULL, // IsBadBlock(), let UFFS take care of it. + NULL, // MarkBadBlock(), let UFFS take care of it. nand_erase_block, // EraseBlock() }; diff --git a/components/dfs/filesystems/uffs/uffs_nandif.c b/components/dfs/filesystems/uffs/uffs_nandif.c index 47cb88b6aa..2e1a981fba 100644 --- a/components/dfs/filesystems/uffs/uffs_nandif.c +++ b/components/dfs/filesystems/uffs/uffs_nandif.c @@ -135,7 +135,7 @@ const uffs_FlashOps nand_ops = nand_read_page, /* ReadPage() */ NULL, /* ReadPageWithLayout */ nand_write_page, /* WritePage() */ - NULL, /* WirtePageWithLayout */ + NULL, /* WritePageWithLayout */ #if defined(RT_UFFS_USE_CHECK_MARK_FUNCITON) nand_check_block, nand_mark_badblock, @@ -302,7 +302,7 @@ const uffs_FlashOps nand_ops = NULL, /* ReadPage() */ ReadPageWithLayout, /* ReadPageWithLayout */ NULL, /* WritePage() */ - WritePageWithLayout,/* WirtePageWithLayout */ + WritePageWithLayout,/* WritePageWithLayout */ #if defined(RT_UFFS_USE_CHECK_MARK_FUNCITON) nand_check_block, diff --git a/components/dfs/include/dfs.h b/components/dfs/include/dfs.h index eb32a4b411..1158df93cb 100644 --- a/components/dfs/include/dfs.h +++ b/components/dfs/include/dfs.h @@ -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 diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c index b20de13988..7ace0bc160 100644 --- a/components/dfs/src/dfs.c +++ b/components/dfs/src/dfs.c @@ -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); diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c index 91d39597f0..fd205f2f3a 100644 --- a/components/dfs/src/dfs_file.c +++ b/components/dfs/src/dfs_file.c @@ -157,7 +157,7 @@ int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args) return -EINVAL; /* regular file system fd */ - if (fd->type == FT_REGULAR) + if (fd->type == FT_REGULAR || fd->type == FT_DEVICE) { switch (cmd) { diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c index 164beed719..f380cd8997 100644 --- a/components/dfs/src/dfs_fs.c +++ b/components/dfs/src/dfs_fs.c @@ -129,7 +129,7 @@ const char *dfs_filesystem_get_mounted_path(struct rt_device *device) for (iter = &filesystem_table[0]; iter < &filesystem_table[DFS_FILESYSTEMS_MAX]; iter++) { - /* fint the mounted device */ + /* find the mounted device */ if (iter->ops == NULL) continue; else if (iter->dev_id == device) { @@ -321,7 +321,7 @@ int dfs_mount(const char *device_name, if (rt_device_open(fs->dev_id, RT_DEVICE_OFLAG_RDWR) != RT_EOK) { - /* The underlaying device has error, clear the entry. */ + /* The underlying device has error, clear the entry. */ dfs_lock(); memset(fs, 0, sizeof(struct dfs_filesystem)); diff --git a/components/dfs/src/poll.c b/components/dfs/src/poll.c index 3f304549f7..fc48eca758 100644 --- a/components/dfs/src/poll.c +++ b/components/dfs/src/poll.c @@ -137,6 +137,14 @@ static int do_pollfd(struct pollfd *pollfd, rt_pollreq_t *req) req->_key = pollfd->events | POLLERR | POLLHUP; mask = f->fops->poll(f, req); + + /* dealwith the device return error -1*/ + if (mask < 0) + { + fd_put(f); + pollfd->revents = 0; + return mask; + } } /* Mask out unneeded events. */ mask &= pollfd->events | POLLERR | POLLHUP; @@ -154,6 +162,7 @@ static int poll_do(struct pollfd *fds, nfds_t nfds, struct rt_poll_table *pt, in int istimeout = 0; int n; struct pollfd *pf; + int ret = 0; if (msec == 0) { @@ -168,7 +177,14 @@ static int poll_do(struct pollfd *fds, nfds_t nfds, struct rt_poll_table *pt, in for (n = 0; n < nfds; n ++) { - if (do_pollfd(pf, &pt->req)) + ret = do_pollfd(pf, &pt->req); + if(ret < 0) + { + /*dealwith the device return error -1 */ + pt->req._proc = RT_NULL; + return ret; + } + else if(ret > 0) { num ++; pt->req._proc = RT_NULL; |
