X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Finclude%2Fvfs_ext.h;h=73d82ce58cd4d65643210d48029a123173677a74;hb=86b0974b33759726b99f8940900a88e395247460;hp=d9bc833c2e67f1ee8aa6516fea30c456fbf7ae71;hpb=bf62604f78c2d8bc88cac3664e15ed02c6e6d581;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/include/vfs_ext.h b/KernelLand/Kernel/include/vfs_ext.h index d9bc833c..73d82ce5 100644 --- a/KernelLand/Kernel/include/vfs_ext.h +++ b/KernelLand/Kernel/include/vfs_ext.h @@ -13,6 +13,8 @@ typedef Uint64 tInode; 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) /** @@ -20,17 +22,19 @@ typedef Uint32 tMount; * \{ */ //! 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 0x100 +#define VFS_OPENFLAG_DIRECTORY 0x1000 //! Open as a user #define VFS_OPENFLAG_USER 0x8000 /** @@ -56,35 +60,20 @@ enum eVFS_SeekDirs * \name ACL Permissions * \{ */ -/** - * \brief Readable - */ -#define VFS_PERM_READ 0x00000001 -/** - * \brief Writeable - */ -#define VFS_PERM_WRITE 0x00000002 -/** - * \brief Append allowed - */ -#define VFS_PERM_APPEND 0x00000004 -/** - * \brief Executable - */ -#define VFS_PERM_EXECUTE 0x00000008 -/** - * \brief All permissions granted - */ -#define VFS_PERM_ALL 0x7FFFFFFF // Mask for permissions -/** - * \brief Denies instead of granting permissions - * \note Denials take precedence - */ -#define VFS_PERM_DENY 0x80000000 // Inverts permissions +#define VFS_PERM_READ 0x00000001 //!< Readable +#define VFS_PERM_WRITE 0x00000002 //!< Writable +#define VFS_PERM_APPEND 0x00000004 //!< Appendable (/create file) +#define VFS_PERM_EXEC 0x00000008 //!< Executable (/Traversable) +#define VFS_PERM_ALL 0x7FFFFFFF //!< All permission bits +#define VFS_PERM_DENY 0x80000000 //!< Flag for denying a permission set (higher precedence) /** * \} */ +#define VFS_ACLENT_ALL 0x7FFFFFFF +#define VFS_GROUP_ANY {1, VFS_ACLENT_ALL} //!< Rules for all users +#define VFS_USER_NOBODY {0, VFS_ACLENT_ALL} //!< Rules for nobody + /** * \brief MMap protection flags * \{ @@ -114,14 +103,16 @@ enum eVFS_SeekDirs */ 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; /** @@ -142,6 +133,10 @@ typedef struct sFInfo 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() */ @@ -169,6 +164,7 @@ typedef struct * \param fdsetp Set to modify */ #define FD_ISSET(fd, fdsetp) ((fdsetp)->flags[(fd)/16]&(1<<((fd)%16))) +#endif // === FUNCTIONS === /** @@ -211,12 +207,43 @@ extern int VFS_OpenChild(int FD, const char *Name, Uint Mode); */ 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 Save specified file handle such that it can be passed between processes + * \param FD File descriptor to save + * \return Marshalled handle, or (uint64_t)-1 on error + */ +extern Uint64 VFS_MarshalHandle(int FD); + +/** + * \brief Restore a marshalled handle into the current process + * \param Handle returned by VFS_MarshalHandle + * \return File descriptor, or -1 on error + */ +extern int VFS_UnmarshalHandle(Uint64 Handle); + /** * \brief Get file information from an open file * \param FD File handle returned by ::VFS_Open @@ -305,6 +332,16 @@ extern size_t VFS_ReadAt(int FD, Uint64 Offset, size_t Length, void *Buffer); */ extern size_t VFS_WriteAt(int FD, Uint64 Offset, size_t Length, const void *Buffer); +/** + * \brief Set the valid size of a file + * \param FD File descriptor + * \param Size New file size + * \return Actual new file size (-1 if error occurred) + * + * \note Not all files support this call (will return ENOTIMPL) + */ +extern off_t VFS_Truncate(int FD, off_t Size); + /** * \brief Sends an IOCtl request to the driver * \param FD File handle returned by ::VFS_Open @@ -368,10 +405,10 @@ extern int VFS_Symlink(const char *Name, const char *Link); /** * \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