Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
obj-m += simplefs.o
simplefs-objs := fs.o super.o inode.o file.o dir.o extent.o
simplefs-objs := fs.o super.o inode.o file.o dir.o extent.o hash.o

KDIR ?= /lib/modules/$(shell uname -r)/build

Expand Down
8 changes: 5 additions & 3 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ static int simplefs_iterate(struct file *dir, struct dir_context *ctx)
for (; remained_nr_files && ei < SIMPLEFS_MAX_EXTENTS; ei++) {
if (eblock->extents[ei].ee_start == 0)
continue;

int ei_nr = eblock->extents[ei].nr_files;
/* Iterate over blocks in one extent */
for (bi = 0; bi < eblock->extents[ei].ee_len && remained_nr_files;
for (bi = 0;
bi < eblock->extents[ei].ee_len && remained_nr_files && ei_nr;
bi++) {
bh2 = sb_bread(sb, eblock->extents[ei].ee_start + bi);
if (!bh2) {
Expand All @@ -80,12 +81,13 @@ static int simplefs_iterate(struct file *dir, struct dir_context *ctx)
continue;
}

for (fi = 0; fi < SIMPLEFS_FILES_PER_BLOCK;) {
for (fi = 0; fi < SIMPLEFS_FILES_PER_BLOCK && dblock->nr_files;) {
if (dblock->files[fi].inode != 0) {
if (offset) {
offset--;
} else {
remained_nr_files--;
ei_nr--;
if (!dir_emit(ctx, dblock->files[fi].filename,
SIMPLEFS_FILENAME_LEN,
dblock->files[fi].inode, DT_UNKNOWN)) {
Expand Down
9 changes: 9 additions & 0 deletions hash.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <linux/stringhash.h>
#include <linux/types.h>
#include "simplefs.h"

uint32_t simplefs_hash(struct dentry *dentry)
{
return full_name_hash(dentry, dentry->d_name.name,
strlen(dentry->d_name.name));
}
Loading