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
James Matlik
redoxfs
Commits
6126bfee
Commit
6126bfee
authored
6 years ago
by
Liam Naddell
Browse files
Options
Downloads
Patches
Plain Diff
docs
parent
3ef85578
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
src/extent.rs
+1
-1
1 addition, 1 deletion
src/extent.rs
src/filesystem.rs
+2
-0
2 additions, 0 deletions
src/filesystem.rs
src/node.rs
+7
-0
7 additions, 0 deletions
src/node.rs
with
10 additions
and
1 deletion
src/extent.rs
+
1
−
1
View file @
6126bfee
...
...
@@ -21,7 +21,7 @@ impl Iterator<> for BlockIter {
}
}
/// A disk extent
/// A disk extent
, [wikipedia](https://en.wikipedia.org/wiki/Extent_(file_systems))
#[derive(Copy,
Clone,
Debug,
Default)]
#[repr(packed)]
pub
struct
Extent
{
...
...
This diff is collapsed.
Click to expand it.
src/filesystem.rs
+
2
−
0
View file @
6126bfee
...
...
@@ -43,6 +43,7 @@ impl<D: Disk> FileSystem<D> {
/// Create a file system on a disk, with reserved data at the beginning
/// Reserved data will be zero padded up to the nearest block
/// We need to pass ctime and ctime_nsec in order to initialize the unix timestamps
pub
fn
create_reserved
(
mut
disk
:
D
,
reserved
:
&
[
u8
],
ctime
:
u64
,
ctime_nsec
:
u32
)
->
Result
<
Self
>
{
let
size
=
disk
.size
()
?
;
let
block_offset
=
(
reserved
.len
()
as
u64
+
BLOCK_SIZE
-
1
)
/
BLOCK_SIZE
;
...
...
@@ -80,6 +81,7 @@ impl<D: Disk> FileSystem<D> {
}
}
/// Read at a certain spot in the disk, returning data into buffer
pub
fn
read_at
(
&
mut
self
,
block
:
u64
,
buffer
:
&
mut
[
u8
])
->
Result
<
usize
>
{
self
.disk
.read_at
(
self
.block
+
block
,
buffer
)
}
...
...
This diff is collapsed.
Click to expand it.
src/node.rs
+
7
−
0
View file @
6126bfee
...
...
@@ -110,19 +110,26 @@ impl Node {
self
.mode
&
Node
::
MODE_TYPE
==
Node
::
MODE_SYMLINK
}
/// Tests if UID is the owner of that file, only true when uid=0 or when the UID stored in metadata is equal to the UID you supply
pub
fn
owner
(
&
self
,
uid
:
u32
)
->
bool
{
uid
==
0
||
self
.uid
==
uid
}
/// Tests if the current user has enough permissions to view the file, op is the operation,
/// like read and write, these modes are MODE_EXEC, MODE_READ, and MODE_WRITE
pub
fn
permission
(
&
self
,
uid
:
u32
,
gid
:
u32
,
op
:
u16
)
->
bool
{
let
mut
perm
=
self
.mode
&
0o7
;
if
self
.uid
==
uid
{
// If self.mode is 101100110, >> 6 would be 000000101
// 0o7 is octal for 111, or, when expanded to 9 digits is 000000111
perm
|
=
(
self
.mode
>>
6
)
&
0o7
;
// Since we erased the GID and OTHER bits when >>6'ing, |= will keep those bits in place.
}
if
self
.gid
==
gid
||
gid
==
0
{
perm
|
=
(
self
.mode
>>
3
)
&
0o7
;
}
if
uid
==
0
{
//set the `other` bits to 111
perm
|
=
0o7
;
}
perm
&
op
==
op
...
...
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