]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/blockdev-util.h
Merge pull request #24628 from medhefgo/boot-sections
[thirdparty/systemd.git] / src / shared / blockdev-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <sys/types.h>
5
6 #include "sd-device.h"
7
8 #include "macro.h"
9 #include "stdio-util.h"
10 #include "string-util.h"
11
12 #define SYS_BLOCK_PATH_MAX(suffix) \
13 (STRLEN("/sys/dev/block/") + DECIMAL_STR_MAX(dev_t) + 1 + DECIMAL_STR_MAX(dev_t) + strlen_ptr(suffix))
14 #define xsprintf_sys_block_path(buf, suffix, devno) \
15 xsprintf(buf, "/sys/dev/block/%u:%u%s", major(devno), minor(devno), strempty(suffix))
16
17 int block_device_is_whole_disk(sd_device *dev);
18 int block_device_get_whole_disk(sd_device *dev, sd_device **ret);
19
20 int block_get_whole_disk(dev_t d, dev_t *ret);
21 int block_get_originating(dev_t d, dev_t *ret);
22
23 int get_block_device_fd(int fd, dev_t *ret);
24 int get_block_device(const char *path, dev_t *dev);
25
26 int get_block_device_harder_fd(int fd, dev_t *dev);
27 int get_block_device_harder(const char *path, dev_t *dev);
28
29 int lock_whole_block_device(dev_t devt, int operation);
30
31 int blockdev_partscan_enabled(int fd);
32
33 int fd_is_encrypted(int fd);
34 int path_is_encrypted(const char *path);
35
36 int fd_get_whole_disk(int fd, bool backing, dev_t *ret);
37 int path_get_whole_disk(const char *path, bool backing, dev_t *ret);
38
39 int block_device_add_partition(int fd, const char *name, int nr, uint64_t start, uint64_t size);
40 int block_device_remove_partition(int fd, const char *name, int nr);
41 int block_device_resize_partition(int fd, int nr, uint64_t start, uint64_t size);
42 int partition_enumerator_new(sd_device *dev, sd_device_enumerator **ret);
43 int block_device_remove_all_partitions(sd_device *dev, int fd);
44 int block_device_has_partitions(sd_device *dev);
45 int blockdev_reread_partition_table(sd_device *dev);