Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b43f58bc
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b43f58bc
编写于
7月 18, 2017
作者:
M
Mark Simulacrum
提交者:
GitHub
7月 18, 2017
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #43304 - ids1024:path2, r=aturon
redox: handle multiple paths in PATH
上级
f568249c
6f80cd7b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
21 deletion
+28
-21
src/libstd/sys/redox/os.rs
src/libstd/sys/redox/os.rs
+3
-3
src/libstd/sys/redox/process.rs
src/libstd/sys/redox/process.rs
+22
-15
src/libstd/sys/redox/syscall/call.rs
src/libstd/sys/redox/syscall/call.rs
+3
-3
未找到文件。
src/libstd/sys/redox/os.rs
浏览文件 @
b43f58bc
...
@@ -73,10 +73,10 @@ pub fn split_paths(unparsed: &OsStr) -> SplitPaths {
...
@@ -73,10 +73,10 @@ pub fn split_paths(unparsed: &OsStr) -> SplitPaths {
fn
bytes_to_path
(
b
:
&
[
u8
])
->
PathBuf
{
fn
bytes_to_path
(
b
:
&
[
u8
])
->
PathBuf
{
PathBuf
::
from
(
<
OsStr
as
OsStrExt
>
::
from_bytes
(
b
))
PathBuf
::
from
(
<
OsStr
as
OsStrExt
>
::
from_bytes
(
b
))
}
}
fn
is_
colon
(
b
:
&
u8
)
->
bool
{
*
b
==
b
':
'
}
fn
is_
semicolon
(
b
:
&
u8
)
->
bool
{
*
b
==
b
';
'
}
let
unparsed
=
unparsed
.as_bytes
();
let
unparsed
=
unparsed
.as_bytes
();
SplitPaths
{
SplitPaths
{
iter
:
unparsed
.split
(
is_colon
as
fn
(
&
u8
)
->
bool
)
iter
:
unparsed
.split
(
is_
semi
colon
as
fn
(
&
u8
)
->
bool
)
.map
(
bytes_to_path
as
fn
(
&
[
u8
])
->
PathBuf
)
.map
(
bytes_to_path
as
fn
(
&
[
u8
])
->
PathBuf
)
}
}
}
}
...
@@ -94,7 +94,7 @@ pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
...
@@ -94,7 +94,7 @@ pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
where
I
:
Iterator
<
Item
=
T
>
,
T
:
AsRef
<
OsStr
>
where
I
:
Iterator
<
Item
=
T
>
,
T
:
AsRef
<
OsStr
>
{
{
let
mut
joined
=
Vec
::
new
();
let
mut
joined
=
Vec
::
new
();
let
sep
=
b
'
:
'
;
let
sep
=
b
'
;
'
;
for
(
i
,
path
)
in
paths
.enumerate
()
{
for
(
i
,
path
)
in
paths
.enumerate
()
{
let
path
=
path
.as_ref
()
.as_bytes
();
let
path
=
path
.as_ref
()
.as_bytes
();
...
...
src/libstd/sys/redox/process.rs
浏览文件 @
b43f58bc
...
@@ -9,11 +9,12 @@
...
@@ -9,11 +9,12 @@
// except according to those terms.
// except according to those terms.
use
collections
::
hash_map
::
HashMap
;
use
collections
::
hash_map
::
HashMap
;
use
env
;
use
env
::{
self
,
split_paths
}
;
use
ffi
::
OsStr
;
use
ffi
::
OsStr
;
use
os
::
unix
::
ffi
::
OsStrExt
;
use
fmt
;
use
fmt
;
use
io
::{
self
,
Error
,
ErrorKind
};
use
io
::{
self
,
Error
,
ErrorKind
};
use
path
::
Path
;
use
path
::
{
Path
,
PathBuf
}
;
use
sys
::
fd
::
FileDesc
;
use
sys
::
fd
::
FileDesc
;
use
sys
::
fs
::{
File
,
OpenOptions
};
use
sys
::
fs
::{
File
,
OpenOptions
};
use
sys
::
pipe
::{
self
,
AnonPipe
};
use
sys
::
pipe
::{
self
,
AnonPipe
};
...
@@ -313,23 +314,29 @@ unsafe fn do_exec(&mut self, stdio: ChildPipes) -> io::Error {
...
@@ -313,23 +314,29 @@ unsafe fn do_exec(&mut self, stdio: ChildPipes) -> io::Error {
}
}
let
program
=
if
self
.program
.contains
(
':'
)
||
self
.program
.contains
(
'/'
)
{
let
program
=
if
self
.program
.contains
(
':'
)
||
self
.program
.contains
(
'/'
)
{
self
.program
.to_owned
()
Some
(
PathBuf
::
from
(
&
self
.program
))
}
else
{
}
else
if
let
Ok
(
path_env
)
=
::
env
::
var
(
"PATH"
)
{
let
mut
path_env
=
::
env
::
var
(
"PATH"
)
.unwrap_or
(
"."
.to_string
());
let
mut
program
=
None
;
for
mut
path
in
split_paths
(
&
path_env
)
{
if
!
path_env
.ends_with
(
'/'
)
{
path
.push
(
&
self
.program
);
path_env
.push
(
'/'
);
if
path
.exists
()
{
program
=
Some
(
path
);
break
;
}
}
}
program
path_env
.push_str
(
&
self
.program
);
}
else
{
None
path_env
};
};
if
let
Err
(
err
)
=
syscall
::
execve
(
&
program
,
&
args
)
{
if
let
Some
(
program
)
=
program
{
io
::
Error
::
from_raw_os_error
(
err
.errno
as
i32
)
if
let
Err
(
err
)
=
syscall
::
execve
(
program
.as_os_str
()
.as_bytes
(),
&
args
)
{
io
::
Error
::
from_raw_os_error
(
err
.errno
as
i32
)
}
else
{
panic!
(
"return from exec without err"
);
}
}
else
{
}
else
{
panic!
(
"return from exec without err"
);
io
::
Error
::
new
(
io
::
ErrorKind
::
NotFound
,
""
)
}
}
}
}
...
...
src/libstd/sys/redox/syscall/call.rs
浏览文件 @
b43f58bc
...
@@ -77,9 +77,9 @@ pub fn dup2(fd: usize, newfd: usize, buf: &[u8]) -> Result<usize> {
...
@@ -77,9 +77,9 @@ pub fn dup2(fd: usize, newfd: usize, buf: &[u8]) -> Result<usize> {
}
}
/// Replace the current process with a new executable
/// Replace the current process with a new executable
pub
fn
execve
(
path
:
&
str
,
args
:
&
[[
usize
;
2
]])
->
Result
<
usize
>
{
pub
fn
execve
<
T
:
AsRef
<
[
u8
]
>>
(
path
:
T
,
args
:
&
[[
usize
;
2
]])
->
Result
<
usize
>
{
unsafe
{
syscall4
(
SYS_EXECVE
,
path
.as_
ptr
()
as
usize
,
path
.len
()
,
unsafe
{
syscall4
(
SYS_EXECVE
,
path
.as_
ref
()
.as_ptr
()
as
usize
,
args
.as_ptr
()
as
usize
,
args
.len
())
}
path
.as_ref
()
.len
(),
args
.as_ptr
()
as
usize
,
args
.len
())
}
}
}
/// Exit the current process
/// Exit the current process
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录