for( ent = gSysFS_FileList; ent; ent = ent->Next )
{
// It's a reverse sorted list
- if(ent->Node.Inode < ID) return 0;
- if(ent->Node.Inode == ID)
+ if(ent->Node.Inode < (Uint64)ID)
+ return 0;
+ if(ent->Node.Inode == (Uint64)ID)
{
ent->Node.ImplPtr = (void*)Data;
ent->Node.Size = Length;
for( ent = gSysFS_FileList; ent; prev = ent, ent = ent->Next )
{
// It's a reverse sorted list
- if(ent->Node.Inode < ID) return 0;
- if(ent->Node.Inode == ID) break;
+ if(ent->Node.Inode < (Uint64)ID) return 0;
+ if(ent->Node.Inode == (Uint64)ID) break;
}
if(!ent) return 0;
char *SysFS_Comm_ReadDir(tVFS_Node *Node, int Pos)
{
tSysFS_Ent *child = (tSysFS_Ent*)Node->ImplPtr;
- if(Pos < 0 || Pos >= Node->Size) return NULL;
+ if(Pos < 0 || (Uint64)Pos >= Node->Size) return NULL;
for( ; child; child = child->Next, Pos-- )
{
#include <api_drv_disk.h>
// --- Disk Driver Helpers ---
-Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,
- tDrvUtil_Read_Callback ReadBlocks, Uint64 BlockSize, void *Argument)
+size_t DrvUtil_ReadBlock(Uint64 Start, size_t Length, void *Buffer,
+ tDrvUtil_Read_Callback ReadBlocks, size_t BlockSize, void *Argument)
{
Uint8 tmp[BlockSize]; // C99
Uint64 block = Start / BlockSize;
int offset = Start - block * BlockSize;
- int leading = BlockSize - offset;
+ size_t leading = BlockSize - offset;
Uint64 num;
int tailings;
- Uint64 ret;
+ size_t ret;
ENTER("XStart XLength pBuffer pReadBlocks XBlockSize pArgument",
Start, Length, Buffer, ReadBlocks, BlockSize, Argument);
return Length;
}
-Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, const void *Buffer,
+size_t DrvUtil_WriteBlock(Uint64 Start, size_t Length, const void *Buffer,
tDrvUtil_Read_Callback ReadBlocks, tDrvUtil_Write_Callback WriteBlocks,
- Uint64 BlockSize, void *Argument)
+ size_t BlockSize, void *Argument)
{
Uint8 tmp[BlockSize]; // C99
Uint64 block = Start / BlockSize;
- int offset = Start - block * BlockSize;
- int leading = BlockSize - offset;
+ size_t offset = Start - block * BlockSize;
+ size_t leading = BlockSize - offset;
Uint64 num;
int tailings;
- Uint64 ret;
+ size_t ret;
ENTER("XStart XLength pBuffer pReadBlocks pWriteBlocks XBlockSize pArgument",
Start, Length, Buffer, ReadBlocks, WriteBlocks, BlockSize, Argument);
* \param Argument An argument to pass to \a ReadBlocks\r
* \return Number of bytes read\r
*/\r
-extern Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,\r
- tDrvUtil_Read_Callback ReadBlocks, Uint64 BlockSize, void *Argument);\r
+extern size_t DrvUtil_ReadBlock(Uint64 Start, size_t Length, void *Buffer,\r
+ tDrvUtil_Read_Callback ReadBlocks, size_t BlockSize, void *Argument);\r
/**\r
* \brief Writes a range to a block device using aligned writes\r
* \param Start Base byte offset\r
* \param Argument An argument to pass to \a ReadBlocks and \a WriteBlocks\r
* \return Number of bytes written\r
*/\r
-extern Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, const void *Buffer,\r
+extern size_t DrvUtil_WriteBlock(Uint64 Start, size_t Length, const void *Buffer,\r
tDrvUtil_Read_Callback ReadBlocks, tDrvUtil_Write_Callback WriteBlocks,\r
- Uint64 BlockSize, void *Argument);\r
+ size_t BlockSize, void *Argument);\r
\r
/**\r
* \}\r
* \param Buffer Destination of read data
* \return Number of read bytes
*/
-extern Uint64 VFS_Read(int FD, Uint64 Length, void *Buffer);
+extern size_t VFS_Read(int FD, size_t Length, void *Buffer);
/**
* \brief Writes data to a file
* \param FD File handle returned by ::VFS_Open
* \param Buffer Source of written data
* \return Number of bytes written
*/
-extern Uint64 VFS_Write(int FD, Uint64 Length, const void *Buffer);
+extern size_t VFS_Write(int FD, size_t Length, const void *Buffer);
/**
* \brief Reads from a specific offset in the file
* \param Buffer Source of read data
* \return Number of bytes read
*/
-extern Uint64 VFS_ReadAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer);
+extern size_t VFS_ReadAt(int FD, Uint64 Offset, size_t Length, void *Buffer);
/**
* \brief Writes to a specific offset in the file
* \param FD File handle returned by ::VFS_Open
* \param Buffer Source of written data
* \return Number of bytes written
*/
-extern Uint64 VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length, const void *Buffer);
+extern size_t VFS_WriteAt(int FD, Uint64 Offset, size_t Length, const void *Buffer);
/**
* \brief Sends an IOCtl request to the driver
{
// ASCII Range
if(Search < 128) {
- if(str[pos] == Search) return pos;
+ if(str[pos] == (char)Search) return pos;
continue;
}
if(*(Uint8*)(str+pos) < 128) continue;
int Hex(char *Dest, size_t Size, const Uint8 *SourceData)
{
- int i;
+ size_t i;
for( i = 0; i < Size; i ++ )
{
sprintf(Dest + i*2, "%02x", SourceData[i]);
*/
int UnHex(Uint8 *Dest, size_t DestSize, const char *SourceString)
{
- int i;
-
+ size_t i;
for( i = 0; i < DestSize*2; i += 2 )
{
Uint8 val = 0;
return 0;
}
- if(h->Node->Size != -1 && h->Position >= h->Node->Size) {
+ if(h->Node->Size != (Uint64)-1 && h->Position >= h->Node->Size) {
//LEAVE('i', 0);
return 0;
}
*/
#define DEBUG 0
#include <acess.h>
-#include "vfs.h"
-#include "vfs_int.h"
+#include <vfs.h>
+#include <vfs_ext.h>
+#include <vfs_int.h>
// === CODE ===
/**
* \fn Uint64 VFS_Read(int FD, Uint64 Length, void *Buffer)
* \brief Read data from a node (file)
*/
-Uint64 VFS_Read(int FD, Uint64 Length, void *Buffer)
+size_t VFS_Read(int FD, size_t Length, void *Buffer)
{
tVFS_Handle *h;
- Uint64 ret;
+ size_t ret;
ENTER("iFD XLength pBuffer", FD, Length, Buffer);
}
ret = h->Node->Type->Read(h->Node, h->Position, Length, Buffer);
- if(ret == -1) LEAVE_RET('i', -1);
+ if(ret == (size_t)-1) LEAVE_RET('i', -1);
h->Position += ret;
LEAVE('X', ret);
* \fn Uint64 VFS_ReadAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Read data from a given offset (atomic)
*/
-Uint64 VFS_ReadAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer)
+size_t VFS_ReadAt(int FD, Uint64 Offset, size_t Length, void *Buffer)
{
tVFS_Handle *h;
- Uint64 ret;
+ size_t ret;
h = VFS_GetHandle(FD);
if(!h) return -1;
}
ret = h->Node->Type->Read(h->Node, Offset, Length, Buffer);
- if(ret == -1) return -1;
+ if(ret == (size_t)-1) return -1;
return ret;
}
* \fn Uint64 VFS_Write(int FD, Uint64 Length, const void *Buffer)
* \brief Read data from a node (file)
*/
-Uint64 VFS_Write(int FD, Uint64 Length, const void *Buffer)
+size_t VFS_Write(int FD, size_t Length, const void *Buffer)
{
tVFS_Handle *h;
- Uint64 ret;
+ size_t ret;
h = VFS_GetHandle(FD);
if(!h) return -1;
}
ret = h->Node->Type->Write(h->Node, h->Position, Length, Buffer);
- if(ret == -1) return -1;
+ if(ret == (size_t)-1) return -1;
h->Position += ret;
return ret;
* \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, const void *Buffer)
+size_t VFS_WriteAt(int FD, Uint64 Offset, size_t Length, const void *Buffer)
{
tVFS_Handle *h;
- Uint64 ret;
+ size_t ret;
h = VFS_GetHandle(FD);
if(!h) return -1;
return -1;
}
ret = h->Node->Type->Write(h->Node, Offset, Length, Buffer);
- if(ret == -1) return -1;
+ if(ret == (size_t)-1) return -1;
return ret;
}
// Set relative to end of file
if(Whence < 0) {
- if( h->Node->Size == -1 ) return -1;
+ if( h->Node->Size == (Uint64)-1 ) return -1;
h->Position = h->Node->Size - Offset;
return 0;
EXPORT(VFS_AddDriver);
// === GLOBALS ===
-tVFS_Node NULLNode = {0};
+tVFS_Node NULLNode = {.Type=NULL};
tShortSpinlock slDriverListLock;
tVFS_Driver *gVFS_Drivers = NULL;
char *gsVFS_DriverFile = NULL;
Uint32 ClusterCount; //!< Total Cluster Count
fat_bootsect bootsect; //!< Boot Sector
tVFS_Node rootNode; //!< Root Node
- int BytesPerCluster;
+ size_t BytesPerCluster;
tMutex lNodeCache;
tFAT_CachedNode *NodeCache;
while(extendedLBA != 0)
{
extendedLBA = LVM_MBR_int_ReadExt(Volume, extendedLBA, &base, &len);
- if( extendedLBA == -1 ) break;
+ if( extendedLBA == (Uint64)-1 )
+ break;
numPartitions ++;
}
LOG("numPartitions = %i", numPartitions);
while(extendedLBA != 0)
{
extendedLBA = LVM_MBR_int_ReadExt(Volume, extendedLBA, &base, &len);
- if(extendedLBA == -1) break;
+ if(extendedLBA == (Uint64)-1)
+ break;
LVM_int_SetSubvolume_Anon( Volume, j, base, len );
j ++ ;
}
// Translate path
size_t tpath_len = DiskTool_int_TranslatePath(NULL, Path);
- if(tpath_len == -1)
- return -1;
char tpath[tpath_len-1];
DiskTool_int_TranslatePath(tpath, Path);
int DiskTool_int_TranslateOpen(const char *File, int Flags)
{
size_t tpath_len = DiskTool_int_TranslatePath(NULL, File);
- if(tpath_len == -1)
+ if(tpath_len == 0)
return -1;
char tpath[tpath_len-1];
DiskTool_int_TranslatePath(tpath, File);