mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-29 03:00:19 +00:00
1dab58a2cf
This search/replace updates all copyright notices to drop the "All rights reserved", Use "ChromiumOS" instead of "Chromium OS" and drops the trailing dots. This fulfills the request from legal and unifies our notices. ./tools/health-check has been updated to only accept this style. BUG=b:246579983 TEST=./tools/health-check Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Dennis Kempin <denniskempin@google.com>
58 lines
1.5 KiB
C
58 lines
1.5 KiB
C
// Copyright 2019 The ChromiumOS Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef _GNU_SOURCE
|
|
#define _GNU_SOURCE
|
|
#endif
|
|
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <linux/fs.h>
|
|
#include <stdio.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#include <sys/ioctl.h>
|
|
#include <unistd.h>
|
|
|
|
extern char* program_invocation_short_name;
|
|
|
|
int main(int argc, char** argv) {
|
|
if (argc != 2) {
|
|
printf("Usage: %s <path_to_directory>\n", program_invocation_short_name);
|
|
return 1;
|
|
}
|
|
|
|
int dir = open(argv[1], O_DIRECTORY | O_CLOEXEC);
|
|
if (dir < 0) {
|
|
perror("Failed to open directory");
|
|
return 1;
|
|
}
|
|
|
|
struct fscrypt_policy policy;
|
|
int ret = ioctl(dir, FS_IOC_GET_ENCRYPTION_POLICY, &policy);
|
|
if (ret < 0) {
|
|
perror("FS_IOC_GET_ENCRYPTION_POLICY failed");
|
|
return 1;
|
|
}
|
|
|
|
printf("File system encryption policy:\n");
|
|
printf("\tversion = %#x\n", policy.version);
|
|
printf("\tcontents_encryption_mode = %#x\n", policy.contents_encryption_mode);
|
|
printf("\tfilenames_encryption_mode = %#x\n",
|
|
policy.filenames_encryption_mode);
|
|
printf("\tflags = %#x\n", policy.flags);
|
|
printf("\tmaster_key_descriptor = 0x");
|
|
for (int i = 0; i < FS_KEY_DESCRIPTOR_SIZE; ++i) {
|
|
printf("%x", policy.master_key_descriptor[i]);
|
|
}
|
|
printf("\n");
|
|
|
|
ret = ioctl(dir, FS_IOC_SET_ENCRYPTION_POLICY, &policy);
|
|
if (ret < 0) {
|
|
perror("FS_IOC_SET_ENCRYPTION_POLICY failed");
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|