basic: split out dev_t related calls into new devno-util.[ch]
No actual code changes, just splitting out of some dev_t handling related calls from stat-util.[ch], they are quite a number already, and deserve their own module now I think. Also, try to settle on the name "devnum" as the name for the concept, instead of "devno" or "dev" or "devid". "devnum" is the name exported in udev APIs, hence probably best to stick to that. (this just renames a few symbols to "devum", local variables are left untouched, to make the patch not too invasive) No actual code changes.
This commit is contained in:
@@ -6,12 +6,12 @@
|
||||
#include "alloc-util.h"
|
||||
#include "blockdev-util.h"
|
||||
#include "btrfs-util.h"
|
||||
#include "devnum-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "missing_magic.h"
|
||||
#include "parse-util.h"
|
||||
#include "stat-util.h"
|
||||
|
||||
int block_get_whole_disk(dev_t d, dev_t *ret) {
|
||||
char p[SYS_BLOCK_PATH_MAX("/partition")];
|
||||
@@ -44,7 +44,7 @@ int block_get_whole_disk(dev_t d, dev_t *ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = parse_dev(s, &devt);
|
||||
r = parse_devnum(s, &devt);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -170,7 +170,7 @@ int block_get_originating(dev_t dt, dev_t *ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = parse_dev(t, &devt);
|
||||
r = parse_devnum(t, &devt);
|
||||
if (r < 0)
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "bootspec.h"
|
||||
#include "bootspec-fundamental.h"
|
||||
#include "conf-files.h"
|
||||
#include "devnum-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "efi-loader.h"
|
||||
#include "env-file.h"
|
||||
@@ -15,7 +16,6 @@
|
||||
#include "pe-header.h"
|
||||
#include "recurse-dir.h"
|
||||
#include "sort-util.h"
|
||||
#include "stat-util.h"
|
||||
#include "strv.h"
|
||||
#include "unaligned.h"
|
||||
|
||||
@@ -918,7 +918,7 @@ int boot_config_load_auto(
|
||||
return r; /* It's fine if the XBOOTLDR partition doesn't exist, hence we ignore ENOKEY here */
|
||||
|
||||
/* If both paths actually refer to the same inode, suppress the xbootldr path */
|
||||
if (esp_where && xbootldr_where && devid_set_and_equal(esp_devid, xbootldr_devid))
|
||||
if (esp_where && xbootldr_where && devnum_set_and_equal(esp_devid, xbootldr_devid))
|
||||
xbootldr_where = mfree(xbootldr_where);
|
||||
|
||||
return boot_config_load(config, esp_where, xbootldr_where);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <linux/magic.h>
|
||||
#include <sys/vfs.h>
|
||||
|
||||
#include "sd-device.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "blkid-util.h"
|
||||
#include "devnum-util.h"
|
||||
#include "env-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "find-esp.h"
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "alloc-util.h"
|
||||
#include "blockdev-util.h"
|
||||
#include "device-util.h"
|
||||
#include "devnum-util.h"
|
||||
#include "env-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
@@ -876,7 +877,7 @@ static int resize_partition(int partition_fd, uint64_t offset, uint64_t size) {
|
||||
r = read_one_line_file(sysfs, &buffer);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = parse_dev(buffer, &devno);
|
||||
r = parse_devnum(buffer, &devno);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/quota.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "blockdev-util.h"
|
||||
#include "devnum-util.h"
|
||||
#include "quota-util.h"
|
||||
#include "stat-util.h"
|
||||
|
||||
int quotactl_devno(int cmd, dev_t devno, int id, void *addr) {
|
||||
int quotactl_devnum(int cmd, dev_t devnum, int id, void *addr) {
|
||||
_cleanup_free_ char *devnode = NULL;
|
||||
int r;
|
||||
|
||||
/* Like quotactl() but takes a dev_t instead of a path to a device node, and fixes caddr_t → void*,
|
||||
* like we should, today */
|
||||
|
||||
r = device_path_make_major_minor(S_IFBLK, devno, &devnode);
|
||||
r = device_path_make_major_minor(S_IFBLK, devnum, &devnode);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -37,5 +38,5 @@ int quotactl_path(int cmd, const char *path, int id, void *addr) {
|
||||
if (devno == 0) /* Doesn't have a block device */
|
||||
return -ENODEV;
|
||||
|
||||
return quotactl_devno(cmd, devno, id, addr);
|
||||
return quotactl_devnum(cmd, devno, id, addr);
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@ static inline int QCMD_FIXED(uint32_t cmd, uint32_t type) {
|
||||
return (int) QCMD(cmd, type);
|
||||
}
|
||||
|
||||
int quotactl_devno(int cmd, dev_t devno, int id, void *addr);
|
||||
int quotactl_devnum(int cmd, dev_t devnum, int id, void *addr);
|
||||
int quotactl_path(int cmd, const char *path, int id, void *addr);
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
#include "btrfs-util.h"
|
||||
#include "conf-parser.h"
|
||||
#include "def.h"
|
||||
#include "devnum-util.h"
|
||||
#include "env-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "sleep-config.h"
|
||||
#include "stat-util.h"
|
||||
@@ -274,7 +274,7 @@ static int read_resume_files(dev_t *ret_resume, uint64_t *ret_resume_offset) {
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Error reading /sys/power/resume: %m");
|
||||
|
||||
r = parse_dev(resume_str, &resume);
|
||||
r = parse_devnum(resume_str, &resume);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Error parsing /sys/power/resume device: %s: %m", resume_str);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user