diff --git a/Makefile b/Makefile index b51a8a6..83ae1f5 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,9 @@ libc_old: src (cd src/lib/libc_old;make) +libc_a: src + (cd src/lib/libc;make LIBPATH=${.CURDIR} lib.a) + libc: src (cd src/lib/libc;make LIBPATH=${.CURDIR}) diff --git a/src/bin/ls/ls.c b/src/bin/ls/ls.c index f796cd8..0c62e7b 100644 --- a/src/bin/ls/ls.c +++ b/src/bin/ls/ls.c @@ -458,6 +458,7 @@ traverse(argc, argv, fts_options); else traverse(1, dotav, fts_options); + printf("EXITING: [%i]\n",rval); exit(rval); } diff --git a/src/bin/ls/print.c b/src/bin/ls/print.c index 6fd48f6..37d3772 100644 --- a/src/bin/ls/print.c +++ b/src/bin/ls/print.c @@ -121,6 +121,7 @@ int printname(const char *name) { +printf("printname\n"); if (f_octal || f_octal_escape) return prn_octal(name); else if (f_nonprint) @@ -142,6 +143,8 @@ int haveacls; dev_t prevdev; + printf("PRINTLONG\n"); + if ((dp->list == NULL || dp->list->fts_level != FTS_ROOTLEVEL) && (f_longform || f_size)) { (void)printf("total %lu\n", howmany(dp->btotal, blocksize)); @@ -218,6 +221,7 @@ { FTSENT *p; int chcnt; +printf("printstream\n"); for (p = dp->list, chcnt = 0; p; p = p->fts_link) { if (p->fts_number == NO_PRINT) @@ -257,6 +261,8 @@ int row; int tabwidth; +printf("printcol"); + if (f_notabs) tabwidth = 1; else @@ -322,6 +328,8 @@ if (f_sortacross && col + 1 >= numcols) break; (void)putchar(f_notabs ? ' ' : '\t'); + //Hack + printf("%s",f_notabs ? ' ' : '\t'); chcnt = cnt; } endcol += colwidth; @@ -343,6 +351,8 @@ int color_printed = 0; #endif +printf("printaname:\n"); + sp = p->fts_statp; chcnt = 0; if (f_inode) @@ -372,6 +382,7 @@ const char *format; static int d_first = -1; +printf("printtime\n"); if (d_first < 0) d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); if (now == 0) @@ -394,6 +405,7 @@ static int printtype(u_int mode) { +printf("printtype\n"); if (f_slash) { if ((mode & S_IFMT) == S_IFDIR) { @@ -433,6 +445,7 @@ static int putch(int c) { +printf("putch\n"); (void)putchar(c); return 0; } @@ -442,6 +455,8 @@ { char tmp = (char)c; +printf("writech\n"); + (void)write(STDOUT_FILENO, &tmp, 1); return 0; } diff --git a/src/bin/shell/exec.c b/src/bin/shell/exec.c index 5ccf887..d0b6f81 100644 --- a/src/bin/shell/exec.c +++ b/src/bin/shell/exec.c @@ -45,6 +45,7 @@ exec(file,data->argv,data->envp); else execn(file,&data->argv); + printf("%s: Command Not Found.\n",argv[1]); exit(-1); } diff --git a/src/bin/shell/main.c b/src/bin/shell/main.c index 5684bad..aa92cbb 100644 --- a/src/bin/shell/main.c +++ b/src/bin/shell/main.c @@ -59,7 +59,6 @@ inBuf->bg = 0x0; parseInput(inBuf,buffer); - printf("parsed: [0x%X]",inBuf->args->arg); if (inBuf->args->arg != 0x0) { if (!commands(inBuf)) diff --git a/src/bin/tcc/tcc.c b/src/bin/tcc/tcc.c index 2061366..35ac7dd 100644 --- a/src/bin/tcc/tcc.c +++ b/src/bin/tcc/tcc.c @@ -1847,15 +1847,8 @@ /* fill input buffer and peek next char */ static int tcc_peekc_slow(BufferedFile *bf) { int len; - int x,i; //printf("peekc: (%s:%i)",bf->filename,bf->fd); -/* - for (i=0;i<50000;i++) - for (x=0;x<10000;x++) - asm("nop"); -*/ - /* only tries to read if really end of buffer */ if (bf->buf_ptr >= bf->buf_end) { if (bf->fd != -1) { @@ -2904,7 +2897,6 @@ buf1[size] = '\0'; pstrcat(buf1, sizeof(buf1), buf); f = tcc_open(s1, buf1); - printf("to1"); if (f) { if (tok == TOK_INCLUDE_NEXT) tok = TOK_INCLUDE; @@ -2926,7 +2918,6 @@ pstrcat(buf1, sizeof(buf1), "/"); pstrcat(buf1, sizeof(buf1), buf); f = tcc_open(s1, buf1); - printf("to2"); if (f) { if (tok == TOK_INCLUDE_NEXT) tok = TOK_INCLUDE; @@ -2952,7 +2943,6 @@ } tok_flags |= TOK_FLAG_BOF | TOK_FLAG_BOL; ch = file->buf_ptr[0]; - printf("gte"); goto the_end; } break; @@ -9627,50 +9617,43 @@ } /* launch the compiled program with the given arguments */ -int tcc_run(TCCState *s1, int argc, char **argv) -{ - printf("PROG_MAIN\n"); - int (*prog_main)(int, char **); - printf("REL\n"); +int tcc_run(TCCState *s1, int argc, char **argv) { + int (*prog_main)(int, char **); - if (tcc_relocate(s1) < 0) - return -1; + if (tcc_relocate(s1) < 0) + return -1; - printf("OCATED\n"); - - prog_main = tcc_get_symbol_err(s1, "main"); -printf("TCC_GET_SYM\n"); + prog_main = tcc_get_symbol_err(s1, "main"); + printf("TCC_GET_SYM\n"); - if (do_debug) { - struct sigaction sigact; - /* install TCC signal handlers to print debug info on fatal - runtime errors */ - sigact.sa_flags = SA_SIGINFO | SA_RESETHAND; - sigact.sa_sigaction = sig_error; - sigemptyset(&sigact.sa_mask); - sigaction(SIGFPE, &sigact, NULL); - sigaction(SIGILL, &sigact, NULL); - sigaction(SIGSEGV, &sigact, NULL); - sigaction(SIGBUS, &sigact, NULL); - sigaction(SIGABRT, &sigact, NULL); + if (do_debug) { + struct sigaction sigact; + /* install TCC signal handlers to print debug info on fatal + runtime errors */ + sigact.sa_flags = SA_SIGINFO | SA_RESETHAND; + sigact.sa_sigaction = sig_error; + sigemptyset(&sigact.sa_mask); + sigaction(SIGFPE, &sigact, NULL); + sigaction(SIGILL, &sigact, NULL); + sigaction(SIGSEGV, &sigact, NULL); + sigaction(SIGBUS, &sigact, NULL); + sigaction(SIGABRT, &sigact, NULL); } -#ifdef CONFIG_TCC_BCHECK - if (do_bounds_check) { - void (*bound_init)(void); + #ifdef CONFIG_TCC_BCHECK + if (do_bounds_check) { + void (*bound_init)(void); - /* set error function */ - rt_bound_error_msg = (void *)tcc_get_symbol_err(s1, - "__bound_error_msg"); - - /* XXX: use .init section so that it also work in binary ? */ - bound_init = (void *)tcc_get_symbol_err(s1, "__bound_init"); - bound_init(); + /* set error function */ + rt_bound_error_msg = (void *)tcc_get_symbol_err(s1,"__bound_error_msg"); + /* XXX: use .init section so that it also work in binary ? */ + bound_init = (void *)tcc_get_symbol_err(s1, "__bound_init"); + bound_init(); } -#endif -printf("HI!: [0x%X]\n",prog_main); - return (*prog_main)(argc, argv); -} + #endif + printf("HI!: [0x%X][0x%X][%s]\n",prog_main,argv,argv[0]); + return (*prog_main)(argc, argv); + } TCCState *tcc_new(void) { diff --git a/src/lib/libc/Makefile b/src/lib/libc/Makefile index 4354340..f60ed5f 100644 --- a/src/lib/libc/Makefile +++ b/src/lib/libc/Makefile @@ -18,6 +18,7 @@ #Output OUTPUT = libc.so +OUTPUT2 = libc.a lib.so: $(OBJS) (cd yp;make LIBPATH=${LIBPATH}) @@ -49,7 +50,39 @@ $(CC) -nostdlib -shared -Wl,-x -o $(OUTPUT) -Wl,-soname,$(OUTPUT) `lorder $(OBJS) $(SUBS) | tsort -q` #$(CC) -nostdlib -shared -Wl,-x -o lib-c.so -Wl,-soname,lib-c.so `lorder $(OBJS) $(SUBS) | tsort -q` #(rm -fr pic.a;ar cq pic.a ./i386/*/*.o ./stdio/*.o ./stdlib/*.o ./string/*.o ./sys/*.o ./xdr/*.o ./yp/*.o ./locale/*.o ./gen/*.o ; ranlib ./pic.a) - (rm pic.a) + #(rm pic.a) + #$(AR) cq $(LPIC) `lorder $(OBJS) $(SUBS) | tsort -q` + #ranlib $(LPIC) + +lib.a: $(OBJS) +# (make clean) + (cd yp;make LIBPATH=${LIBPATH} PICA=true) + (cd xdr;make LIBPATH=${LIBPATH} PICA=true) + (cd uuid;make LIBPATH=${LIBPATH} PICA=true) +# (cd uthread;make LIBPATH=${LIBPATH} PICA=true) + (cd sys;make LIBPATH=${LIBPATH} PICA=true) + (cd string;make LIBPATH=${LIBPATH} PICA=true) + (cd stdtime;make LIBPATH=${LIBPATH} PICA=true) + (cd stdlib;make LIBPATH=${LIBPATH} PICA=true) + (cd stdio;make LIBPATH=${LIBPATH} PICA=true) + (cd rpc;make LIBPATH=${LIBPATH} PICA=true) + (cd resolv;make LIBPATH=${LIBPATH} PICA=true) + (cd regex;make LIBPATH=${LIBPATH} PICA=true) + (cd quad;make LIBPATH=${LIBPATH} PICA=true) + (cd posix1e;make LIBPATH=${LIBPATH} PICA=true) + (cd nls;make LIBPATH=${LIBPATH} PICA=true) + (cd net;make LIBPATH=${LIBPATH}) + (cd nameser;make LIBPATH=${LIBPATH}) + (cd locale;make LIBPATH=${LIBPATH}) + (cd isc;make LIBPATH=${LIBPATH}) + (cd inet;make LIBPATH=${LIBPATH}) + (cd i386;make LIBPATH=${LIBPATH}) + (cd gmon;make LIBPATH=${LIBPATH}) + (cd gen;make LIBPATH=${LIBPATH}) + (cd gdtoa;make LIBPATH=${LIBPATH}) + (cd db;make LIBPATH=${LIBPATH}) + (cd compat-43;make LIBPATH=${LIBPATH}) + (rm -fr libc.a) $(AR) cq $(LPIC) `lorder $(OBJS) $(SUBS) | tsort -q` ranlib $(LPIC) diff --git a/src/lib/libc/stdio/fflush.c b/src/lib/libc/stdio/fflush.c index 59da908..14d604c 100644 --- a/src/lib/libc/stdio/fflush.c +++ b/src/lib/libc/stdio/fflush.c @@ -58,6 +58,8 @@ { int retval; +printf("fflush\n"); + if (fp == NULL) return (_fwalk(sflush_locked)); FLOCKFILE(fp); diff --git a/src/lib/libc/stdio/putchar.c b/src/lib/libc/stdio/putchar.c index d23161d..74e55ca 100644 --- a/src/lib/libc/stdio/putchar.c +++ b/src/lib/libc/stdio/putchar.c @@ -57,6 +57,7 @@ { int retval; FILE *so = stdout; +printf("putchar\n"); FLOCKFILE(so); /* Orientation set by __sputc() when buffer is full. */ diff --git a/src/sys/Makefile.inc b/src/sys/Makefile.inc index 776f5cc..882e13f 100644 --- a/src/sys/Makefile.inc +++ b/src/sys/Makefile.inc @@ -1,6 +1,6 @@ -# $Id: +# $Id$ # global 'sys' options INCLUDES = -I../include -CFLAGS = -Wall -nostdlib -nostdinc -fno-builtin -fno-exceptions -O -DNOTIMP #-DVFSDEBUG #-DVMMDEBUG #-DVFSDEBUG -DDEBUG +CFLAGS = -Wall -nostdlib -nostdinc -fno-builtin -fno-exceptions -O -DNOTIMP #-DVFSDEBUG -DDEBUG #-DVMMDEBUG #-DVFSDEBUG KERNEL = ubix.elf diff --git a/src/sys/include/sys/kern_descrip.h b/src/sys/include/sys/kern_descrip.h index 243c902..4c9e92a 100644 --- a/src/sys/include/sys/kern_descrip.h +++ b/src/sys/include/sys/kern_descrip.h @@ -160,7 +160,9 @@ int close(struct thread *,struct close_args *); int falloc(struct thread *, struct file **, int *); int getdtablesize(struct thread *, struct getdtablesize_args *); -int fstat(struct thread *, struct fstat_args *); +int stat(struct thread *, struct stat_args *); +int fstat(struct thread *, struct fstat_args *); +int lstat(struct thread *, struct lstat_args *); int ioctl(struct thread *, struct ioctl_args *); int getfd(struct thread *td,struct file **fp,int fd); diff --git a/src/sys/include/sys/sysproto.h b/src/sys/include/sys/sysproto.h index d8cf2c3..b50e60d 100644 --- a/src/sys/include/sys/sysproto.h +++ b/src/sys/include/sys/sysproto.h @@ -177,10 +177,22 @@ char tp_l_[PADL_(struct timeval *)]; struct timeval * tp; char tp_r_[PADR_(struct timeval *)]; char tzp_l_[PADL_(struct timezone *)]; struct timezone * tzp; char tzp_r_[PADR_(struct timezone *)]; }; + +struct stat_args { + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char ub_l_[PADL_(struct stat *)]; struct stat * ub; char ub_r_[PADR_(struct stat *)]; +}; + struct fstat_args { char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; char sb_l_[PADL_(struct stat *)]; struct stat * sb; char sb_r_[PADR_(struct stat *)]; }; + +struct lstat_args { + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char ub_l_[PADL_(struct stat *)]; struct stat * ub; char ub_r_[PADR_(struct stat *)]; +}; + struct ioctl_args { char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; char com_l_[PADL_(u_long)]; u_long com; char com_r_[PADR_(u_long)]; diff --git a/src/sys/include/ubixos/syscalls_new.h b/src/sys/include/ubixos/syscalls_new.h index 3240417..9008e43 100644 --- a/src/sys/include/ubixos/syscalls_new.h +++ b/src/sys/include/ubixos/syscalls_new.h @@ -48,7 +48,9 @@ int munmap(); int sigprocmask(); int gettimeofday_new(); +int stat(); int fstat(); +int lstat(); int ioctl(); #define invalid_call 0x0 @@ -250,9 +252,9 @@ invalid_call, /** 185 **/ invalid_call, /** 186 **/ invalid_call, /** 187 **/ - invalid_call, /** 188 **/ + stat, /** 188 **/ fstat, /** 189 **/ - invalid_call, /** 190 **/ + lstat, /** 190 **/ invalid_call, /** 191 **/ invalid_call, /** 192 **/ invalid_call, /** 193 **/ diff --git a/src/sys/kernel/kern_descrip.c b/src/sys/kernel/kern_descrip.c index cae0ddf..45edcdd 100644 --- a/src/sys/kernel/kern_descrip.c +++ b/src/sys/kernel/kern_descrip.c @@ -100,6 +100,36 @@ } /* BUGS: Getting closer*/ +int stat(struct thread *td,struct stat_args *uap) { + #ifdef VFSDEBUG + kprintf("[%s:%i]",__FILE__,__LINE__,__FUNCTION__); + #endif + + #ifdef NOTIMP + kprintf("stat: %s\n",uap->path); + #endif + + if (!strcmp(uap->path,"ls")) { + kprintf("LS: [%i]\n",td->td_retval[0]); + uap->ub->st_dev = 81; + uap->ub->st_ino = 31; + uap->ub->st_nlink = 1; + uap->ub->st_atime = 1213841701; + uap->ub->st_mtime = 1213841701; + uap->ub->st_ctime = 1213841701; + uap->ub->st_birthtime = 1213841701; + uap->ub->st_size = 25228; + uap->ub->st_rdev = 2496; + uap->ub->st_mode = 33133; + uap->ub->st_blocks = 52; + uap->ub->st_blksize = 4096; + return(0x0); + } + td->td_retval[0] = -1; + return(0x0); + } + + int fstat(struct thread *td,struct fstat_args *uap) { struct file *fp = 0x0; @@ -112,11 +142,41 @@ uap->sb->st_blksize = 0x1000; uap->sb->st_size = fp->size; #ifdef NOTIMP - kprintf("fstat: %i",uap->fd); + kprintf("fstat: %i\n",uap->fd); #endif return(0x0); } +int lstat(struct thread *td,struct lstat_args *uap) { + #ifdef VFSDEBUG + kprintf("[%s:%i]",__FILE__,__LINE__,__FUNCTION__); + #endif + + #ifdef NOTIMP + kprintf("lstat: %s\n",uap->path); + #endif + + if (!strcmp(uap->path,"ls")) { + kprintf("LS: [%i]\n",td->td_retval[0]); + uap->ub->st_dev = 81; + uap->ub->st_ino = 31; + uap->ub->st_nlink = 1; + uap->ub->st_atime = 1213841701; + uap->ub->st_mtime = 1213841701; + uap->ub->st_ctime = 1213841701; + uap->ub->st_birthtime = 1213841701; + uap->ub->st_size = 25228; + uap->ub->st_rdev = 2496; + uap->ub->st_mode = 33133; + uap->ub->st_blocks = 52; + uap->ub->st_blksize = 4096; + return(0x0); + } + td->td_retval[0] = -1; + return(0); + } + + /*! * \brief ioctl functionality not implimented yet * diff --git a/src/sys/kernel/syscall.c b/src/sys/kernel/syscall.c index 6fd7de7..379d4ca 100644 --- a/src/sys/kernel/syscall.c +++ b/src/sys/kernel/syscall.c @@ -181,7 +181,7 @@ if ((tmpTask != 0x0) && (ptr != 0x0)) { *ptr = tmpTask->state; if (*ptr != 1) - kprintf("[%i]",*ptr); + kprintf("CP: [%i]\n",*ptr); } else *ptr = 0x0; diff --git a/src/sys/vfs/vfs_syscalls.c b/src/sys/vfs/vfs_syscalls.c index 55be61a..2c53c96 100644 --- a/src/sys/vfs/vfs_syscalls.c +++ b/src/sys/vfs/vfs_syscalls.c @@ -163,7 +163,7 @@ td->td_retval[0] = uap->nbyte; } else { - kprintf("[%i]",uap->nbyte); + kprintf("WUAP[%i]",uap->nbyte); buffer = kmalloc(uap->nbyte); memcpy(buffer,uap->buf,uap->nbyte); //kprint(buffer); @@ -196,14 +196,20 @@ if (error) return(error); - strcpy(nfp->path,uap->path); + kprintf("opening: %s\n",uap->path); + + if (!strcmp(".",uap->path)) { + kprintf("GOTCHA!\n"); + strcpy(nfp->path,"/bin"); + } + else + strcpy(nfp->path,uap->path); if (uap->flags != 0x0) { kprintf("BAD!\n"); while (1); } - - if (fopen(nfp,uap->path,"r") == 0x0) { + if (fopen(nfp,nfp->path,"r") == 0x0) { td->td_retval[0] = -1; td->o_files[index] = 0x0; } diff --git a/src/sys/vmm/paging.c b/src/sys/vmm/paging.c index 200dc2f..e2658f1 100644 --- a/src/sys/vmm/paging.c +++ b/src/sys/vmm/paging.c @@ -557,7 +557,7 @@ } else if (new < old) { kprintf("0x%X < 0x%X\n",new,old); - K_PANIC("new < old"); + //K_PANIC("new < old"); td->vm_dsize -= btoc(old - new); }