summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/ext2.c8
-rw-r--r--fs/ext2.h3
-rw-r--r--fs/mount.c16
-rw-r--r--fs/mount.h29
-rw-r--r--fs/pipe.c4
-rw-r--r--fs/sysfs.c1
6 files changed, 28 insertions, 33 deletions
diff --git a/fs/ext2.c b/fs/ext2.c
index 9cc5b34..49484c4 100644
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -1,9 +1,11 @@
+#include "ext2.h"
+
#include <stdbool.h>
#include <stdint.h>
+
#include "mount.h"
#include "kernel.h"
-#include "ext2.h"
#include "log.h"
@@ -37,7 +39,8 @@ typedef struct ext2_superblock_struct
uint16_t gid_reserved;
}ext2_superblock;
-/* we dont use this
+/* we dont use this for now */
+/*
typedef struct ext2_superblock_ext_struct
{
uint32_t first_inode;
@@ -268,7 +271,6 @@ uint32_t ext2_read_inode(uint32_t ext2_start_addr, int inode_nr, char *buf, uint
}
return count;
-
}
int ext2_read_dir(uint32_t ext2_start_addr, int inode_nr, fs_dirent *dirs, uint32_t *pos)
diff --git a/fs/ext2.h b/fs/ext2.h
index 3c53350..524f8fd 100644
--- a/fs/ext2.h
+++ b/fs/ext2.h
@@ -4,7 +4,8 @@
// =======================
//
// based on osdev wiki article: http://wiki.osdev.org/Ext2
-// root directory is inode 2 per definition!
+// The root directory is inode 2 per definition!
+//
// we do not care about files >4gb (no triply linked lists and no size_high)
// we also use only name_length_low so max length is 255 chars
//
diff --git a/fs/mount.c b/fs/mount.c
index 92f9b8a..62cfe9f 100644
--- a/fs/mount.c
+++ b/fs/mount.c
@@ -6,7 +6,7 @@
#include "log.h"
#include "lib/string/string.h"
-// temporary
+
#include "fd.h"
static mount mounts[MAX_MOUNTS];
@@ -17,7 +17,7 @@ char *mount_type_to_str(uint32_t t)
switch(t)
{
case MOUNT_TYPE_EXT2: return "EXT2";
- case MOUNT_TYPE_PIPES: return "PIPES";
+// case MOUNT_TYPE_PIPES: return "PIPES";
case MOUNT_TYPE_SYS: return "SYSFS";
}
return "UNKNOWN";
@@ -30,22 +30,12 @@ void mount_add(mount mnt)
klog("Mounted %s at %s",mount_type_to_str(mnt.type),mnt.path);
}
-void mount_dump()
-{
- for(int i=0;i<mounts_count;i++)
- {
- mount *m=&mounts[i];
- klog("%s mounted at: %s ",mount_type_to_str(m->type),m->path);
- }
-}
-
void mount_sysfs(ringbuffer *r, void (*f)(ringbuffer *r,char *fmt, ...))
{
- f(r,"mounts:");
for(int i=0;i<mounts_count;i++)
{
mount *m=&mounts[i];
- f(r,"%s mounted at: %s ",mount_type_to_str(m->type),m->path);
+ f(r,"%s at %s",mount_type_to_str(m->type),m->path);
}
}
diff --git a/fs/mount.h b/fs/mount.h
index 8a61f2b..ba3d704 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -1,30 +1,34 @@
/**
* @file
+ *
* Simple mount point manager
* ==========================
*
- * Add up to MAX_MOUNTS (as defined in kernel.h) mounts and use
- * mount_file_open() and mount_read_dir() to transparently
- * be dispatch the underlying commands to them based on the supplied paths.
+ * Add up to MAX_MOUNTS (as defined in kernel.h) mountpoints and use the
+ * provided functions to transparently dispatch them to the undelying
+ * infrastructure provided via the mount_struct structures
+ *
+ * unt_file_open() and mount_read_dir()
*
- * Mount directories should exist on root direcotry '/'
+ * The mount directories itself should exist inside the
+ * root direcotry '/'.
*/
#ifndef MOUNT_H
#define MOUNT_H
#include <stdint.h>
-#include "interface/fs.h" // fs_dirent for read_dir
-#include "fd.h" // file descriptor returned by open
+
+#include "interface/fs.h" // provides fs_dirent structure for read_dir()
+#include "fd.h" // file descriptor returned by open
/** the possible values for mount_struct.type */
enum MOUNT_TYPE{
MOUNT_TYPE_EXT2 = 1,
- MOUNT_TYPE_PIPES = 2,
- MOUNT_TYPE_SYS = 3
+ MOUNT_TYPE_SYS = 3
};
-/** struct telling all we need about a single mountpoint */
+/** struct providing all the required info, about a single mountpoint */
typedef struct mount_struct
{
uint32_t type; // MOUNT_TYPE
@@ -34,13 +38,10 @@ typedef struct mount_struct
fd (*mount_file_open)(struct mount_struct*, char *path);
int (*mount_read_dir) (struct mount_struct*, char *path, fs_dirent *dirs, uint32_t *pos);
- void *data; //opaque data
+ void *data; // pointer to some opaque private data
}mount;
-/** dumps mount info to klog */
-void mount_dump();
-
/** adds a new mountpoints */
void mount_add(mount mnt);
@@ -50,7 +51,7 @@ fd mount_file_open(char *path);
/** TODO: should use fd number instead of PATH on each call*/
int mount_read_dir (char *path, fs_dirent *dirs, uint32_t *pos);
-/** sysfs interface */
+/** sysfs interface / exposing status via /sysfs/ file */
void mount_sysfs(ringbuffer *r, void (*f)(ringbuffer *r,char *fmt, ...));
#endif
diff --git a/fs/pipe.c b/fs/pipe.c
index 3802851..f983988 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -17,14 +17,13 @@ fd pipe_file_open(mount *m,char *path)
return a;
}
+/*
int pipe_read_dir(mount *m,char *path, fs_dirent *dirs, uint32_t *pos)
{
- /*
if(*pos>=count)return 0;
memcpy(dirs->name,names[*pos],strlen(names[*pos])+1);
*pos+=1;
return 1;
- */
return 0;
}
@@ -37,3 +36,4 @@ void pipe_mount(char* path)
m.mount_read_dir=pipe_read_dir;
mount_add(m);
}
+*/
diff --git a/fs/sysfs.c b/fs/sysfs.c
index 5288a93..b7901d0 100644
--- a/fs/sysfs.c
+++ b/fs/sysfs.c
@@ -15,6 +15,7 @@ static uint32_t map[]={mem_sysfs,mem_sysfs_set,
kmalloc_sysfs,NULL,
mount_sysfs,NULL,
};
+
static uint32_t count=3;
/* mount interface */