Skip to content

Commit

Permalink
mount: Fix ioctl to not use GNU C extension
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Sep 26, 2024
1 parent bcbc609 commit 8b032b3
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions libcomposefs/lcfs-mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,20 @@ static errint_t lcfs_validate_mount_options(struct lcfs_mount_state_s *state)

static errint_t lcfs_validate_verity_fd(struct lcfs_mount_state_s *state)
{
struct {
struct fsverity_digest fsv;
char buf[MAX_DIGEST_SIZE];
} buf;
char buf[sizeof(struct fsverity_digest) + MAX_DIGEST_SIZE];
struct fsverity_digest *fsv = (struct fsverity_digest *)&buf;
int res;

if (state->expected_digest_len != 0) {
buf.fsv.digest_size = MAX_DIGEST_SIZE;
res = ioctl(state->fd, FS_IOC_MEASURE_VERITY, &buf.fsv);
fsv->digest_size = MAX_DIGEST_SIZE;
res = ioctl(state->fd, FS_IOC_MEASURE_VERITY, fsv);
if (res == -1) {
if (errno == ENODATA || errno == EOPNOTSUPP || errno == ENOTTY)
return -ENOVERITY;
return -errno;
}
if (buf.fsv.digest_size != state->expected_digest_len ||
memcmp(state->expected_digest, buf.fsv.digest,
buf.fsv.digest_size) != 0)
if (fsv->digest_size != state->expected_digest_len ||
memcmp(state->expected_digest, fsv->digest, fsv->digest_size) != 0)
return -EWRONGVERITY;
}

Expand Down

0 comments on commit 8b032b3

Please sign in to comment.