7 * \brief Acess VFS Layer
14 //! \name ACL Permissions
19 #define VFS_PERM_READ 0x00000001
23 #define VFS_PERM_WRITE 0x00000002
25 * \brief Append allowed
27 #define VFS_PERM_APPEND 0x00000004
31 #define VFS_PERM_EXECUTE 0x00000008
33 * \brief All permissions granted
35 #define VFS_PERM_ALL 0x7FFFFFFF // Mask for permissions
37 * \brief Denies instead of granting permissions
38 * \note Denials take precedence
40 #define VFS_PERM_DENY 0x80000000 // Inverts permissions
44 * \name VFS Node Flags
47 #define VFS_FFLAG_READONLY 0x01 //!< Read-only file
48 #define VFS_FFLAG_DIRECTORY 0x02 //!< Directory
49 #define VFS_FFLAG_SYMLINK 0x04 //!< Symbolic Link
57 typedef struct sVFS_Node {
58 Uint64 Inode; //!< Inode ID
59 Uint ImplInt; //!< Implementation Usable Integer
60 void *ImplPtr; //!< Implementation Usable Pointer
62 int ReferenceCount; //!< Number of times the node is used
64 Uint64 Size; //!< File Size
66 Uint32 Flags; //!< File Flags
68 Sint64 ATime; //!< Last Accessed Time
69 Sint64 MTime; //!< Last Modified Time
70 Sint64 CTime; //!< Creation Time
72 Uint UID; //!< Owning User
73 Uint GID; //!< Owning Group
75 int NumACLs; //!< Number of ACL entries
76 tVFS_ACL *ACLs; //!< ACL Entries
78 //! Reference the node
79 void (*Reference)(struct sVFS_Node *Node);
80 //! Close (dereference) the node
81 void (*Close)(struct sVFS_Node *Node);
82 //! Send an IO Control
83 int (*IOCtl)(struct sVFS_Node *Node, int Id, void *Data);
85 //! \brief Read from the file
86 Uint64 (*Read)(struct sVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
87 //! \brief Write to the file
88 Uint64 (*Write)(struct sVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
90 //! \brief Find an directory entry by name
91 //! \note The node returned must be accessable until ::tVFS_Node.Close is called
92 struct sVFS_Node *(*FindDir)(struct sVFS_Node *Node, char *Name);
94 //! \brief Read from a directory
95 //! \note MUST return a heap address
96 char *(*ReadDir)(struct sVFS_Node *Node, int Pos);
98 //! \brief Create a node in a directory
99 int (*MkNod)(struct sVFS_Node *Node, char *Name, Uint Flags);
101 //! \brief Relink (Rename/Remove) a file/directory
102 int (*Relink)(struct sVFS_Node *Node, char *OldName, char *NewName);
108 * \brief VFS Driver (Filesystem) Definition
110 typedef struct sVFS_Driver
112 //! \brief Unique Identifier for this filesystem type
114 //! \brief Flags applying to this driver
117 //! \brief Callback to mount a device
118 tVFS_Node *(*InitDevice)(char *Device, char **Options);
119 //! \brief Callback to unmount a device
120 void (*Unmount)(tVFS_Node *Node);
121 //! \brief Used internally (next driver in the chain)
122 struct sVFS_Driver *Next;
126 //! \brief Maximum number of elements that can be skipped in one return
127 #define VFS_MAXSKIP ((void*)1024)
128 //! \brief Skip a single entry in readdir
129 #define VFS_SKIP ((void*)1)
130 //! \brief Skip \a n entries in readdir
131 #define VFS_SKIPN(n) ((void*)(n))
133 extern tVFS_Node NULLNode; //!< NULL VFS Node (Ignored/Skipped)
135 * \name Simple ACLs to aid writing drivers
138 extern tVFS_ACL gVFS_ACL_EveryoneRWX; //!< Everyone Read/Write/Execute
139 extern tVFS_ACL gVFS_ACL_EveryoneRW; //!< Everyone Read/Write
140 extern tVFS_ACL gVFS_ACL_EveryoneRX; //!< Everyone Read/Execute
141 extern tVFS_ACL gVFS_ACL_EveryoneRO; //!< Everyone Read only
148 * \fn int VFS_AddDriver(tVFS_Driver *Info)
149 * \brief Registers the driver with the DevFS layer
150 * \param Info Driver information structure
152 extern int VFS_AddDriver(tVFS_Driver *Info);
154 * \fn tVFS_Driver *VFS_GetFSByName(char *Name)
155 * \brief Get the information structure of a driver given its name
156 * \param Name Name of filesystem driver to find
158 extern tVFS_Driver *VFS_GetFSByName(char *Name);
160 * \fn tVFS_ACL *VFS_UnixToAcessACL(Uint Mode, Uint Owner, Uint Group)
161 * \brief Transforms Unix Permssions into Acess ACLs
162 * \param Mode Unix RWXrwxRWX mask
163 * \param Owner UID of the file's owner
164 * \param Group GID of the file's owning group
165 * \return An array of 3 Acess ACLs
167 extern tVFS_ACL *VFS_UnixToAcessACL(Uint Mode, Uint Owner, Uint Group);
173 * \fn int Inode_GetHandle()
174 * \brief Gets a unique handle to the Node Cache
175 * \return A unique handle for use for the rest of the Inode_* functions
177 extern int Inode_GetHandle();
179 * \fn tVFS_Node *Inode_GetCache(int Handle, Uint64 Inode)
180 * \brief Gets an inode from the node cache
181 * \param Handle A handle returned by Inode_GetHandle()
182 * \param Inode Value of the Inode field of the ::tVFS_Node you want
183 * \return A pointer to the cached node
185 extern tVFS_Node *Inode_GetCache(int Handle, Uint64 Inode);
187 * \fn tVFS_Node *Inode_CacheNode(int Handle, tVFS_Node *Node)
188 * \brief Caches a node in the Node Cache
189 * \param Handle A handle returned by Inode_GetHandle()
190 * \param Node A pointer to the node to be cached (a copy is taken)
191 * \return A pointer to the node in the node cache
193 extern tVFS_Node *Inode_CacheNode(int Handle, tVFS_Node *Node);
195 * \fn void Inode_UncacheNode(int Handle, Uint64 Inode)
196 * \brief Dereferences (and removes if needed) a node from the cache
197 * \param Handle A handle returned by Inode_GetHandle()
198 * \param Inode Value of the Inode field of the ::tVFS_Node you want to remove
200 extern void Inode_UncacheNode(int Handle, Uint64 Inode);
202 * \fn void Inode_ClearCache(int Handle)
203 * \brief Clears the cache for a handle
204 * \param Handle A handle returned by Inode_GetHandle()
206 extern void Inode_ClearCache(int Handle);