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
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
the ssd
redoxfs
Commits
81d2aa7b
Commit
81d2aa7b
authored
1 year ago
by
the ssd
Browse files
Options
Downloads
Patches
Plain Diff
added other function
parent
b0f6cf9c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fuzz/fuzz_targets/fuzz_target_1.rs
+62
-20
62 additions, 20 deletions
fuzz/fuzz_targets/fuzz_target_1.rs
with
62 additions
and
20 deletions
fuzz/fuzz_targets/fuzz_target_1.rs
+
62
−
20
View file @
81d2aa7b
...
...
@@ -18,7 +18,7 @@ enum FilesystemAction {
path
:
String
,
contents
:
String
,
},
/*
WriteFile {
WriteFile
{
index
:
u32
,
contents
:
String
,
},
...
...
@@ -27,7 +27,7 @@ enum FilesystemAction {
},
DeleteFile
{
index
:
u32
},
*/
},
//read/delete/rename file that doesn't exist
...
...
@@ -43,7 +43,19 @@ impl FilesystemAction {
match
self
{
FilesystemAction
::
CreateFile
{
path
,
contents
}
=>
{
if
!
path
.is_ascii
()
||
path
.contains
(|
ch
:
char
|
!
ch
.is_alphanumeric
()
)
{
// || path.contains(&['\0', '\n', '\t'])
return
Ok
(
None
);
}
if
contents
.contains
(
'\0'
)
{
return
Ok
(
None
);
}
let
path
=
Path
::
new
(
path
);
if
path
.file_name
()
.is_none
()
{
return
Ok
(
None
);
}
paths
.push
(
path
);
match
helper
::
create_inner
(
path
.as_ref
(),
Node
::
MODE_FILE
,
&
metadata
,
tx
)
{
...
...
@@ -66,18 +78,30 @@ impl FilesystemAction {
};
},
/*
FilesystemAction::WriteFile { index, contents } => {
FilesystemAction
::
WriteFile
{
index
,
contents
}
=>
{
if
paths
.len
()
==
0
{
return
Ok
(
None
);
}
if
contents
.contains
(
'\0'
)
{
return
Ok
(
None
);
}
let
path
=
paths
[
*
index
as
usize
%
paths
.len
()];
let name = path.file_name().ok_or(syscall::Error::new(-1))?.to_str().unwrap();
let node = tx.find_node(TreePtr::root(), name)?;
let data = contents.as_bytes();
let
name
=
match
path
.file_name
()
{
Some
(
s
)
=>
s
,
None
=>
panic!
(
"Path is wrong"
),
}
.to_str
()
.unwrap
();
let
mut
children
=
vec!
[];
tx
.child_nodes
(
TreePtr
::
root
(),
&
mut
children
)
?
;
let
child
=
children
.into_iter
()
.find
(|
x
|
x
.name
()
.unwrap
()
==
name
)
.unwrap
();
let
data
=
contents
.as_bytes
();
let
count
=
tx
.write_node
(
node
.
ptr(),
child
.
node
_
ptr
(),
0
,
&
data
,
metadata
.mtime
,
...
...
@@ -87,32 +111,50 @@ impl FilesystemAction {
if
count
!=
data
.len
()
{
panic!
(
"file write count {} != {}"
,
count
,
data
.len
());
}
},
FilesystemAction::DeleteFile { index } => {
/*
FilesystemAction::DeleteFile { index } => {
if paths.len() == 0 {
return Ok(None);
}
let path = paths[*index as usize % paths.len()];
let name = path.file_name().ok_or(syscall::Error::new(-1))?.to_str().unwrap();
let node = tx.find_node(TreePtr::root(), name)?;
tx.remove_node(node.ptr(), name, Node::MODE_FILE)?;
}
let name = match path.file_name() {
Some(s) => s,
None => panic!("Path is wrong"),
}.to_str().unwrap();
let mut children = vec![];
tx.child_nodes(TreePtr::root(), &mut children)?;
let child = children.into_iter().find(| x | x.name().unwrap() == name).unwrap();
tx.remove_node(child.node_ptr(), child.name().unwrap(), Node::MODE_FILE)?;
paths.remove(*index as usize % paths.len());
},*/
FilesystemAction
::
ReadFile
{
index
}
=>
{
if
paths
.len
()
==
0
{
return
Ok
(
None
);
}
let
path
=
paths
[
*
index
as
usize
%
paths
.len
()];
let name = path.file_name().ok_or(syscall::Error::new(-1))?.to_str().unwrap();
let node = tx.find_node(TreePtr::root(), name)?;
let
name
=
match
path
.file_name
()
{
Some
(
s
)
=>
s
,
None
=>
panic!
(
"Path is wrong"
),
}
.to_str
()
.unwrap
();
let
mut
children
=
vec!
[];
tx
.child_nodes
(
TreePtr
::
root
(),
&
mut
children
)
?
;
let
child
=
children
.into_iter
()
.find
(|
x
|
x
.name
()
.unwrap
()
==
name
)
.unwrap
();
let
mut
buffer
:
[
u8
;
1024
]
=
[
0
;
1024
];
tx.read_node(node
.
ptr(), 0, &mut buffer, 0, 0)?;
tx
.read_node
(
child
.
node
_
ptr
(),
0
,
&
mut
buffer
,
0
,
0
)
?
;
let string = match String::from_utf8(buffer.to_vec()) {
/*
let string = match String::from_utf8(buffer.to_vec()) {
Ok(s) => s,
Err(
_
) =>
{ return Ok(Some(io::Error::from(ErrorKind::Other))) }
,
};
Err(
e
) =>
panic!("Contents are wrong {e:?}")
,
};
*/
// TODO: Validate
},
*/
},
_
=>
()
}
...
...
@@ -121,7 +163,7 @@ impl FilesystemAction {
let end_block = tx.header.size() / BLOCK_SIZE;
tx.header.size = (end_block * BLOCK_SIZE).into();
tx.header_changed = true;*/
tx
.sync
(
fals
e
)
?
;
tx
.sync
(
tru
e
)
?
;
Ok
(
None
)
})
.map_err
(|
err
|
io
::
Error
::
from_raw_os_error
(
err
.errno
))
?
;
...
...
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