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
7952e3ed
Commit
7952e3ed
authored
8 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Add null: and zero:
parent
aad20b0e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scheme/mod.rs
+10
-0
10 additions, 0 deletions
scheme/mod.rs
scheme/null.rs
+37
-0
37 additions, 0 deletions
scheme/null.rs
scheme/zero.rs
+42
-0
42 additions, 0 deletions
scheme/zero.rs
with
89 additions
and
0 deletions
scheme/mod.rs
+
10
−
0
View file @
7952e3ed
...
...
@@ -20,9 +20,11 @@ use self::event::EventScheme;
use
self
::
env
::
EnvScheme
;
use
self
::
initfs
::
InitFsScheme
;
use
self
::
irq
::{
IRQ_SCHEME_ID
,
IrqScheme
};
use
self
::
null
::
NullScheme
;
use
self
::
pipe
::{
PIPE_SCHEME_ID
,
PipeScheme
};
use
self
::
root
::{
ROOT_SCHEME_ID
,
RootScheme
};
use
self
::
sys
::
SysScheme
;
use
self
::
zero
::
ZeroScheme
;
/// Debug scheme
pub
mod
debug
;
...
...
@@ -39,6 +41,9 @@ pub mod initfs;
/// IRQ handling
pub
mod
irq
;
/// Null scheme
pub
mod
null
;
/// Anonymouse pipe
pub
mod
pipe
;
...
...
@@ -51,6 +56,9 @@ pub mod sys;
/// Userspace schemes
pub
mod
user
;
/// Zero scheme
pub
mod
zero
;
/// Limit on number of schemes
pub
const
SCHEME_MAX_SCHEMES
:
usize
=
65536
;
...
...
@@ -132,8 +140,10 @@ fn init_schemes() -> RwLock<SchemeList> {
list
.insert
(
Box
::
new
(
*
b"env"
),
Arc
::
new
(
Box
::
new
(
EnvScheme
::
new
())))
.expect
(
"failed to insert env scheme"
);
list
.insert
(
Box
::
new
(
*
b"initfs"
),
Arc
::
new
(
Box
::
new
(
InitFsScheme
::
new
())))
.expect
(
"failed to insert initfs scheme"
);
IRQ_SCHEME_ID
.store
(
list
.insert
(
Box
::
new
(
*
b"irq"
),
Arc
::
new
(
Box
::
new
(
IrqScheme
)))
.expect
(
"failed to insert irq scheme"
),
Ordering
::
SeqCst
);
list
.insert
(
Box
::
new
(
*
b"null"
),
Arc
::
new
(
Box
::
new
(
NullScheme
)))
.expect
(
"failed to insert null scheme"
);
PIPE_SCHEME_ID
.store
(
list
.insert
(
Box
::
new
(
*
b"pipe"
),
Arc
::
new
(
Box
::
new
(
PipeScheme
)))
.expect
(
"failed to insert pipe scheme"
),
Ordering
::
SeqCst
);
list
.insert
(
Box
::
new
(
*
b"sys"
),
Arc
::
new
(
Box
::
new
(
SysScheme
::
new
())))
.expect
(
"failed to insert sys scheme"
);
list
.insert
(
Box
::
new
(
*
b"zero"
),
Arc
::
new
(
Box
::
new
(
ZeroScheme
)))
.expect
(
"failed to insert zero scheme"
);
RwLock
::
new
(
list
)
}
...
...
This diff is collapsed.
Click to expand it.
scheme/null.rs
0 → 100644
+
37
−
0
View file @
7952e3ed
use
syscall
::
error
::
*
;
use
syscall
::
scheme
::
Scheme
;
pub
struct
NullScheme
;
impl
Scheme
for
NullScheme
{
fn
open
(
&
self
,
_path
:
&
[
u8
],
_flags
:
usize
,
_uid
:
u32
,
_gid
:
u32
)
->
Result
<
usize
>
{
Ok
(
0
)
}
fn
dup
(
&
self
,
_file
:
usize
,
_buf
:
&
[
u8
])
->
Result
<
usize
>
{
Ok
(
0
)
}
/// Read the file `number` into the `buffer`
///
/// Returns the number of bytes read
fn
read
(
&
self
,
_file
:
usize
,
_buf
:
&
mut
[
u8
])
->
Result
<
usize
>
{
Ok
(
0
)
}
/// Write the `buffer` to the `file`
///
/// Returns the number of bytes written
fn
write
(
&
self
,
_file
:
usize
,
buffer
:
&
[
u8
])
->
Result
<
usize
>
{
Ok
(
buffer
.len
())
}
fn
fsync
(
&
self
,
_file
:
usize
)
->
Result
<
usize
>
{
Ok
(
0
)
}
/// Close the file `number`
fn
close
(
&
self
,
_file
:
usize
)
->
Result
<
usize
>
{
Ok
(
0
)
}
}
This diff is collapsed.
Click to expand it.
scheme/zero.rs
0 → 100644
+
42
−
0
View file @
7952e3ed
use
syscall
::
error
::
*
;
use
syscall
::
scheme
::
Scheme
;
pub
struct
ZeroScheme
;
impl
Scheme
for
ZeroScheme
{
fn
open
(
&
self
,
_path
:
&
[
u8
],
_flags
:
usize
,
_uid
:
u32
,
_gid
:
u32
)
->
Result
<
usize
>
{
Ok
(
0
)
}
fn
dup
(
&
self
,
_file
:
usize
,
_buf
:
&
[
u8
])
->
Result
<
usize
>
{
Ok
(
0
)
}
/// Read the file `number` into the `buffer`
///
/// Returns the number of bytes read
fn
read
(
&
self
,
_file
:
usize
,
buf
:
&
mut
[
u8
])
->
Result
<
usize
>
{
let
mut
i
=
0
;
while
i
<
buf
.len
()
{
buf
[
i
]
=
0
;
i
+=
1
;
}
Ok
(
i
)
}
/// Write the `buffer` to the `file`
///
/// Returns the number of bytes written
fn
write
(
&
self
,
_file
:
usize
,
buffer
:
&
[
u8
])
->
Result
<
usize
>
{
Ok
(
buffer
.len
())
}
fn
fsync
(
&
self
,
_file
:
usize
)
->
Result
<
usize
>
{
Ok
(
0
)
}
/// Close the file `number`
fn
close
(
&
self
,
_file
:
usize
)
->
Result
<
usize
>
{
Ok
(
0
)
}
}
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