Merge pull request #15845 from poettering/btrfs-encrypted-fix

make path_is_encrypted() test pass on btrfs inside container
This commit is contained in:
Lennart Poettering 2020-05-19 17:15:22 +02:00 committed by GitHub
commit 1d06deba0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -319,7 +319,7 @@ int btrfs_get_block_device_fd(int fd, dev_t *dev) {
return -errno;
if (!S_ISBLK(st.st_mode))
return -ENODEV;
return -ENOTBLK;
if (major(st.st_rdev) == 0)
return -ENODEV;

View File

@ -850,6 +850,12 @@ static void test_path_is_encrypted_one(const char *p, int expect) {
int r;
r = path_is_encrypted(p);
if (r == -ENOENT) /* This might fail, if btrfs is used and we run in a container. In that case we
* cannot resolve the device node paths that BTRFS_IOC_DEV_INFO returns, because
* the device nodes are unlikely to exist in the container. But if we can't stat()
* them we cannot determine the dev_t of them, and thus cannot figure out if they
* are enrypted. Hence let's just ignore ENOENT here. */
return;
assert_se(r >= 0);
printf("%s encrypted: %s\n", p, yes_no(r));