Commit Graph

20 Commits

Author SHA1 Message Date
Lennart Poettering
bff5d2fd5a blockdev-util: add partscan check function that takes an sd_device* 2024-07-01 16:35:56 +02:00
Lennart Poettering
01db9c85cf blockdev-util: add new helper blockdev_get_device_size()
This function is just a wrapper around the BLKGETSIZE64. Which is a
pretty simple ioctl. The only reason to wrap it, is that the headers we
need to call it are a bit messy (as "linux/fs.h" is incompatible with
certain glibc headers). Hence add the simple helper that wraps it and
allows us to do the header mess needed in one file only.

It's also nicely symmetric to blockdev_get_sector_size().
2023-12-13 17:35:22 +01:00
Lennart Poettering
50ab93eb0e blockdev-util: export block_device_get_originating() 2023-11-02 14:19:32 +01:00
Lennart Poettering
c56be2c294 bootctl: add new --print-root-device option
We already have this nice code in system that determines the block
device backing the root file system, but it's only used internally in
systemd-gpt-generator. Let's make this more accessible and expose it
directly in bootctl.

It doesn't fit immediately into the topic of bootctl, but I think it's
close enough and behaves very similar to the existing "bootctl
--print-boot-path" and "--print-esp-path" tools.

If --print-root-device (or -R) is specified once, will show the block device
backing the root fs, and if specified twice (probably easier: -RR) it
will show the whole block device that block device belongs to in case it
is a partition block device.

Suggested use:

        # cfdisk `bootctl -RR`

To get access to the partition table, behind the OS install, for
whatever it might be.
2023-02-21 18:19:38 +01:00
Lennart Poettering
65046b92dc blockdev-util: add simple wrapper around BLKSSZGET
Just adds some typesafety and generates an error if the field is not
initialized in the block device yet.
2023-01-18 10:10:57 +01:00
Yu Watanabe
fd690a4b7f blockdev-util: introduce block_device_new_from_fd() and block_device_new_from_path()
These are possible replacements of get_block_device(),
get_block_device_harder(), path_get_whole_disk(), and friends.
2022-09-28 17:42:23 +09:00
Yu Watanabe
2f9d231738 udev: use block_device_is_whole_disk()
No functional changes, just refactoring.

Note, this also makes synthesize_change() propagate the error from
synthesize_change_one(). However, the caller of synthesize_change()
ignores the failure anyway, hence the change does not take any effect.
2022-09-20 09:44:19 +02:00
Yu Watanabe
55a437f8b2 blockdev-util: introduce block_device_get_whole_disk() 2022-09-18 22:54:20 +09:00
Yu Watanabe
86f9b69a6a blockdev-util: split out blockdev_reread_partition_table()
No functional changes, just refactoring.
2022-09-10 01:19:41 +09:00
Yu Watanabe
9409174ee7 udevd: use partition enumerator at one more place
No functional changes, just refactoring.
2022-09-10 00:48:34 +09:00
Yu Watanabe
aa0295f1d9 loop-util: move device_has_block_children() to blockdev-util.c
As the function is not only for loopback block device.

No actual code changes, just refactoring.
2022-09-07 20:45:24 +09:00
Yu Watanabe
46c3a28845 blockdev-util: make block_device_remove_all_partitions() take sd_device object
Then, it is not necessary to recreate sd_device object when we already
have.
2022-09-07 20:45:20 +09:00
Lennart Poettering
91e1ce1a7c loop-util: move resize partition ioctl call to blockdev-util.[ch]
The other BLKPG calls have wrappers in blockdev-util.[ch], let's place
them all there.

No change in behaviour.
2022-09-01 15:59:54 +02:00
Daan De Meyer
35d40302af blockdev-util: Add block_device_remove_all_partitions()
This function takes a block device, uses sd-device to iterate all
the partitions, and removes them one by one.
2022-08-03 20:55:32 +02:00
Daan De Meyer
d25697f578 blockdev-util: Introduce block_device_add/remove_partition()
Extracted from dissect-image.c.
2022-08-03 20:55:29 +02:00
Daan De Meyer
26aa4800f8 blockdev-util: Introduce fd_get_whole_disk()
Extracted from find_devno() in udevadm-lock.c.
2022-08-03 20:55:00 +02:00
Lennart Poettering
bcf8fc267f blockdev-util: add fd-based APIs for getting backing block device for file 2021-07-08 14:49:02 +02:00
Lennart Poettering
91358db9dc fs-util: add fd-based flavour of path_is_encrypted() 2021-07-08 09:29:33 +02:00
Lennart Poettering
0bfef8b46f blockdev-util: add fd-based flavour of get_block_device() 2021-07-08 09:29:18 +02:00
Zbigniew Jędrzejewski-Szmek
b25a930f0e basic,shared: move a bunch of files to src/shared/
The goal is to move everything that requires selinux or smack
away from src/basic/. This means that src/basic/label.[ch] must move,
which implies btrfs-util.[ch], copy.[ch], and a bunch of other files
which form a cluster of internal use.

This is just moving text around, so there should be no functional difference.

test-blockdev-util is new, because path_is_encrypted() is moved to
blockdev-util.c, and so far we didn't have any tests for code there.
2021-06-24 10:11:00 +02:00