You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "Gary-Hobson (via GitHub)" <gi...@apache.org> on 2023/03/21 16:01:19 UTC

[GitHub] [nuttx] Gary-Hobson opened a new pull request, #8868: fs/hostfs: add sim hostfs path convert

Gary-Hobson opened a new pull request, #8868:
URL: https://github.com/apache/nuttx/pull/8868

   ## Summary
   Set sim/hostfs to use the path where the executable file is located as the root path
   
   In the sim, hostfs uses $CWD as the root path. When running in different paths, the access path of hostfs is different.
   
   This patch is changed to use the path where the nuttx file is located as the root path, so that the mounted path is fixed when executed in different paths
   
   ## Impact
   sim
   
   ## Testing
   sim:nsh
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] Gary-Hobson commented on a diff in pull request #8868: fs/hostfs: switch working directory

Posted by "Gary-Hobson (via GitHub)" <gi...@apache.org>.
Gary-Hobson commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1166365739


##########
arch/sim/Kconfig:
##########
@@ -159,6 +159,20 @@ config SIM_HOSTFS
 	---help---
 		Access host filesystem through HostFS.
 
+if SIM_HOSTFS
+config SIM_IMAGEPATH_AS_CWD
+	bool "Simulator switch working directory"

Review Comment:
   done
   I put it inside sim_misc.c so it can be independent of hostfs



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#issuecomment-1479625519

   
   > > ls /data will report the error. This patch ensures the user get the consistent result regardless he launches the program from anywhere.
   > 
   > probably sometimes it's a good thing. in the other cases it can be a bad thing.
   
   could you explain more when is it good or bad? I can't understand why it's a bad thing to give the user the consistent result.
   
   > i don't see much motivation to change the behavior.
   > 
   
   So, you don't reject the change, thanks.
   
   > > Do you have better suggestion?
   > 
   > if you want a consistent result, why don't you use a consistent cwd?
   
   I never complain this since I am very familiar with the code base and understand I need launch from nuttx directory. But many people who use hostfs first time hit this problem frequently. Actually, this is the hottest issue reported by the end user.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] Gary-Hobson commented on a diff in pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "Gary-Hobson (via GitHub)" <gi...@apache.org>.
Gary-Hobson commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1161482603


##########
arch/sim/Kconfig:
##########
@@ -159,6 +159,15 @@ config SIM_HOSTFS
 	---help---
 		Access host filesystem through HostFS.
 
+if SIM_HOSTFS
+config SIM_HOSTFS_PATH_CONVERSION
+bool "Simulated HostFS path conversion"
+default n
+---help---
+	If this option is enabled, the nuttx image folder will be used as the root path
+	when hostfs accesses the file, otherwise $CWD will be used as the root path to search

Review Comment:
   Regardless of whether this configuration is enabled or not, it will not affect the absolute path.
   After executing mount -t hostfs -o fs=/absolutepath /mnt, /mnt is always mapped to /absolutepath
   
   The root path here indicates the starting point to find the file, maybe I should change the description



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1160047733


##########
arch/sim/Kconfig:
##########
@@ -159,6 +159,15 @@ config SIM_HOSTFS
 	---help---
 		Access host filesystem through HostFS.
 
+if SIM_HOSTFS
+	config SIM_HOSTFS_PATH_CONVERSION

Review Comment:
   ```suggestion
   config SIM_HOSTFS_PATH_CONVERSION
   	depends on SIM_HOSTFS
   ```
   and remove if/endif



##########
arch/sim/Kconfig:
##########
@@ -159,6 +159,15 @@ config SIM_HOSTFS
 	---help---
 		Access host filesystem through HostFS.
 
+if SIM_HOSTFS
+	config SIM_HOSTFS_PATH_CONVERSION
+	bool "Simulated HostFS path conversion"
+	default n
+	---help---
+		If this option is enabled, the nuttx file will be used as the root path

Review Comment:
   ```suggestion
   		If this option is enabled, the nuttx image folder will be used as the root path
   ```



