]>
Commit | Line | Data |
---|---|---|
c8e94d4b TL |
1 | package PVE::Syscall; |
2 | ||
967e9823 TL |
3 | use strict; |
4 | use warnings; | |
5 | ||
c8e94d4b | 6 | my %syscalls; |
5569cc16 | 7 | my %fsmount_constants; |
c8e94d4b TL |
8 | BEGIN { |
9 | die "syscall.ph can only be required once!\n" if $INC{'syscall.ph'}; | |
10 | require("syscall.ph"); | |
11 | %syscalls = ( | |
12 | unshare => &SYS_unshare, | |
13 | setns => &SYS_setns, | |
14 | syncfs => &SYS_syncfs, | |
cee0e23a | 15 | fsync => &SYS_fsync, |
c8e94d4b TL |
16 | openat => &SYS_openat, |
17 | close => &SYS_close, | |
18 | mkdirat => &SYS_mkdirat, | |
b792e8df | 19 | mknod => &SYS_mknod, |
c8e94d4b | 20 | faccessat => &SYS_faccessat, |
0c078e66 | 21 | setresuid => &SYS_setresuid, |
6cf6b404 | 22 | fchownat => &SYS_fchownat, |
5569cc16 | 23 | mount => &SYS_mount, |
bd9eb367 | 24 | renameat2 => &SYS_renameat2, |
bfa10639 TL |
25 | open_tree => &SYS_open_tree, |
26 | move_mount => &SYS_move_mount, | |
27 | fsopen => &SYS_fsopen, | |
28 | fsconfig => &SYS_fsconfig, | |
29 | fsmount => &SYS_fsmount, | |
30 | fspick => &SYS_fspick, | |
4c0c5c90 TL |
31 | getxattr => &SYS_getxattr, |
32 | setxattr => &SYS_setxattr, | |
33 | fgetxattr => &SYS_fgetxattr, | |
34 | fsetxattr => &SYS_fsetxattr, | |
63b74c50 | 35 | prctl => &SYS_prctl, |
bfa10639 TL |
36 | |
37 | # Below aren't yet in perl's syscall.ph but use asm-generic, so the same across (sane) archs | |
38 | # -> none unknown currently, yay | |
5569cc16 WB |
39 | ); |
40 | ||
41 | %fsmount_constants = ( | |
42 | OPEN_TREE_CLONE => 0x0000_0001, | |
43 | OPEN_TREE_CLOEXEC => 000200_0000, # octal! | |
44 | ||
45 | MOVE_MOUNT_F_SYMLINKS => 0x0000_0001, | |
46 | MOVE_MOUNT_F_AUTOMOUNTS => 0x0000_0002, | |
47 | MOVE_MOUNT_F_EMPTY_PATH => 0x0000_0004, | |
48 | MOVE_MOUNT_F_MASK => 0x0000_0007, | |
49 | ||
50 | MOVE_MOUNT_T_SYMLINKS => 0x0000_0010, | |
51 | MOVE_MOUNT_T_AUTOMOUNTS => 0x0000_0020, | |
52 | MOVE_MOUNT_T_EMPTY_PATH => 0x0000_0040, | |
53 | MOVE_MOUNT_T_MASK => 0x0000_0070, | |
54 | ||
55 | FSMOUNT_CLOEXEC => 0x0000_0001, | |
56 | ||
57 | FSOPEN_CLOEXEC => 0x0000_0001, | |
58 | ||
59 | MOUNT_ATTR_RDONLY => 0x0000_0001, | |
60 | MOUNT_ATTR_NOSUID => 0x0000_0002, | |
61 | MOUNT_ATTR_NODEV => 0x0000_0004, | |
62 | MOUNT_ATTR_NOEXEC => 0x0000_0008, | |
63 | MOUNT_ATTR_RELATIME => 0x0000_0000, | |
64 | MOUNT_ATTR_NOATIME => 0x0000_0010, | |
65 | MOUNT_ATTR_STRICTATIME => 0x0000_0020, | |
66 | MOUNT_ATTR_NODIRATIME => 0x0000_0080, | |
67 | ||
68 | FSPICK_CLOEXEC => 0x0000_0001, | |
69 | FSPICK_SYMLINK_NOFOLLOW => 0x0000_0002, | |
70 | FSPICK_NO_AUTOMOUNT => 0x0000_0004, | |
71 | FSPICK_EMPTY_PATH => 0x0000_0008, | |
72 | ||
73 | FSCONFIG_SET_FLAG => 0, | |
74 | FSCONFIG_SET_STRING => 1, | |
75 | FSCONFIG_SET_BINARY => 2, | |
76 | FSCONFIG_SET_PATH => 3, | |
77 | FSCONFIG_SET_PATH_EMPTY => 4, | |
78 | FSCONFIG_SET_FD => 5, | |
79 | FSCONFIG_CMD_CREATE => 6, | |
80 | FSCONFIG_CMD_RECONFIGURE => 7, | |
c8e94d4b TL |
81 | ); |
82 | }; | |
83 | ||
84 | use constant \%syscalls; | |
5569cc16 | 85 | use constant \%fsmount_constants; |
c8e94d4b TL |
86 | |
87 | use base 'Exporter'; | |
88 | ||
5569cc16 WB |
89 | our @EXPORT_OK = (keys(%syscalls), keys(%fsmount_constants), 'file_handle_result'); |
90 | our %EXPORT_TAGS = (fsmount => [keys(%fsmount_constants)]); | |
91 | ||
92 | # Create a file handle from a numeric file descriptor (to make sure it's close()d when it goes out | |
93 | # of scope). | |
94 | sub file_handle_result($) { | |
95 | my ($fd_num) = @_; | |
96 | return undef if $fd_num < 0; | |
97 | ||
98 | open(my $fh, '<&=', $fd_num) | |
99 | or return undef; | |
100 | ||
101 | return $fh; | |
102 | } | |
88c2babd WB |
103 | |
104 | 1; |