Skip to content

Commit baeb63d

Browse files
authored
Merge pull request #1066 from BernardXiong/master
[DFS] fix the filesystem_operation_table issue.
2 parents f004ff1 + ae7237d commit baeb63d

File tree

13 files changed

+58
-33
lines changed

13 files changed

+58
-33
lines changed

bsp/simulator/applications/application.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@
2626
#include <stdio.h>
2727
#include <board.h>
2828

29+
extern int platform_init(void);
30+
extern int mnt_init(void);
31+
2932
void rt_init_thread_entry(void *parameter)
3033
{
31-
#ifdef RT_USING_COMPONENTS_INIT
32-
rt_components_init();
33-
#endif
34-
3534
rt_kprintf("Hello RT-Thread!\n");
35+
36+
platform_init();
37+
mnt_init();
3638
}
3739

3840
int rt_application_init()

bsp/simulator/applications/mnt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
int mnt_init(void)
1717
{
18+
dfs_init();
19+
1820
#ifdef RT_USING_DFS_WINSHAREDIR
1921
dfs_win32_init();
2022
rt_win_sharedir_init("wshare");
@@ -47,7 +49,7 @@ int mnt_init(void)
4749
}
4850
#endif
4951

52+
return 0;
5053
}
51-
INIT_ENV_EXPORT(mnt_init);
5254

5355
#endif

bsp/simulator/applications/platform.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#include <rtthread.h>
22
#include "board.h"
33

4-
void platform_init(void)
4+
#include <shell.h>
5+
6+
int platform_init(void)
57
{
8+
finsh_system_init();
9+
610
#ifdef RT_USING_LWIP
711
#ifdef RT_USING_TAPNETIF
812
tap_netif_hw_init();
@@ -24,5 +28,6 @@ void platform_init(void)
2428
#endif
2529

2630
#endif /* RT_USING_DFS */
31+
32+
return 0;
2733
}
28-
INIT_DEVICE_EXPORT(platform_init);

bsp/simulator/applications/startup.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
/*
22
* File : startup.c
33
* This file is part of RT-Thread RTOS
4-
* COPYRIGHT (C) 2006, RT-Thread Develop Team
4+
* COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
55
*
6-
* The license and distribution terms for this file may be
7-
* found in the file LICENSE in this distribution or at
8-
* http://openlab.rt-thread.com/license/LICENSE
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with this program; if not, write to the Free Software Foundation, Inc.,
18+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
919
*
1020
* Change Logs:
1121
* Date Author Notes
@@ -24,12 +34,8 @@
2434
/*@{*/
2535

2636
extern int rt_application_init(void);
27-
#ifdef RT_USING_FINSH
28-
extern int finsh_system_init(void);
29-
extern void finsh_set_device(const char *device);
30-
#endif
31-
3237
extern rt_uint8_t *heap;
38+
3339
/**
3440
* This function will startup RT-Thread RTOS.
3541
*/

bsp/simulator/rtconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
// <bool name="RT_USING_PTHREADS" description="Using POSIX threads library" default="true" />
100100
// #define RT_USING_PTHREADS
101101
// <bool name="RT_USING_COMPONENTS_INIT" description="Using automatically component initialization." default="true" />
102-
#define RT_USING_COMPONENTS_INIT
102+
// #define RT_USING_COMPONENTS_INIT
103103
// <bool name="RT_USING_MODULE" description="Enable Moudle Application" default="true" />
104104
// #define RT_USING_MODULE
105105
// </section>

bsp/simulator/rtconfig.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
POST_ACTION = ''
6868

6969
elif PLATFORM == 'mingw':
70-
# toolchains
70+
# toolchains
7171
PREFIX = ''
7272
CC = PREFIX + 'gcc'
7373
CXX = PREFIX + 'g++'
@@ -79,11 +79,9 @@
7979
OBJDUMP = PREFIX + 'objdump'
8080
OBJCPY = PREFIX + 'objcopy'
8181

82-
# DEVICE = ' -ffunction-sections -fdata-sections'
8382
DEVICE = ''
8483
CFLAGS = DEVICE + ' -D_Win32 -DNO_OLDNAMES -fno-pic -fno-builtin -fno-exceptions -fno-omit-frame-pointer'
8584

86-
8785
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
8886
LFLAGS = DEVICE + ' -static-libgcc -Wl,--gc-sections,-Map=rtthread-win32.map -T mingw.ld '
8987
CPATH = ''
@@ -117,7 +115,7 @@
117115
CFLAGS += ' /MT'
118116
LFLAGS += ''
119117

120-
CFLAGS += ' /Zi /Od /W 3 /WL '
118+
CFLAGS += ' /Zi /Od /W 3 /WL /D_Win32'
121119
LFLAGS += ' /SUBSYSTEM:CONSOLE /MACHINE:X86 /INCREMENTAL:NO'
122120

123121
CPATH = ''

components/dfs/src/dfs_fs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* 2005-02-22 Bernard The first version.
2323
* 2010-06-30 Bernard Optimize for RT-Thread RTOS
2424
* 2011-03-12 Bernard fix the filesystem lookup issue.
25+
* 2017-11-30 Bernard fix the filesystem_operation_table issue.
2526
*/
2627

2728
#include <dfs_fs.h>
@@ -252,7 +253,7 @@ int dfs_mount(const char *device_name,
252253

253254
for (ops = &filesystem_operation_table[0];
254255
ops < &filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX]; ops++)
255-
if ((ops != NULL) && (strcmp((*ops)->name, filesystemtype) == 0))
256+
if ((*ops != NULL) && (strcmp((*ops)->name, filesystemtype) == 0))
256257
break;
257258

258259
dfs_unlock();

include/libc/libc_errno.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include <rtconfig.h>
2929

30-
#ifdef RT_USING_NEWLIB
30+
#if defined(RT_USING_NEWLIB) || defined(_WIN32)
3131
/* use errno.h file in newlib */
3232
#include <errno.h>
3333
#else

include/libc/libc_fcntl.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
#ifndef LIBC_FCNTL_H__
55
#define LIBC_FCNTL_H__
66

7-
#ifdef RT_USING_NEWLIB
7+
#if defined(RT_USING_NEWLIB) || defined(_WIN32)
88
#include <fcntl.h>
99

1010
#ifndef O_NONBLOCK
1111
#define O_NONBLOCK 04000
1212
#endif
1313

14+
#if defined(_WIN32)
15+
#define O_DIRECTORY 0200000
16+
#define O_ACCMODE (_O_RDONLY | _O_WRONLY | _O_RDWR)
17+
#endif
18+
1419
#else
1520
#define O_RDONLY 00
1621
#define O_WRONLY 01

include/libc/libc_fdset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include <rtconfig.h>
2929

30-
#ifdef RT_USING_NEWLIB
30+
#if defined(RT_USING_NEWLIB) || defined(_WIN32)
3131
#include <sys/types.h>
3232
#else
3333

0 commit comments

Comments
 (0)