blob: 3ee3faed0f6c4c98b997ec2972cdc35ab55daf3d [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001#include <stdlib.h>
2#include <stdio.h>
3#include <string.h>
4#include <sys/ioctl.h>
5#include <fcntl.h>
6#include <getopt.h>
7#include "acl_ioctl.h"
8
9int SetAclEntry(struct acl_args *opt, unsigned int cmd)
10{
11 int fd;
12
13 fd = open("/dev/"ACL_DEVNAME, O_RDONLY);
14 if (fd < 0)
15 {
16 printf("Open %s pseudo device failed\n","/dev/"ACL_DEVNAME);
17 return ACL_FAIL;
18 }
19
20 if(ioctl(fd, cmd, opt)<0) {
21 printf("ACL_API: ioctl error\n");
22 close(fd);
23 return ACL_FAIL;
24 }
25
26 close(fd);
27 return ACL_SUCCESS;
28}
29int AclGetAllEntries(struct acl_list_args *opt)
30{
31 int fd=0;
32
33 fd = open("/dev/"ACL_DEVNAME, O_RDONLY);
34 if (fd < 0)
35 {
36 printf("Open %s pseudo device failed\n","/dev/"ACL_DEVNAME);
37 return ACL_FAIL;
38 }
39
40 if(ioctl(fd, ACL_GET_ALL_ENTRIES, opt)<0) {
41 printf("ACL_API: ioctl error\n");
42 close(fd);
43 return ACL_FAIL;
44 }
45
46 close(fd);
47
48 return ACL_SUCCESS;
49
50}