Merge pull request #1066 from BernardXiong/master
[DFS] fix the filesystem_operation_table issue.
This commit is contained in:
commit
baeb63dbf0
|
@ -26,13 +26,15 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
|
|
||||||
|
extern int platform_init(void);
|
||||||
|
extern int mnt_init(void);
|
||||||
|
|
||||||
void rt_init_thread_entry(void *parameter)
|
void rt_init_thread_entry(void *parameter)
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_COMPONENTS_INIT
|
|
||||||
rt_components_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rt_kprintf("Hello RT-Thread!\n");
|
rt_kprintf("Hello RT-Thread!\n");
|
||||||
|
|
||||||
|
platform_init();
|
||||||
|
mnt_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
int rt_application_init()
|
int rt_application_init()
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
int mnt_init(void)
|
int mnt_init(void)
|
||||||
{
|
{
|
||||||
|
dfs_init();
|
||||||
|
|
||||||
#ifdef RT_USING_DFS_WINSHAREDIR
|
#ifdef RT_USING_DFS_WINSHAREDIR
|
||||||
dfs_win32_init();
|
dfs_win32_init();
|
||||||
rt_win_sharedir_init("wshare");
|
rt_win_sharedir_init("wshare");
|
||||||
|
@ -47,7 +49,7 @@ int mnt_init(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
INIT_ENV_EXPORT(mnt_init);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
void platform_init(void)
|
#include <shell.h>
|
||||||
|
|
||||||
|
int platform_init(void)
|
||||||
{
|
{
|
||||||
|
finsh_system_init();
|
||||||
|
|
||||||
#ifdef RT_USING_LWIP
|
#ifdef RT_USING_LWIP
|
||||||
#ifdef RT_USING_TAPNETIF
|
#ifdef RT_USING_TAPNETIF
|
||||||
tap_netif_hw_init();
|
tap_netif_hw_init();
|
||||||
|
@ -24,5 +28,6 @@ void platform_init(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* RT_USING_DFS */
|
#endif /* RT_USING_DFS */
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
INIT_DEVICE_EXPORT(platform_init);
|
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
/*
|
/*
|
||||||
* File : startup.c
|
* File : startup.c
|
||||||
* This file is part of RT-Thread RTOS
|
* This file is part of RT-Thread RTOS
|
||||||
* COPYRIGHT (C) 2006, RT-Thread Develop Team
|
* COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* The license and distribution terms for this file may be
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* found in the file LICENSE in this distribution or at
|
* it under the terms of the GNU General Public License as published by
|
||||||
* http://openlab.rt-thread.com/license/LICENSE
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
|
@ -24,12 +34,8 @@
|
||||||
/*@{*/
|
/*@{*/
|
||||||
|
|
||||||
extern int rt_application_init(void);
|
extern int rt_application_init(void);
|
||||||
#ifdef RT_USING_FINSH
|
|
||||||
extern int finsh_system_init(void);
|
|
||||||
extern void finsh_set_device(const char *device);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern rt_uint8_t *heap;
|
extern rt_uint8_t *heap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will startup RT-Thread RTOS.
|
* This function will startup RT-Thread RTOS.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -99,7 +99,7 @@
|
||||||
// <bool name="RT_USING_PTHREADS" description="Using POSIX threads library" default="true" />
|
// <bool name="RT_USING_PTHREADS" description="Using POSIX threads library" default="true" />
|
||||||
// #define RT_USING_PTHREADS
|
// #define RT_USING_PTHREADS
|
||||||
// <bool name="RT_USING_COMPONENTS_INIT" description="Using automatically component initialization." default="true" />
|
// <bool name="RT_USING_COMPONENTS_INIT" description="Using automatically component initialization." default="true" />
|
||||||
#define RT_USING_COMPONENTS_INIT
|
// #define RT_USING_COMPONENTS_INIT
|
||||||
// <bool name="RT_USING_MODULE" description="Enable Moudle Application" default="true" />
|
// <bool name="RT_USING_MODULE" description="Enable Moudle Application" default="true" />
|
||||||
// #define RT_USING_MODULE
|
// #define RT_USING_MODULE
|
||||||
// </section>
|
// </section>
|
||||||
|
|
|
@ -67,7 +67,7 @@ if PLATFORM == 'gcc':
|
||||||
POST_ACTION = ''
|
POST_ACTION = ''
|
||||||
|
|
||||||
elif PLATFORM == 'mingw':
|
elif PLATFORM == 'mingw':
|
||||||
# toolchains
|
# toolchains
|
||||||
PREFIX = ''
|
PREFIX = ''
|
||||||
CC = PREFIX + 'gcc'
|
CC = PREFIX + 'gcc'
|
||||||
CXX = PREFIX + 'g++'
|
CXX = PREFIX + 'g++'
|
||||||
|
@ -79,11 +79,9 @@ elif PLATFORM == 'mingw':
|
||||||
OBJDUMP = PREFIX + 'objdump'
|
OBJDUMP = PREFIX + 'objdump'
|
||||||
OBJCPY = PREFIX + 'objcopy'
|
OBJCPY = PREFIX + 'objcopy'
|
||||||
|
|
||||||
# DEVICE = ' -ffunction-sections -fdata-sections'
|
|
||||||
DEVICE = ''
|
DEVICE = ''
|
||||||
CFLAGS = DEVICE + ' -D_Win32 -DNO_OLDNAMES -fno-pic -fno-builtin -fno-exceptions -fno-omit-frame-pointer'
|
CFLAGS = DEVICE + ' -D_Win32 -DNO_OLDNAMES -fno-pic -fno-builtin -fno-exceptions -fno-omit-frame-pointer'
|
||||||
|
|
||||||
|
|
||||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
||||||
LFLAGS = DEVICE + ' -static-libgcc -Wl,--gc-sections,-Map=rtthread-win32.map -T mingw.ld '
|
LFLAGS = DEVICE + ' -static-libgcc -Wl,--gc-sections,-Map=rtthread-win32.map -T mingw.ld '
|
||||||
CPATH = ''
|
CPATH = ''
|
||||||
|
@ -117,7 +115,7 @@ elif PLATFORM == 'cl':
|
||||||
CFLAGS += ' /MT'
|
CFLAGS += ' /MT'
|
||||||
LFLAGS += ''
|
LFLAGS += ''
|
||||||
|
|
||||||
CFLAGS += ' /Zi /Od /W 3 /WL '
|
CFLAGS += ' /Zi /Od /W 3 /WL /D_Win32'
|
||||||
LFLAGS += ' /SUBSYSTEM:CONSOLE /MACHINE:X86 /INCREMENTAL:NO'
|
LFLAGS += ' /SUBSYSTEM:CONSOLE /MACHINE:X86 /INCREMENTAL:NO'
|
||||||
|
|
||||||
CPATH = ''
|
CPATH = ''
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* 2005-02-22 Bernard The first version.
|
* 2005-02-22 Bernard The first version.
|
||||||
* 2010-06-30 Bernard Optimize for RT-Thread RTOS
|
* 2010-06-30 Bernard Optimize for RT-Thread RTOS
|
||||||
* 2011-03-12 Bernard fix the filesystem lookup issue.
|
* 2011-03-12 Bernard fix the filesystem lookup issue.
|
||||||
|
* 2017-11-30 Bernard fix the filesystem_operation_table issue.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <dfs_fs.h>
|
#include <dfs_fs.h>
|
||||||
|
@ -252,7 +253,7 @@ int dfs_mount(const char *device_name,
|
||||||
|
|
||||||
for (ops = &filesystem_operation_table[0];
|
for (ops = &filesystem_operation_table[0];
|
||||||
ops < &filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX]; ops++)
|
ops < &filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX]; ops++)
|
||||||
if ((ops != NULL) && (strcmp((*ops)->name, filesystemtype) == 0))
|
if ((*ops != NULL) && (strcmp((*ops)->name, filesystemtype) == 0))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
dfs_unlock();
|
dfs_unlock();
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include <rtconfig.h>
|
#include <rtconfig.h>
|
||||||
|
|
||||||
#ifdef RT_USING_NEWLIB
|
#if defined(RT_USING_NEWLIB) || defined(_WIN32)
|
||||||
/* use errno.h file in newlib */
|
/* use errno.h file in newlib */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -4,13 +4,18 @@
|
||||||
#ifndef LIBC_FCNTL_H__
|
#ifndef LIBC_FCNTL_H__
|
||||||
#define LIBC_FCNTL_H__
|
#define LIBC_FCNTL_H__
|
||||||
|
|
||||||
#ifdef RT_USING_NEWLIB
|
#if defined(RT_USING_NEWLIB) || defined(_WIN32)
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#ifndef O_NONBLOCK
|
#ifndef O_NONBLOCK
|
||||||
#define O_NONBLOCK 04000
|
#define O_NONBLOCK 04000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#define O_DIRECTORY 0200000
|
||||||
|
#define O_ACCMODE (_O_RDONLY | _O_WRONLY | _O_RDWR)
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define O_RDONLY 00
|
#define O_RDONLY 00
|
||||||
#define O_WRONLY 01
|
#define O_WRONLY 01
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include <rtconfig.h>
|
#include <rtconfig.h>
|
||||||
|
|
||||||
#ifdef RT_USING_NEWLIB
|
#if defined(RT_USING_NEWLIB) || defined(_WIN32)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#define _IOC_WRITE 1U
|
#define _IOC_WRITE 1U
|
||||||
#define _IOC_READ 2U
|
#define _IOC_READ 2U
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
#define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
|
#define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
|
||||||
#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
|
#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
|
||||||
#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
|
#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */
|
#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */
|
||||||
#define FIONWRITE _IOR('f', 121, int) /* get # bytes outstanding
|
#define FIONWRITE _IOR('f', 121, int) /* get # bytes outstanding
|
||||||
* in send queue. */
|
* in send queue. */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TCGETS 0x5401
|
#define TCGETS 0x5401
|
||||||
#define TCSETS 0x5402
|
#define TCSETS 0x5402
|
||||||
|
@ -98,7 +100,11 @@
|
||||||
|
|
||||||
#define FIONCLEX 0x5450
|
#define FIONCLEX 0x5450
|
||||||
#define FIOCLEX 0x5451
|
#define FIOCLEX 0x5451
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
#define FIOASYNC 0x5452
|
#define FIOASYNC 0x5452
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TIOCSERCONFIG 0x5453
|
#define TIOCSERCONFIG 0x5453
|
||||||
#define TIOCSERGWILD 0x5454
|
#define TIOCSERGWILD 0x5454
|
||||||
#define TIOCSERSWILD 0x5455
|
#define TIOCSERSWILD 0x5455
|
||||||
|
|
|
@ -40,7 +40,7 @@ typedef signed long off_t;
|
||||||
typedef int mode_t;
|
typedef int mode_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__MINGW32__)
|
#if defined(__MINGW32__) || defined(_WIN32)
|
||||||
typedef signed long off_t;
|
typedef signed long off_t;
|
||||||
typedef int mode_t;
|
typedef int mode_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
/**@{*/
|
/**@{*/
|
||||||
|
|
||||||
/* global errno in RT-Thread */
|
/* global errno in RT-Thread */
|
||||||
static volatile int _errno;
|
static volatile int __rt_errno;
|
||||||
|
|
||||||
#if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE)
|
#if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE)
|
||||||
static rt_device_t _console_device = RT_NULL;
|
static rt_device_t _console_device = RT_NULL;
|
||||||
|
@ -64,12 +64,12 @@ rt_err_t rt_get_errno(void)
|
||||||
if (rt_interrupt_get_nest() != 0)
|
if (rt_interrupt_get_nest() != 0)
|
||||||
{
|
{
|
||||||
/* it's in interrupt context */
|
/* it's in interrupt context */
|
||||||
return _errno;
|
return __rt_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
tid = rt_thread_self();
|
tid = rt_thread_self();
|
||||||
if (tid == RT_NULL)
|
if (tid == RT_NULL)
|
||||||
return _errno;
|
return __rt_errno;
|
||||||
|
|
||||||
return tid->error;
|
return tid->error;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ void rt_set_errno(rt_err_t error)
|
||||||
if (rt_interrupt_get_nest() != 0)
|
if (rt_interrupt_get_nest() != 0)
|
||||||
{
|
{
|
||||||
/* it's in interrupt context */
|
/* it's in interrupt context */
|
||||||
_errno = error;
|
__rt_errno = error;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ void rt_set_errno(rt_err_t error)
|
||||||
tid = rt_thread_self();
|
tid = rt_thread_self();
|
||||||
if (tid == RT_NULL)
|
if (tid == RT_NULL)
|
||||||
{
|
{
|
||||||
_errno = error;
|
__rt_errno = error;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -114,13 +114,13 @@ int *_rt_errno(void)
|
||||||
rt_thread_t tid;
|
rt_thread_t tid;
|
||||||
|
|
||||||
if (rt_interrupt_get_nest() != 0)
|
if (rt_interrupt_get_nest() != 0)
|
||||||
return (int *)&_errno;
|
return (int *)&__rt_errno;
|
||||||
|
|
||||||
tid = rt_thread_self();
|
tid = rt_thread_self();
|
||||||
if (tid != RT_NULL)
|
if (tid != RT_NULL)
|
||||||
return (int *) & (tid->error);
|
return (int *) & (tid->error);
|
||||||
|
|
||||||
return (int *)&_errno;
|
return (int *)&__rt_errno;
|
||||||
}
|
}
|
||||||
RTM_EXPORT(_rt_errno);
|
RTM_EXPORT(_rt_errno);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue