xiaoxiang781216 commented on code in PR #19456:
URL: https://github.com/apache/nuttx/pull/19456#discussion_r3621993734
##########
arch/sim/src/sim/posix/sim_hostfs.c:
##########
@@ -39,10 +39,192 @@
#include "hostfs.h"
#include "sim_internal.h"
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define HOSTFS_RETRY_DELAY_US 10000
+
/****************************************************************************
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: host_oflags_convert
+ ****************************************************************************/
+
+static int host_oflags_convert(int flags)
+{
+ int mapflags = 0;
+
+ switch (flags & NUTTX_O_ACCMODE)
+ {
+ case NUTTX_O_RDONLY:
+ mapflags = O_RDONLY;
+ break;
+
+ case NUTTX_O_WRONLY:
+ mapflags = O_WRONLY;
+ break;
+
+ case NUTTX_O_RDWR:
+ mapflags = O_RDWR;
+ break;
+ }
+
+ if (flags & NUTTX_O_APPEND)
+ {
+ mapflags |= O_APPEND;
+ }
+
+ if (flags & NUTTX_O_CREAT)
+ {
+ mapflags |= O_CREAT;
+ }
+
+ if (flags & NUTTX_O_EXCL)
+ {
+ mapflags |= O_EXCL;
+ }
+
+ if (flags & NUTTX_O_TRUNC)
+ {
+ mapflags |= O_TRUNC;
+ }
+
+ if (flags & NUTTX_O_NONBLOCK)
+ {
+ mapflags |= O_NONBLOCK;
+ }
+
+ if (flags & NUTTX_O_SYNC)
+ {
+ mapflags |= O_SYNC;
+ }
+
+#ifdef O_DIRECT
+ if (flags & NUTTX_O_DIRECT)
+ {
+ mapflags |= O_DIRECT;
+ }
+#endif
+
+ if (flags & NUTTX_O_CLOEXEC)
+ {
+ mapflags |= O_CLOEXEC;
+ }
+
+ if (flags & NUTTX_O_DIRECTORY)
+ {
+ mapflags |= O_DIRECTORY;
+ }
+
+ return mapflags;
+}
+
+/****************************************************************************
+ * Name: host_flock_type_convert
+ ****************************************************************************/
+
+static int host_flock_type_convert(int type)
+{
+ switch (type)
+ {
+ case NUTTX_F_RDLCK:
+ return F_RDLCK;
+
+ case NUTTX_F_WRLCK:
+ return F_WRLCK;
+
+ case NUTTX_F_UNLCK:
+ return F_UNLCK;
+
+ default:
+ return -EINVAL;
+ }
+}
+
+/****************************************************************************
+ * Name: host_flock_type_revert
+ ****************************************************************************/
+
+static int host_flock_type_revert(int type)
+{
+ switch (type)
+ {
+ case F_RDLCK:
+ return NUTTX_F_RDLCK;
+
+ case F_WRLCK:
+ return NUTTX_F_WRLCK;
+
+ case F_UNLCK:
+ return NUTTX_F_UNLCK;
+
+ default:
+ return -EINVAL;
+ }
+}
+
+/****************************************************************************
+ * Name: host_ioctl_fcntl
+ ****************************************************************************/
+
+static int host_ioctl_fcntl(int fd, int request, unsigned long arg)
+{
+ struct nuttx_flock_s *lock = (struct nuttx_flock_s *)(uintptr_t)arg;
+ struct flock hostlock;
+ int ret;
+
+ if (lock == NULL)
+ {
+ return -EINVAL;
+ }
+
+ hostlock.l_type = host_flock_type_convert(lock->l_type);
+ if (hostlock.l_type < 0)
+ {
+ return hostlock.l_type;
+ }
+
+ hostlock.l_whence = lock->l_whence;
+ hostlock.l_start = lock->l_start;
+ hostlock.l_len = lock->l_len;
+ hostlock.l_pid = lock->l_pid;
+
+ do
Review Comment:
for (; ; )
##########
fs/hostfs/hostfs.c:
##########
@@ -616,6 +610,16 @@ static int hostfs_ioctl(FAR struct file *filep, int cmd,
unsigned long arg)
{
switch (cmd)
{
+ case FIOC_GETLK:
+ case FIOC_SETLK:
+ case FIOC_SETLKW:
Review Comment:
revert, let's convert -ENOSYS to -ENOTTY in arch/sim
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]