Issue created by Sang Woo Kim: 
https://gitlab.rtems.org/rtems/pkg/rtems-libbsd/-/work_items/101



## Summary

`dup()`, `dup2()`, `fcntl(F_DUPFD)` and `fcntl(F_DUPFD_CLOEXEC)` fail with 
`ENXIO` for every libbsd descriptor. Present on `7-freebsd-14`, `6-freebsd-14` 
and `6-freebsd-12`.

Two causes. libbsd descriptors sit on `rtems_filesystem_null_mt_entry`, whose 
`clonenod_h` refuses unconditionally, so `duplicate_iop()`'s 
`rtems_filesystem_location_clone()` fails and the handler that then runs, 
`null_handler_open()`, returns -1 with `errno` untouched. And `struct 
file::f_io` can name only one libio descriptor, so a duplicate has nowhere to 
record its identity.

Fix: a mount entry of their own with a working `clonenod_h`, and the 
file-to-descriptor link moved into `struct filedescent::fde_io`. 
[7-freebsd-14](https://github.com/physwkim/rtems-libbsd/commit/dfa662354bc77feb71a806d1b1c6bf936e2eb18b)
 · 
[6-freebsd-14](https://github.com/physwkim/rtems-libbsd/commit/62a6ad41c58263af1d43cf536562a0791bf870fa)
 · 
[6-freebsd-12](https://github.com/physwkim/rtems-libbsd/commit/682ed19fbc25bf0114f92baa17c9398c2703dd8c)

## Steps to reproduce

```c
int s = socket(AF_INET, SOCK_STREAM, 0);
int d = dup(s);          /* -1, errno == ENXIO */
```

-- 
View it on GitLab: 
https://gitlab.rtems.org/rtems/pkg/rtems-libbsd/-/work_items/101
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/sent_notifications/4-4yizlcnnegkv8a1iakdlhcs6d-k/unsubscribe
 | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | 
Help: https://gitlab.rtems.org/help


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to