Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
relibc
Commits
50c03f28
Verified
Commit
50c03f28
authored
6 years ago
by
jD91mZM2
Browse files
Options
Downloads
Patches
Plain Diff
Support shebangs in redox execve
parent
077e922c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#1214
failed
6 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/platform/redox/mod.rs
+50
-3
50 additions, 3 deletions
src/platform/redox/mod.rs
with
50 additions
and
3 deletions
src/platform/redox/mod.rs
+
50
−
3
View file @
50c03f28
...
@@ -21,10 +21,10 @@ use header::sys_times::tms;
...
@@ -21,10 +21,10 @@ use header::sys_times::tms;
use
header
::
sys_utsname
::
utsname
;
use
header
::
sys_utsname
::
utsname
;
use
header
::
termios
::
termios
;
use
header
::
termios
::
termios
;
use
header
::
time
::
timespec
;
use
header
::
time
::
timespec
;
use
header
::
unistd
::{
F_OK
,
R_OK
,
W_OK
,
X_OK
};
use
header
::
unistd
::{
F_OK
,
R_OK
,
W_OK
,
X_OK
,
SEEK_SET
};
use
super
::
types
::
*
;
use
super
::
types
::
*
;
use
super
::{
errno
,
FileReader
,
FileWriter
,
Pal
,
RawFile
,
Read
};
use
super
::{
errno
,
FileReader
,
FileWriter
,
Line
,
Pal
,
RawFile
,
RawLineBuffer
,
Read
};
mod
signal
;
mod
signal
;
mod
socket
;
mod
socket
;
...
@@ -179,12 +179,58 @@ impl Pal for Sys {
...
@@ -179,12 +179,58 @@ impl Pal for Sys {
Err
(
_
)
=>
return
-
1
,
Err
(
_
)
=>
return
-
1
,
};
};
// Count arguments
let
mut
len
=
0
;
let
mut
len
=
0
;
while
!
(
*
argv
.offset
(
len
))
.is_null
()
{
while
!
(
*
argv
.offset
(
len
))
.is_null
()
{
len
+=
1
;
len
+=
1
;
}
}
let
mut
args
:
Vec
<
[
usize
;
2
]
>
=
Vec
::
with_capacity
(
len
as
usize
);
let
mut
args
:
Vec
<
[
usize
;
2
]
>
=
Vec
::
with_capacity
(
len
as
usize
);
// Read shebang (for example #!/bin/sh)
let
mut
shebang
=
[
0
;
2
];
let
mut
read
=
0
;
while
read
<
2
{
match
Self
::
read
(
*
fd
,
&
mut
shebang
)
{
0
=>
break
,
i
if
i
<
0
=>
return
-
1
,
i
=>
read
+=
i
}
}
let
mut
_interpreter_path
=
None
;
let
mut
_interpreter_file
=
None
;
let
mut
interpreter_fd
=
*
fd
;
if
&
shebang
==
b"#!"
{
match
RawLineBuffer
::
new
(
*
fd
)
.next
()
{
Line
::
Error
=>
return
-
1
,
Line
::
EOF
=>
(),
Line
::
Some
(
line
)
=>
{
let
mut
path
=
match
CString
::
new
(
line
)
{
Ok
(
path
)
=>
path
,
Err
(
_
)
=>
return
-
1
};
match
RawFile
::
open
(
&
path
,
O_RDONLY
as
c_int
,
0
)
{
Ok
(
file
)
=>
{
interpreter_fd
=
*
file
;
_interpreter_path
=
Some
(
path
);
_interpreter_file
=
Some
(
file
);
let
path_ref
=
_interpreter_path
.as_ref
()
.unwrap
();
args
.push
([
path_ref
.as_ptr
()
as
usize
,
path_ref
.to_bytes
()
.len
()]);
},
Err
(
_
)
=>
return
-
1
}
}
}
}
if
Self
::
lseek
(
*
fd
,
0
,
SEEK_SET
)
<
0
{
return
-
1
;
}
// Arguments
while
!
(
*
argv
)
.is_null
()
{
while
!
(
*
argv
)
.is_null
()
{
let
arg
=
*
argv
;
let
arg
=
*
argv
;
...
@@ -196,6 +242,7 @@ impl Pal for Sys {
...
@@ -196,6 +242,7 @@ impl Pal for Sys {
argv
=
argv
.offset
(
1
);
argv
=
argv
.offset
(
1
);
}
}
// Environment variables
let
mut
len
=
0
;
let
mut
len
=
0
;
while
!
(
*
envp
.offset
(
len
))
.is_null
()
{
while
!
(
*
envp
.offset
(
len
))
.is_null
()
{
len
+=
1
;
len
+=
1
;
...
@@ -213,7 +260,7 @@ impl Pal for Sys {
...
@@ -213,7 +260,7 @@ impl Pal for Sys {
envp
=
envp
.offset
(
1
);
envp
=
envp
.offset
(
1
);
}
}
e
(
syscall
::
fexec
(
*
fd
as
usize
,
&
args
,
&
envs
))
as
c_int
e
(
syscall
::
fexec
(
interpreter_
fd
as
usize
,
&
args
,
&
envs
))
as
c_int
}
}
fn
fchdir
(
fd
:
c_int
)
->
c_int
{
fn
fchdir
(
fd
:
c_int
)
->
c_int
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment