LingaoM opened a new pull request, #19456:
URL: https://github.com/apache/nuttx/pull/19456

   ## Summary
   
     This PR improves NuttX sim compatibility for standard POSIX-facing APIs 
used by simulated applications.
   
     Changes included:
   
     - Add `AF_LOCAL` / `AF_UNIX` support to sim `usrsock`, so applications can 
use the normal NuttX socket API to communicate with host Unix-domain sockets.
     - Translate hostfs POSIX byte-range lock operations. 
`fcntl(F_GETLK/F_SETLK)` reaches file systems as `FIOC_*` ioctl commands after 
VFS handling; hostfs now converts those lock
     requests back to host `fcntl()` for host-backed files.
     - Add built-in `http` and `https` service entries to libc netdb so 
`getservbyname()` / `getaddrinfo()` can resolve common service names without 
requiring numeric ports.
   
     The changes keep applications using standard NuttX/POSIX interfaces rather 
than exposing host-only APIs directly to application code.
   
     ## Impact
   
     - Affects sim builds using `usrsock`, `hostfs`, or libc `netdb`.
     - Applications can use `socket(AF_LOCAL, ...)` through the normal NuttX 
socket layer on sim.
     - Applications using hostfs can use non-blocking POSIX file locks through 
`fcntl(F_GETLK/F_SETLK)`.
     - `F_SETLKW` is intentionally left unsupported for hostfs and returns 
`-ENOSYS`, because forwarding a blocking host `fcntl()` could block the whole 
sim OS.
     - `http` and `https` become available in the built-in service database 
when `CONFIG_LIBC_NETDB=y`.
     - No hardware targets are affected by the sim host-side changes.
   
     ## Testing
   
     Host machine:
   
     - Ubuntu 22.04 x86_64
   
     Board/config:
   
     - `sim:nsh`
   
     Build test:
   
     ```bash
     make clean
     make -j16
   
     Runtime tests performed with temporary hello examples, then restored 
before commit.
   
     AF_LOCAL / usrsock test:
   
     - Built sim:nsh with usrsock enabled.
     - Ran a temporary hello app that connected to host Unix-domain sockets 
using normal NuttX socket(AF_LOCAL, ...).
     - Verified both SOCK_STREAM and SOCK_SEQPACKET.
     - The app exchanged data with a host socket server and printed:
   
     AF_LOCAL usrsock test passed
   
     hostfs file lock test:
   
     - Built sim:nsh with:
   
     CONFIG_FS_HOSTFS=y
     CONFIG_SIM_HOSTFS=y
     CONFIG_EXAMPLES_HELLO=y
   
     - Ran a temporary hello app that mounted /tmp through hostfs, opened a 
host-backed file, then verified:
   
     fcntl(fd, F_SETLK, ...)
     fcntl(fd, F_GETLK, ...)
     fcntl(fd, F_SETLK, F_UNLCK)
   
     - The app printed:
   
     hostfs fcntl lock test passed
   
     netdb service-name test:
   
     - Built sim:nsh with:
   
     CONFIG_LIBC_NETDB=y
     CONFIG_EXAMPLES_HELLO=y
   
     - Ran a temporary hello app that verified:
   
     getservbyname("http", "tcp")  -> port 80
     getservbyname("https", "tcp") -> port 443
   
     - The app printed:
   
     getservbyname http/https test passed


-- 
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]

Reply via email to