From 1a6da07e9a6ef7661a58cb6ce22b2874370d6c0d Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Thu, 20 Nov 2014 20:24:18 +0100 Subject: experimenting wih userspace and syscalls --- userspace/add.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'userspace/add.c') diff --git a/userspace/add.c b/userspace/add.c index eecb05a..8f1dc56 100644 --- a/userspace/add.c +++ b/userspace/add.c @@ -3,29 +3,59 @@ #include "syscalls.c" #include "../fs/fs.h" - int main(int argc, char **argv) { - FILE *input; - input=fopen(1,"r"); - char *buf=malloc(256); + sbrk(1024); + sbrk(1024); + sbrk(1024); + write(1,"dupa",4); + puts("started ADD"); + while(1); +// FILE *input; +// input=fopen("input2.txt","r"); //stdin +/* int sum=0; int i=0; + while(1); + + char *buf=malloc(256); + //printf("(buf= 0x%08X)\n",buf); + + + + while(1) + { + char *ret=gets(buf); + if(ret==NULL) + { + printf("returned NULL. ABORTING"); + break; + } + printf("entered %s: ",buf); + + //buf[strlen(buf)-1]=0; // remove \n + //process(buf); + } + + + while(1) { printf("enter numer %i: ",i+1); fgets(buf,255,input); + printf("entered %s: ",buf); + if(buf[1]=='x')break; + i++; sum+=atoi(buf); - } - printf("sum = %i \n",sum); printf("avg = %i \n\n",sum/i); +*/ execve(15,0,0); } -- cgit v1.2.3