##########
arch/sim/src/sim/posix/sim_hostfs.c:
##########
@@ -36,10 +36,66 @@
 
 #include "hostfs.h"
 
+#ifdef CONFIG_HOST_MACOS
+#include <sys/syslimits.h>
+#include <mach-o/dyld.h>
+#endif
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: host_path_convert
+ ****************************************************************************/
+
+static int host_path_convert(const char *path, char *abspath,
+                             uint32_t buflen)
+{
+#ifndef CONFIG_SIM_HOSTFS_PATH_CONVERSION

Review Comment:
   ```suggestion
   #ifdef CONFIG_SIM_HOSTFS_PATH_CONVERSION
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] Gary-Hobson commented on a diff in pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "Gary-Hobson (via GitHub)" <gi...@apache.org>.
Gary-Hobson commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1163714289


##########
arch/sim/src/sim/posix/sim_hostfs.c:
##########
@@ -36,10 +36,66 @@
 
 #include "hostfs.h"
 
+#ifdef CONFIG_HOST_MACOS
+#include <sys/syslimits.h>
+#include <mach-o/dyld.h>
+#endif
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: host_path_convert
+ ****************************************************************************/
+
+static int host_path_convert(const char *path, char *abspath,
+                             uint32_t buflen)
+{
+#ifndef CONFIG_SIM_HOSTFS_PATH_CONVERSION
+      strncpy(abspath, path, buflen);
+      abspath[buflen - 1] = '\0';
+      return 0;
+#else
+  int ret;
+  char *name;
+
+  if (path[0] == '/')
+    {
+      strncpy(abspath, path, buflen);
+      abspath[buflen - 1] = '\0';
+      return 0;
+    }
+
+  /* Get the absolute path of the executable file */
+
+#  ifdef CONFIG_HOST_LINUX
+  ret = readlink("/proc/self/exe", abspath, buflen);

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] Gary-Hobson commented on a diff in pull request #8868: fs/hostfs: switch working directory

Posted by "Gary-Hobson (via GitHub)" <gi...@apache.org>.
Gary-Hobson commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1166269085


##########
arch/sim/Kconfig:
##########
@@ -159,6 +159,20 @@ config SIM_HOSTFS
 	---help---
 		Access host filesystem through HostFS.
 
+if SIM_HOSTFS
+config SIM_IMAGEPATH_AS_CWD
+	bool "Simulator switch working directory"

Review Comment:
   At present I think its impact is limited to hostfs, because nuttx does not request other path-related data from host.
   
   If it needs to be changed, I haven't figured out where to put the "host_fs_init" function. If it is placed in sim_hostfs.c, it needs to rely on SIM_HOSTFS



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] Gary-Hobson commented on a diff in pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "Gary-Hobson (via GitHub)" <gi...@apache.org>.
Gary-Hobson commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1163544061


##########
arch/sim/src/sim/posix/sim_hostfs.c:
##########
@@ -36,10 +36,66 @@
 
 #include "hostfs.h"
 
+#ifdef CONFIG_HOST_MACOS
+#include <sys/syslimits.h>
+#include <mach-o/dyld.h>
+#endif
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: host_path_convert
+ ****************************************************************************/
+
+static int host_path_convert(const char *path, char *abspath,
+                             uint32_t buflen)
+{
+#ifndef CONFIG_SIM_HOSTFS_PATH_CONVERSION

Review Comment:
   It should be ifndef, only when the CONFIG_SIM_HOSTFS_PATH_CONVERSION option is enabled, the folder where nuttx is located will be used as the initial search path



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] yamt commented on a diff in pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "yamt (via GitHub)" <gi...@apache.org>.
yamt commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1163614758


##########
arch/sim/src/sim/posix/sim_hostfs.c:
##########
@@ -36,10 +36,66 @@
 
 #include "hostfs.h"
 
+#ifdef CONFIG_HOST_MACOS
+#include <sys/syslimits.h>
+#include <mach-o/dyld.h>
+#endif
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: host_path_convert
+ ****************************************************************************/
+
+static int host_path_convert(const char *path, char *abspath,
+                             uint32_t buflen)
+{
+#ifndef CONFIG_SIM_HOSTFS_PATH_CONVERSION
+      strncpy(abspath, path, buflen);
+      abspath[buflen - 1] = '\0';
+      return 0;
+#else
+  int ret;
+  char *name;
+
+  if (path[0] == '/')
+    {
+      strncpy(abspath, path, buflen);
+      abspath[buflen - 1] = '\0';
+      return 0;
+    }
+
+  /* Get the absolute path of the executable file */
+
+#  ifdef CONFIG_HOST_LINUX
+  ret = readlink("/proc/self/exe", abspath, buflen);

Review Comment:
   i meant to chdir into the directory where the nuttx executable is.
   or use the directory for the "at" fd for openat family.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#issuecomment-1496175434

   > > > > > > ls /data will report the error. This patch ensures the user get the consistent result regardless he launches the program from anywhere.
   > > > > > 
   > > > > > 
   > > > > > probably sometimes it's a good thing. in the other cases it can be a bad thing.
   > > > > 
   > > > > 
   > > > > could you explain more when is it good or bad? I can't understand why it's a bad thing to give the user the consistent result.
   > > > 
   > > > 
   > > > i usually don't use relative path to mount hostfs.
   > > 
   > > 
   > > If you want to share the prebuilt nuttx binary or initial script to other people, the related path is better than the absolute path, since the host resource folder mounted by the initial script is normally at the fix location related to nuttx binary.
   > > > but when i do, i expect it means relative to the host cwd.
   > > 
   > > 
   > > From the previous example, you can see the location related to nuttx binary is better than the current directory.
   > > > this change introduces a surprising behavior to me.
   > > 
   > > 
   > > As I explain before, it's the top complaint from our daily report. Since you seldom use the relative path in mount, please trust the data we collected, thanks.
   > 
   > what's "our daily report"?
   > 
   > i can understand some people is not happy with the current behavior. i suspect there can be more people who is happy with the current behavior though.
   > 
   > with the current behavior, if you want to use a path relative to the executable, you can just set cwd. after this change, it's impossible to use a cwd-relative path. i consider it less flexible.
   > 
   > > > at least on traditional unix, the path of executable usually doesn't affect the behavior of it.
   > > 
   > > 
   > > Here is a demo that shared-object search path may relate to the path of executable: https://unix.stackexchange.com/questions/22926/where-do-executables-look-for-shared-objects-at-runtime
   > 
   > i'm aware of $ORIGIN stuff. that's why i said "traditional". IMO it's a misfeature.
   
   Ok, let's stop the discussion which one is better. @Gary-Hobson let's support both.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#issuecomment-1501362215

   @yamt is the new change good?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] yamt commented on pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "yamt (via GitHub)" <gi...@apache.org>.
yamt commented on PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#issuecomment-1478728855

   > In the sim, hostfs uses $CWD as the root path. When running in different paths, the access path of hostfs is different.
   
   what's wrong with it?
   
   > This patch is changed to use the path where the nuttx file is located as the root path, so that the mounted path is fixed when executed in different paths
   
   i feel it's awkward to use the path of the executable for this purpose.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] yamt commented on a diff in pull request #8868: fs/hostfs: switch working directory

Posted by "yamt (via GitHub)" <gi...@apache.org>.
yamt commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1166373248


##########
arch/sim/Kconfig:
##########
@@ -159,6 +159,20 @@ config SIM_HOSTFS
 	---help---
 		Access host filesystem through HostFS.
 
+if SIM_HOSTFS
+config SIM_IMAGEPATH_AS_CWD
+	bool "Simulator switch working directory"

Review Comment:
   thank you.
   for example, `SIM_NETDEV_VPNKIT_PATH` can be affected.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8868: fs/hostfs: switch working directory

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1166896537


##########
arch/sim/src/sim/win/sim_misc.c:
##########
@@ -0,0 +1,68 @@
+/****************************************************************************
+ * arch/sim/src/sim/win/sim_misc.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <direct.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <windows.h>
+#include <libloaderapi.h>
+
+#include "sim_internal.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: host_change_cwd
+ ****************************************************************************/
+
+#ifdef CONFIG_SIM_IMAGEPATH_AS_CWD
+void sim_change_cwd(void)
+{
+  int ret;
+  char *name;
+  char nuttxpath[MAX_PATH];
+
+  /* Get the absolute path of the executable file */
+
+  ret = GetModuleFileNameA(GetModuleHandleA(NULL), nuttxpath, MAX_PATH);
+  if (ret == 0)
+    {
+      perror("sim_change_cwd failed");

Review Comment:
   ```suggestion
         perror("GetModuleFileNameA failed");
   ```



##########
arch/sim/src/sim/sim_internal.h:
##########
@@ -209,6 +209,12 @@ int sim_init_ipi(int irq);
 void sim_timer_update(void);
 #endif
 
+/* sim_misc.c ***************************************************************/
+
+#ifdef CONFIG_SIM_IMAGEPATH_AS_CWD
+void sim_change_cwd(void);

Review Comment:
   ```suggestion
   void sim_init_cwd(void);
   ```



##########
arch/sim/src/sim/win/sim_misc.c:
##########
@@ -0,0 +1,68 @@
+/****************************************************************************
+ * arch/sim/src/sim/win/sim_misc.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <direct.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <windows.h>
+#include <libloaderapi.h>
+
+#include "sim_internal.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: host_change_cwd
+ ****************************************************************************/
+
+#ifdef CONFIG_SIM_IMAGEPATH_AS_CWD
+void sim_change_cwd(void)
+{
+  int ret;
+  char *name;
+  char nuttxpath[MAX_PATH];

Review Comment:
   path



##########
arch/sim/src/sim/posix/sim_misc.c:
##########
@@ -0,0 +1,80 @@
+/****************************************************************************
+ * arch/sim/src/sim/posix/sim_misc.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <dirent.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "sim_internal.h"
+
+#ifdef CONFIG_HOST_MACOS
+#include <sys/syslimits.h>
+#include <mach-o/dyld.h>
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sim_change_cwd
+ ****************************************************************************/
+
+#ifdef CONFIG_SIM_IMAGEPATH_AS_CWD
+void sim_change_cwd(void)
+{
+  int ret;
+  char *name;
+  char nuttxpath[PATH_MAX];

Review Comment:
   ```suggestion
     char path[PATH_MAX];
   ```



##########
arch/sim/src/sim/posix/sim_misc.c:
##########
@@ -0,0 +1,80 @@
+/****************************************************************************
+ * arch/sim/src/sim/posix/sim_misc.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <dirent.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "sim_internal.h"
+
+#ifdef CONFIG_HOST_MACOS
+#include <sys/syslimits.h>
+#include <mach-o/dyld.h>
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sim_change_cwd
+ ****************************************************************************/
+
+#ifdef CONFIG_SIM_IMAGEPATH_AS_CWD
+void sim_change_cwd(void)
+{
+  int ret;
+  char *name;
+  char nuttxpath[PATH_MAX];
+  int buflen = PATH_MAX;
+
+  /* Get the absolute path of the executable file */
+
+#  ifdef CONFIG_HOST_LINUX
+  ret = readlink("/proc/self/exe", nuttxpath, buflen);
+  if (ret < 0)
+    {
+      perror("sim_change_cwd failed");

Review Comment:
   ```suggestion
         perror("readlink failed");
   ```



##########
arch/sim/src/sim/posix/sim_misc.c:
##########
@@ -0,0 +1,80 @@
+/****************************************************************************
+ * arch/sim/src/sim/posix/sim_misc.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <dirent.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "sim_internal.h"
+
+#ifdef CONFIG_HOST_MACOS
+#include <sys/syslimits.h>
+#include <mach-o/dyld.h>
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sim_change_cwd
+ ****************************************************************************/
+
+#ifdef CONFIG_SIM_IMAGEPATH_AS_CWD
+void sim_change_cwd(void)
+{
+  int ret;
+  char *name;
+  char nuttxpath[PATH_MAX];
+  int buflen = PATH_MAX;
+
+  /* Get the absolute path of the executable file */
+
+#  ifdef CONFIG_HOST_LINUX
+  ret = readlink("/proc/self/exe", nuttxpath, buflen);
+  if (ret < 0)
+    {
+      perror("sim_change_cwd failed");
+      return;
+    }
+
+  nuttxpath[ret] = '\0';
+#  else
+  ret = _NSGetExecutablePath(nuttxpath, &buflen);
+  if (ret < 0)
+    {
+      perror("sim_change_cwd failed");

Review Comment:
   ```suggestion
         perror("_NSGetExecutablePath failed");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] yamt commented on pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "yamt (via GitHub)" <gi...@apache.org>.
