Add device_is_mounted() support for BSDs
Implement '#elif' part of lib/mountcheck.c using getmntinfo(3).
This should implement device_is_mounted() on most BSDs, and has been
tested on FreeBSD/DragonFlyBSD. NetBSD/OpenBSD do have getmntinfo(3)
but may need to include different headers according to their online
manpages.
--
# cat ./test1.c
#include <stdio.h>
#include "./lib/mountcheck.h"
int main(int argc, char *argv[]) {
printf("%s %d\n", argv[1], device_is_mounted(argv[1]));
return 0;
}
--
# uname
FreeBSD
# clang -Wall -g ./test1.c ./lib/mountcheck.o -o ./test1
# ./test1 /dev/ada0p2 /* UFS */
/dev/ada0p2 1
# ./test1 zfs /* ZFS */
zfs 1
# ./test1 zfs/test /* ZFS */
zfs/test 1
# ./test1 /dev/da0 /* not mounted device */
/dev/da0 0
# ./test1 random /* irrelevant string */
random 0
--
# uname
DragonFly
# gcc -Wall -g ./test1.c ./lib/mountcheck.o -o ./test1
# ./test1 /pfs/@@-1:00005 /* HAMMER */
/pfs/@@-1:00005 1
# ./test1 procfs /* procfs */
procfs 1
# ./test1 /dev/da8 /* not mounted device */
/dev/da8 0
# ./test1 random /* irrelevant string */
random 0