Notice: We have migrated to GitLab launching 2024-05-01 see here:

#4475 closed task (fixed)

Add NFSv4 client support to libbsd

Reported by: Chris Johns Owned by: Chris Johns
Priority: normal Milestone: 6.1
Component: network/libbsd Version: 6
Severity: normal Keywords: nfs-v4
Cc: Blocked By:

Description (last modified by Chris Johns)

Add NFSv4 client support to libbsd. The client support is part of kernel and provides support for a range of the NFS protocol version including version 4.

The task is made of the following:

  1. Update the locks and locking to support the lock manager. VFS requires this be supported
  2. Add support for the FreeBSD Virtual File System (VFS)
  3. Add the kernel RPC implementation
  4. Add NFS client support


VFS is built around the FB's file structure and file descriptor structure. These need to be supported. The file struct and file descriptor form the basis for all fd based interactions with the FB kernel code such as files, devices and sockets.

LibIO and FB fd

The FB fd and file support clashes with the existing libio implementations used for things like socket, kqueue and select. The work to port the VFS requires:

  1. socket, kqueue, select support FB fd support. This is closer to the kernel. No direct libio access
  2. Provide an interface to libio mapping the iop descriptors to FB descriptors.

This approach nests the FB file descriptors inside the libio support. This is not optimal in terms of some activities but the hot paths in the code should not see a significant change in performance. Some paths like open are not optimal because the RTEMS file system op handlers imply a specific implementation that does not match up well with the FB namei interface. The long term approach is to look at libio and the handlers and consider allowing closer integration of FB's fd support.

BIO and Paging

The bio layer is required for VFS. No paging support other than the calls needed to have VFS link are provided. No VM paging is need and none of that code need be ported.

System Calls

Collect all the syscall functionality exported to RTEMS into a single place. Currently the calls are spread around the code and this:

  1. Does not centralize the code
  2. Add a lot of code to FB being ported


FreeBSD's initialization creates the initial process called proc0. Add support to create proc0 and let all thread' reference it. This allow the creds to be managed, kernel trace to work and it removes a number of changes that do not need to be made.

File Descripter Reuse

The libio functionality of cycling across the fd range rather than reusing lower fd numbers is not compatible with the select call. Not reusing fd numbers once closed until the range as been used provides some protection against bugs where a user does not cleanly handle the fd they own however this is not compatible with FB and makes supporting select harder.

The select interface should not be used on RTEMS and users should be encourages to use threads for concurrent IO or kqueue. The means select may exist for legacy code porting reasons however the cycling fd count reduces how well the code ported will actually work. For example port a piece of select code, open a socket and use, it may work. Then open and close a file 64 times then run the same code. It will fail.

FB fd's are reused.


The legacy NFSv2 client the the NFSv4 cannot be built at the same time.

The kernel RPC and the user land RPC cannot exist in the same build. I have not looked extensively into this but I was seeing clashes with headers for the same types but different contents. The legacy NFSv2 client uses the user land RPC code while the kernel NFSv4 uses the kernel's RPC.

Module support is already in libbsd to handle the separate building of each piece.


NFSv4 provides a number of extra security features. The code will be ported is possible but little or no security tested is planned at this point in time.


The NFSv4 stack will be tested against Linux and FreeBSD servers.

Change History (24)

comment:1 Changed on 07/20/21 at 07:36:52 by Chris Johns

Description: modified (diff)

comment:2 Changed on 07/20/21 at 14:51:34 by Joel Sherrill

Summary: Add NFSv4 client support to libbdsAdd NFSv4 client support to libbsd

comment:3 Changed on 09/02/21 at 02:43:16 by Chris Johns <chrisj@…>

In [changeset:"59f652fe881de4a170d4916d148fe72f33e35ef2/rtems-libbsd" 59f652fe/rtems-libbsd]:

Implement portable kernel symbol namespace tool

  • The script's use of sort proved to not be portable
  • No need to check the commits as symbols are only added
  • Regenerated kernel header to reset the sort order

Update #4475

comment:4 Changed on 09/02/21 at 02:43:19 by Chris Johns <chrisj@…>

In [changeset:"f700edc5b83a68c40ddbe03eb2b1d40fa93fa42b/rtems-libbsd" f700edc/rtems-libbsd]:

waf: Fix clashing symbols in the user land symbols

Update #4475

comment:5 Changed on 09/02/21 at 02:43:21 by Chris Johns <chrisj@…>

In [changeset:"5ef23a2836a3c56ea370affa9e81221dcf49b6e8/rtems-libbsd" 5ef23a2/rtems-libbsd]:

sys/netinet/libalias: Fix symbols clashes

Update #4475

comment:6 Changed on 09/02/21 at 02:43:24 by Chris Johns <chrisj@…>

In [changeset:"974742defc96f25501e5ca71011c3c5ddf745562/rtems-libbsd" 974742d/rtems-libbsd]:

kern-symbols: Add symbols from the everything build set

Update #4475

comment:7 Changed on 09/02/21 at 02:43:27 by Chris Johns <chrisj@…>

In [changeset:"684cf3cdc20d2adcc5211dff90570f26d5aea534/rtems-libbsd" 684cf3c/rtems-libbsd]:

rtemsbsd: Add FrreBSD's clang-format style

Update #4475

comment:8 Changed on 09/02/21 at 02:43:29 by Chris Johns <chrisj@…>

In [changeset:"2a01430ba5f2cbb3c4275abc6ab6fb7dec1e44c5/rtems-libbsd" 2a01430/rtems-libbsd]:

