Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kernel
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
kernel
Commits
0bd1cda1
Commit
0bd1cda1
authored
8 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup schemes list, remove lazy_static
parent
b9e721d4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib.rs
+1
-2
1 addition, 2 deletions
lib.rs
scheme/mod.rs
+17
-7
17 additions, 7 deletions
scheme/mod.rs
syscall/fs.rs
+3
-1
3 additions, 1 deletion
syscall/fs.rs
with
21 additions
and
10 deletions
lib.rs
+
1
−
2
View file @
0bd1cda1
...
...
@@ -67,6 +67,7 @@
#![feature(alloc)]
#![feature(collections)]
#![feature(const_fn)]
#![feature(drop_types_in_const)]
#![feature(question_mark)]
#![no_std]
...
...
@@ -88,8 +89,6 @@ extern crate collections;
#[macro_use]
extern
crate
bitflags
;
#[macro_use]
extern
crate
lazy_static
;
extern
crate
spin
;
/// Context management
...
...
This diff is collapsed.
Click to expand it.
scheme/mod.rs
+
17
−
7
View file @
0bd1cda1
...
...
@@ -11,7 +11,7 @@ use alloc::boxed::Box;
use
collections
::
BTreeMap
;
use
spin
::{
Mutex
,
RwLock
};
use
spin
::{
Once
,
Mutex
,
RwLock
,
RwLockReadGuard
,
RwLockWriteGuard
};
use
syscall
::
Result
;
...
...
@@ -20,13 +20,23 @@ use self::debug::DebugScheme;
/// Debug scheme
pub
mod
debug
;
pub
type
SchemeList
=
BTreeMap
<
Box
<
[
u8
]
>
,
Arc
<
Mutex
<
Box
<
Scheme
+
Send
>>>>
;
/// Schemes list
lazy_static!
{
pub
static
ref
SCHEMES
:
RwLock
<
BTreeMap
<
Box
<
[
u8
]
>
,
Arc
<
Mutex
<
Box
<
Scheme
+
Send
>>>>>
=
{
let
mut
map
:
BTreeMap
<
Box
<
[
u8
]
>
,
Arc
<
Mutex
<
Box
<
Scheme
+
Send
>>>>
=
BTreeMap
::
new
();
map
.insert
(
Box
::
new
(
*
b"debug"
),
Arc
::
new
(
Mutex
::
new
(
Box
::
new
(
DebugScheme
))));
RwLock
::
new
(
map
)
};
static
SCHEMES
:
Once
<
RwLock
<
SchemeList
>>
=
Once
::
new
();
fn
init_schemes
()
->
RwLock
<
SchemeList
>
{
let
mut
map
:
SchemeList
=
BTreeMap
::
new
();
map
.insert
(
Box
::
new
(
*
b"debug"
),
Arc
::
new
(
Mutex
::
new
(
Box
::
new
(
DebugScheme
))));
RwLock
::
new
(
map
)
}
pub
fn
schemes
()
->
RwLockReadGuard
<
'static
,
SchemeList
>
{
SCHEMES
.call_once
(
init_schemes
)
.read
()
}
pub
fn
schemes_mut
()
->
RwLockWriteGuard
<
'static
,
SchemeList
>
{
SCHEMES
.call_once
(
init_schemes
)
.write
()
}
/// A scheme trait, implemented by a scheme handler
...
...
This diff is collapsed.
Click to expand it.
syscall/fs.rs
+
3
−
1
View file @
0bd1cda1
//! Filesystem syscalls
use
scheme
;
use
super
::{
Error
,
Result
};
/// Read syscall
...
...
@@ -33,7 +35,7 @@ pub fn open(path: &[u8], flags: usize) -> Result<usize> {
let
file
=
{
if
let
Some
(
namespace
)
=
namespace_opt
{
let
schemes
=
::
scheme
::
SCHEMES
.read
();
let
schemes
=
scheme
::
schemes
();
if
let
Some
(
scheme_mutex
)
=
schemes
.get
(
namespace
)
{
scheme_mutex
.lock
()
.open
(
reference_opt
.unwrap_or
(
b""
),
flags
)
}
else
{
...
...
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