summaryrefslogtreecommitdiffstats
path: root/lib/utils_devpath.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 08:35:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 08:35:42 +0000
commit8909d83a3ed226e4a7c962261217cb2c14ff2ec9 (patch)
tree6244f99976b171d94833db21dc498c3a89d04fe4 /lib/utils_devpath.c
parentReleasing progress-linux version 2:2.6.1-6~progress7.99u1. (diff)
downloadcryptsetup-8909d83a3ed226e4a7c962261217cb2c14ff2ec9.tar.xz
cryptsetup-8909d83a3ed226e4a7c962261217cb2c14ff2ec9.zip
Merging upstream version 2:2.7.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--lib/utils_devpath.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/utils_devpath.c b/lib/utils_devpath.c
index dc5a5bb..5e7e13e 100644
--- a/lib/utils_devpath.c
+++ b/lib/utils_devpath.c
@@ -3,8 +3,8 @@
*
* Copyright (C) 2004 Jana Saout <jana@saout.de>
* Copyright (C) 2004-2007 Clemens Fruhwirth <clemens@endorphin.org>
- * Copyright (C) 2009-2023 Red Hat, Inc. All rights reserved.
- * Copyright (C) 2009-2023 Milan Broz
+ * Copyright (C) 2009-2024 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2009-2024 Milan Broz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -210,6 +210,24 @@ static int _path_get_uint64(const char *sysfs_path, uint64_t *value, const char
return _read_uint64(path, value);
}
+int crypt_dev_get_partition_number(const char *dev_path)
+{
+ uint64_t partno;
+ struct stat st;
+
+ if (stat(dev_path, &st) < 0)
+ return 0;
+
+ if (!S_ISBLK(st.st_mode))
+ return 0;
+
+ if (!_sysfs_get_uint64(major(st.st_rdev), minor(st.st_rdev),
+ &partno, "partition"))
+ return -EINVAL;
+
+ return (int)partno;
+}
+
int crypt_dev_is_rotational(int major, int minor)
{
uint64_t val;
@@ -220,6 +238,16 @@ int crypt_dev_is_rotational(int major, int minor)
return val ? 1 : 0;
}
+int crypt_dev_is_dax(int major, int minor)
+{
+ uint64_t val;
+
+ if (!_sysfs_get_uint64(major, minor, &val, "queue/dax"))
+ return 0; /* if failed, expect non-DAX device */
+
+ return val ? 1 : 0;
+}
+
int crypt_dev_is_partition(const char *dev_path)
{
uint64_t val;
@@ -253,6 +281,7 @@ uint64_t crypt_dev_partition_offset(const char *dev_path)
&val, "start"))
return 0;
+ /* coverity[tainted_data_return:FALSE] */
return val;
}