yamt commented on PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#issuecomment-1493726460

   > > > ls /data will report the error. This patch ensures the user get the consistent result regardless he launches the program from anywhere.
   > > 
   > > 
   > > probably sometimes it's a good thing. in the other cases it can be a bad thing.
   > 
   > could you explain more when is it good or bad? I can't understand why it's a bad thing to give the user the consistent result.
   
   i usually don't use relative path to mount hostfs.
   but when i do, i expect it means relative to the host cwd.
   this change introduces a surprising behavior to me.
   
   at least on traditional unix, the path of executable usually doesn't affect the behavior of it.
   
   > 
   > > i don't see much motivation to change the behavior.
   > 
   > So, you don't reject the change, thanks.
   > 
   > > > Do you have better suggestion?
   > > 
   > > 
   > > if you want a consistent result, why don't you use a consistent cwd?
   > 
   > I never complain this since I am very familiar with the code base and understand I need launch from nuttx directory. But many people who use hostfs first time hit this problem frequently. Actually, this is the hottest issue reported by the end user and key reason that @Gary-Hobson provide this patch.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#issuecomment-1494735139

   > > > > ls /data will report the error. This patch ensures the user get the consistent result regardless he launches the program from anywhere.
   > > > 
   > > > 
   > > > probably sometimes it's a good thing. in the other cases it can be a bad thing.
   > > 
   > > 
   > > could you explain more when is it good or bad? I can't understand why it's a bad thing to give the user the consistent result.
   > 
   > i usually don't use relative path to mount hostfs.
   
   If you want to share the prebuilt nuttx binary or initial script to other people, the related path is better than the absolute path, since the host resource folder mounted by the initial script is normally at the fix location related to nuttx binary.
   
   > but when i do, i expect it means relative to the host cwd.
   
   From the previous example, you can see the location related to nuttx binary is better than the current directory.
   
   > this change introduces a surprising behavior to me.
   > 
   
   As I explain before, it's the top complaint from our daily report. Since you seldom use the relative path in mount, please trust the data we collected, thanks.
   
   > at least on traditional unix, the path of executable usually doesn't affect the behavior of it.
   > 
   
   Here is a demo that shared-object search path may relate to the path of executable:
   https://unix.stackexchange.com/questions/22926/where-do-executables-look-for-shared-objects-at-runtime


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] yamt commented on a diff in pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "yamt (via GitHub)" <gi...@apache.org>.
yamt commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1161477288


