dcache: add initial dcache
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
27c3ffa8b1
commit
5ae890b3b0
3 changed files with 123 additions and 2 deletions
32
include/fs/dcache.h
Normal file
32
include/fs/dcache.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _DCACHE_H_
|
||||
#define _DCACHE_H_
|
||||
|
||||
#include <kernel/spinlock.h>
|
||||
#include <fs/vfs.h>
|
||||
|
||||
#include <lib/list.h>
|
||||
|
||||
#define DCACHE_SHIFT 10
|
||||
#define DCACHE_SIZE (1 << DCACHE_SHIFT)
|
||||
|
||||
#define DCACHE_LOCK_SHIFT 4
|
||||
#define DCACHE_NLOCKS (1 << DCACHE_LOCK_SHIFT)
|
||||
|
||||
struct dc_entry {
|
||||
struct dc_entry *parent;
|
||||
struct mount *mount;
|
||||
spinlock_t lock;
|
||||
list_t children;
|
||||
dirent_t *dirent;
|
||||
char d_name[FILE_NAME_MAX_LEN + 1];
|
||||
};
|
||||
|
||||
extern struct dc_entry dcache[DCACHE_SIZE];
|
||||
|
||||
void dcache_init(void);
|
||||
void dcache_insert(struct dc_entry *parent, dirent_t *dirent, const char *name);
|
||||
void dcache_remove(struct dc_entry *d);
|
||||
struct dc_entry *dcache_lookup(struct dc_entry *parent, const char *name);
|
||||
|
||||
#endif /* _DCACHE_H_ */
|
||||
Loading…
Reference in a new issue