Ver Fonte

内核使用lwp_getcwd打开文件有错误,无法获取当前目录

@lin12345678 há 4 anos atrás
pai
commit
9933755954
2 ficheiros alterados com 10 adições e 5 exclusões
  1. 0 4
      components/dfs/src/dfs_posix.c
  2. 10 1
      components/lwp/lwp.c

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

@@ -936,10 +936,6 @@ char *getcwd(char *buf, size_t size)
     dfs_lock();
     dfs_lock();
 #ifdef RT_USING_LWP
 #ifdef RT_USING_LWP
     dir_buf = lwp_getcwd();
     dir_buf = lwp_getcwd();
-    if(dir_buf[0] != '/')
-    {
-        dir_buf = &working_directory[0];
-    }
     rt_strncpy(buf, dir_buf, size);
     rt_strncpy(buf, dir_buf, size);
 #else
 #else
     dir_buf = &working_directory[0];
     dir_buf = &working_directory[0];

+ 10 - 1
components/lwp/lwp.c

@@ -80,7 +80,16 @@ char *lwp_getcwd(void)
 
 
     lwp = (struct rt_lwp *)rt_thread_self()->lwp;
     lwp = (struct rt_lwp *)rt_thread_self()->lwp;
     if (lwp)
     if (lwp)
-        dir_buf = &lwp->working_directory[0];
+    {
+        if(lwp->working_directory[0] != '/')
+        {
+            dir_buf = &working_directory[0];
+        }
+        else
+        {
+            dir_buf = &lwp->working_directory[0];
+        }
+    }
     else
     else
         dir_buf = &working_directory[0];
         dir_buf = &working_directory[0];
 #else
 #else