mirror of
https://github.com/drasko/codezero.git
synced 2026-01-29 11:13:14 +01:00
sys_readdir and memfs_readdir closer to targeted look and feel.
We now have a single dirbuf of size PAGE_SIZE kept on the vnode. This is to be used for directory contents only. The reason it's kept on FS0 is because the contents are modified by calls such as mkdir or create, and otherwise these would have been handled by mm0 on the page cache buffers, which wouldn't work.
This commit is contained in:
@@ -96,8 +96,8 @@ struct vnode {
|
||||
struct vnode_ops ops; /* Operations on this vnode */
|
||||
struct file_ops fops; /* File-related operations on this vnode */
|
||||
struct list_head dentries; /* Dirents that refer to this vnode */
|
||||
struct list_head state_list; /* List for vnode's dirty/clean state */
|
||||
struct list_head cache_list; /* For adding the vnode to vnode cache */
|
||||
struct dirbuf dirbuf; /* Only directory buffers are kept */
|
||||
u32 type; /* Vnode type, dev? socket? dir? ... */
|
||||
u32 mode; /* Permissions */
|
||||
u32 owner; /* Owner */
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
* that fs0 maintains. All other file data is in mm0 page cache.
|
||||
*/
|
||||
struct dirbuf {
|
||||
struct list_head list;
|
||||
unsigned long bufsize;
|
||||
u8 *buffer;
|
||||
unsigned long npages;
|
||||
int dirty;
|
||||
u8 *buf;
|
||||
};
|
||||
|
||||
extern struct list_head vnode_cache;
|
||||
extern struct list_head dentry_cache;
|
||||
|
||||
@@ -54,6 +55,7 @@ static inline struct dentry *vfs_alloc_dentry(void)
|
||||
INIT_LIST_HEAD(&d->child);
|
||||
INIT_LIST_HEAD(&d->children);
|
||||
INIT_LIST_HEAD(&d->vref);
|
||||
INIT_LIST_HEAD(&d->cache_list);
|
||||
|
||||
return d;
|
||||
}
|
||||
@@ -68,9 +70,7 @@ static inline struct vnode *vfs_alloc_vnode(void)
|
||||
struct vnode *v = kzalloc(sizeof(struct vnode));
|
||||
|
||||
INIT_LIST_HEAD(&v->dentries);
|
||||
INIT_LIST_HEAD(&v->state_list);
|
||||
INIT_LIST_HEAD(&v->cache_list);
|
||||
list_add(&v->cache_list, &vnode_cache);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user