I think it works. needs tests

This commit is contained in:
Ryan Voots 2017-05-03 20:55:32 -07:00
parent 4c84df8538
commit 4e68b27347
4 changed files with 8 additions and 7 deletions

View file

@ -4,6 +4,9 @@ use strict;
use warnings; use warnings;
require Exporter; require Exporter;
our @ISA = qw/Exporter/; our @ISA = qw/Exporter/;
require XSLoader;
XSLoader::load();
my @mount_consts = qw/MS_RDONLY MS_NOSUID MS_NODEV MS_NOEXEC MS_SYNCHRONOUS MS_REMOUNT MS_MANDLOCK MS_DIRSYNC MS_NOATIME MS_NODIRATIME MS_BIND MS_MOVE MS_REC MS_SILENT MS_POSIXACL MS_UNBINDABLE MS_PRIVATE MS_SLAVE MS_SHARED MS_RELATIME MS_KERNMOUNT MS_I_VERSION MS_STRICTATIME MS_LAZYTIME MS_ACTIVE MS_NOUSER/; my @mount_consts = qw/MS_RDONLY MS_NOSUID MS_NODEV MS_NOEXEC MS_SYNCHRONOUS MS_REMOUNT MS_MANDLOCK MS_DIRSYNC MS_NOATIME MS_NODIRATIME MS_BIND MS_MOVE MS_REC MS_SILENT MS_POSIXACL MS_UNBINDABLE MS_PRIVATE MS_SLAVE MS_SHARED MS_RELATIME MS_KERNMOUNT MS_I_VERSION MS_STRICTATIME MS_LAZYTIME MS_ACTIVE MS_NOUSER/;
@ -19,7 +22,7 @@ sub mount {
my $options_str = join ',', map {"$_=".$options_hr->{$_}} keys %$options_hr; my $options_str = join ',', map {"$_=".$options_hr->{$_}} keys %$options_hr;
my $ret = syscall(SYS_mount(), $source, $target, $filesystem//undef, $flags, $options_str); my $ret = _mount_sys($source, $target, $filesystem//undef, $flags, $options_str);
if ($ret != 0) { if ($ret != 0) {
die "mount failed: $ret $!"; die "mount failed: $ret $!";

View file

@ -12,12 +12,11 @@ PROTOTYPES: ENABLE
# XS comments begin with " #" to avoid them being interpreted as pre-processor # XS comments begin with " #" to avoid them being interpreted as pre-processor
# directives # directives
int int _mount_sys(source, target, filesystem, mountflags, data)
_unshare_sys(source, target, filesystem, mount, data)
const char *source const char *source
const char *target const char *target
const char *filesystem const char *filesystem
unsigned long mountflags unsigned long mountflags
const char *data const char *data
CODE: CODE:
return mount(source, target, filesystem, mount, (const void *) data); RETVAL = mount(source, target, filesystem, mountflags, (const void *) data);

View file

@ -24,8 +24,7 @@ sub unshare {
local $! = 0; local $! = 0;
### FIXME XXX HACK FUCK YOU = 272 unshare syscall number on x86_64 my $ret = _unshare_sys($flags);
my $ret = syscall(SYS_unshare(), $flags);
if ($ret != 0) { if ($ret != 0) {
die "unshare failed $ret $!"; die "unshare failed $ret $!";

View file

@ -19,5 +19,5 @@ int
_unshare_sys(flags) _unshare_sys(flags)
int flags int flags
CODE: CODE:
return unshare(flags); RETVAL = unshare(flags);