text: #include "system.h"
  
  
  
  
  struct cmd{
      char input[20];
      char description[30];
  };
  
  
  struct cmd cmd_list[SYS_CMD_NUM] = {
      {.input = "help\t\t", 		.description="List commands."},
      {.input = "hello\t\t", 		.description="Print hello world."}
  	
  };
  
  void system_command(char* buf){
      char *args = buf;
      int arg_idx = 0;
      for(; buf[arg_idx] != '\0'; ++arg_idx, ++args){
          if(buf[arg_idx] == ' '){
              buf[arg_idx] = '\0';
              args = buf + arg_idx + 1;
              break;
          }
      }
  	
  	
  	if     (strcmp(buf, "help" ) == 0) 			help();
  	else if(strcmp(buf, "hello") == 0)			hello();
  	//else if(strcmp(buf, "reset") == 0)			reset(100);
      //else if(strcmp(buf, "loadimg") == 0)		loadimg();
      //else if(strcmp(buf, "ls") == 0)   			cpio_list();
  	//else if(strcmp(buf, "cat") == 0)   			cpio_cat(args);
  	//else if(strcmp(buf, "dtb_ls") == 0)   		print_dt_info();
  	//else if(strcmp(buf, "dtb_cat") == 0)   		parse_dt();
  	//else if(strcmp(buf, "info") == 0)   		print_buddy_info();
  	//else if(strcmp(buf, "stat") == 0)   		print_buddy_stat();
  	//else if(strcmp(buf, "slab") == 0)   		print_slab();
  	//else if(strcmp(buf, "load") == 0)   		load_app(args);
  	//else if(strcmp(buf, "el") == 0)   			print_el();
  	//else if(strcmp(buf, "async") == 0)   		test_uart_async();
  	//else if(strcmp(buf, "timeout") == 0)   		set_timeout(args);
  	else if(strcmp(buf, "loadapp") == 0)			threadTest();
  	else if(strcmp(buf, "lab6-1") == 0)				lab6_1();
  
  }
  
  
  void help(){
  	           
      uart_puts("---------------------------------------------\n");
      uart_puts("[Command]\t[Description]\r\n");
      for(int i = 0; i < SYS_CMD_NUM; ++i){
          uart_puts(cmd_list[i].input);
          uart_puts(cmd_list[i].description);
          uart_puts("\r\n");
      }
  	uart_puts("---------------------------------------------\n");
  }
  
  void hello(){
      uart_puts("Hello World !\n");
  }
  
  
  
  
  void lab6_1(){
  
  	char buf[100];
  	//RW test
  	struct file* f=vfs_open("dir/dirdir/f3",0);
  
  	for(int i=0;i<10;++i)vfs_write(f,"12345",5);
  	vfs_close(f);
  	f=vfs_open("dir/dirdir/f3",0);
  	int n=vfs_read(f,buf,100);
  	buf[n]=0;
  	uart_printf("%d: %s\n",n,buf);
  	vfs_close(f);
  
  	//create test
  	file* a=vfs_open("dir/hello",O_CREAT);
  	file* b=vfs_open("dir/world",O_CREAT);
  	vfs_write(a,"Hello ",6);
  	vfs_write(b,"World!",6);
  	vfs_close(a);
  	vfs_close(b);
  	b=vfs_open("dir/hello",0);
  	a=vfs_open("dir/world",0);
  	int sz;
  	sz=vfs_read(b,buf,100);
  	sz+=vfs_read(a,buf+sz,100);
  	buf[sz]=0;
  	uart_printf("%s\n",buf);//should be Hello World!
  	vfs_close(a);
  	vfs_close(b);
  
  	//ls test
  	f=vfs_open("dir",0);
  	while(1){
  		n=vfs_read(f,buf,100);
  		if(n==0)break;
  		buf[n]=0;
  		uart_printf("...%s\n",buf);
  	}
  	vfs_close(f);
  }
  