nbdkit FreeBSD support

With this patch series, nbdkit, the pluggable Network Block Device server, supports FreeBSD ≥ 11.2.



Filed under Uncategorized

4 responses to “nbdkit FreeBSD support

  1. Conrad Meyer

    Thanks Richard, that’s really great. FreeBSD developer here — what is your use case for the reentrant random(3) functions? Usually people want good random numbers, in which case there are the thread-safe getrandom(2) or getentropy(3) APIs. I might even consider the old random() routines an undesirable legacy interface (which may explain why no one has added the reentrant APIs to FreeBSD).

    Any other missing pieces that made this more painful for you than you would like? I’m interested to hear about any pain points in porting — I want to help make it as pain-free as possible. Gaps in documentation, gaps in APIs, you name it.

    All the best,

    • rich


      In this filter we’re using random numbers simply to inject random errors into the request stream for testing. In this case we could actually use getrandom(2) (although IIRC glibc didn’t provide bindings for this so it mght not work on Linux yet — edit: looks like latest glibc does have this now). We don’t really need the random numbers to be cryptographically secure for this application, although as long as they aren’t too onerous to generate it doesn’t matter. However we do need the function to be thread safe (the current FreeBSD code calling random(3) probably is not and so will fail under various conditions).

      Other issues we had in no particular order:

      It would be nice if bash was installed as /bin/bash as it is on every Linux distro.
      glibc has a useful (non-POSIX) function get_current_dir_name. It would be just a few lines of code to implement this on BSD for compatibility. https://github.com/libguestfs/nbdkit/blob/cee9060625254c5c14aac84a0821333cc8803136/src/utils.c#L49
      truncate (command) doesn’t support long --size option, so we had to change this to use -s instead.
      There’s some problem with automake-generated Makefiles and BSD make. People can just use gmake so it’s not a serious issue, and it may also be a bug in automake or even in our own Makefile.am’s.

      Most of these are minor porting issues, and in all it wasn’t hard to port the code to FreeBSD (I didn’t try other BSDs yet).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.