typedef Uint32 tMount;
// === CONSTANTS ===
+//! Maximum length of a filename (including NULL byte)
+#define FILENAME_MAX 256
//! Maximum size of a Memory Path generated by VFS_GetMemPath
#define VFS_MEMPATH_SIZE (3 + (BITS/4)*2)
/**
* \{
*/
//! Open for execution
-#define VFS_OPENFLAG_EXEC 0x01
+#define VFS_OPENFLAG_EXEC 0x001
//! Open for reading
-#define VFS_OPENFLAG_READ 0x02
+#define VFS_OPENFLAG_READ 0x002
//! Open for writing
-#define VFS_OPENFLAG_WRITE 0x04
+#define VFS_OPENFLAG_WRITE 0x004
//! Do not resolve the final symbolic link
-#define VFS_OPENFLAG_NOLINK 0x40
+#define VFS_OPENFLAG_NOLINK 0x040
//! Create the file if it doesn't exist
-#define VFS_OPENFLAG_CREATE 0x80
+#define VFS_OPENFLAG_CREATE 0x080
+//! Open file as non-blocking
+#define VFS_OPENFLAG_NONBLOCK 0x100
+//! Treat as a directory
+#define VFS_OPENFLAG_DIRECTORY 0x1000
//! Open as a user
#define VFS_OPENFLAG_USER 0x8000
/**
*/
typedef struct sVFS_ACL
{
+ //! ACL entity selection
struct {
unsigned Group: 1; //!< Group (as opposed to user) flag
unsigned ID: 31; //!< ID of Group/User (-1 for nobody/world)
- };
+ } Ent;
+ //! ACL Permissions mask
struct {
unsigned Inv: 1; //!< Invert Permissions
unsigned Perms: 31; //!< Permission Flags
- };
+ } Perm;
} tVFS_ACL;
/**
tVFS_ACL acls[]; //!< ACL buffer (size is passed in the \a MaxACLs argument to VFS_FInfo)
} PACKED tFInfo;
+// --- fd_set --
+#include "../../../Usermode/Libraries/ld-acess.so_src/include_exp/acess/fd_set.h"
+
+#if 0
/**
* \brief fd_set for select()
*/
* \param fdsetp Set to modify
*/
#define FD_ISSET(fd, fdsetp) ((fdsetp)->flags[(fd)/16]&(1<<((fd)%16)))
+#endif
// === FUNCTIONS ===
/**
*/
extern int VFS_OpenInode(Uint32 Mount, Uint64 Inode, int Mode);
+/**
+ * \brief Open a file reusing an old FD
+ */
+extern int VFS_Reopen(int FD, const char *Path, int Flags);
+
/**
* \brief Close a currently open file
* \param FD Handle returned by ::VFS_Open
*/
extern void VFS_Close(int FD);
+/**
+ * \brief Copy one FD to another
+ * \param SrcFD Source file descriptor
+ * \param DstFD Destination file descriptor (-1 means allocate new)
+ */
+extern int VFS_DuplicateFD(int SrcFD, int DstFD);
+
+/**
+ * \brief Update the flags on a FD
+ */
+extern int VFS_SetFDFlags(int FD, int Mask, int Value);
+
/**
* \brief Get file information from an open file
* \param FD File handle returned by ::VFS_Open
* \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
* \return 1 on succes, -1 on error
*/
extern int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options);
+/**
+ * \brief Unmount a mounted filesystem
+ * \param Mountpoint Location of the mount
+ * \return 0 on success, errno on error
+ */
+extern int VFS_Unmount(const char *Mountpoint);
+/**
+ * \brief Attemt to unmount all fileystems
+ * \return Number of unmounted filesytems, -1 if none left to unmount
+ * \note Can return 0 when there are stil volumes mounted if there are open handles
+ */
+extern int VFS_UnmountAll(void);
+
/**
* \brief Create a new directory
* \param Path Path to new directory (absolute or relative)
/**
* \brief Read from a directory
* \param FD File handle returned by ::VFS_Open
- * \param Dest Destination array for the file name (max 255 bytes)
+ * \param Dest Destination array for the file name (max FILENAME_MAX bytes)
* \return Boolean Success
*/
-extern int VFS_ReadDir(int FD, char *Dest);
+extern int VFS_ReadDir(int FD, char Dest[FILENAME_MAX]);
/**
* \brief Wait for an aciton on a file descriptor
* \param MaxHandle Maximum set handle in \a *Handles