you’ll need to uninstall that package and install an older version
1
2
3
4
5
6
cd ~/MIT-6S081/
wget https://download.qemu.org/qemu-5.1.0.tar.xz
tar -xf qemu-5.1.0.tar.xz
cd qemu-5.1.0
./configure --disable-werror --target-list=riscv64-softmmu
make
❯ ./riscv64-softmmu/qemu-system-riscv64 --version
QEMU emulator version 5.1.0
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers
cd ~/MIT-6S081/
wget https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.12/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
tar -zxf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz -C ./riscv64-toolchain
❯ ./riscv64-toolchain/bin/riscv64-unknown-elf-gcc --version
riscv64-unknown-elf-gcc (SiFive GCC-Metal 10.2.0-2020.12.8) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#include"kernel/types.h"#include"kernel/stat.h"#include"kernel/fs.h"#include"kernel/fcntl.h"#include"user/user.h"voidfind(constchar*path,constchar*name){intfd=open(path,O_RDONLY);if(fd<0){fprintf(2,"find: cannot open %s\n",path);exit(1);}structstatst;if(fstat(fd,&st)<0){fprintf(2,"find: cannot fstat %s\n",path);close(fd);exit(1);}if(st.type==T_FILE){inti;for(i=strlen(path);path[i-1]!='/';i--);if(strcmp(path+i,name)==0)printf("%s\n",path);}elseif(st.type==T_DIR){charbuf[256];strcpy(buf,path);char*p=buf+strlen(buf);*p++='/';structdirentde;while(read(fd,&de,sizeof(de))==sizeof(de)){if(de.inum==0)continue;if(strcmp(de.name,".")==0||strcmp(de.name,"..")==0)continue;if(strlen(path)+1+DIRSIZ+1>sizeofbuf){printf("find: path too long\n");close(fd);exit(1);}memmove(p,de.name,DIRSIZ);find(buf,name);}}close(fd);}intmain(intargc,charconst*argv[]){if(argc!=3){fprintf(2,"Usage: find DIR FILENAME\n");exit(1);}chardir[256];if(strlen(argv[1])>255){printf("find: path too long\n");exit(1);}strcpy(dir,argv[1]);char*p=dir+strlen(dir)-1;while(*p=='/')*p--=0;intfd=open(dir,O_RDONLY);if(fd<0){fprintf(2,"find: cannot open %s\n",dir);exit(1);}structstatst;if(fstat(fd,&st)<0){fprintf(2,"find: cannot fstat %s\n",dir);close(fd);exit(1);}if(st.type!=T_DIR){fprintf(2,"'%s' is not a directory\n",argv[1]);close(fd);exit(1);}find(dir,argv[2]);exit(0);}
#include"kernel/types.h"#include"kernel/stat.h"#include"kernel/param.h"#include"user/user.h"intgetline(char*buf){intcnt=0;while(read(0,buf,1)){if(++cnt>=256){fprintf(2,"xargs: line too long\n");exit(1);}if(*buf++=='\n')break;}*(buf-1)=0;returncnt;}intprase(char*buf,char**nargv,constintmax){intcnt=0;while(*buf){char*last=buf-1;if(*last==0&&*buf!=' '){if(cnt>=max){fprintf(2,"xargs: args too many\n");exit(1);}nargv[cnt++]=buf;}elseif(*buf==' ')*buf=0;buf++;}nargv[cnt]=0;returncnt;}intmain(intargc,charconst*argv[]){if(argc==1){fprintf(2,"Usage: xargs COMMAND ...\n");exit(1);}charbuf[257]={0};while(getline(buf+1)){char*nargv[MAXARG+1];memcpy(nargv,argv+1,sizeof(char*)*(argc-1));prase(buf+1,nargv+argc-1,MAXARG-argc+1);intpid=fork();if(pid>0){intstatus;wait(&status);}elseif(pid==0){charcmd[128];strcpy(cmd,argv[1]);exec(cmd,nargv);}else{fprintf(2,"fork error\n");exit(1);}}exit(0);}