##########
arch/sim/Kconfig:
##########
@@ -159,6 +159,15 @@ config SIM_HOSTFS
 	---help---
 		Access host filesystem through HostFS.
 
+if SIM_HOSTFS
+config SIM_HOSTFS_PATH_CONVERSION
+bool "Simulated HostFS path conversion"
+default n
+---help---
+	If this option is enabled, the nuttx image folder will be used as the root path
+	when hostfs accesses the file, otherwise $CWD will be used as the root path to search

Review Comment:
   my understanding is this option doesn't affect `mount -t hostfs -o fs=/absolutepath /mnt`. right?
   this description makes me think otherwise.
   especially the term `the root path` gives me an impression it changes the behavior of absolute paths.



##########
arch/sim/src/sim/posix/sim_hostfs.c:
##########
@@ -36,10 +36,66 @@
 
 #include "hostfs.h"
 
+#ifdef CONFIG_HOST_MACOS
+#include <sys/syslimits.h>
+#include <mach-o/dyld.h>
+#endif
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: host_path_convert
+ ****************************************************************************/
+
+static int host_path_convert(const char *path, char *abspath,
+                             uint32_t buflen)
+{
+#ifndef CONFIG_SIM_HOSTFS_PATH_CONVERSION
+      strncpy(abspath, path, buflen);
+      abspath[buflen - 1] = '\0';
+      return 0;
+#else
+  int ret;
+  char *name;
+
+  if (path[0] == '/')
+    {
+      strncpy(abspath, path, buflen);
+      abspath[buflen - 1] = '\0';
+      return 0;
+    }
+
+  /* Get the absolute path of the executable file */
+
+#  ifdef CONFIG_HOST_LINUX
+  ret = readlink("/proc/self/exe", abspath, buflen);

Review Comment:
   isn't it simpler to use chdir(2)?
   or maybe even openat family?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] Gary-Hobson commented on a diff in pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "Gary-Hobson (via GitHub)" <gi...@apache.org>.
