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)
#endif
break;
+ case SYS_FINFO:
+ ret = VFS_FInfo( Regs->Arg1, (void*)Regs->Arg2, Regs->Arg3 );
+ break;
// -- Debug
case SYS_DEBUG:
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;
/**
* \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)
{
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;
+}
write(_stdout, 4, "\x1B[2J"); //Clear Screen\r
}\r
\r
+/**\r
+ * \fn void Command_Cd(int argc, char **argv)\r
+ * \brief Change directory\r
+ */\r
void Command_Cd(int argc, char **argv)\r
{\r
char tmpPath[1024];\r
finfo(fp, &stats);\r
close(fp);\r
\r
- if(!(stats.flags & FILEFLAG_DIRECTORY)) {\r
+ if( !(stats.flags & FILEFLAG_DIRECTORY) ) {\r
write(_stdout, 17, "Not a Directory\n");\r
return;\r
}\r
[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
#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;
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);