From: John Hodge Date: Wed, 23 Sep 2009 08:38:04 +0000 (+0800) Subject: Added SYS_FINFO and functions required to support it X-Git-Tag: rel0.06~526 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=f8528eeb40cbea394df23878f78ff9cb19f25771;p=tpg%2Facess2.git Added SYS_FINFO and functions required to support it --- diff --git a/Kernel/syscalls.c b/Kernel/syscalls.c index ddcdfa2d..8e02c5de 100644 --- a/Kernel/syscalls.c +++ b/Kernel/syscalls.c @@ -15,6 +15,7 @@ extern Uint Proc_SendMessage(Uint *Err, Uint Dest, Uint Length, void *Data); extern int Proc_GetMessage(Uint *Err, Uint *Source, void *Buffer); extern int Proc_Execve(char *File, char **ArgV, char **EnvP); extern Uint Binary_Load(char *file, Uint *entryPoint); +extern int VFS_FInfo(int FD, void *Dest, int MaxACLs); // === CODE === void SyscallHandler(tSyscallRegs *Regs) @@ -132,6 +133,9 @@ void SyscallHandler(tSyscallRegs *Regs) #endif break; + case SYS_FINFO: + ret = VFS_FInfo( Regs->Arg1, (void*)Regs->Arg2, Regs->Arg3 ); + break; // -- Debug case SYS_DEBUG: @@ -143,7 +147,7 @@ void SyscallHandler(tSyscallRegs *Regs) default: Warning("SyscallHandler: Unknown System Call %i", Regs->Num); if(Regs->Num < NUM_SYSCALLS) - Warning(" Syscall %s", cSYSCALL_NAMES[Regs->Num]); + Warning(" Syscall '%s'", cSYSCALL_NAMES[Regs->Num]); err = -ENOSYS; ret = -1; break; diff --git a/Kernel/vfs/io.c b/Kernel/vfs/io.c index 689121e7..4a44b40a 100644 --- a/Kernel/vfs/io.c +++ b/Kernel/vfs/io.c @@ -169,6 +169,7 @@ int VFS_Seek(int FD, Sint64 Distance, int Whence) /** * \fn int VFS_IOCtl(int FD, int ID, void *Buffer) + * \brief Call an IO Control on a file */ int VFS_IOCtl(int FD, int ID, void *Buffer) { @@ -180,3 +181,46 @@ int VFS_IOCtl(int FD, int ID, void *Buffer) if(!h->Node->IOCtl) return -1; return h->Node->IOCtl(h->Node, ID, Buffer); } + +// -- System Call Structures --- +struct s_sysFInfo { + Uint uid, gid; + Uint flags; + Uint64 size; + Sint64 atime; + Sint64 mtime; + Sint64 ctime; + int numacls; + tVFS_ACL acls[]; +}; + +/** + * \fn int VFS_FInfo(int FD, struct s_sysFInfo *Dest, int MaxACLs) + * \brief Retrieve file information + * \return Number of ACLs stored + */ +int VFS_FInfo(int FD, struct s_sysFInfo *Dest, int MaxACLs) +{ + tVFS_Handle *h; + int max; + + h = VFS_GetHandle(FD); + if(!h) return -1; + + Dest->uid = h->Node->UID; + Dest->gid = h->Node->GID; + Dest->size = h->Node->Size; + Dest->atime = h->Node->ATime; + Dest->ctime = h->Node->MTime; + Dest->mtime = h->Node->CTime; + Dest->numacls = h->Node->NumACLs; + + Dest->flags = 0; + if(h->Node->Flags & VFS_FFLAG_DIRECTORY) Dest->flags |= 0x10; + if(h->Node->Flags & VFS_FFLAG_SYMLINK) Dest->flags |= 0x20; + + max = (MaxACLs < h->Node->NumACLs) ? MaxACLs : h->Node->NumACLs; + memcpy(&Dest->acls, h->Node->ACLs, max*sizeof(tVFS_ACL)); + + return max; +} diff --git a/Usermode/Applications/CLIShell_src/main.c b/Usermode/Applications/CLIShell_src/main.c index 9b37ecbc..f753788d 100644 --- a/Usermode/Applications/CLIShell_src/main.c +++ b/Usermode/Applications/CLIShell_src/main.c @@ -292,6 +292,10 @@ void Command_Clear(int argc, char **argv) write(_stdout, 4, "\x1B[2J"); //Clear Screen } +/** + * \fn void Command_Cd(int argc, char **argv) + * \brief Change directory + */ void Command_Cd(int argc, char **argv) { char tmpPath[1024]; @@ -314,7 +318,7 @@ void Command_Cd(int argc, char **argv) finfo(fp, &stats); close(fp); - if(!(stats.flags & FILEFLAG_DIRECTORY)) { + if( !(stats.flags & FILEFLAG_DIRECTORY) ) { write(_stdout, 17, "Not a Directory\n"); return; } diff --git a/Usermode/Libraries/libacess.so_src/vfs.asm b/Usermode/Libraries/libacess.so_src/vfs.asm index 2be8ce07..430a2f54 100644 --- a/Usermode/Libraries/libacess.so_src/vfs.asm +++ b/Usermode/Libraries/libacess.so_src/vfs.asm @@ -7,10 +7,10 @@ [extern _errno] [section .text] -SYSCALL2 open, SYS_OPEN -SYSCALL3 reopen, SYS_REOPEN -SYSCALL1 close, SYS_CLOSE +SYSCALL2 open, SYS_OPEN ; char*, int +SYSCALL3 reopen, SYS_REOPEN ; int, char*, int +SYSCALL1 close, SYS_CLOSE ; int SYSCALL4 read, SYS_READ ; int, int64_t, void* SYSCALL4 write, SYS_WRITE ; int, int64_t, void* SYSCALL4 seek, SYS_SEEK ; int, int64_t, int -SYSCALL2 finfo, SYS_FINFO +SYSCALL3 finfo, SYS_FINFO ; int, void*, int diff --git a/Usermode/include/acess/sys.h b/Usermode/include/acess/sys.h index 4431e0b9..03a02bec 100644 --- a/Usermode/include/acess/sys.h +++ b/Usermode/include/acess/sys.h @@ -16,16 +16,22 @@ #define SEEK_END -1 #define CLONE_VM 0x10 #define FILEFLAG_DIRECTORY 0x10 +#define FILEFLAG_SYMLINK 0x20 // === TYPES === +struct s_sysACL { + uint32_t object; + uint32_t perms; +}; struct s_sysFInfo { uint uid, gid; uint flags; - int numacls; uint64_t size; uint64_t atime; uint64_t mtime; uint64_t ctime; + int numacls; + struct s_sysACL acls[]; }; typedef struct s_sysFInfo t_sysFInfo; @@ -43,7 +49,7 @@ uint64_t read(int fd, uint64_t length, void *buffer); uint64_t write(int fd, uint64_t length, void *buffer); int seek(int fd, uint64_t offset, int whence); int ioctl(int fd, int id, void *data); - int finfo(int fd, t_sysFInfo *info); + int finfo(int fd, t_sysFInfo *info, int maxacls); // --- MEMORY --- uint64_t _SysGetPhys(uint vaddr);