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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Uygar Sapmaz
redoxfs
Commits
e4ca510b
Commit
e4ca510b
authored
1 year ago
by
George Malandrakis
Committed by
Jeremy Soller
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Master - Name check & Duplicate code removed & Makefile modification
parent
e7cf569a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
src/dir.rs
+5
-9
5 additions, 9 deletions
src/dir.rs
src/lib.rs
+2
-0
2 additions, 0 deletions
src/lib.rs
src/transaction.rs
+25
-19
25 additions, 19 deletions
src/transaction.rs
with
33 additions
and
29 deletions
Makefile
+
1
−
1
View file @
e4ca510b
...
...
@@ -14,8 +14,8 @@ else
endif
image.bin
:
dd
if
=
/dev/zero
of
=
image.bin
bs
=
1048576
count
=
1024
cargo build
--release
--bin
redoxfs-mkfs
dd
if
=
/dev/zero
of
=
image.bin
bs
=
1048576
count
=
1024
target/release/redoxfs-mkfs image.bin
mount
:
image.bin FORCE
...
...
This diff is collapsed.
Click to expand it.
src/dir.rs
+
5
−
9
View file @
e4ca510b
use
alloc
::{
boxed
::
Box
,
vec
};
use
core
::{
mem
,
ops
,
slice
,
str
};
use
crate
::{
BlockLevel
,
BlockTrait
,
Node
,
TreePtr
,
RECORD_LEVEL
};
use
crate
::{
BlockLevel
,
BlockTrait
,
Node
,
TreePtr
,
RECORD_LEVEL
,
DIR_ENTRY_MAX_LENGTH
};
#[repr(packed)]
pub
struct
DirEntry
{
node_ptr
:
TreePtr
<
Node
>
,
name
:
[
u8
;
252
],
name
:
[
u8
;
DIR_ENTRY_MAX_LENGTH
],
}
impl
DirEntry
{
pub
fn
new
(
node_ptr
:
TreePtr
<
Node
>
,
name
:
&
str
)
->
Option
<
DirEntry
>
{
pub
fn
new
(
node_ptr
:
TreePtr
<
Node
>
,
name
:
&
str
)
->
DirEntry
{
let
mut
entry
=
DirEntry
{
node_ptr
,
..
Default
::
default
()
};
if
name
.len
()
>
entry
.name
.len
()
{
return
None
;
}
entry
.name
[
..
name
.len
()]
.copy_from_slice
(
name
.as_bytes
());
Some
(
entry
)
entry
}
pub
fn
node_ptr
(
&
self
)
->
TreePtr
<
Node
>
{
...
...
@@ -54,7 +50,7 @@ impl Default for DirEntry {
fn
default
()
->
Self
{
Self
{
node_ptr
:
TreePtr
::
default
(),
name
:
[
0
;
252
],
name
:
[
0
;
DIR_ENTRY_MAX_LENGTH
],
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
2
−
0
View file @
e4ca510b
...
...
@@ -14,6 +14,8 @@ pub const RECORD_LEVEL: usize = 5;
pub
const
RECORD_SIZE
:
u64
=
BLOCK_SIZE
<<
RECORD_LEVEL
;
pub
const
SIGNATURE
:
&
[
u8
;
8
]
=
b"RedoxFS
\0
"
;
pub
const
VERSION
:
u64
=
6
;
pub
const
DIR_ENTRY_MAX_LENGTH
:
usize
=
252
;
pub
static
IS_UMT
:
AtomicUsize
=
AtomicUsize
::
new
(
0
);
pub
use
self
::
allocator
::{
AllocEntry
,
AllocList
,
Allocator
,
ALLOC_LIST_ENTRIES
};
...
...
This diff is collapsed.
Click to expand it.
src/transaction.rs
+
25
−
19
View file @
e4ca510b
...
...
@@ -12,11 +12,7 @@ use syscall::error::{
Error
,
Result
,
EEXIST
,
EINVAL
,
EIO
,
EISDIR
,
ENOENT
,
ENOSPC
,
ENOTDIR
,
ENOTEMPTY
,
ERANGE
,
};
use
crate
::{
AllocEntry
,
AllocList
,
Allocator
,
BlockAddr
,
BlockData
,
BlockLevel
,
BlockPtr
,
BlockTrait
,
DirEntry
,
DirList
,
Disk
,
FileSystem
,
Header
,
Node
,
NodeLevel
,
RecordRaw
,
TreeData
,
TreePtr
,
ALLOC_LIST_ENTRIES
,
HEADER_RING
,
};
use
crate
::{
AllocEntry
,
AllocList
,
Allocator
,
BlockAddr
,
BlockData
,
BlockLevel
,
BlockPtr
,
BlockTrait
,
DirEntry
,
DirList
,
Disk
,
FileSystem
,
Header
,
Node
,
NodeLevel
,
RecordRaw
,
TreeData
,
TreePtr
,
ALLOC_LIST_ENTRIES
,
HEADER_RING
,
DIR_ENTRY_MAX_LENGTH
};
pub
struct
Transaction
<
'a
,
D
:
Disk
>
{
fs
:
&
'a
mut
FileSystem
<
D
>
,
...
...
@@ -569,12 +565,8 @@ impl<'a, D: Disk> Transaction<'a, D> {
ctime
:
u64
,
ctime_nsec
:
u32
,
)
->
Result
<
TreeData
<
Node
>>
{
if
name
.contains
(
':'
)
{
return
Err
(
Error
::
new
(
EINVAL
));
}
if
self
.find_node
(
parent_ptr
,
name
)
.is_ok
()
{
return
Err
(
Error
::
new
(
EEXIST
));
if
let
Err
(
err
)
=
self
.check_name
(
&
parent_ptr
,
&
name
){
return
Err
(
err
);
}
unsafe
{
...
...
@@ -605,13 +597,11 @@ impl<'a, D: Disk> Transaction<'a, D> {
name
:
&
str
,
node_ptr
:
TreePtr
<
Node
>
,
)
->
Result
<
()
>
{
if
name
.contains
(
':'
)
{
return
Err
(
Error
::
new
(
EINVAL
)
);
}
if
let
Err
(
err
)
=
self
.check_name
(
&
parent_ptr
,
&
name
)
{
return
Err
(
err
);
}
if
self
.find_node
(
parent_ptr
,
name
)
.is_ok
()
{
return
Err
(
Error
::
new
(
EEXIST
));
}
let
entry
=
DirEntry
::
new
(
node_ptr
,
name
);
let
mut
parent
=
self
.read_tree
(
parent_ptr
)
?
;
...
...
@@ -619,8 +609,6 @@ impl<'a, D: Disk> Transaction<'a, D> {
let
links
=
node
.data
()
.links
();
node
.data_mut
()
.set_links
(
links
+
1
);
let
entry
=
DirEntry
::
new
(
node_ptr
,
name
)
.ok_or
(
Error
::
new
(
EINVAL
))
?
;
let
record_level
=
parent
.data
()
.record_level
();
let
record_end
=
parent
.data
()
.size
()
/
record_level
.bytes
();
for
record_offset
in
0
..
record_end
{
...
...
@@ -795,6 +783,24 @@ impl<'a, D: Disk> Transaction<'a, D> {
Ok
(())
}
fn
check_name
(
&
mut
self
,
parent_ptr
:
&
TreePtr
<
Node
>
,
name
:
&
str
)
->
Result
<
()
>
{
if
name
.contains
(
':'
)
{
return
Err
(
Error
::
new
(
EINVAL
));
}
if
name
.len
()
>
DIR_ENTRY_MAX_LENGTH
{
return
Err
(
Error
::
new
(
EINVAL
));
}
if
self
.find_node
(
parent_ptr
.clone
(),
name
)
.is_ok
()
{
return
Err
(
Error
::
new
(
EEXIST
));
}
Ok
(())
}
fn
node_record_ptr
(
&
mut
self
,
node
:
&
TreeData
<
Node
>
,
...
...
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