Re: impossible to use <libzfs.h> out-of-tree

From: Mark Millard <marklmi_at_yahoo.com>
Date: Thu, 12 Jun 2025 05:02:15 UTC
Alan Somers <asomers_at_freebsd.org> wrote on
Date: Thu, 12 Jun 2025 03:13:08 UTC :

> On Wed, Jun 11, 2025 at 8:03 PM Lexi Winter <ivy@freebsd.org> wrote:
> 
> > hello,
> >
> > i'm writing an application which wants to interact with ZFS filesystems,
> > so i thought i would use libzfs via <libzfs.h>. however, <libzfs.h>
> > includes <libshare.h>, which exists in src but is not installed.
> >
> > this means that nothing can use <libzfs.h>, so it should not be
> > installed; this is a bug, we should not install <libzfs.h> if it
> > cannot be used.
> >
> > but does this mean we have no way for out-of-tree utilities to interact
> > with ZFS except by calling "/sbin/zfs" and parsing the output?
> >
> > tested on 15.0-CURRENT, commit ~a5fe142e084.
> >
> 
> libzfs is unstable, and out-of-tree utilities should avoid using it, if
> possible. If an out-of-tree utility links to it, then that utility might
> break as a result of an OS upgrade, even a minor one.
> 
> But all hope is not lost! libzfs_core is stable, and its use is
> encouraged. See /usr/include/libzfs_core.h . It can do most of the stuff
> that libzfs can do, but the API is guaranteed to be stable. You should use
> that, if possible.

FYI:

Bug 257222 - Cannot use libzfs_core from user space programs due to missing libnvpair.h and other dependencies
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257222

Bug 251730 - net/samba419: [RFE] add support for vfs_shadow_copy_zfs
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251730

> If you really must use libzfs.h, then we should install libshare.h. It
> used to be the case that all of the necessary headers were installed. This
> is probably a recent regression.



===
Mark Millard
marklmi at yahoo.com