Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 Jan 2022 16:04:40 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 257222] Cannot use libzfs.h from user space programs due to missing libnvpair.h and other dependencies
Message-ID:  <bug-257222-227-CMWTN1GSpB@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-257222-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-257222-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D257222

--- Comment #3 from Michael Gmelin <grembo@FreeBSD.org> ---
Simple working example:

```
$ cat >test.c <<EOF
#include <sys/stdtypes.h>
#include <libzfs_core.h>

int main(int argc, char** argv)
{
  if (argc !=3D 2) {
    fprintf(stderr, "Invalid arguments\n");
    return 101;
  }

  if (libzfs_core_init() !=3D 0) {
    fprintf(stderr, "Can't init libzfs\n");
    return 101;
  }
  int exists =3D lzc_exists(argv[1]);
  printf("%s %s\n", argv[1],
    exists ? "exists" : "doesn't exist");
  libzfs_core_fini();
  return exists ? 0 : 1;
}
EOF

$ cc \
    -I/usr/src/sys/contrib/openzfs/include \
    -I/usr/src/sys/contrib/openzfs/lib/libspl/include \
    -lzfs_core -lzfs -o test test.c
$ ./test zroot
zroot exists
```

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-257222-227-CMWTN1GSpB>