Gary-Hobson commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1163543146


##########
arch/sim/src/sim/posix/sim_hostfs.c:
##########
@@ -36,10 +36,66 @@
 
 #include "hostfs.h"
 
+#ifdef CONFIG_HOST_MACOS
+#include <sys/syslimits.h>
+#include <mach-o/dyld.h>
+#endif
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: host_path_convert
+ ****************************************************************************/
+
+static int host_path_convert(const char *path, char *abspath,
+                             uint32_t buflen)
+{
+#ifndef CONFIG_SIM_HOSTFS_PATH_CONVERSION
+      strncpy(abspath, path, buflen);
+      abspath[buflen - 1] = '\0';
+      return 0;
+#else
+  int ret;
+  char *name;
+
+  if (path[0] == '/')
+    {
+      strncpy(abspath, path, buflen);
+      abspath[buflen - 1] = '\0';
+      return 0;
+    }
+
+  /* Get the absolute path of the executable file */
+
+#  ifdef CONFIG_HOST_LINUX
+  ret = readlink("/proc/self/exe", abspath, buflen);

Review Comment:
   Just using chdir doesn't solve the problem,
   Because its problem is how to provide a fixed path as the starting search location.
   chdir still uses $CWD as the starting path, and the results of executing nuttx in different paths are still different.
   So we need to get the folder where the nuttx file is located as the starting path



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] yamt commented on pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "yamt (via GitHub)" <gi...@apache.org>.
yamt commented on PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#issuecomment-1496884086

   > > > > > > > ls /data will report the error. This patch ensures the user get the consistent result regardless he launches the program from anywhere.
   > > > > > > 
   > > > > > > 
   > > > > > > probably sometimes it's a good thing. in the other cases it can be a bad thing.
   > > > > > 
   > > > > > 
   > > > > > could you explain more when is it good or bad? I can't understand why it's a bad thing to give the user the consistent result.
   > > > > 
   > > > > 
   > > > > i usually don't use relative path to mount hostfs.
   > > > 
   > > > 
   > > > If you want to share the prebuilt nuttx binary or initial script to other people, the related path is better than the absolute path, since the host resource folder mounted by the initial script is normally at the fix location related to nuttx binary.
   > > > > but when i do, i expect it means relative to the host cwd.
   > > > 
   > > > 
   > > > From the previous example, you can see the location related to nuttx binary is better than the current directory.
   > > > > this change introduces a surprising behavior to me.
   > > > 
   > > > 
   > > > As I explain before, it's the top complaint from our daily report. Since you seldom use the relative path in mount, please trust the data we collected, thanks.
   > > 
   > > 
   > > what's "our daily report"?
   > > i can understand some people is not happy with the current behavior. i suspect there can be more people who is happy with the current behavior though.
   > > with the current behavior, if you want to use a path relative to the executable, you can just set cwd. after this change, it's impossible to use a cwd-relative path. i consider it less flexible.
   > > > > at least on traditional unix, the path of executable usually doesn't affect the behavior of it.
   > > > 
   > > > 
   > > > Here is a demo that shared-object search path may relate to the path of executable: https://unix.stackexchange.com/questions/22926/where-do-executables-look-for-shared-objects-at-runtime
   > > 
   > > 
   > > i'm aware of $ORIGIN stuff. that's why i said "traditional". IMO it's a misfeature.
   > 
   > Ok, let's stop the discussion which one is better. @Gary-Hobson let's support both.
   
   i agree that there seems no single "obvious" behavior.
   maybe you can support something similar to "$ORIGIN" in the path.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] yamt commented on pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "yamt (via GitHub)" <gi...@apache.org>.
