Configure failure under NetBSD
Submitted by Julio Merino
Link to original bug (#337098)
Description
The configure process aborts prematurely under NetBSD because it cannot find any function to retrieve the list of mounted file systems. In the past it used to work because the script properly detected the 4.4BSD getmntinfo routine as provided by NetBSD.
However, starting with NetBSD 3.0, the getmntinfo prototype was changed to use the statvfs structure instead of statfs. This also changed the required #include's to get the function definition -- something that makes the configure check fail because it relies solely on grepping the delicate system headers (a very error prone way to check for features).
Therefore, we are now faced with two different getmntinfo implementations. The new, NetBSD-specific one:
#include <sys/types.h>
#include <sys/statvfs.h>
int
getmntinfo(struct statvfs **mntbufp, int flags);
And the legacy one:
#include <sys/param.h>
#include <sys/mount.h>
int
getmntinfo(struct statfs **mntbufp, int flags);
The configure script needs to check which one is available and use it accordingly in the code. It'd be good to check for the feature instead of assuming that the first implementation is provided by NetBSD alone; this way, if other OSes switch, libgtop will continue to work on them. This is what the attached patch does.
Furthermore, I've seized the opportunity to add a check for the f_fstypename field in either the statfs or the statvfs structures, which is somewhat related to this issue. This makes the code more OS-independent because it does not rely any more on OS-specific macros (e.g. NetBSD) and instead uses macros OS-agnostic defined by configure.