Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
redoxfs
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
Anand Sundararaj
redoxfs
Commits
7a4a41a3
Unverified
Commit
7a4a41a3
authored
7 years ago
by
Ian Douglas Scott
Browse files
Options
Downloads
Patches
Plain Diff
Work in progress symlink implementation
parent
7470cc78
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mount/redox/scheme.rs
+30
-4
30 additions, 4 deletions
mount/redox/scheme.rs
src/node.rs
+5
-0
5 additions, 0 deletions
src/node.rs
with
35 additions
and
4 deletions
mount/redox/scheme.rs
+
30
−
4
View file @
7a4a41a3
...
...
@@ -8,8 +8,8 @@ use std::str;
use
std
::
sync
::
atomic
::{
AtomicUsize
,
Ordering
};
use
syscall
::
data
::{
Stat
,
StatVfs
};
use
syscall
::
error
::{
Error
,
Result
,
EACCES
,
EEXIST
,
EISDIR
,
ENOTDIR
,
EPERM
,
ENOENT
,
EBADF
};
use
syscall
::
flag
::{
O_APPEND
,
O_CREAT
,
O_DIRECTORY
,
O_STAT
,
O_EXCL
,
O_TRUNC
,
O_ACCMODE
,
O_RDONLY
,
O_WRONLY
,
O_RDWR
,
MODE_PERM
};
use
syscall
::
error
::{
Error
,
Result
,
EACCES
,
EEXIST
,
EISDIR
,
ENOTDIR
,
EPERM
,
ENOENT
,
EBADF
,
ELOOP
};
use
syscall
::
flag
::{
O_APPEND
,
O_CREAT
,
O_DIRECTORY
,
O_STAT
,
O_EXCL
,
O_TRUNC
,
O_ACCMODE
,
O_RDONLY
,
O_WRONLY
,
O_RDWR
,
MODE_PERM
,
O_SYMLINK
};
use
syscall
::
scheme
::
Scheme
;
pub
struct
FileScheme
{
...
...
@@ -67,7 +67,7 @@ impl Scheme for FileScheme {
fn
open
(
&
self
,
url
:
&
[
u8
],
flags
:
usize
,
uid
:
u32
,
gid
:
u32
)
->
Result
<
usize
>
{
let
path
=
str
::
from_utf8
(
url
)
.unwrap_or
(
""
)
.trim_matches
(
'/'
);
//
println!("Open '{}' {:X}", path, flags);
println!
(
"Open '{}' {:X}"
,
path
,
flags
);
let
mut
fs
=
self
.fs
.borrow_mut
();
...
...
@@ -108,6 +108,25 @@ impl Scheme for FileScheme {
// println!("dir not opened with O_RDONLY");
return
Err
(
Error
::
new
(
EACCES
));
}
}
else
if
node
.1
.is_symlink
()
&&
flags
&
O_STAT
!=
O_STAT
&&
flags
&
O_SYMLINK
!=
O_SYMLINK
{
// TODO: Find way to support symlink to another scheme
let
mut
node
=
node
;
for
_
in
1
..
10
{
// XXX What should the limit be?
let
mut
buf
=
[
0
;
4096
];
let
count
=
fs
.read_node
(
node
.0
,
0
,
&
mut
buf
)
?
;
// XXX Relative paths
let
path
=
str
::
from_utf8
(
&
buf
[
0
..
count
])
.unwrap_or
(
""
)
.trim_matches
(
'/'
);
if
let
Some
(
next_node
)
=
path_nodes
(
&
mut
fs
,
path
,
uid
,
gid
,
&
mut
nodes
)
?
{
if
!
next_node
.1
.is_symlink
()
{
drop
(
fs
);
return
self
.open
(
&
buf
[
0
..
count
],
flags
,
uid
,
gid
);
}
node
=
next_node
;
}
else
{
return
Err
(
Error
::
new
(
ENOENT
));
}
}
return
Err
(
Error
::
new
(
ELOOP
));
}
else
{
if
flags
&
O_DIRECTORY
==
O_DIRECTORY
{
// println!("{:X} & {:X}: ENOTDIR {}", flags, O_DIRECTORY, path);
...
...
@@ -156,8 +175,15 @@ impl Scheme for FileScheme {
}
let
dir
=
flags
&
O_DIRECTORY
==
O_DIRECTORY
;
let
mode_type
=
if
dir
{
Node
::
MODE_DIR
}
else
if
flags
&
O_SYMLINK
==
O_SYMLINK
{
Node
::
MODE_SYMLINK
}
else
{
Node
::
MODE_FILE
};
let
mut
node
=
fs
.create_node
(
if
dir
{
Node
::
MODE_DIR
}
else
{
Node
::
MODE_FILE
}
|
(
flags
as
u16
&
Node
::
MODE_PERM
),
&
last_part
,
parent
.0
)
?
;
let
mut
node
=
fs
.create_node
(
mode_type
|
(
flags
as
u16
&
Node
::
MODE_PERM
),
&
last_part
,
parent
.0
)
?
;
node
.1
.uid
=
uid
;
node
.1
.gid
=
gid
;
fs
.write_at
(
node
.0
,
&
node
.1
)
?
;
...
...
This diff is collapsed.
Click to expand it.
src/node.rs
+
5
−
0
View file @
7a4a41a3
...
...
@@ -18,6 +18,7 @@ impl Node {
pub
const
MODE_TYPE
:
u16
=
0xF000
;
pub
const
MODE_FILE
:
u16
=
0x8000
;
pub
const
MODE_DIR
:
u16
=
0x4000
;
pub
const
MODE_SYMLINK
:
u16
=
0xA000
;
pub
const
MODE_PERM
:
u16
=
0x0FFF
;
pub
const
MODE_EXEC
:
u16
=
0o1
;
...
...
@@ -74,6 +75,10 @@ impl Node {
self
.mode
&
Node
::
MODE_TYPE
==
Node
::
MODE_FILE
}
pub
fn
is_symlink
(
&
self
)
->
bool
{
self
.mode
&
Node
::
MODE_TYPE
==
Node
::
MODE_SYMLINK
}
pub
fn
permission
(
&
self
,
uid
:
u32
,
gid
:
u32
,
op
:
u16
)
->
bool
{
let
mut
perm
=
self
.mode
&
0o7
;
if
self
.uid
==
uid
{
...
...
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