Skip to content

Commit 1f16147

Browse files
committed
Merge the patch to fix fd issue; lwIP protect issue
1 parent 8e43999 commit 1f16147

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

Diff for: components/dfs/src/dfs_file.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* Date Author Notes
2222
* 2005-02-22 Bernard The first version.
2323
* 2011-12-08 Bernard Merges rename patch from iamcacy.
24+
* 2015-05-27 Bernard Fix the fd clear issue.
2425
*/
2526

2627
#include <dfs.h>
@@ -97,7 +98,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
9798
{
9899
/* clear fd */
99100
rt_free(fd->path);
100-
rt_memset(fd, 0, sizeof(*fd));
101+
fd->path = RT_NULL;
101102

102103
return -DFS_STATUS_ENOSYS;
103104
}
@@ -106,7 +107,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
106107
{
107108
/* clear fd */
108109
rt_free(fd->path);
109-
rt_memset(fd, 0, sizeof(*fd));
110+
fd->path = RT_NULL;
110111

111112
dfs_log(DFS_DEBUG_INFO, ("open failed"));
112113

@@ -143,7 +144,7 @@ int dfs_file_close(struct dfs_fd *fd)
143144
return result;
144145

145146
rt_free(fd->path);
146-
rt_memset(fd, 0, sizeof(struct dfs_fd));
147+
fd->path = RT_NULL;
147148

148149
return result;
149150
}
@@ -165,7 +166,7 @@ int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args)
165166
return -DFS_STATUS_EINVAL;
166167

167168
fs = fd->fs;
168-
if (fs->ops->ioctl != RT_NULL)
169+
if (fs->ops->ioctl != RT_NULL)
169170
return fs->ops->ioctl(fd, cmd, args);
170171

171172
return -DFS_STATUS_ENOSYS;
@@ -652,7 +653,6 @@ static void copyfile(const char *src, const char *dst)
652653
extern int mkdir(const char *path, mode_t mode);
653654
static void copydir(const char * src, const char * dst)
654655
{
655-
struct dfs_fd fd;
656656
struct dirent dirent;
657657
struct stat stat;
658658
int length;

Diff for: components/dfs/src/dfs_posix.c

+4
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,15 @@ off_t lseek(int fd, off_t offset, int whence)
230230
break;
231231

232232
default:
233+
fd_put(d);
233234
rt_set_errno(-DFS_STATUS_EINVAL);
234235

235236
return -1;
236237
}
237238

238239
if (offset < 0)
239240
{
241+
fd_put(d);
240242
rt_set_errno(-DFS_STATUS_EINVAL);
241243

242244
return -1;
@@ -427,6 +429,7 @@ int mkdir(const char *path, mode_t mode)
427429

428430
if (result < 0)
429431
{
432+
fd_put(d);
430433
fd_put(d);
431434
rt_set_errno(result);
432435

@@ -435,6 +438,7 @@ int mkdir(const char *path, mode_t mode)
435438

436439
dfs_file_close(d);
437440
fd_put(d);
441+
fd_put(d);
438442

439443
return 0;
440444
}

Diff for: components/net/lwip-1.4.1/src/arch/include/arch/cc.h

+4
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,9 @@ void sys_arch_assert(const char* file, int line);
103103

104104
#include "string.h"
105105

106+
#define SYS_ARCH_DECL_PROTECT(level)
107+
#define SYS_ARCH_PROTECT(level) rt_enter_critical()
108+
#define SYS_ARCH_UNPROTECT(level) rt_exit_critical()
109+
106110
#endif /* __ARCH_CC_H__ */
107111

Diff for: include/rtdef.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* File : rtdef.h
33
* This file is part of RT-Thread RTOS
4-
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
4+
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
55
*
66
* This program is free software; you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by

Diff for: src/kservice.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1072,8 +1072,8 @@ rt_device_t rt_console_set_device(const char *name)
10721072
}
10731073

10741074
/* set new console device */
1075+
rt_device_open(new, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_STREAM);
10751076
_console_device = new;
1076-
rt_device_open(_console_device, RT_DEVICE_OFLAG_RDWR);
10771077
}
10781078

10791079
return old;

0 commit comments

Comments
 (0)