Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hellofs
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
hellofs
Commits
32380f12
There was an error fetching the commit references. Please try again later.
Commit
32380f12
authored
5 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
more fuck
parent
dbf0545f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
dir.c
+8
-16
8 additions, 16 deletions
dir.c
file.c
+12
-29
12 additions, 29 deletions
file.c
krfs.c
+2
-8
2 additions, 8 deletions
krfs.c
krfs.h
+4
-12
4 additions, 12 deletions
krfs.h
with
26 additions
and
65 deletions
dir.c
+
8
−
16
View file @
32380f12
...
@@ -5,22 +5,15 @@
...
@@ -5,22 +5,15 @@
#endif
#endif
int
rfs_iterate
(
struct
file
*
filp
,
struct
dir_context
*
ctx
)
{
int
rfs_iterate
(
struct
file
*
filp
,
struct
dir_context
*
ctx
)
{
loff_t
pos
;
struct
inode
*
inode
;
struct
super_block
*
sb
;
struct
buffer_head
*
bh
;
struct
rfs_inode
*
rfs_inode
;
struct
rfs_dir_record
*
dir_record
;
uint64_t
i
;
RLIB_KTRACE_FUNC
(
iterate
);
RLIB_KTRACE_FUNC
(
iterate
);
pos
=
ctx
->
pos
;
auto
inode
=
filp
->
f_path
.
dentry
->
d_inode
;
inode
=
filp
->
f_path
.
dentry
->
d_inode
;
auto
sb
=
inode
->
i_sb
;
sb
=
inode
->
i_sb
;
auto
rfs_inode
=
RFS_INODE
(
inode
);
rfs_inode
=
RFS_INODE
(
inode
);
if
(
pos
)
{
if
(
ctx
->
pos
)
{
// TODO @Sankar: we use a hack of reading pos to figure if we have filled in data.
// TODO @Sankar: we use a hack of reading pos to figure if we have filled in data.
printk
(
KERN_ALERT
"iterate, pos != 0.
\n
"
);
return
0
;
return
0
;
}
}
...
@@ -34,14 +27,13 @@ int rfs_iterate(struct file *filp, struct dir_context *ctx) {
...
@@ -34,14 +27,13 @@ int rfs_iterate(struct file *filp, struct dir_context *ctx) {
return
-
ENOTDIR
;
return
-
ENOTDIR
;
}
}
bh
=
sb_bread
(
sb
,
rfs_inode
->
data_block_no
);
auto
bh
=
sb_bread
(
sb
,
rfs_inode
->
data_block_no
);
BUG_ON
(
!
bh
);
BUG_ON
(
!
bh
);
dir_record
=
(
struct
rfs_dir_record
*
)
bh
->
b_data
;
auto
dir_record
=
(
struct
rfs_dir_record
*
)
bh
->
b_data
;
for
(
i
=
0
;
i
<
rfs_inode
->
dir_children_count
;
i
++
)
{
for
(
auto
i
=
0
;
i
<
rfs_inode
->
dir_children_count
;
i
++
)
{
dir_emit
(
ctx
,
dir_record
->
filename
,
RFS_FILENAME_MAXLEN
,
dir_record
->
inode_no
,
DT_UNKNOWN
);
dir_emit
(
ctx
,
dir_record
->
filename
,
RFS_FILENAME_MAXLEN
,
dir_record
->
inode_no
,
DT_UNKNOWN
);
ctx
->
pos
+=
sizeof
(
struct
rfs_dir_record
);
ctx
->
pos
+=
sizeof
(
struct
rfs_dir_record
);
pos
+=
sizeof
(
struct
rfs_dir_record
);
dir_record
++
;
dir_record
++
;
}
}
brelse
(
bh
);
brelse
(
bh
);
...
...
This diff is collapsed.
Click to expand it.
file.c
+
12
−
29
View file @
32380f12
#include
"krfs.h"
#include
"krfs.h"
ssize_t
rfs_read
(
struct
file
*
filp
,
char
__user
*
buf
,
size_t
len
,
ssize_t
rfs_read
(
struct
file
*
filp
,
char
__user
*
buf
,
size_t
len
,
loff_t
*
ppos
)
{
loff_t
*
ppos
)
{
auto
inode
=
filp
->
f_path
.
dentry
->
d_inode
;
struct
super_block
*
sb
;
auto
sb
=
inode
->
i_sb
;
struct
inode
*
inode
;
auto
rfs_inode
=
RFS_INODE
(
inode
);
struct
rfs_inode
*
rfs_inode
;
struct
buffer_head
*
bh
;
char
*
buffer
;
int
nbytes
;
inode
=
filp
->
f_path
.
dentry
->
d_inode
;
sb
=
inode
->
i_sb
;
rfs_inode
=
RFS_INODE
(
inode
);
if
(
*
ppos
>=
rfs_inode
->
file_size
)
{
if
(
*
ppos
>=
rfs_inode
->
file_size
)
{
return
0
;
return
0
;
}
}
bh
=
sb_bread
(
sb
,
rfs_inode
->
data_block_no
);
auto
bh
=
sb_bread
(
sb
,
rfs_inode
->
data_block_no
);
if
(
!
bh
)
{
if
(
!
bh
)
{
printk
(
KERN_ERR
"Failed to read data block %llu
\n
"
,
printk
(
KERN_ERR
"Failed to read data block %llu
\n
"
,
rfs_inode
->
data_block_no
);
rfs_inode
->
data_block_no
);
return
0
;
return
0
;
}
}
buffer
=
(
char
*
)
bh
->
b_data
+
*
ppos
;
auto
buffer
=
(
char
*
)
bh
->
b_data
+
*
ppos
;
nbytes
=
min
((
size_t
)(
rfs_inode
->
file_size
-
*
ppos
),
len
);
auto
nbytes
=
min
((
size_t
)(
rfs_inode
->
file_size
-
*
ppos
),
len
);
if
(
copy_to_user
(
buf
,
buffer
,
nbytes
))
{
if
(
copy_to_user
(
buf
,
buffer
,
nbytes
))
{
brelse
(
bh
);
brelse
(
bh
);
...
@@ -45,18 +37,9 @@ ssize_t rfs_read(struct file *filp, char __user *buf, size_t len,
...
@@ -45,18 +37,9 @@ ssize_t rfs_read(struct file *filp, char __user *buf, size_t len,
we will use write to pagecache instead. */
we will use write to pagecache instead. */
ssize_t
rfs_write
(
struct
file
*
filp
,
const
char
__user
*
buf
,
size_t
len
,
ssize_t
rfs_write
(
struct
file
*
filp
,
const
char
__user
*
buf
,
size_t
len
,
loff_t
*
ppos
)
{
loff_t
*
ppos
)
{
struct
super_block
*
sb
;
auto
inode
=
filp
->
f_path
.
dentry
->
d_inode
;
struct
inode
*
inode
;
auto
sb
=
inode
->
i_sb
;
struct
rfs_inode
*
rfs_inode
;
auto
rfs_inode
=
RFS_INODE
(
inode
);
struct
buffer_head
*
bh
;
struct
rfs_superblock
*
rfs_sb
;
char
*
buffer
;
int
ret
;
inode
=
filp
->
f_path
.
dentry
->
d_inode
;
sb
=
inode
->
i_sb
;
rfs_inode
=
RFS_INODE
(
inode
);
rfs_sb
=
RFS_SB
(
sb
);
// Recolic: compilation issue, temporary disable. TODO
// Recolic: compilation issue, temporary disable. TODO
// ret = generic_write_checks(filp, ppos, &len, 0);
// ret = generic_write_checks(filp, ppos, &len, 0);
...
@@ -64,14 +47,14 @@ ssize_t rfs_write(struct file *filp, const char __user *buf, size_t len,
...
@@ -64,14 +47,14 @@ ssize_t rfs_write(struct file *filp, const char __user *buf, size_t len,
// return ret;
// return ret;
// }
// }
bh
=
sb_bread
(
sb
,
rfs_inode
->
data_block_no
);
auto
bh
=
sb_bread
(
sb
,
rfs_inode
->
data_block_no
);
if
(
!
bh
)
{
if
(
!
bh
)
{
printk
(
KERN_ERR
"Failed to read data block %llu
\n
"
,
printk
(
KERN_ERR
"Failed to read data block %llu
\n
"
,
rfs_inode
->
data_block_no
);
rfs_inode
->
data_block_no
);
return
0
;
return
0
;
}
}
buffer
=
(
char
*
)
bh
->
b_data
+
*
ppos
;
auto
buffer
=
(
char
*
)
bh
->
b_data
+
*
ppos
;
if
(
copy_from_user
(
buffer
,
buf
,
len
))
{
if
(
copy_from_user
(
buffer
,
buf
,
len
))
{
brelse
(
bh
);
brelse
(
bh
);
printk
(
KERN_ERR
printk
(
KERN_ERR
...
...
This diff is collapsed.
Click to expand it.
krfs.c
+
2
−
8
View file @
32380f12
...
@@ -35,8 +35,6 @@ struct kmem_cache *rfs_inode_cache = NULL;
...
@@ -35,8 +35,6 @@ struct kmem_cache *rfs_inode_cache = NULL;
static
int
__init
rfs_init
(
void
)
static
int
__init
rfs_init
(
void
)
{
{
int
ret
;
rfs_inode_cache
=
kmem_cache_create
(
"rfs_inode_cache"
,
rfs_inode_cache
=
kmem_cache_create
(
"rfs_inode_cache"
,
sizeof
(
struct
rfs_inode
),
sizeof
(
struct
rfs_inode
),
0
,
0
,
...
@@ -46,8 +44,7 @@ static int __init rfs_init(void)
...
@@ -46,8 +44,7 @@ static int __init rfs_init(void)
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
ret
=
register_filesystem
(
&
rfs_fs_type
);
if
(
likely
(
register_filesystem
(
&
rfs_fs_type
)
==
0
))
{
if
(
likely
(
0
==
ret
))
{
printk
(
KERN_INFO
"Sucessfully registered rfs
\n
"
);
printk
(
KERN_INFO
"Sucessfully registered rfs
\n
"
);
}
else
{
}
else
{
printk
(
KERN_ERR
"Failed to register rfs. Error code: %d
\n
"
,
ret
);
printk
(
KERN_ERR
"Failed to register rfs. Error code: %d
\n
"
,
ret
);
...
@@ -58,12 +55,9 @@ static int __init rfs_init(void)
...
@@ -58,12 +55,9 @@ static int __init rfs_init(void)
static
void
__exit
rfs_exit
(
void
)
static
void
__exit
rfs_exit
(
void
)
{
{
int
ret
;
ret
=
unregister_filesystem
(
&
rfs_fs_type
);
kmem_cache_destroy
(
rfs_inode_cache
);
kmem_cache_destroy
(
rfs_inode_cache
);
if
(
likely
(
ret
==
0
))
{
if
(
likely
(
unregister_filesystem
(
&
rfs_fs_type
)
==
0
))
{
printk
(
KERN_INFO
"Sucessfully unregistered rfs
\n
"
);
printk
(
KERN_INFO
"Sucessfully unregistered rfs
\n
"
);
}
else
{
}
else
{
printk
(
KERN_ERR
"Failed to unregister rfs. Error code: %d
\n
"
,
printk
(
KERN_ERR
"Failed to unregister rfs. Error code: %d
\n
"
,
...
...
This diff is collapsed.
Click to expand it.
krfs.h
+
4
−
12
View file @
32380f12
...
@@ -71,27 +71,19 @@ static inline uint64_t RFS_INODES_PER_BLOCK(struct super_block *sb) {
...
@@ -71,27 +71,19 @@ static inline uint64_t RFS_INODES_PER_BLOCK(struct super_block *sb) {
// Given the inode_no, calcuate which block in inode table contains the corresponding inode
// Given the inode_no, calcuate which block in inode table contains the corresponding inode
static
inline
uint64_t
RFS_INODE_BLOCK_OFFSET
(
struct
super_block
*
sb
,
uint64_t
inode_no
)
{
static
inline
uint64_t
RFS_INODE_BLOCK_OFFSET
(
struct
super_block
*
sb
,
uint64_t
inode_no
)
{
struct
rfs_superblock
*
rfs_sb
;
return
inode_no
/
RFS_INODES_PER_BLOCK_HSB
(
RFS_SB
(
sb
));
rfs_sb
=
RFS_SB
(
sb
);
return
inode_no
/
RFS_INODES_PER_BLOCK_HSB
(
rfs_sb
);
}
}
static
inline
uint64_t
RFS_INODE_BYTE_OFFSET
(
struct
super_block
*
sb
,
uint64_t
inode_no
)
{
static
inline
uint64_t
RFS_INODE_BYTE_OFFSET
(
struct
super_block
*
sb
,
uint64_t
inode_no
)
{
struct
rfs_superblock
*
rfs_sb
;
return
(
inode_no
%
RFS_INODES_PER_BLOCK_HSB
(
RFS_SB
(
sb
)))
*
sizeof
(
struct
rfs_inode
);
rfs_sb
=
RFS_SB
(
sb
);
return
(
inode_no
%
RFS_INODES_PER_BLOCK_HSB
(
rfs_sb
))
*
sizeof
(
struct
rfs_inode
);
}
}
static
inline
uint64_t
RFS_DIR_MAX_RECORD
(
struct
super_block
*
sb
)
{
static
inline
uint64_t
RFS_DIR_MAX_RECORD
(
struct
super_block
*
sb
)
{
struct
rfs_superblock
*
rfs_sb
;
return
RFS_SB
(
sb
)
->
blocksize
/
sizeof
(
struct
rfs_dir_record
);
rfs_sb
=
RFS_SB
(
sb
);
return
rfs_sb
->
blocksize
/
sizeof
(
struct
rfs_dir_record
);
}
}
// From which block does data blocks start
// From which block does data blocks start
static
inline
uint64_t
RFS_DATA_BLOCK_TABLE_START_BLOCK_NO
(
struct
super_block
*
sb
)
{
static
inline
uint64_t
RFS_DATA_BLOCK_TABLE_START_BLOCK_NO
(
struct
super_block
*
sb
)
{
struct
rfs_superblock
*
rfs_sb
;
return
RFS_DATA_BLOCK_TABLE_START_BLOCK_NO_HSB
(
RFS_SB
(
sb
));
rfs_sb
=
RFS_SB
(
sb
);
return
RFS_DATA_BLOCK_TABLE_START_BLOCK_NO_HSB
(
rfs_sb
);
}
}
void
rfs_save_sb
(
struct
super_block
*
sb
);
void
rfs_save_sb
(
struct
super_block
*
sb
);
...
...
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