-
Notifications
You must be signed in to change notification settings - Fork 1
/
crypt_main.c~
executable file
·60 lines (56 loc) · 1.28 KB
/
crypt_main.c~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include "cryptctl_driver.h"
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<unistd.h>
int main(int argc, char** argv)
{
if(argc<3)
{
printf("Not enough arguments\n");
return -1;
}
char command[1024];
strcpy(command, argv[2]);
if(strcmp(command, CREATE) == 0)
{
char dev_id[1024];
char dev_name1[1024];
char dev_name2[1024];
strcpy(dev_name1,ENCRYPT_DEV_NAME );
strcpy(dev_name2,DECRYPT_DEV_NAME );
strcpy(dev_id, argv[1]);
strcat(dev_name1, dev_id);
strcat(dev_name2, dev_id);
char key[];
encryptctl_struct my_encrypt;
strcpy( my_encrypt.encrypt_name, dev_name1);
strcpy( my_encrypt.decrypt_name, dev_name2);
printf("device names %s, %s\n",my_encrypt.encrypt_name, my_encrypt.decrypt_name);
int control_file = open( ENCRYPTCTL_PATH, O_RDWR );
if(control_file< 0)
{
perror("open");
return -1;
}
printf("open file: %d\n", control_file);
if( ioctl(control_file,CREATE_DEV_CODE, &my_encrypt) < 0)
{
perror("ioctl");
return -1;
}
sleep(10);
if( close(control_file)<0)
{
perror("close");
return -1;
}
printf("File closed. Done.\n");
}
return 0;
// return 0;
}