You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/02/13 07:17:43 UTC
[incubator-nuttx] branch master updated: sim: Make hostfs build for
macOS
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 1a3f59b sim: Make hostfs build for macOS
1a3f59b is described below
commit 1a3f59be581acc289f9dd3a7e42a6d7dc71e330e
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Wed Feb 12 12:05:04 2020 +0900
sim: Make hostfs build for macOS
* Ignore O_DIRECT if the host OS doesn't provide it.
* Use statvfs instead of statfs. The former is in POSIX and
more widely available these days.
---
arch/sim/src/sim/up_hostfs.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/sim/src/sim/up_hostfs.c b/arch/sim/src/sim/up_hostfs.c
index 941b149..6958eb9 100644
--- a/arch/sim/src/sim/up_hostfs.c
+++ b/arch/sim/src/sim/up_hostfs.c
@@ -41,7 +41,7 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/statfs.h>
+#include <sys/statvfs.h>
#include <sys/ioctl.h>
#include <dirent.h>
@@ -168,10 +168,12 @@ int host_open(const char *pathname, int flags, int mode)
mapflags |= O_SYNC;
}
+#ifdef O_DIRECT
if (flags & NUTTX_O_DIRECT)
{
mapflags |= O_DIRECT;
}
+#endif
return open(pathname, mapflags, mode);
}
@@ -376,17 +378,17 @@ int host_closedir(void *dirp)
int host_statfs(const char *path, struct nuttx_statfs_s *buf)
{
- int ret;
- struct statfs hostbuf;
+ int ret;
+ struct statvfs hostbuf;
/* Call the host's statfs routine */
- ret = statfs(path, &hostbuf);
+ ret = statvfs(path, &hostbuf);
/* Map the struct statfs value */
- buf->f_type = hostbuf.f_type;
- buf->f_namelen = hostbuf.f_namelen;
+ buf->f_type = 0; /* hostfs overwrites f_type anyway */
+ buf->f_namelen = hostbuf.f_namemax;
buf->f_bsize = hostbuf.f_bsize;
buf->f_blocks = hostbuf.f_blocks;
buf->f_bfree = hostbuf.f_bfree;