Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Pierre Couderc <pierre@couderc.eu>
To: linux-btrfs@vger.kernel.org
Subject: Re: Is there some doc or some example of libbtrfs ?
Date: Fri, 7 Aug 2020 17:20:34 +0200	[thread overview]
Message-ID: <37ddafc3-bc69-0848-ab8d-4c05d8a686b8@couderc.eu> (raw)
In-Reply-To: <4700f999-7914-0453-7096-f2ca360b4be7@suse.com>


On 8/7/20 12:17 PM, Nikolay Borisov wrote:
>
> On 7.08.20 г. 12:36 ч., Pierre Couderc wrote:
>> Ho do I get programmatically btrfs xxxxx....?
>>
> Well, the example is in the source code of btrfs-progs, namely :
>
> btrfs_list_subvols_print
>   list_subvol_search
>
> TLDR You'd have to use the TREE_SEARCH ioctl which allows you to get
> data from btrfs' various trees. In order to figure out what data to pass
> to  the ioctl you'd have to familiarize yourself with the internal
> structure of btrfs trees to know which items represent a snapshot and
> which proper subvolumes. You should check the "ROOT ITEM" description at
> https://github.com/btrfs/btrfs-dev-docs/blob/master/tree-items.txt to
> see when a root item is a snapshot and not a subvolume.
>
A small tip for the next one :

To understand how and where some function is called (here 
btrfs_list_subvols_print), grep in in "cmds" subdirectory (here 
logically subvolume.c).


  parent reply	other threads:[~2020-08-07 15:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07  9:36 Is there some doc or some example of libbtrfs ? Pierre Couderc
2020-08-07 10:17 ` Nikolay Borisov
2020-08-07 10:38   ` Pierre Couderc
2020-08-07 15:20   ` Pierre Couderc [this message]
2020-08-10 15:13 ` David Sterba
2020-08-10 16:02   ` Pierre Couderc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=37ddafc3-bc69-0848-ab8d-4c05d8a686b8@couderc.eu \
    --to=pierre@couderc.eu \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox