All of lore.kernel.org
 help / color / mirror / Atom feed
From: Goffredo Baroncelli <kreijack@tiscali.it>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.cz>, Goffredo Baroncelli <kreijack@inwind.it>
Subject: [PATCH 0/4] RFC: add the btrfs_info helper
Date: Wed,  6 Dec 2023 20:32:41 +0100	[thread overview]
Message-ID: <cover.1701891165.git.kreijack@inwind.it> (raw)

From: Goffredo Baroncelli <kreijack@inwind.it>

The aim of this patches set is to add some helper to query the layout
of a btrfs filesystem.

A btrfs filesystem may be composed by multiple disks, and several
mountpoints on which different subvolumes are mounted.

Sometime we need to know the devices list starting from a path, or
a path starting from a device.

These helpers allow to know all the information of a filesystem like
- UUID
- Label
- Mountpoints list (if mounted), and for each mountpoint
   - subvolume
   - options
- Devices list, and for each device
   - major, minor
   - device name
   - partuuid, uuid_sub 
   - devid (if the user is root)

And it is possible to build these information giving any of:
- a path (if mounted)
- UUID
- Label
- partuuid
- uuid_sub


These helpers uses only libblkid and /proc/self/mountinfo to extract all
these information. It is not required to be root; if the user is root
it is returned also the devid of a device.

The first patch add the helpers. From the second patch there are two new
commands ('btrfs fi info' and 'btrfs fi get-info') and an enachement of 
'btrfs fi label', which can be used passing both a device or a path,
 or UUID=<uuid>, LABEL=<label>... ; before the user has to pass a path
if the filesystem is mounted, and a device otherwise. This command
refuse to work with a device when the fielsystem is mounted, which is
not very user friendly.

The goal is to enanche some btrfs commands that now force the user to
pass a device or a path even when it is possible to pass any valid
reference to a btrfs filesystem (like UUID or Label).

BR

Goffredo Baroncelli (4):
  btrfs-info: some utility to query a filesystem info
  new command: btrfs filesystem info [<path>...]
  new command: btrfs filesystem get-info ...
  btrfs-progs: 'btrfs fi label' using a dev instead of a path

 Makefile                  |    1 +
 cmds/filesystem.c         |  141 +++++
 common/btrfs-info.c       | 1036 +++++++++++++++++++++++++++++++++++++
 common/btrfs-info.h       |  220 ++++++++
 common/filesystem-utils.c |   51 +-
 5 files changed, 1437 insertions(+), 12 deletions(-)
 create mode 100644 common/btrfs-info.c
 create mode 100644 common/btrfs-info.h

-- 
2.43.0


             reply	other threads:[~2023-12-06 19:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 19:32 Goffredo Baroncelli [this message]
2023-12-06 19:32 ` [PATCH 1/4] btrfs-info: some utility to query a filesystem info Goffredo Baroncelli
2023-12-06 19:32 ` [PATCH 2/4] new command: btrfs filesystem info [<path>...] Goffredo Baroncelli
2023-12-06 19:32 ` [PATCH 3/4] new command: btrfs filesystem get-info Goffredo Baroncelli
2023-12-06 19:32 ` [PATCH 4/4] btrfs-progs: 'btrfs fi label' using a dev instead of a path Goffredo Baroncelli

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=cover.1701891165.git.kreijack@inwind.it \
    --to=kreijack@tiscali.it \
    --cc=dsterba@suse.cz \
    --cc=kreijack@inwind.it \
    --cc=kreijack@libero.it \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.