From 63950c9259cb099c4182e29fef3d27b929d66258 Mon Sep 17 00:00:00 2001 From: longtengmcu Date: Sun, 17 May 2020 15:51:35 +0800 Subject: 1、解决do_pollfd函数中处理底层网络设备返回错误-1的情况,返回-1时select函数也要返回-1 2、网卡设备调用关闭dhcp时,底层要调用dhcp_stop函数来关闭dhcp功能,打开时再调用dhcp_start,否则再次打开dhcp时无法获取ip地址或者出现在使用静态ip地址会在dhcp租约到期时自动再获取ip地址。 3、sal_socket.c程序中的sal_accept函数增加判断网卡up,down的功能 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/src/poll.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'components/dfs/src') diff --git a/components/dfs/src/poll.c b/components/dfs/src/poll.c index 3f304549f7..3996fdf580 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 zhaoshimin 20200509*/ + 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 zhaoshimin 20200509*/ + pt->req._proc = RT_NULL; + return ret; + } + else if(ret > 0) { num ++; pt->req._proc = RT_NULL; -- cgit v1.3.1 From d75f03e4b03be4c72c5155cc0b00683da31ae74b Mon Sep 17 00:00:00 2001 From: longtengmcu Date: Thu, 21 May 2020 22:05:38 +0800 Subject: 1、解决do_pollfd函数中处理底层网络设备返回错误-1的情况,返回-1时select函数也要返回-1 … 2、网卡设备调用关闭dhcp时,底层要调用dhcp_stop函数来关闭dhcp功能,打开时再调用dhcp_start,否则再次打开dhcp时无法获取ip地址或者出现在使用静态ip地址会在dhcp租约到期时自动再获取ip地址。 3、sal_socket.c程序中的sal_accept函数增加判断网卡up,down的功能 4、修改注释信息 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/src/poll.c | 4 ++-- components/net/lwip-2.0.2/src/netif/ethernetif.c | 18 +++++++++--------- components/net/sal_socket/src/sal_socket.c | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'components/dfs/src') diff --git a/components/dfs/src/poll.c b/components/dfs/src/poll.c index 3996fdf580..fc48eca758 100644 --- a/components/dfs/src/poll.c +++ b/components/dfs/src/poll.c @@ -138,7 +138,7 @@ static int do_pollfd(struct pollfd *pollfd, rt_pollreq_t *req) mask = f->fops->poll(f, req); - /* dealwith the device return error -1 zhaoshimin 20200509*/ + /* dealwith the device return error -1*/ if (mask < 0) { fd_put(f); @@ -180,7 +180,7 @@ static int poll_do(struct pollfd *fds, nfds_t nfds, struct rt_poll_table *pt, in ret = do_pollfd(pf, &pt->req); if(ret < 0) { - /*dealwith the device return error -1 zhaoshimin 20200509*/ + /*dealwith the device return error -1 */ pt->req._proc = RT_NULL; return ret; } diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c index 8e90f0daf3..be16da7ad3 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -165,15 +165,15 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) { netdev_low_level_set_dhcp_status(netif, is_enabled); - /*zhaoshimin 20200508 add dhcp start or stop must call dhcp_start and dhcp_stop function*/ - if(is_enabled == RT_TRUE) - { - dhcp_start((struct netif *)netif->user_data); - } - else - { - dhcp_stop((struct netif *)netif->user_data); - } + /*add dhcp start or stop must call dhcp_start and dhcp_stop function*/ + if(is_enabled == RT_TRUE) + { + dhcp_start((struct netif *)netif->user_data); + } + else + { + dhcp_stop((struct netif *)netif->user_data); + } return ERR_OK; } #endif /* RT_LWIP_DHCP */ diff --git a/components/net/sal_socket/src/sal_socket.c b/components/net/sal_socket/src/sal_socket.c index 1e43896012..ec0519df02 100644 --- a/components/net/sal_socket/src/sal_socket.c +++ b/components/net/sal_socket/src/sal_socket.c @@ -564,7 +564,7 @@ int sal_accept(int socket, struct sockaddr *addr, socklen_t *addrlen) /* get the socket object by socket descriptor */ SAL_SOCKET_OBJ_GET(sock, socket); - /* check the network interface is up status zhaoshimin add 20200509*/ + /* check the network interface is up status */ SAL_NETDEV_IS_UP(sock->netdev); /* check the network interface socket operations */ -- cgit v1.3.1 From ad3e6d889854f646fcfb1abc618d5fa3e1140b4e Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Fri, 7 Aug 2020 08:51:22 +0800 Subject: [DFS] clean the unnecessary checking --- components/dfs/src/dfs_fs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'components/dfs/src') diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c index 476e47fc06..c21b914727 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)); @@ -568,8 +568,7 @@ int dfs_unmount_device(rt_device_t dev) iter < &filesystem_table[DFS_FILESYSTEMS_MAX]; iter++) { /* check if the PATH is mounted */ - if ((iter->dev_id->parent.name != NULL) - && (strcmp(iter->dev_id->parent.name, dev->parent.name) == 0)) + if (strcmp(iter->dev_id->parent.name, dev->parent.name) == 0) { fs = iter; break; -- cgit v1.3.1 From 50dc41468ef69b6b79979772f9689d8d3099df30 Mon Sep 17 00:00:00 2001 From: tangyuxin <462747508@qq.com> Date: Sat, 26 Sep 2020 09:55:58 +0800 Subject: [add] DFS file system supports device types --- components/dfs/filesystems/devfs/devfs.c | 2 ++ components/dfs/include/dfs.h | 1 + components/dfs/src/dfs.c | 1 + 3 files changed, 4 insertions(+) (limited to 'components/dfs/src') diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c index 936b074ce1..7637074dbb 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; } } 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); -- cgit v1.3.1 From 8861202c3b0a74d5e4d73176c38518a5418b2019 Mon Sep 17 00:00:00 2001 From: tangyuxin <462747508@qq.com> Date: Sat, 26 Sep 2020 12:30:39 +0800 Subject: [dfs] fix the DEVICE could not get or set flags --- components/dfs/src/dfs_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'components/dfs/src') 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) { -- cgit v1.3.1