]> git.proxmox.com Git - pve-common.git/blob - src/PVE/Syscall.pm
bump version to 8.2.1
[pve-common.git] / src / PVE / Syscall.pm
1 package PVE::Syscall;
2
3 my %syscalls;
4 my %fsmount_constants;
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,
12 fsync => &SYS_fsync,
13 openat => &SYS_openat,
14 close => &SYS_close,
15 mkdirat => &SYS_mkdirat,
16 faccessat => &SYS_faccessat,
17 setresuid => &SYS_setresuid,
18 fchownat => &SYS_fchownat,
19 mount => &SYS_mount,
20 renameat2 => &SYS_renameat2,
21
22 # These use asm-generic, so they're the same across (sane) architectures. We use numbers
23 # since they're not in perl's syscall.ph yet...
24 open_tree => 428,
25 move_mount => 429,
26 fsopen => 430,
27 fsconfig => 431,
28 fsmount => 432,
29 fspick => 433,
30 );
31
32 %fsmount_constants = (
33 OPEN_TREE_CLONE => 0x0000_0001,
34 OPEN_TREE_CLOEXEC => 000200_0000, # octal!
35
36 MOVE_MOUNT_F_SYMLINKS => 0x0000_0001,
37 MOVE_MOUNT_F_AUTOMOUNTS => 0x0000_0002,
38 MOVE_MOUNT_F_EMPTY_PATH => 0x0000_0004,
39 MOVE_MOUNT_F_MASK => 0x0000_0007,
40
41 MOVE_MOUNT_T_SYMLINKS => 0x0000_0010,
42 MOVE_MOUNT_T_AUTOMOUNTS => 0x0000_0020,
43 MOVE_MOUNT_T_EMPTY_PATH => 0x0000_0040,
44 MOVE_MOUNT_T_MASK => 0x0000_0070,
45
46 FSMOUNT_CLOEXEC => 0x0000_0001,
47
48 FSOPEN_CLOEXEC => 0x0000_0001,
49
50 MOUNT_ATTR_RDONLY => 0x0000_0001,
51 MOUNT_ATTR_NOSUID => 0x0000_0002,
52 MOUNT_ATTR_NODEV => 0x0000_0004,
53 MOUNT_ATTR_NOEXEC => 0x0000_0008,
54 MOUNT_ATTR_RELATIME => 0x0000_0000,
55 MOUNT_ATTR_NOATIME => 0x0000_0010,
56 MOUNT_ATTR_STRICTATIME => 0x0000_0020,
57 MOUNT_ATTR_NODIRATIME => 0x0000_0080,
58
59 FSPICK_CLOEXEC => 0x0000_0001,
60 FSPICK_SYMLINK_NOFOLLOW => 0x0000_0002,
61 FSPICK_NO_AUTOMOUNT => 0x0000_0004,
62 FSPICK_EMPTY_PATH => 0x0000_0008,
63
64 FSCONFIG_SET_FLAG => 0,
65 FSCONFIG_SET_STRING => 1,
66 FSCONFIG_SET_BINARY => 2,
67 FSCONFIG_SET_PATH => 3,
68 FSCONFIG_SET_PATH_EMPTY => 4,
69 FSCONFIG_SET_FD => 5,
70 FSCONFIG_CMD_CREATE => 6,
71 FSCONFIG_CMD_RECONFIGURE => 7,
72 );
73 };
74
75 use constant \%syscalls;
76 use constant \%fsmount_constants;
77
78 use base 'Exporter';
79
80 our @EXPORT_OK = (keys(%syscalls), keys(%fsmount_constants), 'file_handle_result');
81 our %EXPORT_TAGS = (fsmount => [keys(%fsmount_constants)]);
82
83 # Create a file handle from a numeric file descriptor (to make sure it's close()d when it goes out
84 # of scope).
85 sub file_handle_result($) {
86 my ($fd_num) = @_;
87 return undef if $fd_num < 0;
88
89 open(my $fh, '<&=', $fd_num)
90 or return undef;
91
92 return $fh;
93 }
94
95 1;