From fd5b59d2271d433bf42e9d5d677435c2ff25e24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 9 Sep 2003 02:12:06 +0000 Subject: [PATCH] Added initial support for file systems. Not tested yet, but compiles. New Directory class for use in file systems; file systems need to publish their root directory as a subclass of this class. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4587 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/boot/partitions.h | 29 ++++++++++++++++++++---- headers/private/kernel/boot/vfs.h | 28 ++++++++++++++++++++++- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/headers/private/kernel/boot/partitions.h b/headers/private/kernel/boot/partitions.h index 1921b3cd10..899ded7b42 100644 --- a/headers/private/kernel/boot/partitions.h +++ b/headers/private/kernel/boot/partitions.h @@ -11,17 +11,38 @@ // DiskDeviceTypes we need/support in the boot loader -#define kPartitionTypeAmiga "Amiga RDB" -#define kPartitionTypeIntel "Intel" +#define kPartitionTypeAmiga "Amiga RDB" +#define kPartitionTypeIntel "Intel" #define kPartitionTypeIntelExtended "Intel Extended" -#define kPartitionTypeApple "Apple" +#define kPartitionTypeApple "Apple" -#define kPartitionTypeBFS "BFS" +#define kPartitionTypeBFS "BFS Filesystem" +#define kPartitionTypeAmigaFFS "AmigaFFS Filesystem" +#define kPartitionTypeBFS "BFS Filesystem" +#define kPartitionTypeEXT2 "EXT2 Filesystem" +#define kPartitionTypeEXT3 "EXT3 Filesystem" +#define kPartitionTypeFAT12 "FAT12 Filesystem" +#define kPartitionTypeFAT32 "FAT32 Filesystem" +#define kPartitionTypeISO9660 "ISO9660 Filesystem" +#define kPartitionTypeReiser "Reiser Filesystem" +#define kPartitionTypeUDF "UDF Filesystem" +// structure definitions as used in the boot loader struct partition_module_info; extern partition_module_info gAmigaPartitionModule; extern partition_module_info gIntelPartitionMapModule; extern partition_module_info gIntelExtendedPartitionModule; extern partition_module_info gApplePartitionModule; +// the file system module info is not a standard module info; +// their modules are specifically written for the boot loader, +// and hence, don't need to follow the standard module specs. + +struct file_system_module_info { + const char *pretty_name; + status_t (*get_file_system)(Node *device, Directory **_root); +}; + +extern file_system_module_info gBFSFileSystemModule; + #endif /* KERNEL_BOOT_PARTITIONS_H */ diff --git a/headers/private/kernel/boot/vfs.h b/headers/private/kernel/boot/vfs.h index aac6035899..7a4fa54d97 100644 --- a/headers/private/kernel/boot/vfs.h +++ b/headers/private/kernel/boot/vfs.h @@ -8,7 +8,7 @@ #include -#include +#include #include @@ -27,12 +27,36 @@ class Node { virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize) = 0; virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize) = 0; + virtual status_t GetName(char *nameBuffer, size_t bufferSize) const; + virtual int32 Type() const; + virtual off_t Size() const; + + status_t Acquire(); + status_t Release(); + protected: list_link fLink; int32 fRefCount; }; +class Directory : public Node { + public: + Directory(); + + virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize); + virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize); + + virtual int32 Type() const; + + virtual Node *Lookup(const char *name, bool traverseLinks) = 0; + + virtual status_t GetNextNode(void *cookie, Node **_node) = 0; + virtual status_t Rewind(void *cookie) = 0; + + virtual status_t AddNode(Node *node); +}; + /** The console based nodes don't need cookies for I/O, they * also don't support to change the stream position. * Live is simple in the boot loader :-) @@ -46,6 +70,7 @@ class ConsoleNode : public Node { virtual ssize_t Write(const void *buffer, size_t bufferSize); }; +extern Directory *gRoot; extern "C" { #endif /* __cplusplus */ @@ -53,6 +78,7 @@ extern "C" { extern status_t vfs_init(stage2_args *args); extern status_t mount_boot_file_systems(); extern status_t add_partitions_for(int fd); +extern int open_node(Node *node, int mode); #ifdef __cplusplus }