yamt commented on PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#issuecomment-1479289100

   > > > In the sim, hostfs uses $CWD as the root path. When running in different paths, the access path of hostfs is different.
   > > 
   > > 
   > > what's wrong with it?
   > 
   > @yamt Here is an example, Directory layout:
   > 
   > ```
   > work/apps/
   > work/nuttx/
   > work/data/
   > ```
   > 
   > rcS contain:
   > 
   > ```
   > mount -t hostfs ../data /data
   > ```
   > 
   > if user launch nuttx by:
   > 
   > ```
   > cd work/nuttx
   > ./nuttx
   > ```
   > 
   > he can access PC's data directory without error, but if user launch nuttx by:
   > 
   > ```
   > cd work
   > ./nuttx/nuttx
   > ```
   > 
   > ls /data will report the error. This patch ensures the user get the consistent result regardless he launches the program from anywhere.
   
   probably sometimes it's a good thing.
   in the other cases it can be a bad thing.
   i don't see much motivation to change the behavior.
   
   > 
   > > > This patch is changed to use the path where the nuttx file is located as the root path, so that the mounted path is fixed when executed in different paths
   > > 
   > > 
   > > i feel it's awkward to use the path of the executable for this purpose.
   > 
   > Do you have better suggestion?
   
   if you want a consistent result, why don't you use a consistent cwd?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1143771518


