BSD Port and Linux Differences

Greg Lewis glewis at
Tue Feb 10 21:13:45 PST 2009

On Tue, Feb 10, 2009 at 11:00:35AM -0500, Christos Zoulas wrote:
> On Feb 9,  7:56pm, mvfranz at (Michael Franz) wrote:
> -- Subject: BSD Port and Linux Differences
> | Hi,
> | 
> | I am still working through the issues to get the bsd-port repo to compile on
> | Linux and have run into these issues.
> | 
> | BSD is using statfs instead of statvfs.  Both are available on Linux and OS
> | X.  The difference is how they are included.  Linux uses either sys/statfs.h
> | or sys/statfs.h while OS X (and I assume other BSDs) are use
> | sys/param.h,sys/mount.h or sys/statvfs.h.  See
> | jdk/src/solaris/native/java/io/UnixFileSystem_md.c for more details.
> NetBSD uses statvfs too.
> | Is it better to use one over the other?  Do we really want to use statfs on
> | bsd and statvfs on linux?
> statvfs should be preferred over statfs because:
> 1. it is part of POSIX:
> 2. it is newer and has 64 bit fields where appropriate (in most implementations)
> I think we need some #ifdef's there to handle which include is appropriate
> for which OS.

It looks like everything supports statvfs now, so I don't think we need
any #ifdef's at all.  I've got a patch to revert this change.

> | I have run into a similar issue with strncpy vs strlcpy.  The bsd port is
> | using strlcpy, as far as I can tell, strlcpy does not exist on linux.  Both
> | have strncpy, should this be used instead?
> | 
> | This issue exists in jdk/src/solaris/native/java/util/TimeZone_md.c
> strl{cpy,cat} should be preferred over strn{cpy,cat}. If that is the only
> use though, I say put it back to use strncpy() correctly, since java probably
> uses strn{cpy,cat} all over the place and providing portability just for
> one use is overkill.

*sigh* It looks like the GNU libc maintainers don't like strlcpy, so
although *BSD and Solaris have it, Linux does not.  I'll change it to
strncpy universally rather than adding an #ifdef just for that.

> | A previous difference that I have found was in the use of machine/endian.h
> | in the BSD port.
> This is a more complicated :-) and I will let someone else answer it.

I've already answered this before :).  Its the right thing to do.  We
just need to also do the right thing for Linux and Solaris.

I've got access to an Ubuntu box -- I can try a compile there as well.

Greg Lewis                          Email   : glewis at
Eyes Beyond                         Web     :
Information Technology              FreeBSD : glewis at

More information about the bsd-port-dev mailing list