Import backup from 2005-01-26

This commit is contained in:
Josh Holtrop 2005-01-26 22:00:00 -05:00
parent f09ed66826
commit 3381041a8f
3 changed files with 40 additions and 45 deletions

View File

@ -12,7 +12,7 @@
#include "lang/lang.h" #include "lang/lang.h"
vfs_fs_t *fses[VFS_MAX_FS]; // a vfs_fs structure for every filesystem we support vfs_fs_t *fses[VFS_MAX_FS]; // a vfs_fs structure for every filesystem we support
vfs_mount_node_t *mounts; vfs_mount_t *mounts;
// basic initialization routine, init all filesystem drivers // basic initialization routine, init all filesystem drivers
int vfs_init() int vfs_init()
@ -43,24 +43,26 @@ int vfs_mount(major_t maj, minor_t min, int fsType, char *mountPoint)
if (mounts) if (mounts)
return -2; // root already mounted return -2; // root already mounted
void *super = fses[fsType]->mount_super(maj, min); void *super = fses[fsType]->mount_super(maj, min);
if (!super)
return -3; // didn't mount superblock
vfs_mount_t *mnt = New(vfs_mount_t); vfs_mount_t *mnt = New(vfs_mount_t);
mnt->refs = 0; mnt->refs = 0;
mnt->fs = fsType; mnt->fs = fsType;
mnt->major = maj; mnt->major = maj;
mnt->minor = min; mnt->minor = min;
mnt->super = super; mnt->super = super;
vfs_mount_node_t *node = New(vfs_mount_node_t); mnt->next = NULL;
mount = node; mnt->prev = NULL;
node->next = NULL; node->vfs_mount_inode = 0; // root not mounted on another fs
node->mount = mnt; node->vfs_up_inode = 0;
node->vfs_inode = 0; mounts = mnt;
return 0; return 0; // successfully mounted root
} }
if (mountPoint[0] != '/') if (mountPoint[0] != '/')
return -3; // mount point must be absolute return -3; // mount point must be absolute
int l = strlen(mountPoint); int l = strlen(mountPoint);
if (l < 2) if (l < 2)
return -4; // mount point must be non-null string return -4; // mount point is too short
return -5; return -5;
} }
@ -68,10 +70,29 @@ vfs_inode_t vfs_get_inode_number(char *path)
{ {
if (path[0] != '/') if (path[0] != '/')
return 0; return 0;
vfs_file_addr_t file_addr; vfs_inode_t vfs_inode = 0;
file_addr.mount = mounts->mount;
file_addr.inode = fses[file_addr.mount->fsType]->get_root_inode(file_addr.mount);
}
// look for entry in dir_inode, return the vfs_inode for the entry
vfs_inode_t vfs_entry_lookup(vfs_inode_t dir_inode, char *entry)
{
vfs_open_file_t *open_dir = vfs_open_dir_inode(dir_inode);
if (!open_dir)
return 0x8000000000000001ULL;
vfs_dir_entry_t dentry;
vfs_inode_t vfs_inode = 0;
while (!vfs_read_dir(open_dir, &dentry))
{
if (!strcmp(dentry.name, entry))
{
vfs_inode = (dir_inode & 0xFFFFFFFF00000000ULL) | dentry.inode_number;
break;
}
}
vfs_close_dir(open_dir);
return vfs_inode;
} }

View File

@ -39,28 +39,20 @@
typedef u64_t vfs_inode_t; typedef u64_t vfs_inode_t;
/* Structure to hold information about a mount point */ /* Structure to hold information about a mount point */
typedef struct struct vfs_mount_s
{ {
int refs; int refs;
void *super; void *super;
int fs; int fs;
major_t major; major_t major;
minor_t minor; minor_t minor;
} vfs_mount_t; char *mountPoint;
vfs_inode_t vfs_mount_inode;
struct vfs_mount_node_s vfs_inode_t vfs_up_inode;
{ struct vfs_mount_s *next;
vfs_mount_t *mount; struct vfs_mount_s *prev;
vfs_inode_t vfs_inode;
struct vfs_mount_node_s *next;
}; };
typedef struct vfs_mount_node_s vfs_mount_node_t; typedef struct vfs_mount_s vfs_mount_t;
typedef struct
{
vfs_mount_t *mount;
u32_t inode;
} vfs_file_addr_t;
typedef struct typedef struct
{ {
@ -86,7 +78,7 @@ typedef struct
typedef struct typedef struct
{ {
char name[257]; char name[257];
u32_t inode_number; u32_t inode_number; // relative inode number returned from fs
} vfs_dir_entry_t; } vfs_dir_entry_t;
/* Every filesystem must provide pointers to its respective functions in a structure like this */ /* Every filesystem must provide pointers to its respective functions in a structure like this */

View File

@ -1,18 +0,0 @@
regexp=.*In.function.*
colours=green
-
regexp=.*warning\:.*
colours=yellow
-
regexp=In.file.included.*
colours=green
-
regexp=\s*from.*\:\s*
colours=green
-
regexp=.*error\:.*
colours=red
-
regexp=.*\*\*\*.*
colours=red