X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Finclude%2Fvfs_ext.h;h=5e6b77ddb744c5101eb995909e068ff430f31122;hb=046980a1afd982af07dc97aaadb186e31eebb340;hp=2fd7fd372ad115591df75c4e807a8e9147edfb8a;hpb=bf7d1cd5635d41bd7c58bf99c61cdc670291c543;p=tpg%2Facess2.git diff --git a/Kernel/include/vfs_ext.h b/Kernel/include/vfs_ext.h index 2fd7fd37..5e6b77dd 100644 --- a/Kernel/include/vfs_ext.h +++ b/Kernel/include/vfs_ext.h @@ -8,7 +8,7 @@ // === CONSTANTS === //! Maximum size of a Memory Path generated by VFS_GetMemPath -#define VFS_MEMPATH_SIZE (3 + (BITS/8)*2) +#define VFS_MEMPATH_SIZE (3 + (BITS/4)*2) /** * \name Flags for VFS_Open * \{ @@ -29,6 +29,9 @@ //! Marks a VFS handle as belonging to the kernel #define VFS_KERNEL_FLAG 0x40000000 +//! Architectual maximum number of file descriptors +#define MAX_FILE_DESCS 128 + /** * \brief VFS_Seek directions */ @@ -104,12 +107,24 @@ typedef struct sFInfo tVFS_ACL acls[]; //!< ACL buffer (size is passed in the \a MaxACLs argument to VFS_FInfo) } tFInfo; +/** + * \brief fd_set for select() + */ +typedef struct +{ + Uint16 flags[MAX_FILE_DESCS/16]; +} fd_set; + +#define FD_CLR(fd, fdsetp) ((fdsetp)->flags[(fd)/16]&=~(1<<((fd)%16))) +#define FD_SET(fd, fdsetp) ((fdsetp)->flags[(fd)/16]|=~(1<<((fd)%16))) +#define FD_ISSET(fd, fdsetp) ((fdsetp)->flags[(fd)/16]&(1<<((fd)%16))) + // === FUNCTIONS === /** * \brief Initialise the VFS (called by system.c) * \return Boolean Success */ -extern int VFS_Init(); +extern int VFS_Init(void); /** * \brief Open a file @@ -117,7 +132,7 @@ extern int VFS_Init(); * \param Mode Flags defining how to open the file * \return VFS Handle (an integer) or -1 if an error occured */ -extern int VFS_Open(char *Path, Uint Mode); +extern int VFS_Open(const char *Path, Uint Mode); /** * \brief Close a currently open file * \param FD Handle returned by ::VFS_Open @@ -165,10 +180,10 @@ extern int VFS_ChRoot(char *New); * \brief Change the location of the current file pointer * \param FD File handle returned by ::VFS_Open * \param Offset Offset within the file to go to - * \param Direction A direction from ::eVFS_SeekDirs + * \param Whence A direction from ::eVFS_SeekDirs * \return Boolean success */ -extern int VFS_Seek(int FD, Sint64 Offset, int Direction); +extern int VFS_Seek(int FD, Sint64 Offset, int Whence); /** * \brief Returns the current file pointer * \param FD File handle returned by ::VFS_Open @@ -191,7 +206,7 @@ extern Uint64 VFS_Read(int FD, Uint64 Length, void *Buffer); * \param Buffer Source of written data * \return Number of bytes written */ -extern Uint64 VFS_Write(int FD, Uint64 Length, void *Buffer); +extern Uint64 VFS_Write(int FD, Uint64 Length, const void *Buffer); /** * \brief Reads from a specific offset in the file @@ -210,7 +225,7 @@ extern Uint64 VFS_ReadAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer); * \param Buffer Source of written data * \return Number of bytes written */ -extern Uint64 VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer); +extern Uint64 VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length, const void *Buffer); /** * \brief Sends an IOCtl request to the driver @@ -234,7 +249,7 @@ extern void VFS_GetMemPath(char *Dest, void *Base, Uint Length); * \param Path File path (may contain symlinks, relative elements etc.) * \return Absolute path with no symlinks */ -extern char *VFS_GetTruePath(char *Path); +extern char *VFS_GetTruePath(const char *Path); /** * \brief Mounts a filesystem @@ -244,21 +259,21 @@ extern char *VFS_GetTruePath(char *Path); * \param Options Options string to pass the driver * \return 1 on succes, -1 on error */ -extern int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options); +extern int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options); /** * \brief Create a new directory * \param Path Path to new directory (absolute or relative) * \return Boolean success * \note The parent of the directory must exist */ -extern int VFS_MkDir(char *Path); +extern int VFS_MkDir(const char *Path); /** * \brief Create a symbolic link * \param Name Name of the symbolic link * \param Link File the symlink points to * \return Boolean success (\a Link is not tested for existence) */ -extern int VFS_Symlink(char *Name, char *Link); +extern int VFS_Symlink(const char *Name, const char *Link); /** * \brief Read from a directory * \param FD File handle returned by ::VFS_Open @@ -266,5 +281,27 @@ extern int VFS_Symlink(char *Name, char *Link); * \return Boolean Success */ extern int VFS_ReadDir(int FD, char *Dest); +/** + * \brief Opens a file via an open directory + * \note The file to open must be a direct child of the parent + * \param Errno Error number + * \param FD Parent Directory + * \param Name Child name + * \param Mode Open mode + * \return File handle (same as returned from VFS_Open) + */ +extern int VFS_OpenChild(Uint *Errno, int FD, const char *Name, Uint Mode); + +/** + * \brief Wait for an aciton on a file descriptor + * \param MaxHandle Maximum set handle in \a *Handles + * \param ReadHandles Handles to wait for data on + * \param WriteHandles Handles to wait to write to + * \param ErrHandles Handle to wait for errors on + * \param Timeout Timeout for select() (if null, there is no timeout), if zero select() is non blocking + * \param IsKernel Use kernel handles as opposed to user handles + * \return Number of handles that actioned + */ +extern int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set *ErrHandles, tTime *Timeout, BOOL IsKernel); #endif