##########
arch/sim/src/sim/posix/sim_hostfs.c:
##########
@@ -36,10 +36,56 @@
 
 #include "hostfs.h"
 
+#ifdef CONFIG_HOST_MACOS
+#include <mach-o/dyld.h>
+#endif
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: host_path_convert
+ ****************************************************************************/
+
+static int host_path_convert(const char *path, char *abspath, int buflen)

Review Comment:
   let's do the similar thing for windows too



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 merged pull request #8868: fs/hostfs: switch working directory

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #8868:
URL: https://github.com/apache/nuttx/pull/8868


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] yamt commented on pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "yamt (via GitHub)" <gi...@apache.org>.
yamt commented on PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#issuecomment-1495453430

   > > > > > ls /data will report the error. This patch ensures the user get the consistent result regardless he launches the program from anywhere.
   > > > > 
   > > > > 
   > > > > probably sometimes it's a good thing. in the other cases it can be a bad thing.
   > > > 
   > > > 
   > > > could you explain more when is it good or bad? I can't understand why it's a bad thing to give the user the consistent result.
   > > 
   > > 
   > > i usually don't use relative path to mount hostfs.
   > 
   > If you want to share the prebuilt nuttx binary or initial script to other people, the related path is better than the absolute path, since the host resource folder mounted by the initial script is normally at the fix location related to nuttx binary.
   > 
   > > but when i do, i expect it means relative to the host cwd.
   > 
   > From the previous example, you can see the location related to nuttx binary is better than the current directory.
   > 
   > > this change introduces a surprising behavior to me.
   > 
   > As I explain before, it's the top complaint from our daily report. Since you seldom use the relative path in mount, please trust the data we collected, thanks.
   
   what's "our daily report"?
   
   i can understand some people is not happy with the current behavior.
   i suspect there can be more people who is happy with the current behavior though.
   
   with the current behavior, if you want to use a path relative to the executable, you can just set cwd.
   after this change, it's impossible to use a cwd-relative path. i consider it less flexible.
   
   > 
   > > at least on traditional unix, the path of executable usually doesn't affect the behavior of it.
   > 
   > Here is a demo that shared-object search path may relate to the path of executable: https://unix.stackexchange.com/questions/22926/where-do-executables-look-for-shared-objects-at-runtime
   
   i'm aware of $ORIGIN stuff. that's why i said "traditional". IMO it's a misfeature.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] Gary-Hobson commented on a diff in pull request #8868: fs/hostfs: switch working directory

