diff --git a/src/sys/ubixfsv2/btree.cpp b/src/sys/ubixfsv2/btree.cpp index 9123e87..117899b 100644 --- a/src/sys/ubixfsv2/btree.cpp +++ b/src/sys/ubixfsv2/btree.cpp @@ -611,7 +611,6 @@ assert(fd); assert(node); cout << "writing tag: " << node->tag << endl; - off_t myOffset = node->tag * sizeof(bNode); memcpy(tmpPtr, node, sizeof(bNode)); @@ -633,7 +632,7 @@ if (node->leaf) { for (unsigned int i = 0; i <= node->used; i++) { - ubixfsInode * inode = node->head[i].iPtr; + // ubixfsInode * inode = node->head[i].iPtr; // mji if (inode != NULL) tmp->head[i] = inode-> } // for i } else { diff --git a/src/sys/ubixfsv2/device.h b/src/sys/ubixfsv2/device.h new file mode 100644 index 0000000..c3d31e6 --- /dev/null +++ b/src/sys/ubixfsv2/device.h @@ -0,0 +1,106 @@ +/***************************************************************************************** + Copyright (c) 2002-2004 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +*****************************************************************************************/ + +#ifndef _DEVICE_H +#define _DEVICE_H + +// #include +#include "types.h" + +struct device_node { + struct device_node *prev; + struct device_node *next; + struct device_interface *devInfo; + struct device_resource *devRec; + char type; + int minor; + }; + +struct device_resource { + uInt8 irq; + }; + +struct device_interface { + uInt8 initialized; + uInt32 size; + int major; + void *info; + void (*read)(void *,void *,uInt32,uInt32); + void (*write)(void *,void *,uInt32,uInt32); + void (*reset)(void *); + int (*init)(void *); + void (*ioctl)(void *); + void (*stop)(void *); + void (*start)(void *); + void (*standby)(void *); + }; + + +int device_add(int,char,struct device_interface *); +struct device_node *device_find(int major,int minor); +int device_remove(struct device_node *); +#endif + +/*** + $Log$ + Revision 1.14 2004/08/15 00:33:02 reddawg + Wow the ide driver works again + + Revision 1.13 2004/08/14 21:56:44 reddawg + Added initialized byte to the device system to make it easy to add child devices which use parent hardware. + + Revision 1.12 2004/07/21 10:02:09 reddawg + devfs: renamed functions + device system: renamed functions + fdc: fixed a few potential bugs and cleaned up some unused variables + strol: fixed definition + endtask: made it print out freepage debug info + kmalloc: fixed a huge memory leak we had some unhandled descriptor insertion so some descriptors were lost + ld: fixed a pointer conversion + file: cleaned up a few unused variables + sched: broke task deletion + kprintf: fixed ogPrintf definition + + Revision 1.11 2004/05/22 02:40:04 ionix + + + fixed typo in device.h and initialized previous in device.c :) + + Revision 1.10 2004/05/22 02:34:03 ionix + + + Added proto + + Revision 1.9 2004/05/21 15:12:17 reddawg + Cleaned up + + + END + ***/ + diff --git a/src/sys/ubixfsv2/fsAbstract.h b/src/sys/ubixfsv2/fsAbstract.h index c0963e1..8b81620 100644 --- a/src/sys/ubixfsv2/fsAbstract.h +++ b/src/sys/ubixfsv2/fsAbstract.h @@ -4,12 +4,13 @@ #include #include #include +#include class vfs_abstract { protected: vfs_abstract * prev; vfs_abstract * next; - dev_t * device; + device_interface * device; public: /* File I/O */ virtual int vfs_open(FILE *,int flags,...) = 0; @@ -25,7 +26,7 @@ /* FS Functions */ virtual int vfs_init(void) = 0; - virtual int vfs_format(dev_t *) = 0; + virtual int vfs_format(device_interface *) = 0; virtual int vfs_stop(void) = 0; virtual int vfs_sync(void) = 0; virtual void * vfs_mknod(const char *, mode_t) = 0; diff --git a/src/sys/ubixfsv2/types.h b/src/sys/ubixfsv2/types.h new file mode 100644 index 0000000..0cad845 --- /dev/null +++ b/src/sys/ubixfsv2/types.h @@ -0,0 +1,11 @@ +#ifndef TYPES_H +#define TYPES_H + +typedef signed char int8; +typedef unsigned char uInt8; +typedef unsigned int uInt32; +typedef int int32; +typedef unsigned long long uInt64; +typedef signed long long int64; + +#endif /* !TYPES_H */ diff --git a/src/sys/ubixfsv2/ubixfs.cpp b/src/sys/ubixfsv2/ubixfs.cpp index 17118e8..06cb0b3 100644 --- a/src/sys/ubixfsv2/ubixfs.cpp +++ b/src/sys/ubixfsv2/ubixfs.cpp @@ -5,7 +5,7 @@ #include "ubixfs.h" #include "btree.h" -UbixFS::UbixFS(dev_t * dev) { +UbixFS::UbixFS(device_interface * dev) { device = dev; freeBlockList = NULL; } // UbixFS::UbixFS @@ -166,11 +166,16 @@ memset(inode, 0, sizeof(ubixfsInode)); // inode->magic1 = ; - if (parent == NULL) + if (parent == NULL) { inode->inodeNum = getFreeBlock(); - else + inode->parent.iAddr.allocationGroup = 0; + inode->parent.iAddr.start = 0; + inode->parent.iAddr.len = 0; + } else { inode->inodeNum = getFreeBlock(parent->inodeNum.allocationGroup); - + inode->parent.iAddr = parent->inodeNum; + } // else + strncpy(inode->name, filename, MAX_FILENAME_LENGTH); inode->uid = getuid(); @@ -181,7 +186,6 @@ // inode->lastModifiedTime // inode->type inode->inodeSize = superBlock->inodeSize; - // inode->parent = /* * next and prev are used in memory to hold pointers to the next/prev @@ -200,8 +204,13 @@ } // UbixFS::mknod int -UbixFS::vfs_format(dev_t * dev) { +UbixFS::vfs_format(device_interface * dev) { if (dev == NULL) return -1; +// ubixDiskLabel *d = new ubixDiskLabel; + diskSuperBlock *sb = new diskSuperBlock; + if (sb == NULL) return -1; + memset(sb, 0, sizeof(diskSuperBlock)); + return 0; } // UbixFS::vfs_format diff --git a/src/sys/ubixfsv2/ubixfs.h b/src/sys/ubixfsv2/ubixfs.h index 51abdbb..f6e543d 100644 --- a/src/sys/ubixfsv2/ubixfs.h +++ b/src/sys/ubixfsv2/ubixfs.h @@ -4,6 +4,22 @@ #include #include #include "fsAbstract.h" +#include "types.h" + +#define INODE_IN_USE 0x00000001 +#define ATTR_INODE 0x00000004 +#define INODE_LOGGED 0x00000008 +#define INODE_DELETED 0x00000010 +#define PERMANENT_FLAGS 0x0000ffff +#define INODE_NO_CACHE 0x00010000 +#define INODE_WAS_WRITTEN 0x00020000 +#define NO_TRANSACTION 0x00040000 + +#define NUM_DIRECT_BLOCKS 64 +#define MAX_FILENAME_LENGTH 256 + +struct bNode; +struct ubixfsInode; typedef struct blockRun { int allocationGroup __attribute__ ((packed)); @@ -11,13 +27,12 @@ unsigned short len __attribute__ ((packed)); } inodeAddr; -// typedef unsigned long long off_t; -typedef signed char int8; -typedef unsigned char uInt8; -typedef unsigned int uInt32; -typedef int int32; -typedef unsigned long long uInt64; -typedef signed long long int64; +typedef union uPtr { + inodeAddr iAddr; + bNode * bPtr; + ubixfsInode * iPtr; + off_t offset; +}; typedef struct diskSuperBlock { char name[32] __attribute__ ((packed)); @@ -61,18 +76,6 @@ } diskSuperBlock; -#define INODE_IN_USE 0x00000001 -#define ATTR_INODE 0x00000004 -#define INODE_LOGGED 0x00000008 -#define INODE_DELETED 0x00000010 -#define PERMANENT_FLAGS 0x0000ffff -#define INODE_NO_CACHE 0x00010000 -#define INODE_WAS_WRITTEN 0x00020000 -#define NO_TRANSACTION 0x00040000 - -#define NUM_DIRECT_BLOCKS 64 -#define MAX_FILENAME_LENGTH 256 - typedef struct dataStream { struct blockRun direct[NUM_DIRECT_BLOCKS]; off_t maxDirectRange; @@ -83,15 +86,6 @@ off_t size; } dataStream; -struct ubixfsInode; -struct bNode; - -typedef union uPtr { - inodeAddr iAddr; - bNode * bPtr; - ubixfsInode * iPtr; - off_t offset; -}; typedef struct ubixfsInode { int32 magic1 __attribute__ ((packed)); @@ -124,9 +118,9 @@ void * mknod(const char *, ubixfsInode *); uInt32 getNextAG(void); public: - UbixFS(dev_t *); + UbixFS(device_interface *); virtual int vfs_init(void); - virtual int vfs_format(dev_t *); + virtual int vfs_format(device_interface *); virtual void * vfs_mknod(const char *, mode_t); virtual ~UbixFS(void); }; // UbixFS