1 /*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <stdio.h>
18 #include <sys/ioctl.h>
19 #include <sys/types.h>
20 #include <sys/stat.h>
21 #include <fcntl.h>
22 #include <unistd.h>
23
24
25 #define CITADEL_IOC_MAGIC 'c'
26 #define CITADEL_IOC_RESET _IO(CITADEL_IOC_MAGIC, 2)
27
main(int argc,char * argv[])28 int main(int argc __attribute__((unused)), char *argv[] __attribute__((unused)))
29 {
30 int fd, r;
31
32 fd = open("/dev/citadel0", O_RDWR);
33 if (fd < 0) {
34 perror("can't open /dev/citadel0");
35 fprintf(stderr, "did you run \"setprop ctl.stop vendor.citadeld\" ?\n");
36 return 1;
37 }
38
39 r = ioctl(fd, CITADEL_IOC_RESET);
40 close(fd);
41
42 if (r) {
43 perror("ioctl failed");
44 return 1;
45 }
46
47 fprintf(stderr, "Citadel should have been reset, AFAICT\n");
48
49 return 0;
50 }
51