Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
redoxfs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
redox-os
redoxfs
Commits
a6af6a92
Commit
a6af6a92
authored
Jan 20, 2020
by
Jeremy Soller
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'add-atime' into 'master'
Add tracking of access times See merge request
!48
parents
3191d7d1
d2256b3e
Pipeline
#6852
failed with stages
in 3 minutes and 33 seconds
Changes
7
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
21 deletions
+55
-21
Cargo.lock
Cargo.lock
+1
-1
Cargo.toml
Cargo.toml
+1
-1
src/filesystem.rs
src/filesystem.rs
+16
-0
src/lib.rs
src/lib.rs
+3
-3
src/mount/fuse.rs
src/mount/fuse.rs
+13
-4
src/mount/redox/resource.rs
src/mount/redox/resource.rs
+8
-5
src/node.rs
src/node.rs
+13
-7
No files found.
Cargo.lock
View file @
a6af6a92
...
...
@@ -97,7 +97,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "redoxfs"
version = "0.
3.7
"
version = "0.
4.0
"
dependencies = [
"fuse 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
...
...
Cargo.toml
View file @
a6af6a92
...
...
@@ -2,7 +2,7 @@
name
=
"redoxfs"
description
=
"The Redox Filesystem"
repository
=
"https://gitlab.redox-os.org/redox-os/redoxfs"
version
=
"0.
3.7
"
version
=
"0.
4.0
"
license-file
=
"LICENSE"
readme
=
"README.md"
authors
=
[
"Jeremy Soller <jackpot51@gmail.com>"
]
...
...
src/filesystem.rs
View file @
a6af6a92
use
std
::
cmp
::
min
;
use
std
::
time
::{
SystemTime
,
UNIX_EPOCH
};
use
syscall
::
error
::{
Result
,
Error
,
EEXIST
,
EISDIR
,
EINVAL
,
ENOENT
,
ENOSPC
,
ENOTDIR
,
ENOTEMPTY
};
...
...
@@ -428,6 +429,7 @@ impl<D: Disk> FileSystem<D> {
}
pub
fn
read_node
(
&
mut
self
,
block
:
u64
,
offset
:
u64
,
buf
:
&
mut
[
u8
])
->
Result
<
usize
>
{
let
atime
=
SystemTime
::
now
()
.duration_since
(
UNIX_EPOCH
)
.unwrap
();
let
block_offset
=
offset
/
BLOCK_SIZE
;
let
mut
byte_offset
=
(
offset
%
BLOCK_SIZE
)
as
usize
;
...
...
@@ -483,6 +485,20 @@ impl<D: Disk> FileSystem<D> {
assert_eq!
(
block
,
extent
.block
+
(
extent
.length
+
BLOCK_SIZE
-
1
)
/
BLOCK_SIZE
);
}
if
i
>
0
{
let
atime_nsec
=
atime
.subsec_nanos
();
let
atime
=
atime
.as_secs
();
let
mut
node
=
self
.node
(
block
)
?
;
if
atime
>
node
.1
.atime
||
(
atime
==
node
.1
.atime
&&
atime_nsec
>
node
.1
.atime_nsec
)
{
let
is_old
=
atime
-
node
.1
.atime
>
3600
;
// Last read was more than a day ago
node
.1
.atime
=
atime
;
node
.1
.atime_nsec
=
atime_nsec
;
if
is_old
{
self
.write_at
(
node
.0
,
&
node
.1
)
?
;
}
}
}
Ok
(
i
)
}
...
...
src/lib.rs
View file @
a6af6a92
#![crate_name
=
"redoxfs"
]
#![crate_type
=
"lib"
]
#![crate_name
=
"redoxfs"
]
#![crate_type
=
"lib"
]
extern
crate
syscall
;
extern
crate
uuid
;
...
...
@@ -8,7 +8,7 @@ use std::sync::atomic::AtomicUsize;
pub
const
BLOCK_SIZE
:
u64
=
4096
;
pub
const
SIGNATURE
:
&
'static
[
u8
;
8
]
=
b
"RedoxFS
\0
"
;
pub
const
VERSION
:
u64
=
3
;
pub
const
VERSION
:
u64
=
4
;
pub
static
IS_UMT
:
AtomicUsize
=
AtomicUsize
::
new
(
0
);
pub
use
self
::
archive
::{
archive
,
archive_at
};
...
...
src/mount/fuse.rs
View file @
a6af6a92
...
...
@@ -117,7 +117,7 @@ impl<D: Disk> Filesystem for Fuse<D> {
fn
setattr
(
&
mut
self
,
_
req
:
&
Request
,
block
:
u64
,
mode
:
Option
<
u32
>
,
uid
:
Option
<
u32
>
,
gid
:
Option
<
u32
>
,
size
:
Option
<
u64
>
,
_
atime
:
Option
<
Timespec
>
,
mtime
:
Option
<
Timespec
>
,
_
fh
:
Option
<
u64
>
,
atime
:
Option
<
Timespec
>
,
mtime
:
Option
<
Timespec
>
,
_
fh
:
Option
<
u64
>
,
_
crtime
:
Option
<
Timespec
>
,
_
chgtime
:
Option
<
Timespec
>
,
_
bkuptime
:
Option
<
Timespec
>
,
_
flags
:
Option
<
u32
>
,
reply
:
ReplyAttr
)
{
if
let
Some
(
mode
)
=
mode
{
...
...
@@ -176,11 +176,20 @@ impl<D: Disk> Filesystem for Fuse<D> {
}
}
if
let
Some
(
mtime
)
=
mtime
{
let
need_update
=
atime
.is_some
()
||
mtime
.is_some
();
if
need_update
{
match
self
.fs
.node
(
block
)
{
Ok
(
mut
node
)
=>
{
node
.1
.mtime
=
mtime
.sec
as
u64
;
node
.1
.mtime_nsec
=
mtime
.nsec
as
u32
;
if
let
Some
(
atime
)
=
atime
{
node
.1
.atime
=
atime
.sec
as
u64
;
node
.1
.atime_nsec
=
atime
.nsec
as
u32
;
}
if
let
Some
(
mtime
)
=
mtime
{
node
.1
.mtime
=
mtime
.sec
as
u64
;
node
.1
.mtime_nsec
=
mtime
.nsec
as
u32
;
}
if
let
Err
(
err
)
=
self
.fs
.write_at
(
node
.0
,
&
node
.1
)
{
reply
.error
(
err
.errno
as
i32
);
return
;
...
...
src/mount/redox/resource.rs
View file @
a6af6a92
...
...
@@ -165,6 +165,8 @@ impl<D: Disk> Resource<D> for DirResource {
st_size
:
fs
.node_len
(
self
.block
)
?
,
st_mtime
:
node
.1
.mtime
,
st_mtime_nsec
:
node
.1
.mtime_nsec
,
st_atime
:
node
.1
.atime
,
st_atime_nsec
:
node
.1
.atime_nsec
,
st_ctime
:
node
.1
.ctime
,
st_ctime_nsec
:
node
.1
.ctime_nsec
,
..
Default
::
default
()
...
...
@@ -426,6 +428,8 @@ impl<D: Disk> Resource<D> for FileResource {
st_size
:
fs
.node_len
(
self
.block
)
?
,
st_mtime
:
node
.1
.mtime
,
st_mtime_nsec
:
node
.1
.mtime_nsec
,
st_atime
:
node
.1
.atime
,
st_atime_nsec
:
node
.1
.atime_nsec
,
st_ctime
:
node
.1
.ctime
,
st_ctime_nsec
:
node
.1
.ctime_nsec
,
..
Default
::
default
()
...
...
@@ -455,17 +459,16 @@ impl<D: Disk> Resource<D> for FileResource {
let
mut
node
=
fs
.node
(
self
.block
)
?
;
if
node
.1
.uid
==
self
.uid
||
self
.uid
==
0
{
if
let
Some
(
mtime
)
=
times
.get
(
1
)
{
if
let
&
[
atime
,
mtime
]
=
times
{
node
.1
.mtime
=
mtime
.tv_sec
as
u64
;
node
.1
.mtime_nsec
=
mtime
.tv_nsec
as
u32
;
node
.1
.atime
=
atime
.tv_sec
as
u64
;
node
.1
.atime_nsec
=
atime
.tv_nsec
as
u32
;
fs
.write_at
(
node
.0
,
&
node
.1
)
?
;
Ok
(
0
)
}
else
{
Ok
(
0
)
}
Ok
(
0
)
}
else
{
Err
(
Error
::
new
(
EPERM
))
}
...
...
src/node.rs
View file @
a6af6a92
...
...
@@ -14,10 +14,12 @@ pub struct Node {
pub
ctime_nsec
:
u32
,
pub
mtime
:
u64
,
pub
mtime_nsec
:
u32
,
pub
name
:
[
u8
;
222
],
pub
atime
:
u64
,
pub
atime_nsec
:
u32
,
pub
name
:
[
u8
;
226
],
pub
parent
:
u64
,
pub
next
:
u64
,
pub
extents
:
[
Extent
;
(
BLOCK_SIZE
as
usize
-
2
72
)
/
16
],
pub
extents
:
[
Extent
;
(
BLOCK_SIZE
as
usize
-
2
88
)
/
16
],
}
impl
Node
{
...
...
@@ -40,15 +42,17 @@ impl Node {
ctime_nsec
:
0
,
mtime
:
0
,
mtime_nsec
:
0
,
name
:
[
0
;
222
],
atime
:
0
,
atime_nsec
:
0
,
name
:
[
0
;
226
],
parent
:
0
,
next
:
0
,
extents
:
[
Extent
::
default
();
(
BLOCK_SIZE
as
usize
-
2
72
)
/
16
],
extents
:
[
Extent
::
default
();
(
BLOCK_SIZE
as
usize
-
2
88
)
/
16
],
}
}
pub
fn
new
(
mode
:
u16
,
name
:
&
str
,
parent
:
u64
,
ctime
:
u64
,
ctime_nsec
:
u32
)
->
syscall
::
Result
<
Node
>
{
let
mut
bytes
=
[
0
;
22
2
];
let
mut
bytes
=
[
0
;
22
6
];
if
name
.len
()
>
bytes
.len
()
{
return
Err
(
syscall
::
Error
::
new
(
syscall
::
ENAMETOOLONG
));
}
...
...
@@ -64,10 +68,12 @@ impl Node {
ctime_nsec
:
ctime_nsec
,
mtime
:
ctime
,
mtime_nsec
:
ctime_nsec
,
atime
:
ctime
,
atime_nsec
:
ctime_nsec
,
name
:
bytes
,
parent
:
parent
,
next
:
0
,
extents
:
[
Extent
::
default
();
(
BLOCK_SIZE
as
usize
-
2
72
)
/
16
],
extents
:
[
Extent
::
default
();
(
BLOCK_SIZE
as
usize
-
2
88
)
/
16
],
})
}
...
...
@@ -85,7 +91,7 @@ impl Node {
}
pub
fn
set_name
(
&
mut
self
,
name
:
&
str
)
->
syscall
::
Result
<
()
>
{
let
mut
bytes
=
[
0
;
22
2
];
let
mut
bytes
=
[
0
;
22
6
];
if
name
.len
()
>
bytes
.len
()
{
return
Err
(
syscall
::
Error
::
new
(
syscall
::
ENAMETOOLONG
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment