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
ab3ececc
Commit
ab3ececc
authored
1 year ago
by
Jeremy Soller
Browse files
Options
Downloads
Plain Diff
Merge branch 'scheme-fmt' into 'master'
Scheme fmt See merge request
redox-os/relibc!451
parents
83e4095e
7eefdaf4
No related branches found
No related tags found
1 merge request
!451
Scheme fmt
Pipeline
#14087
passed
1 year ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cargo.lock
+9
-2
9 additions, 2 deletions
Cargo.lock
Cargo.toml
+8
-1
8 additions, 1 deletion
Cargo.toml
src/platform/redox/path.rs
+3
-67
3 additions, 67 deletions
src/platform/redox/path.rs
with
20 additions
and
70 deletions
Cargo.lock
+
9
−
2
View file @
ab3ececc
...
...
@@ -10,9 +10,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "2.4.
1
"
version = "2.4.
2
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07
"
checksum = "
ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf
"
[[package]]
name = "cbitset"
...
...
@@ -198,6 +198,12 @@ dependencies = [
"redox_syscall",
]
[[package]]
name = "redox-path"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f45c7275fe1467ea17542c01766ae9872fa98aa7fe06ba5ea6595f7a9f0699c6"
[[package]]
name = "redox_syscall"
version = "0.4.1"
...
...
@@ -224,6 +230,7 @@ dependencies = [
"rand_jitter",
"rand_xorshift",
"redox-exec",
"redox-path",
"redox_syscall",
"sc",
"unicode-width",
...
...
This diff is collapsed.
Click to expand it.
Cargo.toml
+
8
−
1
View file @
ab3ececc
...
...
@@ -9,7 +9,13 @@ name = "relibc"
crate-type
=
[
"staticlib"
]
[workspace]
members
=
[
"src/crt0"
,
"src/crti"
,
"src/crtn"
,
"src/ld_so"
,
"src/platform/redox/redox-exec"
]
members
=
[
"src/crt0"
,
"src/crti"
,
"src/crtn"
,
"src/ld_so"
,
"src/platform/redox/redox-exec"
,
]
exclude
=
[
"tests"
,
"dlmalloc-rs"
]
[build-dependencies]
...
...
@@ -47,6 +53,7 @@ sc = "0.2.3"
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall
=
"0.4"
redox-exec
=
{
path
=
"src/platform/redox/redox-exec"
}
redox-path
=
"0.1"
[features]
default
=
[
"check_against_libc_crate"
]
...
...
This diff is collapsed.
Click to expand it.
src/platform/redox/path.rs
+
3
−
67
View file @
ab3ececc
use
syscall
::{
data
::
Stat
,
error
::
*
,
flag
::
*
};
use
alloc
::{
borrow
::
ToOwned
,
boxed
::
Box
,
string
::
String
,
vec
::
Vec
};
use
syscall
::{
data
::
Stat
,
error
::
*
,
flag
::
*
};
use
super
::{
libcscheme
,
FdGuard
};
use
crate
::
sync
::
Mutex
;
pub
use
redox_path
::
canonicalize_using_cwd
;
// TODO: Define in syscall
const
PATH_MAX
:
usize
=
4096
;
/// Make a relative path absolute.
///
/// Given a cwd of "scheme:/path", this his function will turn "foo" into "scheme:/path/foo".
/// "/foo" will turn into "scheme:/foo". "bar:/foo" will be used directly, as it is already
/// absolute
pub
fn
canonicalize_using_cwd
<
'a
>
(
cwd_opt
:
Option
<&
str
>
,
path
:
&
'a
str
)
->
Option
<
String
>
{
let
mut
canon
=
if
path
.find
(
':'
)
.is_none
()
{
let
cwd
=
cwd_opt
?
;
let
path_start
=
cwd
.find
(
':'
)
?
+
1
;
let
mut
canon
=
if
!
path
.starts_with
(
'/'
)
{
let
mut
c
=
cwd
.to_owned
();
if
!
c
.ends_with
(
'/'
)
{
c
.push
(
'/'
);
}
c
}
else
{
cwd
[
..
path_start
]
.to_owned
()
};
canon
.push_str
(
&
path
);
canon
}
else
{
path
.to_owned
()
};
// NOTE: assumes the scheme does not include anything like "../" or "./"
let
mut
result
=
{
let
parts
=
canon
.split
(
'/'
)
.rev
()
.scan
(
0
,
|
nskip
,
part
|
{
if
part
==
"."
{
Some
(
None
)
}
else
if
part
==
".."
{
*
nskip
+=
1
;
Some
(
None
)
}
else
if
*
nskip
>
0
{
*
nskip
-=
1
;
Some
(
None
)
}
else
{
Some
(
Some
(
part
))
}
})
.filter_map
(|
x
|
x
)
.filter
(|
x
|
!
x
.is_empty
())
.collect
::
<
Vec
<
_
>>
();
parts
.iter
()
.rev
()
.fold
(
String
::
new
(),
|
mut
string
,
&
part
|
{
string
.push_str
(
part
);
string
.push
(
'/'
);
string
})
};
result
.pop
();
// remove extra '/'
// replace with the root of the scheme if it's empty
Some
(
if
result
.is_empty
()
{
let
pos
=
canon
.find
(
':'
)
.map_or
(
canon
.len
(),
|
p
|
p
+
1
);
canon
.truncate
(
pos
);
canon
}
else
{
result
})
}
// XXX: chdir is not marked thread-safe (MT-safe) by POSIX. But on Linux it is simply run as a
// syscall and is therefore atomic, which is presumably why Rust's libstd doesn't synchronize
// access to this.
...
...
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