Hi all, I''d like to develop a program to work with a zfs filesystem, exploring it and its metadata. I''d like to know if there are examples about the usage of libzfs and the setup of a building environment. Thanks -- This message posted from opensolaris.org
On 05/10/11 10:10 PM, Luca Ferrari wrote:> Hi all, > I''d like to develop a program to work with a zfs filesystem, exploring it and its metadata. I''d like to know if there are examples about the usage of libzfs and the setup of a building environment. > ThanksThe best examples of the use of libzfs are in the source. Go to cvs.opensolaris.org and search on the function of interest. -- Ian.
Hi Luca, The Zdb code maybe be a good place to start. (Zdb allows more or less the sort of exploration you are describing). Getting the OS sources and setting up a build environment has been fairly well documented for the various distros, e.g: https://www.illumos.org/projects/illumos-gate/wiki/How_To_Build_illumos Max Bruning already did a similar "Zfs walkabout" using a hacked Zdb: http://www.google.com/url?sa=t&source=web&cd=3&ved=0CCQQFjAC&url=http%3A%2F%2Fwww.osdevcon.org%2F2008%2Ffiles%2Fosdevcon2008-max.pdf&rct=j&q=zfs%20on-disk&ei=-p7JTYiWDcPIgQe0_Oz2BQ&usg=AFQjCNH6q9Ear4Xecv5P2R5SYMoIAat3qQ&cad=rja Read the "On-Disk format" doc: http://www.google.com/url?sa=t&source=web&cd=7&ved=0CEgQFjAG&url=http%3A%2F%2Fmaczfs.googlecode.com%2Ffiles%2FZFSOnDiskFormat.pdf&rct=j&q=zfs%20on-disk&ei=-p7JTYiWDcPIgQe0_Oz2BQ&usg=AFQjCNGnXRIVQ5f3bLXNyGbNamRJOI-cBw&cad=rja It is missing some details, and is a bit dated, but still, it is the best conceptual overview of Zfs. Good luck hacking Zfs! /sG/ ----- "Luca Ferrari" <no-reply at opensolaris.org> wrote: Hi all, I''d like to develop a program to work with a zfs filesystem, exploring it and its metadata. I''d like to know if there are examples about the usage of libzfs and the setup of a building environment. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/zfs-code/attachments/20110510/069c3fcb/attachment.html>
Thanks, I''ve read the ZDB examples and the on disk format, however I don''t understand how setting up a whole OS building environment could help me developing a zfs application. What I''d like to know is what packages/libraries and if there are pre-configured make files (or if anyone can give me an example) for compiling and linking a simple application (with a main) that uses libzfs. Thanks. -- This message posted from opensolaris.org
On 17/05/2011 09:08, Luca Ferrari wrote:> I''ve read the ZDB examples and the on disk format, however I don''t > understand how setting up a whole OS building environment could help > me developing a zfs application. What I''d like to know is what > packages/libraries and if there are pre-configured make files (or if > anyone can give me an example) for compiling and linking a simple > application (with a main) that uses libzfs.libzfs is a Private library there is no documentation and no public header file. You aren''t supposed to be developing applications to it. -- Darren J Moffat
I''m not sure what "private" means, but am I supposed to be NOT able to create, for instance, my person zfs explorer writing a from-scratch C program? -- This message posted from opensolaris.org
On 05/18/11 16:57, Luca Ferrari wrote:> I''m not sure what "private" means, but am I supposed to be NOT able to create, for instance, my person zfs explorer writing a from-scratch C program?Private means it isn''t documented or a committed interface for people outside of the project itself to write to. So no you aren''t supposed to be able to write 3rd party tools and link them against the libzfs API. -- Darren J Moffat
On May 18, 2011, at 10:32 AM, Darren J Moffat wrote:> On 05/18/11 16:57, Luca Ferrari wrote: >> I''m not sure what "private" means, but am I supposed to be NOT able to create, for instance, my person zfs explorer writing a from-scratch C program? > > Private means it isn''t documented or a committed interface for people outside of the project itself to write to.Previously private interfaces have been known to become committed and public.> So no you aren''t supposed to be able to write 3rd party tools and link them against the libzfs API.This is just a matter of risk management. In the open source (eg illumos) world, it is easy to follow changes in the API. As long as the work involved is known, a decision can be justified. -- richard
On 05/18/11 10:32, Darren J Moffat wrote:> So no you aren''t supposed to be able to write 3rd party tools and link > them against the libzfs API.That''s quite a bit stronger than I''d put it and also too discouraging. libzfs is a private interface. Private does not mean "secret". Private interfaces can change incompatibly at any time -- even in a patch. They''re not guaranteed to keep working when the underlying shared library changes interface or behavior -- a function you depend on may be deleted, or grow another argument, or just change behavior in a way you weren''t expecting. If you find that the path of least resistance is to use a private interface, it''s often a sign that there''s a missing Public interface in the system. - Bill
On 05/19/11 08:49 AM, Bill Sommerfeld wrote:> On 05/18/11 10:32, Darren J Moffat wrote: >> So no you aren''t supposed to be able to write 3rd party tools and link >> them against the libzfs API. > That''s quite a bit stronger than I''d put it and also too discouraging. > > libzfs is a private interface. Private does not mean "secret". > > Private interfaces can change incompatibly at any time -- even in a > patch. They''re not guaranteed to keep working when the underlying > shared library changes interface or behavior -- a function you depend on > may be deleted, or grow another argument, or just change behavior in a > way you weren''t expecting. > > If you find that the path of least resistance is to use a private > interface, it''s often a sign that there''s a missing Public interface in > the system. >I think there is a case for a public interface for a subset of the libzfs API, the functionality provided is too useful to hide away form application programmers. I must confess that I do use the interface in a number of my tools and I use compile time (and conditional compilation) assertions based on SPA_VERSION to force me to review the code when the version changes. This my not be safe, or even a good idea but it has kept me out of trouble since version 15. When I first started playing way back when libzfs first appeared, I hadn''t cottoned on to the interface being private. Some very useful interfaces have remained stable throughout and these would good candidates for a public API. Even just providing the ability to open a pool or dataset, read its properties and iterate its children would be extremely valuable for those of us who live in user space. This only requires a small set from the full API: libzfs_init(), libzfs_fini(), zfs_open(), zfs_close(), zfs_get_xxx(), zfs_prop_get_xxx() and zfs_iter_xxx(). All of these have been stable a long while and given their simple roles, should remain so. -- Ian.
I understand that parts of the library can change between code releases, and this is a risk that is present in almost every piece of code of every project, I mean if the developer goes too deep into the library it is his own risk. However, what I''d like to do is to create a few utilities able to iterate over the zfs structure of an hard disk, so as pointed by ian, using only a small set of library api. In such case, anyone can give me an hint about how to start and set up a development environment? Thanks. -- This message posted from opensolaris.org
On 05/19/11 06:08 PM, Luca Ferrari wrote:> I understand that parts of the library can change between code releases, and this is a risk that is present in almost every piece of code of every project, I mean if the developer goes too deep into the library it is his own risk. > However, what I''d like to do is to create a few utilities able to iterate over the zfs structure of an hard disk, so as pointed by ian, using only a small set of library api. In such case, anyone can give me an hint about how to start and set up a development environment? >As you are working in user-land, any (Open)Solaris based system will do. -- Ian.