blob: a46d9ac6a81aa52226aca05d3c366ab24df1f2fe (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# Copyright (c) 2008 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# PerlHeaders.pm
# - provides automatic generation of required perl headers (for syscalls)
# -----------------------------------------------------------------------------
package OpenSLX::Syscall;
use strict;
use warnings;
our $VERSION = 1.01;
=head1 NAME
OpenSLX::Syscall - provides wrapper functions for syscalls.
=head1 DESCRIPTION
This module exports one wrapper function for each syscall that OpenSLX is
using. Each of these functions takes care to load all required Perl-headers
before trying to invoke the respective syscall.
=cut
use OpenSLX::Basics;
=head1 PUBLIC FUNCTIONS
=over
=item B<enter32BitPersonality()>
Invokes the I<personality()> syscall in order to enter the 32-bit personality
(C<PER_LINUX32>).
=cut
sub enter32BitPersonality
{
_loadPerlHeader('syscall.ph');
_loadPerlHeader('linux/personality.ph', 'sys/personality.ph');
syscall(&SYS_personality, PER_LINUX32()) != -1
or warn _tr("unable to invoke syscall '%s'! ($!)", 'personality');
return;
}
sub _loadPerlHeader
{
my @phFiles = @_;
for my $phFile (@phFiles) {
if (!eval { require $phFile }) {
# perl-header has not been provided by host-OS, so we create it
# manually from C-header (via h2ph):
(my $hFile = $phFile) =~ s{\.ph$}{.h};
if (-e "/usr/include/$hFile") {
my $libDir = "$openslxConfig{'base-path'}/lib";
slxsystem("cd /usr/include && h2ph -d $libDir $hFile") == 0
or die _tr('unable to create %s! (%s)', $phFile, $!);
}
}
return 1 if eval { require $phFile; 1 };
}
die _tr(
'unable to load any of these perl headers: %s', join(',', @phFiles)
);
}
=back
=cut
1;
|