Added a filesystem index value for each superblock

This commit is contained in:
Bahadir Balban
2009-10-08 17:00:00 +03:00
parent 72c6ca1ed0
commit 2192b22677
8 changed files with 27 additions and 6 deletions

View File

@@ -25,7 +25,7 @@ static inline int l4_chdir(const char *pathname)
utcb_full_strcpy_from(pathname);
/* Call pager with shmget() request. Check ipc error. */
if ((fd = l4_sendrecv_full(VFS_TID, VFS_TID, L4_IPC_TAG_CHDIR)) < 0) {
if ((fd = l4_sendrecv_full(PAGER_TID, PAGER_TID, L4_IPC_TAG_CHDIR)) < 0) {
print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd);
return fd;
}

View File

@@ -56,6 +56,15 @@ int vfs_init(void)
void *rootdev_blocks;
struct superblock *root_sb;
/* Initialize superblock ids */
vfs_fsidx_pool = id_pool_new_init(VFS_FSIDX_SIZE);
/*
* Waste first one so that vnums
* always orr with a non-zero value
*/
id_new(vfs_fsidx_pool);
/* Get standard init data from microkernel */
// request_initdata(&initdata);

View File

@@ -126,7 +126,7 @@ int memfs_init_rootdir(struct superblock *sb)
*/
v = sb->root = sb->ops->alloc_vnode(sb);
msb->root_vnum = sb->root->vnum;
BUG_ON(msb->root_vnum != 0);
BUG_ON(msb->root_vnum == 0);
/* Initialise fields */
vfs_set_type(v, S_IFDIR);

View File

@@ -122,7 +122,7 @@ struct vnode *memfs_alloc_vnode(struct superblock *sb)
/* Associate the two together */
v->inode = i;
v->vnum = i->inum;
v->vnum = i->inum | sb->fsidx; /* Globalize by fsidx */
/* Associate memfs-specific fields with vnode */
v->ops = memfs_vnode_operations;
@@ -174,7 +174,7 @@ int memfs_read_vnode(struct superblock *sb, struct vnode *v)
return -EEXIST;
/* Simply copy common fields */
v->vnum = i->inum;
v->vnum = i->inum | sb->fsidx;
v->size = i->size;
v->mode = i->mode;
v->owner = i->owner;
@@ -194,7 +194,7 @@ int memfs_write_vnode(struct superblock *sb, struct vnode *v)
BUG_ON(!i);
/* Simply copy common fields */
i->inum = v->vnum;
i->inum = v->vnum & ~VFS_FSIDX_MASK;
i->size = v->size;
i->mode = v->mode;
i->owner = v->owner;

View File

@@ -12,6 +12,7 @@ LINK_DECLARE(vnode_cache);
LINK_DECLARE(dentry_cache);
struct vfs_mountpoint vfs_root;
struct id_pool *vfs_fsidx_pool;
/*
* Vnodes in the vnode cache have 2 keys. One is their dentry names, the other
@@ -68,7 +69,7 @@ int vfs_mount_root(struct superblock *sb)
* Lookup the root vnode of this superblock.
* The root superblock has vnode number 0.
*/
vfs_root.pivot = vfs_lookup_byvnum(sb, 0);
vfs_root.pivot = vfs_lookup_byvnum(sb, sb->fsidx | 0);
vfs_root.sb = sb;
return 0;

View File

@@ -156,6 +156,7 @@ struct superblock *get_superblock(void *buf);
struct superblock {
u64 fssize;
int fsidx;
unsigned int blocksize;
struct link list;
struct file_system_type *fs;

View File

@@ -62,6 +62,7 @@ struct memfs_inode {
struct memfs_superblock {
u32 magic; /* Filesystem magic number */
char name[8];
int fsidx; /* Index that gets orred to get global vnum */
u32 blocksize; /* Filesystem block size */
u64 fmaxblocks; /* Maximum number of blocks per file */
u64 fssize; /* Total size of filesystem */

View File

@@ -10,8 +10,14 @@
#include <task.h>
#include <path.h>
/* Top nibble of vnum indicates filesystem index */
#define VFS_FSIDX_MASK 0xF0000000
#define VFS_FSIDX_SHIFT 28
#define VFS_FSIDX_SIZE 16
extern struct link vnode_cache;
extern struct link dentry_cache;
extern struct id_pool *vfs_fsidx_pool;
/*
* This is a temporary origacement for page cache support provided by mm0.
@@ -69,6 +75,9 @@ static inline void vfs_free_vnode(struct vnode *v)
static inline struct superblock *vfs_alloc_superblock(void)
{
struct superblock *sb = kmalloc(sizeof(struct superblock));
int fsidx = id_new(vfs_fsidx_pool);
sb->fsidx = fsidx << VFS_FSIDX_SHIFT;
link_init(&sb->list);
return sb;