Просмотр исходного кода

[dfs] fix the getcwd and libc issue

BernardXiong 4 лет назад
Родитель
Сommit
53b8b785fd

+ 0 - 4
components/dfs/src/dfs.c

@@ -19,10 +19,6 @@
 #include <lwp.h>
 #endif
 
-#if defined(RT_USING_DFS_DEVFS) && defined(RT_USING_POSIX)
-#include <libc.h>
-#endif
-
 /* Global variables */
 const struct dfs_filesystem_ops *filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX];
 struct dfs_filesystem filesystem_table[DFS_FILESYSTEMS_MAX];

+ 10 - 2
components/dfs/src/dfs_posix.c

@@ -931,15 +931,23 @@ RTM_EXPORT(setcwd);
  */
 char *getcwd(char *buf, size_t size)
 {
-    char *dir_buf = RT_NULL;
 #ifdef DFS_USING_WORKDIR
+    char *dir_buf = RT_NULL;
+
     dfs_lock();
+
 #ifdef RT_USING_LWP
     dir_buf = lwp_getcwd();
-    rt_strncpy(buf, dir_buf, size);
 #else
     dir_buf = &working_directory[0];
 #endif
+
+    /* copy to buf parameter */
+    if (buf)
+    {
+        rt_strncpy(buf, dir_buf, size);
+    }
+
     dfs_unlock();
 #else
     rt_kprintf(NO_WORKING_DIR);

+ 7 - 3
components/libc/compilers/newlib/SConscript

@@ -6,6 +6,7 @@ cwd = GetCurrentDir()
 group = []
 
 CPPDEFINES = []
+CPPPATH = []
 
 # link with libc and libm:
 # libm is a frequently used lib. Newlib is compiled with -ffunction-sections in
@@ -17,11 +18,14 @@ if rtconfig.PLATFORM == 'gcc' and GetDepend('RT_USING_LIBC'):
     if GetDepend('RT_USING_MUSL'):
         # musl libc is used as a software library.
         src  = []
-        LIBS = []
     elif GetDepend('RT_USING_NEWLIB'):
         # RT_USING_NEWLIB is defined already
         CPPPATH = [cwd]
-        group = DefineGroup('newlib', src, depend = ['RT_USING_LIBC'], 
-            CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
+    else:
+        CPPPATH = [cwd]
+        CPPDEFINES = ['RT_USING_NEWLIB']
+
+    group = DefineGroup('newlib', src, depend = ['RT_USING_LIBC'],
+        CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
 
 Return('group')

+ 1 - 0
libcpu/Kconfig

@@ -82,6 +82,7 @@ config RT_IOREMAP_LATE
     bool "Support to create IO mapping in the kernel address space after system initlalization."
     default n
     depends on ARCH_ARM_CORTEX_A
+    depends on RT_USING_USERSPACE
 
 config ARCH_ARM_ARM9
     bool