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
Usermode/ld-acess - Added two more ARM relocation types
[tpg/acess2.git]
/
Kernel
/
vfs
/
io.c
diff --git
a/Kernel/vfs/io.c
b/Kernel/vfs/io.c
index
67a7075
..
358d703
100644
(file)
--- a/
Kernel/vfs/io.c
+++ b/
Kernel/vfs/io.c
@@
-2,22
+2,11
@@
* AcessMicro VFS
* - File IO Passthru's
*/
* AcessMicro VFS
* - File IO Passthru's
*/
-#include <common.h>
+#define DEBUG 0
+#include <acess.h>
#include "vfs.h"
#include "vfs_int.h"
#include "vfs.h"
#include "vfs_int.h"
-#define DEBUG 0
-
-#if DEBUG
-#else
-# undef ENTER
-# undef LOG
-# undef LEAVE
-# define ENTER(...)
-# define LOG(...)
-# define LEAVE(...)
-#endif
-
// === CODE ===
/**
* \fn Uint64 VFS_Read(int FD, Uint64 Length, void *Buffer)
// === CODE ===
/**
* \fn Uint64 VFS_Read(int FD, Uint64 Length, void *Buffer)
@@
-31,23
+20,15
@@
Uint64 VFS_Read(int FD, Uint64 Length, void *Buffer)
ENTER("iFD XLength pBuffer", FD, Length, Buffer);
h = VFS_GetHandle(FD);
ENTER("iFD XLength pBuffer", FD, Length, Buffer);
h = VFS_GetHandle(FD);
- if(!h)
return -1
;
+ if(!h)
LEAVE_RET('i', -1)
;
- if( !(h->Mode & VFS_OPENFLAG_READ) || h->Node->Flags & VFS_FFLAG_DIRECTORY ) {
- LEAVE('i', -1);
- return -1;
- }
+ if( !(h->Mode & VFS_OPENFLAG_READ) || h->Node->Flags & VFS_FFLAG_DIRECTORY )
+ LEAVE_RET('i', -1);
- if(!h->Node->Read) {
- LEAVE('i', 0);
- return 0;
- }
+ if(!h->Node->Read) LEAVE_RET('i', 0);
ret = h->Node->Read(h->Node, h->Position, Length, Buffer);
ret = h->Node->Read(h->Node, h->Position, Length, Buffer);
- if(ret == -1) {
- LEAVE('i', -1);
- return -1;
- }
+ if(ret == -1) LEAVE_RET('i', -1);
h->Position += ret;
LEAVE('X', ret);
h->Position += ret;
LEAVE('X', ret);
@@
-79,10
+60,10
@@
Uint64 VFS_ReadAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer)
}
/**
}
/**
- * \fn Uint64 VFS_Write(int FD, Uint64 Length, void *Buffer)
+ * \fn Uint64 VFS_Write(int FD, Uint64 Length,
const
void *Buffer)
* \brief Read data from a node (file)
*/
* \brief Read data from a node (file)
*/
-Uint64 VFS_Write(int FD, Uint64 Length, void *Buffer)
+Uint64 VFS_Write(int FD, Uint64 Length,
const
void *Buffer)
{
tVFS_Handle *h;
Uint64 ret;
{
tVFS_Handle *h;
Uint64 ret;
@@
-95,17
+76,18
@@
Uint64 VFS_Write(int FD, Uint64 Length, void *Buffer)
if(!h->Node->Write) return 0;
if(!h->Node->Write) return 0;
- ret = h->Node->Write(h->Node, h->Position, Length, Buffer);
+ // TODO: This is a hack, I need to change VFS_Node to have "const void*"
+ ret = h->Node->Write(h->Node, h->Position, Length, (void*)Buffer);
if(ret == -1) return -1;
h->Position += ret;
return ret;
}
/**
if(ret == -1) return -1;
h->Position += ret;
return ret;
}
/**
- * \fn Uint64 VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer)
- * \brief Write data to a file at a given offset
(atomic)
+ * \fn Uint64 VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length,
const
void *Buffer)
+ * \brief Write data to a file at a given offset
*/
*/
-Uint64 VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length,
const
void *Buffer)
{
tVFS_Handle *h;
Uint64 ret;
{
tVFS_Handle *h;
Uint64 ret;
@@
-117,7
+99,8
@@
Uint64 VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer)
if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) return -1;
if(!h->Node->Write) return 0;
if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) return -1;
if(!h->Node->Write) return 0;
- ret = h->Node->Write(h->Node, Offset, Length, Buffer);
+ // TODO: This is a hack, I need to change VFS_Node to have "const void*"
+ ret = h->Node->Write(h->Node, Offset, Length, (void*)Buffer);
if(ret == -1) return -1;
return ret;
}
if(ret == -1) return -1;
return ret;
}
@@
-137,33
+120,38
@@
Uint64 VFS_Tell(int FD)
}
/**
}
/**
- * \fn int VFS_Seek(int FD, Sint64
Distance
, int Whence)
+ * \fn int VFS_Seek(int FD, Sint64
Offset
, int Whence)
* \brief Seek to a new location
* \param FD File descriptor
* \brief Seek to a new location
* \param FD File descriptor
- * \param
Distance
Where to go
+ * \param
Offset
Where to go
* \param Whence From where
*/
* \param Whence From where
*/
-int VFS_Seek(int FD, Sint64
Distance
, int Whence)
+int VFS_Seek(int FD, Sint64
Offset
, int Whence)
{
tVFS_Handle *h;
h = VFS_GetHandle(FD);
if(!h) return -1;
{
tVFS_Handle *h;
h = VFS_GetHandle(FD);
if(!h) return -1;
+ //Log_Debug("VFS", "VFS_Seek: (fd=0x%x, Offset=0x%llx, Whence=%i)",
+ // FD, Offset, Whence);
+
// Set relative to current position
if(Whence == 0) {
// Set relative to current position
if(Whence == 0) {
- h->Position +=
Distance
;
+ h->Position +=
Offset
;
return 0;
}
// Set relative to end of file
if(Whence < 0) {
return 0;
}
// Set relative to end of file
if(Whence < 0) {
- h->Position = h->Node->Size - Distance;
+ if( h->Node->Size == -1 ) return -1;
+
+ h->Position = h->Node->Size - Offset;
return 0;
}
// Set relative to start of file
return 0;
}
// Set relative to start of file
- h->Position =
Distance
;
+ h->Position =
Offset
;
return 0;
}
return 0;
}
@@
-183,18
+171,23
@@
int VFS_IOCtl(int FD, int ID, void *Buffer)
}
/**
}
/**
- * \fn int VFS_FInfo(int FD,
struct s_sys
FInfo *Dest, int MaxACLs)
+ * \fn int VFS_FInfo(int FD,
t
FInfo *Dest, int MaxACLs)
* \brief Retrieve file information
* \return Number of ACLs stored
*/
* \brief Retrieve file information
* \return Number of ACLs stored
*/
-int VFS_FInfo(int FD,
struct s_sys
FInfo *Dest, int MaxACLs)
+int VFS_FInfo(int FD,
t
FInfo *Dest, int MaxACLs)
{
tVFS_Handle *h;
int max;
h = VFS_GetHandle(FD);
if(!h) return -1;
{
tVFS_Handle *h;
int max;
h = VFS_GetHandle(FD);
if(!h) return -1;
-
+
+ if( h->Mount )
+ Dest->mount = h->Mount->Identifier;
+ else
+ Dest->mount = 0;
+ Dest->inode = h->Node->Inode;
Dest->uid = h->Node->UID;
Dest->gid = h->Node->GID;
Dest->size = h->Node->Size;
Dest->uid = h->Node->UID;
Dest->gid = h->Node->GID;
Dest->size = h->Node->Size;
UCC
git Repository :: git.ucc.asn.au