git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implemented Dependency resolving for compile-time modules and Updated the README
[tpg/acess2.git]
/
Kernel
/
vfs
/
fs
/
ext2.c
diff --git
a/Kernel/vfs/fs/ext2.c
b/Kernel/vfs/fs/ext2.c
index
50be904
..
0b60e54
100644
(file)
--- a/
Kernel/vfs/fs/ext2.c
+++ b/
Kernel/vfs/fs/ext2.c
@@
-5,9
+5,10
@@
/**
\r
* \file fs/ext2.c
\r
* \brief Second Extended Filesystem Driver
\r
/**
\r
* \file fs/ext2.c
\r
* \brief Second Extended Filesystem Driver
\r
- * \todo Implement file
read
support
\r
+ * \todo Implement file
full write
support
\r
*/
\r
#define DEBUG 1
\r
*/
\r
#define DEBUG 1
\r
+#define VERBOSE 0
\r
#include <common.h>
\r
#include <vfs.h>
\r
#include <modules.h>
\r
#include <common.h>
\r
#include <vfs.h>
\r
#include <modules.h>
\r
@@
-69,7
+70,7
@@
int Ext2_Install(char **Arguments)
}
\r
\r
/**
\r
}
\r
\r
/**
\r
- \fn tVFS_Node *Ext2_
i
nitDevice(char *Device, char **Options)
\r
+ \fn tVFS_Node *Ext2_
I
nitDevice(char *Device, char **Options)
\r
\brief Initializes a device to be read by by the driver
\r
\param Device String - Device to read from
\r
\param Options NULL Terminated array of option strings
\r
\brief Initializes a device to be read by by the driver
\r
\param Device String - Device to read from
\r
\param Options NULL Terminated array of option strings
\r
@@
-88,7
+89,7
@@
tVFS_Node *Ext2_InitDevice(char *Device, char **Options)
// Open Disk
\r
fd = VFS_Open(Device, VFS_OPENFLAG_READ|VFS_OPENFLAG_WRITE); //Open Device
\r
if(fd == -1) {
\r
// Open Disk
\r
fd = VFS_Open(Device, VFS_OPENFLAG_READ|VFS_OPENFLAG_WRITE); //Open Device
\r
if(fd == -1) {
\r
- Warning("[EXT2 ] Unable to open '%s'
\n
", Device);
\r
+ Warning("[EXT2 ] Unable to open '%s'", Device);
\r
LEAVE('n');
\r
return NULL;
\r
}
\r
LEAVE('n');
\r
return NULL;
\r
}
\r
@@
-98,7
+99,7
@@
tVFS_Node *Ext2_InitDevice(char *Device, char **Options)
\r
// Sanity Check Magic value
\r
if(sb.s_magic != 0xEF53) {
\r
\r
// Sanity Check Magic value
\r
if(sb.s_magic != 0xEF53) {
\r
- Warning("[EXT2 ] Volume '%s' is not an EXT2 volume
\n
", Device);
\r
+ Warning("[EXT2 ] Volume '%s' is not an EXT2 volume", Device);
\r
VFS_Close(fd);
\r
LEAVE('n');
\r
return NULL;
\r
VFS_Close(fd);
\r
LEAVE('n');
\r
return NULL;
\r
@@
-111,7
+112,7
@@
tVFS_Node *Ext2_InitDevice(char *Device, char **Options)
// Allocate Disk Information
\r
disk = malloc(sizeof(tExt2_Disk) + sizeof(tExt2_Group)*groupCount);
\r
if(!disk) {
\r
// Allocate Disk Information
\r
disk = malloc(sizeof(tExt2_Disk) + sizeof(tExt2_Group)*groupCount);
\r
if(!disk) {
\r
- Warning("[EXT2 ] Unable to allocate disk structure
\n
");
\r
+ Warning("[EXT2 ] Unable to allocate disk structure");
\r
VFS_Close(fd);
\r
LEAVE('n');
\r
return NULL;
\r
VFS_Close(fd);
\r
LEAVE('n');
\r
return NULL;
\r
@@
-135,7
+136,7
@@
tVFS_Node *Ext2_InitDevice(char *Device, char **Options)
disk->Groups
\r
);
\r
\r
disk->Groups
\r
);
\r
\r
- #if
DEBUG
\r
+ #if
VERBOSE
\r
LOG("Block Group 0");
\r
LOG(".bg_block_bitmap = 0x%x", disk->Groups[0].bg_block_bitmap);
\r
LOG(".bg_inode_bitmap = 0x%x", disk->Groups[0].bg_inode_bitmap);
\r
LOG("Block Group 0");
\r
LOG(".bg_block_bitmap = 0x%x", disk->Groups[0].bg_block_bitmap);
\r
LOG(".bg_inode_bitmap = 0x%x", disk->Groups[0].bg_inode_bitmap);
\r
@@
-218,7
+219,7
@@
Uint64 Ext2_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
Offset = Offset / disk->BlockSize;
\r
base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);
\r
if(base == 0) {
\r
Offset = Offset / disk->BlockSize;
\r
base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);
\r
if(base == 0) {
\r
- Warning("[EXT2 ] NULL Block Detected in INode 0x%llx
\n
", Node->Inode);
\r
+ Warning("[EXT2 ] NULL Block Detected in INode 0x%llx", Node->Inode);
\r
LEAVE('i', 0);
\r
return 0;
\r
}
\r
LEAVE('i', 0);
\r
return 0;
\r
}
\r
@@
-243,7
+244,7
@@
Uint64 Ext2_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
{
\r
base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);
\r
if(base == 0) {
\r
{
\r
base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);
\r
if(base == 0) {
\r
- Warning("[EXT2 ] NULL Block Detected in INode 0x%llx
\n
", Node->Inode);
\r
+ Warning("[EXT2 ] NULL Block Detected in INode 0x%llx", Node->Inode);
\r
LEAVE('i', 0);
\r
return 0;
\r
}
\r
LEAVE('i', 0);
\r
return 0;
\r
}
\r
@@
-336,7
+337,7
@@
addBlocks:
}
\r
\r
/**
\r
}
\r
\r
/**
\r
- * \fn void Ext2_CloseFile(
vfs_n
ode *Node)
\r
+ * \fn void Ext2_CloseFile(
tVFS_N
ode *Node)
\r
* \brief Close a file (Remove it from the cache)
\r
*/
\r
void Ext2_CloseFile(tVFS_Node *Node)
\r
* \brief Close a file (Remove it from the cache)
\r
*/
\r
void Ext2_CloseFile(tVFS_Node *Node)
\r
@@
-367,7
+368,7
@@
char *Ext2_ReadDir(tVFS_Node *Node, int Pos)
Ext2_int_GetInode(Node, &inode);
\r
size = inode.i_size;
\r
\r
Ext2_int_GetInode(Node, &inode);
\r
size = inode.i_size;
\r
\r
- LOG("inode.i_block[0] = 0x%x
\n
", inode.i_block[0]);
\r
+ LOG("inode.i_block[0] = 0x%x", inode.i_block[0]);
\r
\r
// Find Entry
\r
// Get First Block
\r
\r
// Find Entry
\r
// Get First Block
\r
@@
-383,7
+384,7
@@
char *Ext2_ReadDir(tVFS_Node *Node, int Pos)
if(ofs >= disk->BlockSize) {
\r
block ++;
\r
if( ofs > disk->BlockSize ) {
\r
if(ofs >= disk->BlockSize) {
\r
block ++;
\r
if( ofs > disk->BlockSize ) {
\r
- Warning("[EXT2] Directory Entry %i of inode %i extends over a block boundary, ignoring
\n
",
\r
+ Warning("[EXT2] Directory Entry %i of inode %i extends over a block boundary, ignoring",
\r
entNum-1, Node->Inode);
\r
}
\r
ofs = 0;
\r
entNum-1, Node->Inode);
\r
}
\r
ofs = 0;
\r
@@
-391,13
+392,17
@@
char *Ext2_ReadDir(tVFS_Node *Node, int Pos)
}
\r
}
\r
\r
}
\r
}
\r
\r
- if(size <= 0) return NULL;
\r
+ // Check for the end of the list
\r
+ if(size <= 0) {
\r
+ LEAVE('n');
\r
+ return NULL;
\r
+ }
\r
\r
// Read Entry
\r
VFS_ReadAt( disk->FD, Base+ofs, sizeof(tExt2_DirEnt), &dirent );
\r
\r
// Read Entry
\r
VFS_ReadAt( disk->FD, Base+ofs, sizeof(tExt2_DirEnt), &dirent );
\r
- //LOG("dirent.inode = %i
\n
", dirent.inode);
\r
- //LOG("dirent.rec_len = %i
\n
", dirent.rec_len);
\r
- //LOG("dirent.name_len = %i
\n
", dirent.name_len);
\r
+ //LOG("dirent.inode = %i", dirent.inode);
\r
+ //LOG("dirent.rec_len = %i", dirent.rec_len);
\r
+ //LOG("dirent.name_len = %i", dirent.name_len);
\r
VFS_ReadAt( disk->FD, Base+ofs+sizeof(tExt2_DirEnt), dirent.name_len, namebuf );
\r
namebuf[ dirent.name_len ] = '\0'; // Cap off string
\r
\r
VFS_ReadAt( disk->FD, Base+ofs+sizeof(tExt2_DirEnt), dirent.name_len, namebuf );
\r
namebuf[ dirent.name_len ] = '\0'; // Cap off string
\r
\r
@@
-457,7
+462,7
@@
tVFS_Node *Ext2_FindDir(tVFS_Node *Node, char *Filename)
if(ofs >= disk->BlockSize) {
\r
block ++;
\r
if( ofs > disk->BlockSize ) {
\r
if(ofs >= disk->BlockSize) {
\r
block ++;
\r
if( ofs > disk->BlockSize ) {
\r
- Warning("[EXT2 ] Directory Entry %i of inode %i extends over a block boundary, ignoring
\n
",
\r
+ Warning("[EXT2 ] Directory Entry %i of inode %i extends over a block boundary, ignoring",
\r
entNum-1, Node->Inode);
\r
}
\r
ofs = 0;
\r
entNum-1, Node->Inode);
\r
}
\r
ofs = 0;
\r
@@
-483,11
+488,11
@@
int Ext2_MkNod(tVFS_Node *Parent, char *Name, Uint Flags)
\r
\r
/**
\r
\r
\r
/**
\r
-
\fn int Ext2_int_GetInode(vfs_n
ode *Node, tExt2_Inode *Inode)
\r
- \brief Gets the inode descriptor for a node
\r
-
\param node
node to get the Inode of
\r
-
\param inode
Destination
\r
-*/
\r
+
* \fn int Ext2_int_GetInode(tVFS_N
ode *Node, tExt2_Inode *Inode)
\r
+
*
\brief Gets the inode descriptor for a node
\r
+
* \param Node
node to get the Inode of
\r
+
* \param Inode
Destination
\r
+
*/
\r
int Ext2_int_GetInode(tVFS_Node *Node, tExt2_Inode *Inode)
\r
{
\r
return Ext2_int_ReadInode(Node->ImplPtr, Node->Inode, Inode);
\r
int Ext2_int_GetInode(tVFS_Node *Node, tExt2_Inode *Inode)
\r
{
\r
return Ext2_int_ReadInode(Node->ImplPtr, Node->Inode, Inode);
\r
@@
-573,7
+578,8
@@
int Ext2_int_ReadInode(tExt2_Disk *Disk, Uint InodeId, tExt2_Inode *Inode)
{
\r
int group, subId;
\r
\r
{
\r
int group, subId;
\r
\r
- //LogF("Ext2_int_ReadInode: (Disk=%p, InodeId=%i, Inode=%p)\n", Disk, InodeId, Inode);
\r
+ //LogF("Ext2_int_ReadInode: (Disk=%p, InodeId=%i, Inode=%p)", Disk, InodeId, Inode);
\r
+ //ENTER("pDisk iInodeId pInode", Disk, InodeId, Inode);
\r
\r
if(InodeId == 0) return 0;
\r
\r
\r
if(InodeId == 0) return 0;
\r
\r
@@
-582,7
+588,7
@@
int Ext2_int_ReadInode(tExt2_Disk *Disk, Uint InodeId, tExt2_Inode *Inode)
group = InodeId / Disk->SuperBlock.s_inodes_per_group;
\r
subId = InodeId % Disk->SuperBlock.s_inodes_per_group;
\r
\r
group = InodeId / Disk->SuperBlock.s_inodes_per_group;
\r
subId = InodeId % Disk->SuperBlock.s_inodes_per_group;
\r
\r
- //L
ogF(" Ext2_int_ReadInode: group=%i, subId = %i\n
", group, subId);
\r
+ //L
OG("group=%i, subId = %i
", group, subId);
\r
\r
// Read Inode
\r
VFS_ReadAt(Disk->FD,
\r
\r
// Read Inode
\r
VFS_ReadAt(Disk->FD,
\r
UCC
git Repository :: git.ucc.asn.au