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