diff --git a/sys/fs/ufs/ufs.c b/sys/fs/ufs/ufs.c index 6aa045d..94f6bf9 100644 --- a/sys/fs/ufs/ufs.c +++ b/sys/fs/ufs/ufs.c @@ -137,11 +137,11 @@ #else if (fs->fs_magic == FS_UFS1_MAGIC) { dp1 = ((struct ufs1_dinode *) blkbuf)[n]; - memcpy(&fd->inode.ufs1, &dp1, sizeof(struct ufs1_dinode)); + memcpy(&fd->inode.u.ufs1_i, &dp1, sizeof(struct ufs1_dinode)); } else{ dp2 = ((struct ufs2_dinode *) blkbuf)[n]; - memcpy(&fd->inode.ufs2, &dp2, sizeof(struct ufs2_dinode)); + memcpy(&fd->inode.u.ufs2_i, &dp2, sizeof(struct ufs2_dinode)); } #endif inomap = inode; diff --git a/sys/fs/vfs/namei.c b/sys/fs/vfs/namei.c index 54c57b3..5c60f2d 100644 --- a/sys/fs/vfs/namei.c +++ b/sys/fs/vfs/namei.c @@ -1,6 +1,7 @@ #include #include #include +#include int follow_link(struct inode * dir, struct inode * inode, int flag, int mode, struct inode ** res_inode) { @@ -49,11 +50,11 @@ perm = permission(dir, MAY_EXEC); if (len == 2 && name[0] == '.' && name[1] == '.') { +#ifdef _IGNORE if (dir == _current->root) { *result = dir; return 0; } - else if ((sb = dir->i_sb) && (dir == sb->s_mounted)) { sb = dir->i_sb; iput(dir); @@ -62,6 +63,7 @@ return -ENOENT; dir->i_count++; } +#endif } if (!dir->i_op || !dir->i_op->lookup) { @@ -91,10 +93,12 @@ *res_inode = NULL; +#ifdef _IGNORE if (!base) { base = _current->pwd; base->i_count++; } +#endif if (!base) { kprintf("BASE == NULL"); @@ -102,7 +106,9 @@ if ((c = *pathname) == '/') { iput(base); +#ifdef _IGNORE base = _current->root; +#endif pathname++; base->i_count++; } diff --git a/sys/fs/vfs/vfs.c b/sys/fs/vfs/vfs.c index 7c971ca..8a82355 100644 --- a/sys/fs/vfs/vfs.c +++ b/sys/fs/vfs/vfs.c @@ -166,6 +166,42 @@ return (error); } +int sys_openat(struct thread *td, struct sys_openat_args *args) { + int error = 0x0; + int index = 0x0; + struct file *nfp = 0x0; + + error = falloc(td,&nfp,&index); + + if (error) + return(error); + + strcpy(nfp->path, args->path); + + nfp->fd = fopen(args->path,"r"); + + if (nfp->fd == 0x0) { + td->td_retval[0] = -1; + } + else { + for (index = 0; index < 256;index++) { + if (td->o_files[index] == 0x0) { + td->o_files[index] = nfp->fd; + td->td_retval[0] = index;//nfp->fd->ino;//MrOlsen 2018index; + break; + } + else { + td->td_retval[0] = -1;//nfp->fd->ino;//MrOlsen 2018index; + } + } + } + + kprintf("path: %s:%i ", args->path, index); + + return (error); + } + + /* HACK */ int fstatfs(struct thread *td, struct fstatfs_args *args) { int error = 0x0; diff --git a/sys/i386/systemtask.c b/sys/i386/systemtask.c index 4663abd..1ddce8b 100644 --- a/sys/i386/systemtask.c +++ b/sys/i386/systemtask.c @@ -106,8 +106,8 @@ */ tmpTask = sched_getDelTask(); if ( tmpTask != 0x0 ) { - if ( tmpTask->imageFd != 0x0 ) - fclose( tmpTask->imageFd ); + if ( tmpTask->files[0] != 0x0 ) + fclose( tmpTask->files[0] ); vmm_freeProcessPages( tmpTask->id ); kfree( tmpTask ); } diff --git a/sys/include/sys/sysproto.h b/sys/include/sys/sysproto.h index 848203b..129586d 100644 --- a/sys/include/sys/sysproto.h +++ b/sys/include/sys/sysproto.h @@ -467,6 +467,14 @@ char nbyte_r_[PADR_(size_t)]; }; +struct sys_openat_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char flag_l_[PADL_(int)]; int flag; char flag_r_[PADR_(int)]; + char mode_l_[PADL_(__mode_t)]; __mode_t mode; char mode_r_[PADR_(__mode_t)]; +}; + + //Func Defs int sys_invalid(struct thread *, void *); int sys_exit(struct thread *, struct sys_exit_args *); @@ -506,6 +514,7 @@ int mprotect(struct thread *td, struct mprotect_args *uap); int sys_lstat(struct thread *td, struct sys_lstat_args *); +int sys_openat(struct thread *td, struct sys_openat_args *); #endif diff --git a/sys/include/ubixos/wait.h b/sys/include/ubixos/wait.h index ccd5355..74726d7 100644 --- a/sys/include/ubixos/wait.h +++ b/sys/include/ubixos/wait.h @@ -2,8 +2,10 @@ #define _UBIXOS_WAIT_H +struct kTask_t; + struct wait_queue { -// struct kTask_t *task; + struct kTask_t *task; struct wait_queue *next; }; diff --git a/sys/include/vfs/inode.h b/sys/include/vfs/inode.h new file mode 100644 index 0000000..d76c7a4 --- /dev/null +++ b/sys/include/vfs/inode.h @@ -0,0 +1,52 @@ +#ifndef _VFS_INODE_H +#define _VFS_INODE_H + +#include +#include + +#include +#include +#include + +struct inode { + __dev_t i_dev; + unsigned long i_ino; + __mode_t i_mode; + __nlink_t i_nlink; + uid_t i_uid; + gid_t i_gid; + __dev_t i_rdev; + off_t i_size; + time_t i_atime; + time_t i_mtime; + time_t i_ctime; + unsigned long i_blksize; + unsigned long i_blocks; + struct semaphore i_sem; + struct inode_operations * i_op; + struct super_block * i_sb; + struct wait_queue * i_wait; + struct file_lock * i_flock; + struct vm_area_struct * i_mmap; + struct inode * i_next, *i_prev; + struct inode * i_hash_next, *i_hash_prev; + struct inode * i_bound_to, *i_bound_by; + struct inode * i_mount; + struct socket * i_socket; + unsigned short i_count; + unsigned short i_flags; + unsigned char i_lock; + unsigned char i_dirt; + unsigned char i_pipe; + unsigned char i_seek; + unsigned char i_update; + union { + struct pipe_inode_info pipe_i; + struct msdos_inode_info msdos_i; + struct ufs1_dinode ufs1_i; + struct ufs2_dinode ufs2_i; + } u; +}; + + +#endif diff --git a/sys/kernel/access.c b/sys/kernel/access.c index 639b76d..ea0a891 100644 --- a/sys/kernel/access.c +++ b/sys/kernel/access.c @@ -82,8 +82,8 @@ if (grp == _current->egid) return 1; - for (i = 0; i < NGROUPS; i++) { - if (_current->groups[i] == NOGROUP) + for (i = 0; i < NR_GROUPS; i++) { + if (_current->groups[i] == NO_GROUP) break; if (_current->groups[i] == grp) return 1; diff --git a/sys/kernel/kern_sysctl.c b/sys/kernel/kern_sysctl.c index bd1d6e2..d068553 100644 --- a/sys/kernel/kern_sysctl.c +++ b/sys/kernel/kern_sysctl.c @@ -192,9 +192,9 @@ } if ( (uint32_t) uap->oldlenp < tmpCtl->val_len ) - memcpy( uap->old, tmpCtl->value, (uInt32) uap->oldlenp ); + memcpy( uap->oldp, tmpCtl->value, (uInt32) uap->oldlenp ); else - memcpy( uap->old, tmpCtl->value, tmpCtl->val_len ); + memcpy( uap->oldp, tmpCtl->value, tmpCtl->val_len ); td->td_retval[0] = 0x0; diff --git a/sys/kernel/syscalls.c b/sys/kernel/syscalls.c index 503f0ca..aa966b2 100644 --- a/sys/kernel/syscalls.c +++ b/sys/kernel/syscalls.c @@ -221,7 +221,7 @@ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 186 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 187 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 188 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 189 - Invalid */ + { ARG_COUNT(sys_lstat_args), "LSTAT", (sys_call_t *) sys_lstat, SYSCALL_VALID }, /* 189 - sys_fstat */ { ARG_COUNT(sys_lstat_args), "LSTAT", (sys_call_t *) sys_lstat, SYSCALL_VALID }, /* 190 - sys_lstat */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 191 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 192 - Invalid */ @@ -531,7 +531,7 @@ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 356 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 357 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 358 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 359 - Invalid */ + { ARG_COUNT(sys_openat_args), "SYS_openat", sys_openat, SYSCALL_VALID }, /* 499 - sys_openat */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 350 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 351 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 352 - Invalid */ diff --git a/sys/vmm/getfreevirtualpage.c b/sys/vmm/getfreevirtualpage.c index ff0fcec..7d87168 100644 --- a/sys/vmm/getfreevirtualpage.c +++ b/sys/vmm/getfreevirtualpage.c @@ -60,12 +60,15 @@ if ( _current->oInfo.vmStart <= 0x100000 ) kpanic( "Invalid vmStart\n" ); + kprintf("type: %i ", type); + type = 0; + /* Get Our Starting Address */ if ( type == VM_THRD ) { start_page = (uint32_t)( _current->td.vm_daddr + ctob( _current->td.vm_dsize ) ); } else if ( type == VM_TASK ) { - //kprintf("vmStart"); + kprintf("vmStart"); start_page = _current->oInfo.vmStart; } else @@ -82,7 +85,7 @@ /* * Lets Start Allocating Pages */ - + kprintf("Count: %i ", count); for ( counter = 0; counter < count; counter++ ) { /* Locate Initial Page Table */ pdI = ((start_page + (counter * 0x1000)) / 0x400000); diff --git a/sys/vmm/vmm_mmap.c b/sys/vmm/vmm_mmap.c index 158be12..6f10c62 100644 --- a/sys/vmm/vmm_mmap.c +++ b/sys/vmm/vmm_mmap.c @@ -171,13 +171,13 @@ return (0x0); //vmm_getFreeVirtualPage(_current->id, round_page( uap->len ) / 0x1000, VM_THRD)); } else { - kprintf("uap->flags: [0x%X]\n", uap->flags); + //kprintf("uap->flags: [0x%X]\n", uap->flags); kprintf("uap->addr: [0x%X]\n", uap->addr); kprintf("uap->len: [0x%X]\n", uap->len); - kprintf("uap->prot: [0x%X]\n", uap->prot); + //kprintf("uap->prot: [0x%X]\n", uap->prot); kprintf("uap->fd: [%i]\n", uap->fd); - kprintf("uap->pad: [0x%X]\n", uap->pad); - kprintf("uap->pos: [0x%X]\n", uap->pos); + //kprintf("uap->pad: [0x%X]\n", uap->pad); + //kprintf("uap->pos: [0x%X]\n", uap->pos); //K_PANIC("NOT YET\n"); getfd(td, &fd, uap->fd); tmp = (char *) vmm_getFreeVirtualPage(_current->id, round_page(uap->len) / 0x1000, VM_TASK);