]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/blockdev-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
9 #include "stdio-util.h"
10 #include "string-util.h"
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))
17 int block_device_is_whole_disk(sd_device
*dev
);
18 int block_device_get_whole_disk(sd_device
*dev
, sd_device
**ret
);
20 int block_get_whole_disk(dev_t d
, dev_t
*ret
);
21 int block_get_originating(dev_t d
, dev_t
*ret
);
23 int get_block_device_fd(int fd
, dev_t
*ret
);
24 int get_block_device(const char *path
, dev_t
*dev
);
26 int get_block_device_harder_fd(int fd
, dev_t
*dev
);
27 int get_block_device_harder(const char *path
, dev_t
*dev
);
29 int lock_whole_block_device(dev_t devt
, int operation
);
31 int blockdev_partscan_enabled(int fd
);
33 int fd_is_encrypted(int fd
);
34 int path_is_encrypted(const char *path
);
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
);
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
);