Does OpenZFS have an API?

Developer discussions about the GUI.

Does OpenZFS have an API?

Postby randolph.kahle » Wed Jan 03, 2018 10:42 am

I am considering writing automation and monitoring tools for OpenZFSonOSX and I am wondering if there is an API.

If not, I'll have to write shell commands and parse the returned textual values - all possible, but I'd rather call an API.

Posts: 10
Joined: Fri Feb 24, 2017 8:13 am

Re: Does OpenZFS have an API?

Postby lundman » Fri Jan 05, 2018 12:24 am

Yes and no.

First, on the spawning of the commands, many options have "-H" for header less and some other option for machine parsable, so that is at least nice. There was ZOL work for JSON output as well.

Internally, libzfs is a pain to work with, so they started libzfs_core, which is what will be the API for calling processes. It is not done, but has a start. I think that Ryao over in ZOL land did some additional work on it, but I never saw a PR, so who knows what happened there.

Personally, I would do new code by just calling libzfs_core and libzfs, and just deal with that the library functions may just not work each time you update ZFS, and tweak the calling code. But if you want something that requires much less maintenance, spawning is probably the most stable.

User avatar
Posts: 1165
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Does OpenZFS have an API?

Postby cbreak » Sat Jul 06, 2019 4:02 am

Depending on what you want to do, the C api in libzfs, libzfs_core and so on is ok in most places. I chose that route for ZetaWatch, after giving up on using the command line tools.

If you want a more higher level convenient interface, there's the part of ZetaWatch that interacts with ZFS is encapsulated in a ZFS Wrapper Library with a clean and easy C++ Interface: ... ZFSWrapper
Posts: 13
Joined: Mon Sep 19, 2016 9:12 am

Return to GUI Development

Who is online

Users browsing this forum: No registered users and 1 guest