diff --git a/src/bin/edit/main.c b/src/bin/edit/main.c index f49f241..5576352 100644 --- a/src/bin/edit/main.c +++ b/src/bin/edit/main.c @@ -33,16 +33,23 @@ int main(int argc,char **argv) { char *a,*b; FILE *out; + char buf[8192]; + int fd; + int len = -1; printf("UbixOS Text Editor\n"); printf("V1.0\n"); - out = fopen("/test.txt","r"); + //out = fopen("/test.txt","r"); + fd = open("/usr/include/stdio.h"); - while (!feof(out)) { - printf("%c",fgetc(out)); + //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("%c",fgetc(out)); } - fclose(out); + //fclose(out); printf("argc: [%i]\n",argc); diff --git a/src/bin/init/main.c b/src/bin/init/main.c index 029ec5a..257d778 100644 --- a/src/bin/init/main.c +++ b/src/bin/init/main.c @@ -1,5 +1,5 @@ /***************************************************************************************** - Copyright (c) 2002-2004,2007 The UbixOS Project + Copyright (c) 2002-2004,2007,2008 The UbixOS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are @@ -85,7 +85,7 @@ if (0 == i) { printf("Starting Login Daemon.\n"); - exec("sys:/bin/login",0x0); + exec("sys:/bin/login",0x0,0x0); printf("Error Starting System\n"); exit(0x0); } diff --git a/src/bin/login/main.c b/src/bin/login/main.c index a504211..c76ffd8 100644 --- a/src/bin/login/main.c +++ b/src/bin/login/main.c @@ -1,5 +1,5 @@ /************************************************************************************** - Copyright (c) 2002 The UbixOS Project + Copyright (c) 2002,2008 The UbixOS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -128,7 +128,7 @@ //chdir(data[i].path); chdir("sys:/bin/"); printf("[%s]\n",data[i].shell); - exec(data[i].shell,0x0); + exec(data[i].shell,0x0,0x0); printf("Error: Problem Starting Shell\n"); exit(-1); } diff --git a/src/bin/shell/commands.c b/src/bin/shell/commands.c index 4bd3ef0..07f2236 100644 --- a/src/bin/shell/commands.c +++ b/src/bin/shell/commands.c @@ -1,5 +1,5 @@ /***************************************************************************************** - Copyright (c) 2002-2004 The UbixOS Project + Copyright (c) 2002-2004,2008 The UbixOS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are @@ -40,14 +40,10 @@ int commands(inputBuffer *data) { int cPid = 0x0,i = 0x0,x = 0x0; - char **argv = &data->argv; + char **argv = data->argv; mpi_message_t cmdMsg; -#ifdef DEBUG -printf("WEST\n\n"); -#endif - if (data == NULL) return 1; if (data->args->arg == NULL) return 1; @@ -68,7 +64,7 @@ /* printf("Starting Clock\n"); */ cPid = fork(); if (cPid == 0x0) { - exec("clock",0x0); + exec("clock",0x0,0x0); exit(0x1); } else { printf("Childs Pid: [%i]\n",cPid); @@ -77,7 +73,7 @@ } cPid = fork(); if (cPid == 0x0) { - exec("ls", 0x0); + exec("ls", 0x0,0x0); exit(0x1); } else { printf("Childs Pid: [%i]\n",cPid); @@ -91,7 +87,7 @@ cPid = fork(); if (cPid == 0x0) { printf("Pid: [%i:%i]\n",cPid,i); - exec("clock",0x0); + exec("clock",0x0,0x0); exit(0x1); } else { diff --git a/src/bin/shell/exec.c b/src/bin/shell/exec.c index 41ff599..5ccf887 100644 --- a/src/bin/shell/exec.c +++ b/src/bin/shell/exec.c @@ -32,17 +32,17 @@ void execProgram(inputBuffer *data) { char file[1024]; - char **argv = &data->argv; + char **argv = data->argv; int cPid = 0x0; - printf("Executing App\n"); + printf("Executing App: %s\n",argv[1]); cPid = fork(); if (!cPid) { sprintf(file,"%s%s",cwd,argv[1]); if (boo == 0) - exec(file,&data->argv); + exec(file,data->argv,data->envp); else execn(file,&data->argv); printf("%s: Command Not Found.\n",argv[1]); diff --git a/src/bin/shell/input.c b/src/bin/shell/input.c index 86203f2..917289d 100644 --- a/src/bin/shell/input.c +++ b/src/bin/shell/input.c @@ -1,5 +1,5 @@ /************************************************************************************** - Copyright (c) 2002 The UbixOS Project + Copyright (c) 2002,2008 The UbixOS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -63,26 +63,24 @@ } /* Alloc memory for argv[] */ - buffer->argv = (char *)malloc(sizeof(char *) * (buffer->argc + 1)); - //buffer->envp = (char **)malloc(sizeof(char)); + buffer->argv = (char *)malloc(sizeof(char *) * (buffer->argc + 2)); + buffer->envp = (char *)malloc(sizeof(char *)); - //buffer->envp[0] = 0x1; + buffer->envp[0] = 0x0; tmpArgs = buffer->args; - argv = &buffer->argv; - - //printf("argc: [%i]\n",buffer->argc); + argv = buffer->argv; for (i=0x1;i <= buffer->argc;i++) { argv[i] = tmpArgs->arg; - printf("argv[%i]: %s\n",i,argv[i]); tmpArgs = tmpArgs->next; } argv[0] = (char *)buffer->argc; - //argv[buffer->argc+1] = buffer->envp; } void freeArgs(inputBuffer *ptr) { free(ptr->args); + free(ptr->argv); + free(ptr->envp); //free(tmpArgs->argv); } diff --git a/src/bin/shell/main.c b/src/bin/shell/main.c index 0be249a..5684bad 100644 --- a/src/bin/shell/main.c +++ b/src/bin/shell/main.c @@ -1,5 +1,5 @@ /************************************************************************************** - Copyright (c) 2002 The UbixOS Project + Copyright (c) 2002,2008 The UbixOS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -59,6 +59,7 @@ 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/shell/shell.h b/src/bin/shell/shell.h index 9a28739..b7b4a25 100644 --- a/src/bin/shell/shell.h +++ b/src/bin/shell/shell.h @@ -9,11 +9,11 @@ }; typedef struct { + uInt8 bg; + struct argsStruct *args; int argc; char *argv; char **envp; - uInt8 bg; - struct argsStruct *args; } inputBuffer; void parseInput(inputBuffer *,char *); diff --git a/src/bin/tcc/tcc.c b/src/bin/tcc/tcc.c index 323a894..9df82b0 100644 --- a/src/bin/tcc/tcc.c +++ b/src/bin/tcc/tcc.c @@ -1374,6 +1374,7 @@ } if (!is_warning || s1->warn_error) s1->nb_errors++; + printf("error1(): [%s]",buf); } #ifdef LIBTCC @@ -1846,6 +1847,14 @@ /* 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) { @@ -1855,7 +1864,9 @@ #else len = IO_BUF_SIZE; #endif + 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]); if (len < 0) len = 0; } @@ -2893,6 +2904,7 @@ 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; @@ -2914,6 +2926,7 @@ 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; @@ -2939,6 +2952,7 @@ } tok_flags |= TOK_FLAG_BOF | TOK_FLAG_BOL; ch = file->buf_ptr[0]; + printf("gte"); goto the_end; } break; @@ -6454,7 +6468,7 @@ s = struct_find(v); if (s) { if (s->type.t != a) - error("invalid type"); + error("invalid type-1"); goto do_decl; } } else { @@ -6821,7 +6835,7 @@ if (l != FUNC_OLD) { if (!parse_btype(&pt, &ad1)) { if (l) { - error("invalid type"); + error("invalid type-2"); } else { l = FUNC_OLD; goto old_proto; @@ -8980,11 +8994,13 @@ } while (1) { /* iterate thru each declaration */ type = btype; + printf("btype (%s)",get_tok_str(v,NULL)); type_decl(&type, &ad, &v, TYPE_DIRECT); + printf("BTYPE"); #if 0 { char buf[500]; - type_to_str(buf, sizeof(buf), t, get_tok_str(v, NULL)); + type_to_str(buf, sizeof(buf), t,get_tok_str(v, NULL)); printf("type = '%s'\n", buf); } #endif @@ -9123,6 +9139,7 @@ } } } +printf("END_DECL"); } /* better than nothing, but needs extension to handle '-E' option @@ -9860,6 +9877,7 @@ /* open the file */ saved_file = file; file = tcc_open(s1, filename); + printf("OF-1"); if (!file) { if (flags & AFF_PRINT_ERROR) { error_noabort("file '%s' not found", filename); diff --git a/src/bin/ubistry/message.c b/src/bin/ubistry/message.c index 264fcc6..d2147c0 100644 --- a/src/bin/ubistry/message.c +++ b/src/bin/ubistry/message.c @@ -1,5 +1,5 @@ /***************************************************************************************** - Copyright (c) 2002-2004 The UbixOS Project + Copyright (c) 2002-2004,2008 The UbixOS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are @@ -70,7 +70,7 @@ mpi_destroyMbox("ubistry"); if (fork() == 0x0) { printf("ubistry: Restarting\n"); - exec("ubistry@sys",0x0); + exec("ubistry@sys",0x0,0x0); } else { exit(0x0); @@ -87,6 +87,9 @@ /*** $Log$ + Revision 1.1.1.1 2007/01/17 03:30:20 reddawg + UbixOS + Revision 1.2 2006/12/12 14:09:17 reddawg Changes diff --git a/src/include/sys/sys.h b/src/include/sys/sys.h index 318def8..c6c4b49 100644 --- a/src/include/sys/sys.h +++ b/src/include/sys/sys.h @@ -24,7 +24,7 @@ #ifndef _SYS_H #define _SYS_H -int exec(char *,char **argv); +int exec(char *,char **argv,char **envp); int execn(char *,char **argv); int pidStatus(int pid); void *getPage(int count,int type); diff --git a/src/lib/libc_old/sys/exec.c b/src/lib/libc_old/sys/exec.c index ffd5419..4566f84 100644 --- a/src/lib/libc_old/sys/exec.c +++ b/src/lib/libc_old/sys/exec.c @@ -27,12 +27,12 @@ *****************************************************************************************/ -int exec(char *file,char *argv) { +int exec(char *file,char *argv,char *envp) { volatile int status = 0x1; asm volatile( "int %0 \n" - : : "i" (0x80),"a" (3),"b" (file),"c" (argv) + : : "i" (0x80),"a" (3),"b" (file),"c" (argv),"d" (envp) ); return(status); } diff --git a/src/sys/Makefile.inc b/src/sys/Makefile.inc index 3d279e3..776f5cc 100644 --- a/src/sys/Makefile.inc +++ b/src/sys/Makefile.inc @@ -2,5 +2,5 @@ # global 'sys' options INCLUDES = -I../include -CFLAGS = -Wall -nostdlib -nostdinc -fno-builtin -fno-exceptions -O -DNOTIMP #-DVMMDEBUG #-DVFSDEBUG -DDEBUG +CFLAGS = -Wall -nostdlib -nostdinc -fno-builtin -fno-exceptions -O -DNOTIMP #-DVFSDEBUG #-DVMMDEBUG #-DVFSDEBUG -DDEBUG KERNEL = ubix.elf diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index c3382e5..11f0c01 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -351,7 +351,7 @@ 04-22-03 - It Now Loads Sections Not The Full File *****************************************************************************************/ -void sysExec(char *file,char *ap) { +void sysExec(char *file,char *ap,char *ep) { int i = 0x0; int x = 0x0; int argc = 0x0; @@ -361,6 +361,7 @@ uInt32 seg_addr = 0x0; char *interp = 0x0; char **argv = 0x0; + char **envp = 0x0; char **argvNew = 0x0; char *args = 0x0; @@ -520,6 +521,10 @@ kprintf("STATING: [0x%X][0x%X]\n",_current->td.vm_dsize,_current->td.vm_daddr); argv = ap; + envp = ep; + + if ((ep != 0x0) && (envp[0] != 0x0)) + kprintf("ENV SIZE: [0x%X]\n",envp[0]); if (argv[1] != 0x0) { argc = argv[0]; diff --git a/src/sys/ufs/ufs.c b/src/sys/ufs/ufs.c index 91e561d..47af23b 100644 --- a/src/sys/ufs/ufs.c +++ b/src/sys/ufs/ufs.c @@ -84,152 +84,152 @@ static ssize_t fsread(ino_t inode, void *buf, size_t nbyte,struct file *fd) { -#ifndef UFS2_ONLY - static struct ufs1_dinode dp1; -#endif -#ifndef UFS1_ONLY - static struct ufs2_dinode dp2; -#endif - static ino_t inomap; - char *blkbuf; - void *indbuf; - struct fs *fs; - char *s; - size_t n, nb, size, off, vboff; - ufs_lbn_t lbn; - ufs2_daddr_t addr, vbaddr; - static ufs2_daddr_t blkmap, indmap; - u_int u; - struct ufs_obj *ufsObj = fd->fsObj; + #ifndef UFS2_ONLY + static struct ufs1_dinode dp1; + #endif + #ifndef UFS1_ONLY + static struct ufs2_dinode dp2; + #endif + static ino_t inomap; + char *blkbuf; + void *indbuf; + struct fs *fs; + char *s; + size_t n, nb, size, off, vboff; + ufs_lbn_t lbn; + ufs2_daddr_t addr, vbaddr; + static ufs2_daddr_t blkmap, indmap; + u_int u; + struct ufs_obj *ufsObj = fd->fsObj; - blkbuf = ufsObj->dmadat->blkbuf; - indbuf = ufsObj->dmadat->indbuf; - fs = (struct fs *)ufsObj->dmadat->sbbuf; + blkbuf = ufsObj->dmadat->blkbuf; + indbuf = ufsObj->dmadat->indbuf; + fs = (struct fs *)ufsObj->dmadat->sbbuf; -#ifdef DEBUG -kprintf("fsread!\n"); -#endif + #ifdef DEBUG + kprintf("fsread!\n"); + #endif - if (!ufsObj->dsk_meta) { - inomap = 0; - for (n = 0; sblock_try[n] != -1; n++) { - if (dskread(fs, sblock_try[n] / DEV_BSIZE, 16,fd)) - return -1; - if (( -#if defined(UFS1_ONLY) - fs->fs_magic == FS_UFS1_MAGIC -#elif defined(UFS2_ONLY) - (fs->fs_magic == FS_UFS2_MAGIC && - fs->fs_sblockloc == sblock_try[n]) -#else - fs->fs_magic == FS_UFS1_MAGIC || - (fs->fs_magic == FS_UFS2_MAGIC && - fs->fs_sblockloc == sblock_try[n]) -#endif - ) && - fs->fs_bsize <= MAXBSIZE && - fs->fs_bsize >= sizeof(struct fs)) - break; - } - if (sblock_try[n] == -1) { - kprintf("Not ufs\n"); - return -1; - } - ufsObj->dsk_meta++; - } + if (!ufsObj->dsk_meta) { + inomap = 0; + for (n = 0; sblock_try[n] != -1; n++) { + if (dskread(fs, sblock_try[n] / DEV_BSIZE, 16,fd)) + return -1; + if (( + #if defined(UFS1_ONLY) + fs->fs_magic == FS_UFS1_MAGIC + #elif defined(UFS2_ONLY) + (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_sblockloc == sblock_try[n]) + #else + fs->fs_magic == FS_UFS1_MAGIC || (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_sblockloc == sblock_try[n]) + #endif + ) && fs->fs_bsize <= MAXBSIZE && fs->fs_bsize >= sizeof(struct fs)) + break; + } + if (sblock_try[n] == -1) { + kprintf("Not ufs\n"); + return -1; + } + ufsObj->dsk_meta++; + } if (!inode) { -#ifdef DEBUG + #ifdef DEBUG kprintf("!node\n"); -#endif + #endif return(0x0); } - if (inomap != inode) { -#ifdef DEBUG - kprintf("inomap != inode\n"); -#endif - n = IPERVBLK(fs); - if (dskread(blkbuf, INO_TO_VBA(fs, n, inode), DBPERVBLK,fd)) - return -1; - n = INO_TO_VBO(n, inode); -#if defined(UFS1_ONLY) - dp1 = ((struct ufs1_dinode *)blkbuf)[n]; -#elif defined(UFS2_ONLY) - dp2 = ((struct ufs2_dinode *)blkbuf)[n]; -#else - if (fs->fs_magic == FS_UFS1_MAGIC) - dp1 = ((struct ufs1_dinode *)blkbuf)[n]; - else - dp2 = ((struct ufs2_dinode *)blkbuf)[n]; -#endif - inomap = inode; - fd->offset = 0; - blkmap = indmap = 0; - } + if (inomap != inode) { + #ifdef DEBUG + kprintf("inomap != inode\n"); + #endif + n = IPERVBLK(fs); + if (dskread(blkbuf, INO_TO_VBA(fs, n, inode), DBPERVBLK,fd)) + return -1; + n = INO_TO_VBO(n, inode); + #if defined(UFS1_ONLY) + dp1 = ((struct ufs1_dinode *)blkbuf)[n]; + #elif defined(UFS2_ONLY) + dp2 = ((struct ufs2_dinode *)blkbuf)[n]; + #else + if (fs->fs_magic == FS_UFS1_MAGIC) + dp1 = ((struct ufs1_dinode *)blkbuf)[n]; + else + dp2 = ((struct ufs2_dinode *)blkbuf)[n]; + #endif - s = buf; - size = DIP(di_size); - fd->size = size; - n = size - fd->offset; -#ifdef DEBUG + inomap = inode; + fd->offset = 0; + //kprintf("RSOF"); + blkmap = indmap = 0; + } + + s = buf; + size = DIP(di_size); + fd->size = size; + n = size - fd->offset; + #ifdef VFSDEBUG kprintf("n: [0x%X:0x%X:0x%X]\n",n,fd->offset,size); -#endif - //Why? - if (n < 0) - return(0x0); - if (nbyte > n) - nbyte = n; - nb = nbyte; - while (nb) { - lbn = lblkno(fs, fd->offset); - off = blkoff(fs, fd->offset); - if (lbn < NDADDR) { - addr = DIP(di_db[lbn]); - } else if (lbn < NDADDR + NINDIR(fs)) { - n = INDIRPERVBLK(fs); - addr = DIP(di_ib[0]); - u = (u_int)(lbn - NDADDR) / (n * DBPERVBLK); - vbaddr = fsbtodb(fs, addr) + u; - if (indmap != vbaddr) { - if (dskread(indbuf, vbaddr, DBPERVBLK,fd)) - return -1; - indmap = vbaddr; - } - n = (lbn - NDADDR) & (n - 1); -#if defined(UFS1_ONLY) - addr = ((ufs1_daddr_t *)indbuf)[n]; -#elif defined(UFS2_ONLY) - addr = ((ufs2_daddr_t *)indbuf)[n]; -#else - if (fs->fs_magic == FS_UFS1_MAGIC) - addr = ((ufs1_daddr_t *)indbuf)[n]; - else - addr = ((ufs2_daddr_t *)indbuf)[n]; -#endif - } else { - return -1; - } - vbaddr = fsbtodb(fs, addr) + (off >> VBLKSHIFT) * DBPERVBLK; - vboff = off & VBLKMASK; - n = sblksize(fs, size, lbn) - (off & ~VBLKMASK); - if (n > VBLKSIZE) - n = VBLKSIZE; - if (blkmap != vbaddr) { - if (dskread(blkbuf, vbaddr, n >> DEV_BSHIFT,fd)) - return -1; - blkmap = vbaddr; - } - n -= vboff; - if (n > nb) - n = nb; - memcpy(s, blkbuf + vboff, n); - s += n; - fd->offset += n; - nb -= n; + #endif + if (n < 0) + return(0x0); + if (nbyte > n) + nbyte = n; + + nb = nbyte; + while (nb) { + lbn = lblkno(fs, fd->offset); + off = blkoff(fs, fd->offset); + if (lbn < NDADDR) { + addr = DIP(di_db[lbn]); + } + else if (lbn < NDADDR + NINDIR(fs)) { + n = INDIRPERVBLK(fs); + addr = DIP(di_ib[0]); + u = (u_int)(lbn - NDADDR) / (n * DBPERVBLK); + vbaddr = fsbtodb(fs, addr) + u; + if (indmap != vbaddr) { + if (dskread(indbuf, vbaddr, DBPERVBLK,fd)) + return -1; + indmap = vbaddr; } - return nbyte; -} + n = (lbn - NDADDR) & (n - 1); + #if defined(UFS1_ONLY) + addr = ((ufs1_daddr_t *)indbuf)[n]; + #elif defined(UFS2_ONLY) + addr = ((ufs2_daddr_t *)indbuf)[n]; + #else + if (fs->fs_magic == FS_UFS1_MAGIC) + addr = ((ufs1_daddr_t *)indbuf)[n]; + else + addr = ((ufs2_daddr_t *)indbuf)[n]; + #endif + } + else { + return -1; + } + vbaddr = fsbtodb(fs, addr) + (off >> VBLKSHIFT) * DBPERVBLK; + vboff = off & VBLKMASK; + n = sblksize(fs, size, lbn) - (off & ~VBLKMASK); + if (n > VBLKSIZE) + n = VBLKSIZE; + if (blkmap != vbaddr) { + if (dskread(blkbuf, vbaddr, n >> DEV_BSHIFT,fd)) + return -1; + blkmap = vbaddr; + } + n -= vboff; + if (n > nb) + n = nb; + memcpy(s, blkbuf + vboff, n); + s += n; + fd->offset += n; + //kprintf("UPOFST"); + nb -= n; + } + return nbyte; + } diff --git a/src/sys/vfs/vfs_syscalls.c b/src/sys/vfs/vfs_syscalls.c index 190017c..19775ff 100644 --- a/src/sys/vfs/vfs_syscalls.c +++ b/src/sys/vfs/vfs_syscalls.c @@ -123,7 +123,7 @@ } #ifdef VFSDEBUG - kprintf("count: %i - %i\n",count,uap->nbyte); + kprintf("count(%i): %i - %i\n",fd->offset,count,uap->nbyte); #endif td->td_retval[0] = count; return(error);