diff --git a/Makefile b/Makefile index 59901a4..b51a8a6 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # $Id$ # The System Makefile (C) 2002 The UbixOS Project -all: kernel tools ubix_api libc_old ubix csu libc libcpp bin +all: kernel tools ubix_api libc_old ubix csu libc libcpp libutil bin # depend kernel tools csu: src @@ -28,6 +28,9 @@ libcpp: src (cd src/lib/libcpp;make) +libutil: src + (cd src/lib/libutil;make) + depend: src (cd src/lib/ubix;make) @@ -52,6 +55,7 @@ (cd src/lib/ubix_api;make clean) (cd src/lib/libc_old;make clean) (cd src/lib/libc;make clean) + (cd src/lib/libutil;make clean) (cd src/bin;make clean) (cd src/lib/ubix;make clean) (cd src/lib/libcpp;make clean) diff --git a/src/bin/Makefile b/src/bin/Makefile index 7f14e27..e2c0aa9 100644 --- a/src/bin/Makefile +++ b/src/bin/Makefile @@ -1,8 +1,8 @@ # $Id$ # The System Makefile (C) 2002 The UbixOS Project -all: init-bin login-bin shell-bin clock-bin cp-bin fdisk-bin format-bin disklabel-bin ubistry-bin edit-bin ld-bin ttyd-bin stat-bin cat-bin rtld-elf-bin tcc-bin -# test-bin pwd-bin cat-bin de-bin ls-bin goofball-bin mount-bin +all: init-bin login-bin shell-bin clock-bin cp-bin fdisk-bin format-bin disklabel-bin ubistry-bin edit-bin ld-bin ttyd-bin stat-bin cat-bin rtld-elf-bin tcc-bin ls-bin +# test-bin pwd-bin cat-bin de-bin goofball-bin mount-bin init-bin: init (cd init;make) diff --git a/src/bin/edit/main.c b/src/bin/edit/main.c index 5576352..f1cc47a 100644 --- a/src/bin/edit/main.c +++ b/src/bin/edit/main.c @@ -40,12 +40,18 @@ printf("V1.0\n"); //out = fopen("/test.txt","r"); - fd = open("/usr/include/stdio.h"); + + if (argc > 1) + fd = open(argv[1]); + else + fd = open("/usr/include/stdio.h"); + + printf("FD: %i\n",fd); //while (!feof(out)) { while (len != 0) { len = read(fd,&buf,8192); - printf("[%i](%c%c%c%c)",len,buf[0],buf[1],buf[2],buf[3]); + printf("[%i](%c%c%c%c)\n",len,buf[0],buf[1],buf[2],buf[3]); //printf("%c",fgetc(out)); } diff --git a/src/bin/shell/commands.c b/src/bin/shell/commands.c index 07f2236..cf987d0 100644 --- a/src/bin/shell/commands.c +++ b/src/bin/shell/commands.c @@ -120,8 +120,8 @@ printf("Base Command Line Interface\n"); } else if (memcmp(data->args->arg,"cd",2) == 0) { - if (argv[1]) { - chdir(argv[1]); + if (argv[2]) { + chdir(argv[2]); getcwd(cwd,1024); } } diff --git a/src/bin/tcc/Makefile b/src/bin/tcc/Makefile index 00c6797..062f048 100644 --- a/src/bin/tcc/Makefile +++ b/src/bin/tcc/Makefile @@ -28,9 +28,9 @@ # Link The Binary $(BINARY) : $(OBJS) $(CC) $(CFLAGS) -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) - $(CC) -DLIBTCC -c -o libtcc.o tcc.c + $(CC) -nostdlib -DLIBTCC -c -o libtcc.o tcc.c ar rcs libtcc.a libtcc.o - $(CC) -O2 -Wall -c -o libtcc1.o libtcc1.c + $(CC) -nostdlib -O2 -Wall -c -o libtcc1.o libtcc1.c ar rcs libtcc1.a libtcc1.o # Compile the source files diff --git a/src/bin/tcc/tcc.c b/src/bin/tcc/tcc.c index 9df82b0..2061366 100644 --- a/src/bin/tcc/tcc.c +++ b/src/bin/tcc/tcc.c @@ -1848,7 +1848,7 @@ static int tcc_peekc_slow(BufferedFile *bf) { int len; int x,i; - printf("peekc: (%s:%i)",bf->filename,bf->fd); + //printf("peekc: (%s:%i)",bf->filename,bf->fd); /* for (i=0;i<50000;i++) @@ -1864,9 +1864,9 @@ #else len = IO_BUF_SIZE; #endif - printf("readl1: [%i]\n",len); + //printf("readl1: [%i]\n",len); len = read(bf->fd, bf->buffer, len); - printf("readl2: [%i](%c%c%c%c)\n",len,bf->buffer[0],bf->buffer[1],bf->buffer[2],bf->buffer[3]); + //printf("readl2: [%i](%c%c%c%c)\n",len,bf->buffer[0],bf->buffer[1],bf->buffer[2],bf->buffer[3]); if (len < 0) len = 0; } @@ -8996,7 +8996,6 @@ type = btype; printf("btype (%s)",get_tok_str(v,NULL)); type_decl(&type, &ad, &v, TYPE_DIRECT); - printf("BTYPE"); #if 0 { char buf[500]; @@ -9591,12 +9590,8 @@ int i; s1->nb_errors = 0; - -#ifdef TCC_TARGET_PE - pe_add_runtime(s1); -#else + tcc_add_runtime(s1); -#endif relocate_common_syms(); @@ -9615,7 +9610,9 @@ } } + printf("RELOCATING"); relocate_syms(s1, 1); + printf("RELOCATED: %i",s1->nb_errors); if (s1->nb_errors != 0) return -1; @@ -9632,6 +9629,7 @@ /* 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"); @@ -9641,11 +9639,9 @@ printf("OCATED\n"); prog_main = tcc_get_symbol_err(s1, "main"); +printf("TCC_GET_SYM\n"); if (do_debug) { -#if defined(WIN32) || defined(CONFIG_TCCBOOT) - error("debug mode currently not available for Windows"); -#else struct sigaction sigact; /* install TCC signal handlers to print debug info on fatal runtime errors */ @@ -9657,7 +9653,6 @@ sigaction(SIGSEGV, &sigact, NULL); sigaction(SIGBUS, &sigact, NULL); sigaction(SIGABRT, &sigact, NULL); -#endif } #ifdef CONFIG_TCC_BCHECK @@ -9673,6 +9668,7 @@ bound_init(); } #endif +printf("HI!: [0x%X]\n",prog_main); return (*prog_main)(argc, argv); } @@ -10686,12 +10682,14 @@ /* XXX: cannot do it with bound checking because of the malloc hooks */ if (!do_bounds_check) tcc_delete(s); + printf("BOOBS6\n"); #ifdef MEM_DEBUG if (do_bench) { printf("memory: %d bytes, max = %d bytes\n", mem_cur_size, mem_max_size); } #endif + printf("BOOBS7\n"); return ret; } diff --git a/src/bin/tcc/tccelf.c b/src/bin/tcc/tccelf.c index e4d4dfc..921f14e 100644 --- a/src/bin/tcc/tccelf.c +++ b/src/bin/tcc/tccelf.c @@ -428,7 +428,7 @@ if (sym_bind == STB_WEAK) { sym->st_value = 0; } else { - error_noabort("undefined symbol '%s'", name); + error_noabort("undefined symbol '%s','%i'", name,sym_bind); } } else if (sh_num < SHN_LORESERVE) { /* add section base */ @@ -988,6 +988,8 @@ } #endif /* add libc */ + +printf("ADD-LIBC"); if (!s1->nostdlib) { tcc_add_library(s1, "c"); @@ -998,6 +1000,7 @@ if (s1->output_type != TCC_OUTPUT_MEMORY && !s1->nostdlib) { tcc_add_file(s1, CONFIG_TCC_CRT_PREFIX "/crtn.o"); } +printf("ADDED\n"); } /* add various standard linker symbols (must be done after the @@ -2014,7 +2017,11 @@ bound = 0; for(p = ar_names, i = 0; i < nsyms; i++, p += strlen(p)+1) { sym_index = find_elf_sym(symtab_section, p); -printf("SI: [%i]",sym_index); +/* + if (sym_index > 0) + printf("SI: [%i]",sym_index); + UBU +*/ if(sym_index) { sym = &((Elf32_Sym *)symtab_section->data)[sym_index]; if(sym->st_shndx == SHN_UNDEF) { diff --git a/src/lib/libc/Makefile b/src/lib/libc/Makefile index 1cd8db5..4354340 100644 --- a/src/lib/libc/Makefile +++ b/src/lib/libc/Makefile @@ -14,7 +14,7 @@ LPIC = pic.a #Sub Sections -SUBS = ./*/*.o ./db/*/*.o ./i386/*/*.o +SUBS = ./*/*.o ./db/*/*.o ./i386/*/*.o ../csu/*.o #Output OUTPUT = libc.so @@ -46,12 +46,15 @@ (cd gdtoa;make LIBPATH=${LIBPATH}) (cd db;make LIBPATH=${LIBPATH}) (cd compat-43;make LIBPATH=${LIBPATH}) - $(CC) -shared -Wl,-x -o $(OUTPUT) -Wl,-soname,$(OUTPUT) `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) + $(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) + $(AR) cq $(LPIC) `lorder $(OBJS) $(SUBS) | tsort -q` + ranlib $(LPIC) pic.a: $(OBJS) - (make clean) - (cd yp;make PICA=true) + (cd yp;make PICA=true LIBPATH=${LIBPATH}) (cd xdr;make PICA=true) (cd uuid;make PICA=true) (cd uthread;make PICA=true) @@ -77,9 +80,9 @@ (cd gdtoa;make) (cd db;make) (cd compat-43;make) -pic_a: $(OBJS) - $(AR) cq $(LPIC) $(OBJS) $(SUBS) - ranlib $(LPIC) +#pic_a: $(OBJS) +# $(AR) cq $(LPIC) $(OBJS) $(SUBS) +# ranlib $(LPIC) # Compile the source files .cc.o: diff --git a/src/lib/libc/include/libc_private.h b/src/lib/libc/include/libc_private.h index 6513a69..f9924e9 100644 --- a/src/lib/libc/include/libc_private.h +++ b/src/lib/libc/include/libc_private.h @@ -134,4 +134,9 @@ */ extern struct _spinlock *__malloc_lock; +/* + * Function to clean up streams, called from abort() and exit(). + */ +extern void (*__cleanup)(void); + #endif /* _LIBC_PRIVATE_H_ */ diff --git a/src/lib/libc/stdlib/abort.c b/src/lib/libc/stdlib/abort.c index 18d0c73..110ddd1 100644 --- a/src/lib/libc/stdlib/abort.c +++ b/src/lib/libc/stdlib/abort.c @@ -45,8 +45,7 @@ #include #include "un-namespace.h" -void (*__cleanup)(); - +#include "libc_private.h" void abort() { diff --git a/src/lib/libutil/Makefile b/src/lib/libutil/Makefile new file mode 100644 index 0000000..dbdb5fe --- /dev/null +++ b/src/lib/libutil/Makefile @@ -0,0 +1,40 @@ +# $Id$ +# The System Makefile (C) 2002 The UbixOS Project + +# Include Global 'Source' Options +#include ../../../Makefile.inc +include ../../Makefile.inc +#include ../Makefile.inc +#include ../libc.inc + +INCLUDES = -I../../include.new -I../libc/gen/ + +OUTPUT = libutil.so + +CFLAGS = -fpic -DPIC -O2 -fno-strict-aliasing -pipe -D__DBINTERFACE_PRIVATE -DINET6 -DPOSIX_MISTAKE -DBROKEN_DES -DPORTMAP -DDES_BUILTIN -DYP -DHESIOD -Wsystem-headers -Wall -Wno-format-y2k -Wno-uninitialized + +OBJS = _secure_path.o gr_util.o login_cap.o login_tty.o pty.o uucplock.o auth.o humanize_number.o login_class.o logout.o pw_util.o expand_number.o kld.o login_crypt.o logwtmp.o realhostname.o flopen.o login.o login_ok.o pidfile.o stub.o fparseln.o login_auth.o login_times.o property.o trimdomain.o + +all: $(OBJS) + $(CC) -fnobuiltin -nostdlib -shared -Wl,-x -o $(OUTPUT) -Wl,-soname,$(OUTPUT) `lorder $(OBJS) $(SUBS) | tsort -q` + +# Compile the source files +.cc.o: + $(CXX) $(CFLAGS) $(INCLUDES) -c -o $@ $< + +.cc.s: + $(CXX) $(CFLAGS) $(INCLUDES) -S -o $@ $< + +.c.o: + $(CC) $(CFLAGS) $(INCLUDES) -c $< + +.c.s: + $(CC) $(CFLAGS) $(INCLUDES) -S -o $@ $< + +.S.o: + $(CC) $(CFLAGS) -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) + diff --git a/src/sys/ufs/ufs.c b/src/sys/ufs/ufs.c index 47af23b..3b98fdc 100644 --- a/src/sys/ufs/ufs.c +++ b/src/sys/ufs/ufs.c @@ -161,7 +161,6 @@ inomap = inode; fd->offset = 0; - //kprintf("RSOF"); blkmap = indmap = 0; } @@ -225,7 +224,6 @@ memcpy(s, blkbuf + vboff, n); s += n; fd->offset += n; - //kprintf("UPOFST"); nb -= n; } return nbyte; diff --git a/src/sys/vfs/file.c b/src/sys/vfs/file.c index 3c0e7de..9f86297 100644 --- a/src/sys/vfs/file.c +++ b/src/sys/vfs/file.c @@ -383,7 +383,9 @@ kfree(tmpFd->buffer); kfree(tmpFd); //spinUnlock(&fdTable_lock); - kprintf("File Not Found? %s\n\n",file); + #ifdef VFSDEBUG + kprintf("File Not Found? (%s)\n\n",file); + #endif return (NULL); } diff --git a/src/sys/vfs/vfs_syscalls.c b/src/sys/vfs/vfs_syscalls.c index 19775ff..55be61a 100644 --- a/src/sys/vfs/vfs_syscalls.c +++ b/src/sys/vfs/vfs_syscalls.c @@ -168,7 +168,7 @@ memcpy(buffer,uap->buf,uap->nbyte); //kprint(buffer); kfree(buffer); - kprintf("(%i) %s",uap->fd,uap->buf); + kprintf("(%i) [%s]",uap->fd,uap->buf); td->td_retval[0] = uap->nbyte; } return(0x0); @@ -198,26 +198,18 @@ strcpy(nfp->path,uap->path); - #ifdef VFSDEBUG - kprintf("OPEN FLAGS: [0x%X],Path: [%s]\n",uap->flags,uap->path); - #endif if (uap->flags != 0x0) { kprintf("BAD!\n"); while (1); } - //BUG make fopen return 0 or -1 if error; - #ifdef VFSDEBUG - kprintf("[0x%X]-234\n",nfp->buffer); - #endif - //fopen(nfp,uap->path,"r"); - kprintf("vfs_open: [0x%X]\n",fopen(nfp,uap->path,"r")); - #ifdef VFSDEBUG - kprintf("[0x%X]-sdf\n",nfp->buffer); - #endif - if (nfp == 0x0) + + if (fopen(nfp,uap->path,"r") == 0x0) { td->td_retval[0] = -1; + td->o_files[index] = 0x0; + } else td->td_retval[0] = index; + return (error); } /* end func open */ diff --git a/src/tools/Makefile b/src/tools/Makefile index b88c559..8a59190 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -45,11 +45,16 @@ (cp ../bin/fdisk/fdisk /mnts/ubix/bin) (cp ../bin/edit/edit /mnts/ubix/bin) (cp ../bin/cat/cat /mnts/ubix/bin) + (cp ../bin/ls/ls /mnts/ubix/bin) (cp ../bin/ld/ld.so /mnts/ubix/lib) #(cp ../bin/rtld-elf/ld-elf.so.1 /mnts/ubix/libexec) (cp ../bin/tcc/tcc /mnts/ubix/bin) + (cp ../bin/tcc/libtcc.a /mnts/ubix/tcc) (cp ../lib/libc_old/libc_old.so /mnts/ubix/lib) + (cp ../lib/libutil/libutil.so /mnts/ubix/lib) (cp ../lib/libc/libc.so /mnts/ubix/lib) + (cp ../lib/libc/libc.so /mnts/ubix/tcc/lib) + (cp ../lib/libc/pic.a /mnts/ubix/tcc/lib/libc.a) (cp ../lib/ubix_api/ubix_api.so /mnts/ubix/lib) (cp ./userdb /mnts/ubix/etc) (cp ./motd /mnts/ubix/etc)