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
b768e446
Unverified
Commit
b768e446
authored
7 years ago
by
Jeremy Soller
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #19 from sajattack/redox-fixes
redox fixes
parents
1dd2f61d
05d316b3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/platform/src/lib.rs
+4
-2
4 additions, 2 deletions
src/platform/src/lib.rs
src/platform/src/redox/mod.rs
+30
-21
30 additions, 21 deletions
src/platform/src/redox/mod.rs
with
34 additions
and
23 deletions
src/platform/src/lib.rs
+
4
−
2
View file @
b768e446
...
@@ -13,8 +13,10 @@ pub use sys::*;
...
@@ -13,8 +13,10 @@ pub use sys::*;
#[path
=
"linux/mod.rs"
]
#[path
=
"linux/mod.rs"
]
mod
sys
;
mod
sys
;
#[cfg(all(not(feature
=
"no_std"
),
target_os
=
"redox"
))]
#[cfg(all(not(feature=
"no_std"
),
target_os
=
"redox"
))]
#[path
=
"redox/mod.rs"
]
#[macro_use]
extern
crate
syscall
;
#[path=
"redox/mod.rs"
]
mod
sys
;
mod
sys
;
pub
mod
types
;
pub
mod
types
;
...
...
This diff is collapsed.
Click to expand it.
src/platform/src/redox/mod.rs
+
30
−
21
View file @
b768e446
...
@@ -4,7 +4,9 @@ use c_str;
...
@@ -4,7 +4,9 @@ use c_str;
use
types
::
*
;
use
types
::
*
;
pub
fn
brk
(
addr
:
*
const
c_void
)
->
c_int
{
pub
fn
brk
(
addr
:
*
const
c_void
)
->
c_int
{
syscall
::
brk
(
addr
as
usize
)
.unwrap_or
(
-
1
)
as
c_int
unsafe
{
syscall
::
brk
(
addr
as
usize
)
.unwrap_or
(
0
-
1
)
as
c_int
}
}
}
pub
fn
chdir
(
path
:
*
const
c_char
)
->
c_int
{
pub
fn
chdir
(
path
:
*
const
c_char
)
->
c_int
{
...
@@ -13,8 +15,9 @@ pub fn chdir(path: *const c_char) -> c_int {
...
@@ -13,8 +15,9 @@ pub fn chdir(path: *const c_char) -> c_int {
}
}
pub
fn
chown
(
path
:
*
const
c_char
,
owner
:
uid_t
,
group
:
gid_t
)
->
c_int
{
pub
fn
chown
(
path
:
*
const
c_char
,
owner
:
uid_t
,
group
:
gid_t
)
->
c_int
{
let
fd
=
syscall
::
open
(
cstr_to_slice
(
path
));
let
path
=
unsafe
{
c_str
(
path
)
};
syscall
::
fchown
(
fd
as
usize
,
owner
as
usize
,
group
as
usize
)
.unwrap_or
(
-
1
)
as
c_int
let
fd
=
syscall
::
open
(
path
,
0x0001
)
.unwrap
();
syscall
::
fchown
(
fd
as
usize
,
owner
as
u32
,
group
as
u32
)
.unwrap_or
(
0
-
1
)
as
c_int
}
}
pub
fn
close
(
fd
:
c_int
)
->
c_int
{
pub
fn
close
(
fd
:
c_int
)
->
c_int
{
...
@@ -23,11 +26,11 @@ pub fn close(fd: c_int) -> c_int {
...
@@ -23,11 +26,11 @@ pub fn close(fd: c_int) -> c_int {
}
}
pub
fn
dup
(
fd
:
c_int
)
->
c_int
{
pub
fn
dup
(
fd
:
c_int
)
->
c_int
{
syscall
::
dup
(
fd
as
usize
,
&
[])
.unwrap_or
(
-
1
)
as
c_int
syscall
::
dup
(
fd
as
usize
,
&
[])
.unwrap_or
(
0
-
1
)
as
c_int
}
}
pub
fn
dup2
(
fd1
:
c_int
,
fd2
:
c_int
)
->
c_int
{
pub
fn
dup2
(
fd1
:
c_int
,
fd2
:
c_int
)
->
c_int
{
syscall
::
dup2
(
fd1
as
usize
,
fd2
as
usize
,
&
[])
.unwrap_or
(
-
1
)
as
c_int
syscall
::
dup2
(
fd1
as
usize
,
fd2
as
usize
,
&
[])
.unwrap_or
(
0
-
1
)
as
c_int
}
}
pub
fn
exit
(
status
:
c_int
)
->
!
{
pub
fn
exit
(
status
:
c_int
)
->
!
{
...
@@ -36,65 +39,71 @@ pub fn exit(status: c_int) -> ! {
...
@@ -36,65 +39,71 @@ pub fn exit(status: c_int) -> ! {
}
}
pub
fn
fchown
(
fd
:
c_int
,
owner
:
uid_t
,
group
:
gid_t
)
->
c_int
{
pub
fn
fchown
(
fd
:
c_int
,
owner
:
uid_t
,
group
:
gid_t
)
->
c_int
{
syscall
::
fchown
(
owner
as
u
size
,
group
as
u
size
)
.unwrap_or
(
-
1
)
as
c_int
syscall
::
fchown
(
fd
as
usize
,
owner
as
u
32
,
group
as
u
32
)
.unwrap_or
(
0
-
1
)
as
c_int
}
}
pub
fn
fchdir
(
fd
:
c_int
)
->
c_int
{
pub
fn
fchdir
(
fd
:
c_int
)
->
c_int
{
let
result
=
fpath
(
fd
as
usize
,
&
[]);
let
path
:
&
mut
[
u8
]
=
&
mut
[
0
;
4096
];
let
result
=
syscall
::
fpath
(
fd
as
usize
,
path
);
if
result
.is_ok
()
{
if
result
.is_ok
()
{
syscall
::
chdir
(
path
)
.unwrap_or
(
-
1
)
as
c_int
syscall
::
chdir
(
path
)
.unwrap_or
(
0
-
1
)
as
c_int
}
else
{
}
else
{
-
1
-
1
}
}
}
}
pub
fn
fsync
(
fd
:
c_int
)
->
c_int
{
pub
fn
fsync
(
fd
:
c_int
)
->
c_int
{
syscall
::
fsync
(
fd
as
usize
)
.unwrap_or
(
-
1
)
as
c_int
syscall
::
fsync
(
fd
as
usize
)
.unwrap_or
(
0
-
1
)
as
c_int
}
}
pub
fn
ftruncate
(
fd
:
c_int
,
len
:
off_t
)
->
c_int
{
pub
fn
ftruncate
(
fd
:
c_int
,
len
:
off_t
)
->
c_int
{
syscall
::
ftruncate
(
fd
as
usize
,
len
as
usize
)
.unwrap_or
(
-
1
)
as
c_int
syscall
::
ftruncate
(
fd
as
usize
,
len
as
usize
)
.unwrap_or
(
0
-
1
)
as
c_int
}
}
pub
fn
getcwd
(
buf
:
*
mut
c_char
,
size
:
size_t
)
->
c_int
{
pub
fn
getcwd
(
buf
:
*
mut
c_char
,
size
:
size_t
)
->
*
mut
c_char
{
// XXX: do something with size maybe
// XXX: do something with size maybe
let
rbuf
=
unsafe
{
c_str
(
buf
)
}
;
let
rbuf
:
&
mut
[
u8
]
=
&
mut
[
0
;
4096
]
;
syscall
::
getcwd
(
rbuf
);
syscall
::
getcwd
(
rbuf
);
unsafe
{
&*
(
rbuf
as
*
mut
[
c_char
])
}
unsafe
{
let
buf
=
*
rbuf
.as_ptr
()
as
*
mut
c_char
;
}
buf
}
}
pub
fn
getegid
()
->
gid_t
{
pub
fn
getegid
()
->
gid_t
{
syscall
::
getegid
()
.unwrap
_or
(
-
1
)
as
gid_t
syscall
::
getegid
()
.unwrap
(
)
as
gid_t
}
}
pub
fn
geteuid
()
->
uid_t
{
pub
fn
geteuid
()
->
uid_t
{
syscall
::
geteuid
()
.unwrap
_or
(
-
1
)
as
uid_t
syscall
::
geteuid
()
.unwrap
(
)
as
uid_t
}
}
pub
fn
getgid
()
->
gid_t
{
pub
fn
getgid
()
->
gid_t
{
syscall
::
getgid
()
.unwrap
_or
(
-
1
)
as
gid_t
syscall
::
getgid
()
.unwrap
(
)
as
gid_t
}
}
pub
fn
getpgid
(
pid
:
pid_t
)
->
pid_t
{
pub
fn
getpgid
(
pid
:
pid_t
)
->
pid_t
{
syscall
::
getpgid
(
pid
as
usize
)
.unwrap
_or
(
-
1
)
as
pid_t
syscall
::
getpgid
(
pid
as
usize
)
.unwrap
(
)
as
pid_t
}
}
pub
fn
getpid
()
->
pid_t
{
pub
fn
getpid
()
->
pid_t
{
syscall
::
getpid
()
.unwrap
_or
(
-
1
)
as
pid_t
syscall
::
getpid
()
.unwrap
(
)
as
pid_t
}
}
pub
fn
getppid
()
->
pid_t
{
pub
fn
getppid
()
->
pid_t
{
syscall
::
getppid
()
.unwrap
_or
(
-
1
)
as
pid_t
syscall
::
getppid
()
.unwrap
(
)
as
pid_t
}
}
pub
fn
getuid
()
->
uid_t
{
pub
fn
getuid
()
->
uid_t
{
syscall
::
getuid
()
.unwrap
_or
(
-
1
)
as
pid_t
syscall
::
getuid
()
.unwrap
(
)
as
pid_t
}
}
pub
fn
link
(
path1
:
*
const
c_char
,
path2
:
*
const
c_char
)
->
c_int
{
pub
fn
link
(
path1
:
*
const
c_char
,
path2
:
*
const
c_char
)
->
c_int
{
let
path1
=
unsafe
{
c_str
(
path1
)
};
let
path1
=
unsafe
{
c_str
(
path1
)
};
let
path2
=
unsafe
{
c_str
(
path2
)
};
let
path2
=
unsafe
{
c_str
(
path2
)
};
syscall
::
link
(
path1
,
path2
)
.unwrap_or
(
-
1
)
as
c_int
unsafe
{
syscall
::
link
(
path1
.as_ptr
(),
path2
.as_ptr
())
.unwrap_or
(
0
-
1
)
as
c_int
}
}
}
pub
fn
open
(
path
:
*
const
c_char
,
oflag
:
c_int
,
mode
:
mode_t
)
->
c_int
{
pub
fn
open
(
path
:
*
const
c_char
,
oflag
:
c_int
,
mode
:
mode_t
)
->
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