Fixing up doxygen comments
[tpg/acess2.git] / Kernel / include / vfs_ext.h
1 /**
2  * \file vfs_ext.h
3  * \brief Exported VFS Definitions
4  * \author John Hodge (thePowersGang)
5  */
6 #ifndef _VFS_EXT_H
7 #define _VFS_EXT_H
8
9 // === CONSTANTS ===
10 //! Maximum size of a Memory Path generated by VFS_GetMemPath
11 #define VFS_MEMPATH_SIZE        (3 + (BITS/4)*2)
12 /**
13  * \name Flags for VFS_Open
14  * \{
15  */
16 //! Open for execution
17 #define VFS_OPENFLAG_EXEC       0x01
18 //! Open for reading
19 #define VFS_OPENFLAG_READ       0x02
20 //! Open for writing
21 #define VFS_OPENFLAG_WRITE      0x04
22 //! Do not resolve the final symbolic link
23 #define VFS_OPENFLAG_NOLINK     0x40
24 //! Open as a user
25 #define VFS_OPENFLAG_USER       0x80
26 /**
27  * \}
28  */
29 //! Marks a VFS handle as belonging to the kernel
30 #define VFS_KERNEL_FLAG 0x40000000
31
32 /**
33  * \brief VFS_Seek directions
34  */
35 enum eVFS_SeekDirs
36 {
37         SEEK_SET = 1,   //!< Set the current file offset
38         SEEK_CUR = 0,   //!< Seek relative to the current position
39         SEEK_END = -1   //!< Seek from the end of the file backwards
40 };
41
42 /**
43  * \name ACL Permissions
44  * \{
45  */
46 /**
47  * \brief Readable
48  */
49 #define VFS_PERM_READ   0x00000001
50 /**
51  * \brief Writeable
52  */
53 #define VFS_PERM_WRITE  0x00000002
54 /**
55  * \brief Append allowed
56  */
57 #define VFS_PERM_APPEND 0x00000004
58 /**
59  * \brief Executable
60  */
61 #define VFS_PERM_EXECUTE        0x00000008
62 /**
63  * \brief All permissions granted
64  */
65 #define VFS_PERM_ALL    0x7FFFFFFF      // Mask for permissions
66 /**
67  * \brief Denies instead of granting permissions
68  * \note Denials take precedence
69  */
70 #define VFS_PERM_DENY   0x80000000      // Inverts permissions
71 /**
72  * \}
73  */
74
75 // -- System Call Structures ---
76 /**
77  * \brief ACL Defintion Structure
78  */
79 typedef struct sVFS_ACL
80 {
81         struct {
82                 unsigned Group: 1;      //!< Group (as opposed to user) flag
83                 unsigned ID:    31;     //!< ID of Group/User (-1 for nobody/world)
84         };
85         struct {
86                 unsigned Inv:   1;      //!< Invert Permissions
87                 unsigned Perms: 31;     //!< Permission Flags
88         };
89 }       tVFS_ACL;
90
91 /**
92  * \brief SYS_FINFO structure
93  */
94 typedef struct sFInfo
95 {
96         Uint    uid;    //!< Owning User ID
97         Uint    gid;    //!< Owning Group ID
98         Uint    flags;  //!< File flags
99         Uint64  size;   //!< File Size
100         Sint64  atime;  //!< Last Accessed time
101         Sint64  mtime;  //!< Last modified time
102         Sint64  ctime;  //!< Creation time
103          int    numacls;        //!< Total number of ACL entries
104         tVFS_ACL        acls[]; //!< ACL buffer (size is passed in the \a MaxACLs argument to VFS_FInfo)
105 }       tFInfo;
106
107 // === FUNCTIONS ===
108 /**
109  * \brief Initialise the VFS (called by system.c)
110  * \return Boolean Success
111  */
112 extern int      VFS_Init(void);
113
114 /**
115  * \brief Open a file
116  * \param Path  Absolute or relative path to the file
117  * \param Mode  Flags defining how to open the file
118  * \return VFS Handle (an integer) or -1 if an error occured
119  */
120 extern int      VFS_Open(char *Path, Uint Mode);
121 /**
122  * \brief Close a currently open file
123  * \param FD    Handle returned by ::VFS_Open
124  */
125 extern void     VFS_Close(int FD);
126
127 /**
128  * \brief Get file information from an open file
129  * \param FD    File handle returned by ::VFS_Open
130  * \param Dest  Destination for the read information
131  * \param MaxACLs       Number of ACL slots allocated in the \a Dest structure
132  * \return Boolean Success
133  * 
134  * If the \a NumACLs is smaller than the number of ACLs the node has, only
135  * \a NumACLs will be copied into \a Dest, but the tFInfo.numacls field
136  * will be set to the true ammount of ACLs. It is up to the user to do with
137  * this information how they like.
138  */
139 extern int      VFS_FInfo(int FD, tFInfo *Dest, int MaxACLs);
140 /**
141  * \brief Gets the permissions appling to a user/group.
142  * \param FD    File handle returned by ::VFS_Open
143  * \param Dest  ACL information structure to edit
144  * \return Boolean success
145  * 
146  * This function sets the tVFS_ACL.Inv and tVFS_ACL.Perms fields to what
147  * permissions the user/group specied in tVFS_ACL.ID has on the file.
148  */
149 extern int      VFS_GetACL(int FD, tVFS_ACL *Dest);
150 /**
151  * \brief Changes the user's current working directory
152  * \param Dest  New working directory (either absolute or relative to the current)
153  * \return Boolean Success
154  */
155 extern int      VFS_ChDir(char *Dest);
156 /**
157  * \brief Change the current virtual root for the user
158  * \param New New virtual root (same as ::VFS_ChDir but cannot go
159  *            above the current virtual root)
160  * \return Boolean success
161  */
162 extern int      VFS_ChRoot(char *New);
163
164 /**
165  * \brief Change the location of the current file pointer
166  * \param FD    File handle returned by ::VFS_Open
167  * \param Offset        Offset within the file to go to
168  * \param Whence        A direction from ::eVFS_SeekDirs
169  * \return Boolean success
170  */
171 extern int      VFS_Seek(int FD, Sint64 Offset, int Whence);
172 /**
173  * \brief Returns the current file pointer
174  * \param FD    File handle returned by ::VFS_Open
175  * \return Current file position
176  */
177 extern Uint64   VFS_Tell(int FD);
178
179 /**
180  * \brief Reads data from a file
181  * \param FD    File handle returned by ::VFS_Open
182  * \param Length        Number of bytes to read from the file
183  * \param Buffer        Destination of read data
184  * \return Number of read bytes
185  */
186 extern Uint64   VFS_Read(int FD, Uint64 Length, void *Buffer);
187 /**
188  * \brief Writes data to a file
189  * \param FD    File handle returned by ::VFS_Open
190  * \param Length        Number of bytes to write to the file
191  * \param Buffer        Source of written data
192  * \return Number of bytes written
193  */
194 extern Uint64   VFS_Write(int FD, Uint64 Length, void *Buffer);
195
196 /**
197  * \brief Reads from a specific offset in the file
198  * \param FD    File handle returned by ::VFS_Open
199  * \param Offset        Byte offset in the file
200  * \param Length        Number of bytes to read from the file
201  * \param Buffer        Source of read data
202  * \return Number of bytes read
203  */
204 extern Uint64   VFS_ReadAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer);
205 /**
206  * \brief Writes to a specific offset in the file
207  * \param FD    File handle returned by ::VFS_Open
208  * \param Offset        Byte offset in the file
209  * \param Length        Number of bytes to write to the file
210  * \param Buffer        Source of written data
211  * \return Number of bytes written
212  */
213 extern Uint64   VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer);
214
215 /**
216  * \brief Sends an IOCtl request to the driver
217  * \param FD    File handle returned by ::VFS_Open
218  * \param ID    IOCtl call ID (driver specific)
219  * \param Buffer        Data pointer to send to the driver
220  * \return Driver specific response
221  */
222 extern int      VFS_IOCtl(int FD, int ID, void *Buffer);
223
224 /**
225  * \brief Creates a VFS Memory path from a pointer and size
226  * \param Dest  Destination for the created path
227  * \param Base  Base of the memory file
228  * \param Length        Length of the memory buffer
229  * \note A maximum of VFS_MEMPATH_SIZE bytes will be required in \a Dest
230  */
231 extern void     VFS_GetMemPath(char *Dest, void *Base, Uint Length);
232 /**
233  * \brief Gets the canoical (true) path of a file
234  * \param Path  File path (may contain symlinks, relative elements etc.)
235  * \return Absolute path with no symlinks
236  */
237 extern char     *VFS_GetTruePath(char *Path);
238
239 /**
240  * \brief Mounts a filesystem
241  * \param Device        Device to mount
242  * \param MountPoint    Location to mount
243  * \param Filesystem    Filesystem to use
244  * \param Options       Options string to pass the driver
245  * \return 1 on succes, -1 on error
246  */
247 extern int      VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options);
248 /**
249  * \brief Create a new directory
250  * \param Path  Path to new directory (absolute or relative)
251  * \return Boolean success
252  * \note The parent of the directory must exist
253  */
254 extern int      VFS_MkDir(char *Path);
255 /**
256  * \brief Create a symbolic link
257  * \param Name  Name of the symbolic link
258  * \param Link  File the symlink points to
259  * \return Boolean success (\a Link is not tested for existence)
260  */
261 extern int      VFS_Symlink(char *Name, char *Link);
262 /**
263  * \brief Read from a directory
264  * \param FD    File handle returned by ::VFS_Open
265  * \param Dest  Destination array for the file name (max 255 bytes)
266  * \return Boolean Success
267  */
268 extern int      VFS_ReadDir(int FD, char *Dest);
269 /**
270  * \brief Opens a file via an open directory
271  * \note The file to open must be a direct child of the parent
272  * \param Errno Error number
273  * \param FD    Parent Directory
274  * \param Name  Child name
275  * \param Mode  Open mode
276  * \return File handle (same as returned from VFS_Open)
277  */
278 extern int      VFS_OpenChild(Uint *Errno, int FD, char *Name, Uint Mode);
279
280 #endif

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