1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00

Merge pull request #12946 from poettering/blockdev-tweaks

three small blockdev-util.[ch] tweaks
This commit is contained in:
Yu Watanabe 2019-07-04 12:36:11 +09:00 committed by GitHub
commit 7810d22171
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {