fs-util: add fd-based flavour of path_is_encrypted()
This commit is contained in:
@@ -334,6 +334,22 @@ static int blockdev_is_encrypted(const char *sysfs_path, unsigned depth_left) {
|
||||
return found_encrypted;
|
||||
}
|
||||
|
||||
int fd_is_encrypted(int fd) {
|
||||
char p[SYS_BLOCK_PATH_MAX(NULL)];
|
||||
dev_t devt;
|
||||
int r;
|
||||
|
||||
r = get_block_device_fd(fd, &devt);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0) /* doesn't have a block device */
|
||||
return false;
|
||||
|
||||
xsprintf_sys_block_path(p, NULL, devt);
|
||||
|
||||
return blockdev_is_encrypted(p, 10 /* safety net: maximum recursion depth */);
|
||||
}
|
||||
|
||||
int path_is_encrypted(const char *path) {
|
||||
char p[SYS_BLOCK_PATH_MAX(NULL)];
|
||||
dev_t devt;
|
||||
|
||||
@@ -24,4 +24,5 @@ int lock_whole_block_device(dev_t devt, int operation);
|
||||
|
||||
int blockdev_partscan_enabled(int fd);
|
||||
|
||||
int fd_is_encrypted(int fd);
|
||||
int path_is_encrypted(const char *path);
|
||||
|
||||
Reference in New Issue
Block a user