Kernel - Slight reworks to timer code
[tpg/acess2.git] / Kernel / include / vfs_ext.h
index d04fcf2..b4d5e2a 100644 (file)
@@ -6,7 +6,10 @@
 #ifndef _VFS_EXT_H
 #define _VFS_EXT_H
 
+//! Inode number type
 typedef Uint64 tInode;
+
+//! Mountpoint identifier type
 typedef Uint32 tMount;
 
 // === CONSTANTS ===
@@ -24,8 +27,10 @@ typedef Uint32       tMount;
 #define VFS_OPENFLAG_WRITE     0x04
 //! Do not resolve the final symbolic link
 #define        VFS_OPENFLAG_NOLINK     0x40
+//! Create the file if it doesn't exist
+#define VFS_OPENFLAG_CREATE    0x80
 //! Open as a user
-#define        VFS_OPENFLAG_USER       0x80
+#define        VFS_OPENFLAG_USER       0x8000
 /**
  * \}
  */
@@ -78,14 +83,28 @@ enum eVFS_SeekDirs
  * \}
  */
 
-#define MMAP_PROT_READ 0x001
-#define MMAP_PROT_WRITE        0x002
-#define MMAP_PROT_EXEC 0x004
+/**
+ * \brief MMap protection flags
+ * \{
+ */
+#define MMAP_PROT_READ 0x001   //!< Readable memory
+#define MMAP_PROT_WRITE        0x002   //!< Writable memory
+#define MMAP_PROT_EXEC 0x004   //!< Executable memory
+/**
+ * \}
+ */
 
-#define MMAP_MAP_SHARED        0x001
-#define MMAP_MAP_PRIVATE       0x002
-#define MMAP_MAP_FIXED         0x004
-#define MMAP_MAP_ANONYMOUS     0x008
+/**
+ * \brief MMap mapping flags
+ * \{
+ */
+#define MMAP_MAP_SHARED        0x001   //!< Shared with all other users of the FD
+#define MMAP_MAP_PRIVATE       0x002   //!< Local (COW) copy
+#define MMAP_MAP_FIXED         0x004   //!< Load to a fixed address
+#define MMAP_MAP_ANONYMOUS     0x008   //!< Not associated with a FD
+/**
+ * \}
+ */
 
 // -- System Call Structures ---
 /**
@@ -101,7 +120,7 @@ typedef struct sVFS_ACL
                unsigned Inv:   1;      //!< Invert Permissions
                unsigned Perms: 31;     //!< Permission Flags
        };
-}      tVFS_ACL;
+} tVFS_ACL;
 
 /**
  * \brief SYS_FINFO structure
@@ -119,18 +138,34 @@ typedef struct sFInfo
        Sint64  ctime;  //!< Creation time
        Sint32  numacls;        //!< Total number of ACL entries
        tVFS_ACL        acls[]; //!< ACL buffer (size is passed in the \a MaxACLs argument to VFS_FInfo)
-}      tFInfo;
+} PACKED tFInfo;
 
 /**
  * \brief fd_set for select()
  */
 typedef struct
 {
+       //! Bitmap of set file descriptors
        Uint16  flags[MAX_FILE_DESCS/16];
 }      fd_set;
 
+/**
+ * \brief Clear a descriptor flag in a fd_set
+ * \param fd   File descriptor to clear
+ * \param fdsetp       Set to modify
+ */
 #define FD_CLR(fd, fdsetp) ((fdsetp)->flags[(fd)/16]&=~(1<<((fd)%16)))
+/**
+ * \brief Set a descriptor flag in a fd_set
+ * \param fd   File descriptor to set
+ * \param fdsetp       Set to modify
+ */
 #define FD_SET(fd, fdsetp) ((fdsetp)->flags[(fd)/16]|=~(1<<((fd)%16)))
+/**
+ * \brief Test a descriptor flag in a fd_set
+ * \param fd   File descriptor to test
+ * \param fdsetp       Set to modify
+ */
 #define FD_ISSET(fd, fdsetp) ((fdsetp)->flags[(fd)/16]&(1<<((fd)%16)))
 
 // === FUNCTIONS ===
@@ -143,10 +178,19 @@ extern int        VFS_Init(void);
 /**
  * \brief Open a file
  * \param Path Absolute or relative path to the file
- * \param Mode Flags defining how to open the file
+ * \param Flags        Flags defining how to open the file
+ * \return VFS Handle (an integer) or -1 if an error occured
+ * \note Calls VFS_OpenEx(Path, Flags, 0)
+ */
+extern int     VFS_Open(const char *Path, Uint Flags);
+/**
+ * \brief Open a file
+ * \param Path Absolute or relative path to the file
+ * \param Flags        Flags defining how to open the file
+ * \param Mode Mode for newly created file (POSIX compatability)
  * \return VFS Handle (an integer) or -1 if an error occured
  */
-extern int     VFS_Open(const char *Path, Uint Mode);
+extern int     VFS_OpenEx(const char *Path, Uint Flags, Uint Mode);
 /**
  * \brief Opens a file via an open directory
  * \note The file to open must be a direct child of the parent
@@ -320,10 +364,11 @@ extern int        VFS_ReadDir(int FD, char *Dest);
  * \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 ExtraEvents  Extra event set to wait on
  * \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);
+extern int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set *ErrHandles, tTime *Timeout, Uint32 ExtraEvents, BOOL IsKernel);
 
 /**
  * \brief Map a file into memory
@@ -338,7 +383,6 @@ extern void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags,
 
 /**
  * \brief Unmap memory allocated by VFS_MMap
- * \param ErrNo        Error status pointer
  * \param Addr Address of data to unmap
  * \param Length       Length of data
  */

UCC git Repository :: git.ucc.asn.au