From fe7d0332267ef1e62153b685d2b5574ce624a4bc Mon Sep 17 00:00:00 2001 From: Miguel Date: Sat, 15 Sep 2018 00:30:36 +0200 Subject: reading ext2 files and using our abstractions --- userspace/cat.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'userspace/cat.c') diff --git a/userspace/cat.c b/userspace/cat.c index 39d994f..5b419ca 100644 --- a/userspace/cat.c +++ b/userspace/cat.c @@ -3,7 +3,11 @@ int main(int argc, char **argv) { FILE *f; - if(argc>1)f=fopen(argv[1],"r"); + if(argc>1){ + char buf[256]; + sprintf(buf,"%s/%s",getenv("PWD"),argv[1]); + f=fopen(buf,"r"); + } else f=stdin; setvbuf(stdin,NULL,_IONBF,0); @@ -11,7 +15,7 @@ int main(int argc, char **argv) char c; - printf("-- read from file byte by byte --\n"); + printf("-- reading from file byte by byte --\n\n"); while(fread(&c,1,1,f)) { -- cgit v1.2.3