rtemsbsd: Catch timeout overflows

Update #4475

comment:9 Changed on 09/02/21 at 02:43:32 by Chris Johns <chrisj@…>

In [changeset:"e1ca99b535bd5ebdfe410cf2653ea447ce7c6ce5/rtems-libbsd" e1ca99b/rtems-libbsd]:

testsuite: Optionally allow all command in a shell

Update #4475

comment:10 Changed on 09/02/21 at 02:43:35 by Chris Johns <chrisj@…>

In [changeset:"46a15fa7aa5a2382d2e09d42786ee931a22e8770/rtems-libbsd" 46a15fa/rtems-libbsd]:

sys/kern: Add lockmgr support

  • See man lockmgr
  • Implement the lock_object and move the RTEMS mutex to that object
  • Add debug support to track the locks with gdb

Update #4475

comment:11 Changed on 09/02/21 at 02:43:38 by Chris Johns <chrisj@…>

In [changeset:"761fd6939386f7b1c44430ad89130583cc94cb04/rtems-libbsd" 761fd693/rtems-libbsd]:

kern: Import kern_prot.c fnd kern_resource.c for proc0

Update #4475

comment:12 Changed on 09/02/21 at 02:43:40 by Chris Johns <chrisj@…>

In [changeset:"c7427fc1548755104a929fc55f7a659937b6cd46/rtems-libbsd" c7427fc/rtems-libbsd]:

kern: Add a proc0

  • Provides the thread's proc pointer and with that access to creds

Update #4475

comment:13 Changed on 09/02/21 at 02:43:43 by Chris Johns <chrisj@…>

In [changeset:"9800a0f9fa49f64684aa00febb4adc962be7e231/rtems-libbsd" 9800a0f/rtems-libbsd]:

kern: Import kern_ktr.c

Update #4475

comment:14 Changed on 09/02/21 at 02:43:46 by Chris Johns <chrisj@…>

In [changeset:"e56b5cb135b9d47f2137b96089ea3bc7f607004b/rtems-libbsd" e56b5cb/rtems-libbsd]:

kern: Add kernel trace support (KTR)

Update #4475

comment:15 Changed on 09/02/21 at 02:43:48 by Chris Johns <chrisj@…>

In [changeset:"1739d74f7dc53232fe20ed3ea9d8b4b0730b4025/rtems-libbsd" 1739d74/rtems-libbsd]:

freebsd/sys: Import VFS support

Update #4475

comment:16 Changed on 09/02/21 at 02:43:51 by Chris Johns <chrisj@…>

In [changeset:"ac4db4cec5b6b1e0a25e910851e50831afb0749d/rtems-libbsd" ac4db4c/rtems-libbsd]:

rtemsbsd: Remove DHCP init wrapper

  • Object files cannot config init and resided in libbsd.a

Update #4475

comment:17 Changed on 09/02/21 at 02:43:53 by Chris Johns <chrisj@…>

In [changeset:"6514d561587fd1527fe6a26cb43e6b5742c8c779/rtems-libbsd" 6514d56/rtems-libbsd]:

sys/kern: Add VFS support

  • Refactor the libio interface
  • Move syscalls into an rtemsbsd location
  • Provide a root directory mount point

Update #4475

comment:18 Changed on 09/02/21 at 02:43:56 by Chris Johns <chrisj@…>

In [changeset:"3da45ae4bcb1cedb32339d15ee1f65706a083540/rtems-libbsd" 3da45ae/rtems-libbsd]:

freebsd/sys: Import RPC and XDR support

Update #4475

comment:19 Changed on 09/02/21 at 02:43:59 by Chris Johns <chrisj@…>

In [changeset:"c6dbc967480ed034cf52992ec5773252b646edc5/rtems-libbsd" c6dbc96/rtems-libbsd]:

kern/sys: Add the kernel RPC and XDR support

Updates #4475

comment:20 Changed on 09/02/21 at 02:44:01 by Chris Johns <chrisj@…>

In [changeset:"6138f242be4f9d989a4052be71f1b116bd806e44/rtems-libbsd" 6138f24/rtems-libbsd]:

kern/sys: Import NFS and NFS file system client

Update #4475

comment:21 Changed on 09/02/21 at 02:44:04 by Chris Johns <chrisj@…>

In [changeset:"882425fe547f73a1a77caa4938dec369cfd1063d/rtems-libbsd" 882425f/rtems-libbsd]:

kern/sys: Add NFSv4 client

Update #4475

comment:22 Changed on 09/02/21 at 02:44:07 by Chris Johns <chrisj@…>

In [changeset:"7e282d25068ec09163e00cbe5819a1b5be3571be/rtems-libbsd" 7e282d2/rtems-libbsd]:

rtemsbsd/nfs: Add support to mount NFSv2

  • NFSv2 requires userland RPC calls to determine the version of NFS and the FH. This is passed to the kernel.
  • Port more libc/rpc.

Update #4475

comment:23 Changed on 09/24/21 at 00:00:06 by Chris Johns

Resolution: fixed
Status: assignedclosed

comment:24 Changed on 06/08/22 at 13:11:44 by Sebastian Huber <sebastian.huber@…>

In [changeset:"dba9346b43351fbcf7cf33c41a3c8bd90fa1060c/rtems-libbsd" dba9346/rtems-libbsd]:

uma_core.c: Fix use of uninitialized variable

Update #4475.

Note: See TracTickets for help on using tickets.