storaged-project / libblockdev

A library for manipulating block devices.
GNU Lesser General Public License v2.1
104 stars 54 forks source link

Consider using libbtrfsutil in the btrfs plugin #552

Open vojtechtrefny opened 4 years ago

vojtechtrefny commented 4 years ago

libbtrfsutil was added in 2018 (btrfs-progs 4.16), we should consider using it in the btrfs plugin instead of calling btrfs tools and parsing their output. It looks like it supports everything we need (but we should take a closer look first to be 100 % sure).

jelly commented 10 months ago

One downside I noticed here is that libbtrsutil is not actually used by the btrfs binary, but it is used by snapper it probably doesn't break a lot but worth to check if it has unit tests.

If libblockdev wants to extend btrfs information, then libbrtfsutil needs to be extended.

tbzatek commented 10 months ago

libbtrsutil is not actually used by the btrfs binary

Isn't it linked statically? Sometimes distros tend to link everything statically for initramfs use.

If libblockdev wants to extend btrfs information, then libbrtfsutil needs to be extended.

Theoretically we may opt for a mixed use - library calls for most of the stuff and external tools as a fallback for missing functionality. Assuming both the library and the tools are part of a single package.

jelly commented 10 months ago

I think I might have looked at it wrong, this struct is indeed re-used in the cli interface https://github.com/search?q=repo%3Akdave%2Fbtrfs-progs+btrfs_util_subvolume&type=code

And FYI there is a list of things which are required for snapper and implemented in libbtrfsutil.