Posted by "Gary-Hobson (via GitHub)" <gi...@apache.org>.
Gary-Hobson commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1166921899


##########
arch/sim/src/sim/posix/sim_misc.c:
##########
@@ -0,0 +1,80 @@
+/****************************************************************************
+ * arch/sim/src/sim/posix/sim_misc.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <dirent.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "sim_internal.h"
+
+#ifdef CONFIG_HOST_MACOS
+#include <sys/syslimits.h>
+#include <mach-o/dyld.h>
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sim_change_cwd
+ ****************************************************************************/
+
+#ifdef CONFIG_SIM_IMAGEPATH_AS_CWD
+void sim_change_cwd(void)
+{
+  int ret;
+  char *name;
+  char nuttxpath[PATH_MAX];
+  int buflen = PATH_MAX;
+
+  /* Get the absolute path of the executable file */
+
+#  ifdef CONFIG_HOST_LINUX
+  ret = readlink("/proc/self/exe", nuttxpath, buflen);
+  if (ret < 0)
+    {
+      perror("sim_change_cwd failed");
+      return;
+    }
+
+  nuttxpath[ret] = '\0';
+#  else
+  ret = _NSGetExecutablePath(nuttxpath, &buflen);
+  if (ret < 0)
+    {
+      perror("sim_change_cwd failed");

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] yamt commented on a diff in pull request #8868: fs/hostfs: switch working directory

Posted by "yamt (via GitHub)" <gi...@apache.org>.
yamt commented on code in PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#discussion_r1166261171


##########
arch/sim/Kconfig:
##########
@@ -159,6 +159,20 @@ config SIM_HOSTFS
 	---help---
 		Access host filesystem through HostFS.
 
+if SIM_HOSTFS
+config SIM_IMAGEPATH_AS_CWD
+	bool "Simulator switch working directory"

Review Comment:
   as this approach affects more than hostfs, i guess it's better to make this option independent from hostfs.
   how do you think?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on pull request #8868: fs/hostfs: add sim hostfs path convert

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #8868:
URL: https://github.com/apache/nuttx/pull/8868#issuecomment-1479228963

   > > In the sim, hostfs uses $CWD as the root path. When running in different paths, the access path of hostfs is different.
   > 
   > what's wrong with it?
   > 
   
   Here is an example, Directory layout:
   ···
   work/apps/
   work/nuttx/
   work/data/
   ···
   rcS contain:
   ···
   mount -t hostfs ../data /data
   ···
   if user launch nuttx by:
   ···
   cd work/nuttx
   ./nuttx
   ···
   he can access PC's data directory without error
   but if user launch nuttx by:
   ···
   cd work
   ./nuttx/nuttx
   ···
   ls /data will report the error.
   This patch ensures the user get the consistent result regardless he launches the program from anywhere.
   
   > > This patch is changed to use the path where the nuttx file is located as the root path, so that the mounted path is fixed when executed in different paths
   > 
   > i feel it's awkward to use the path of the executable for this purpose.
   
   Do you have better suggestion?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org