summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-07-04 12:36:11 +0900
committerGitHub <noreply@github.com>2019-07-04 12:36:11 +0900
commit7810d22171bbff1301397357afd4146016a60bde (patch)
tree3e58417e41acc7e85918a777c176fdd9e1e56d95 /src
parented9aa225e884dc2a0c857ed1603d3bc3a3758c06 (diff)
parenta0ea1dee7be452183365748c245271a619468dc5 (diff)
downloadsystemd-7810d22171bbff1301397357afd4146016a60bde.tar.gz
Merge pull request #12946 from poettering/blockdev-tweaks
three small blockdev-util.[ch] tweaks
Diffstat (limited to 'src')
-rw-r--r--src/basic/blockdev-util.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/basic/blockdev-util.c b/src/basic/blockdev-util.c
index 625bbdd943..0ee14cbc0b 100644
--- a/src/basic/blockdev-util.c
+++ b/src/basic/blockdev-util.c
@@ -21,6 +21,9 @@ int block_get_whole_disk(dev_t d, dev_t *ret) {
assert(ret);
+ if (major(d) == 0)
+ return -ENODEV;
+
/* If it has a queue this is good enough for us */
xsprintf_sys_block_path(p, "/queue", d);
if (access(p, F_OK) >= 0) {
@@ -31,7 +34,7 @@ int block_get_whole_disk(dev_t d, dev_t *ret) {
/* If it is a partition find the originating device */
xsprintf_sys_block_path(p, "/partition", d);
if (access(p, F_OK) < 0)
- return -ENOENT;
+ return -errno;
/* Get parent dev_t */
xsprintf_sys_block_path(p, "/../dev", d);
@@ -46,10 +49,10 @@ int block_get_whole_disk(dev_t d, dev_t *ret) {
/* Only return this if it is really good enough for us. */
xsprintf_sys_block_path(p, "/queue", devt);
if (access(p, F_OK) < 0)
- return -ENOENT;
+ return -errno;
*ret = devt;
- return 0;
+ return 1;
}
int get_block_device(const char *path, dev_t *dev) {