Changeset 775 for soft/giet_vm/applications/shell
- Timestamp:
- Feb 4, 2016, 5:05:56 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/shell/shell.c
r772 r775 44 44 static void cmd_time(int argc, char** argv) 45 45 { 46 giet_tty_printf(" %d\n", giet_proctime());46 giet_tty_printf(" cycle = %d\n", giet_proctime()); 47 47 } 48 48 … … 50 50 static void cmd_ls(int argc, char** argv) 51 51 { 52 int fd; 53 fat_dirent_t entry; 54 55 if (argc < 2) 56 { 57 giet_tty_printf(" usage : %s <pathname>\n", argv[0]); 58 return; 59 } 60 61 fd = giet_fat_opendir(argv[1]); 52 int fd; 53 int rec; 54 char* pathname; 55 fat_dirent_t entry; 56 57 if (argc == 2) 58 { 59 rec = 0; 60 pathname = argv[1]; 61 } 62 else if ( (argc == 3) && (strcmp( argv[1] , "-r" ) == 0) ) 63 { 64 rec = 1; 65 pathname = argv[2]; 66 67 giet_tty_printf(" error : recursive mode not supported yet\n"); 68 return; 69 } 70 else 71 { 72 giet_tty_printf(" usage : ls [-r] pathname\n"); 73 return; 74 } 75 76 fd = giet_fat_opendir( pathname ); 62 77 63 78 if (fd < 0) … … 84 99 if (argc < 2) 85 100 { 86 giet_tty_printf(" usage : %s <path>\n", argv[0]);101 giet_tty_printf(" usage : mkdir pathname\n"); 87 102 return; 88 103 } … … 101 116 if (argc < 3) 102 117 { 103 giet_tty_printf(" usage : %s <src> <dst>\n", argv[0]);118 giet_tty_printf(" usage : cp src_pathname dst_pathname>\n"); 104 119 return; 105 120 } … … 141 156 if (info.is_dir) 142 157 { 143 giet_tty_printf(" error : %s is a directory\n", argv[2] ); // TODO158 giet_tty_printf(" error : %s is a directory\n", argv[2] ); // TODO 144 159 goto exit; 145 160 } … … 150 165 int len = (size - i < 1024 ? size - i : 1024); 151 166 int wlen; 152 153 giet_tty_printf("\rwrite %d/%d (%d%%)", i, size, 100*i/size);154 167 155 168 len = giet_fat_read(src_fd, &buf, len); … … 162 175 i += len; 163 176 } 164 giet_tty_printf("\n");165 177 166 178 exit: … … 176 188 if (argc < 2) 177 189 { 178 giet_tty_printf(" usage : %s <file>\n", argv[0]);190 giet_tty_printf(" usage : rm pathname\n"); 179 191 return; 180 192 } … … 193 205 if (argc < 2) 194 206 { 195 giet_tty_printf(" usage : %s <pathname>\n", argv[0]);207 giet_tty_printf(" usage : rmdir pathname\n"); 196 208 return; 197 209 } … … 209 221 if (argc < 3) 210 222 { 211 giet_tty_printf(" usage : %s <src> <dst>\n", argv[0]);223 giet_tty_printf(" usage : %s src_pathname dst_pathname\n", argv[0]); 212 224 return; 213 225 } … … 225 237 if (argc < 2) 226 238 { 227 giet_tty_printf(" usage : %s <vspace_name>\n", argv[0]);239 giet_tty_printf(" usage : %s vspace_name\n", argv[0]); 228 240 return; 229 241 } … … 241 253 if (argc < 2) 242 254 { 243 giet_tty_printf(" usage : %s <vspace_name>\n", argv[0]);255 giet_tty_printf(" usage : %s vspace_name\n", argv[0]); 244 256 return; 245 257 } … … 274 286 if (argc < 3) 275 287 { 276 giet_tty_printf(" usage : %s <vspace_name> <thread_name>\n", argv[0] );288 giet_tty_printf(" usage : %s vspace_name thread_name\n", argv[0] ); 277 289 return; 278 290 } … … 286 298 if (argc < 3) 287 299 { 288 giet_tty_printf(" usage : %s <vspace_name> <thread_name>\n", argv[0] );300 giet_tty_printf(" usage : %s vspace_name thread_name\n", argv[0] ); 289 301 return; 290 302 } … … 298 310 if (argc < 3) 299 311 { 300 giet_tty_printf(" usage : %s <vspace_name> <thread_name>\n", argv[0] );312 giet_tty_printf(" usage : %s vspace_name thread_name\n", argv[0] ); 301 313 return; 302 314 } … … 308 320 static void cmd_cat(int argc, char** argv) 309 321 { 310 if (argc <2)311 { 312 giet_tty_printf(" usage : %s <path_name> \n", argv[0]);322 if (argc != 2) 323 { 324 giet_tty_printf(" usage : cat pathname \n"); 313 325 return; 314 326 } … … 358 370 } 359 371 360 /*361 // allocate a temporary buffer for the file362 heap_init( x , y );363 buf = (char*)malloc( size );364 if( buf == NULL )365 {366 giet_tty_printf(" error : cannot allocate buffer with size = %d\n", size );367 goto exit;368 }369 // load the file370 len = giet_fat_read( fd , buf , size );371 if ( len != size )372 {373 giet_tty_printf(" error : cannot load file %s / size = %d / len = %d\n",374 argv[1] , size , len );375 goto exit;376 }377 */378 372 // set terminating '0' 379 373 buf[size] = 0; … … 387 381 } 388 382 383 /////////////////////////////////////////// 384 static void cmd_dump(int argc, char** argv) 385 { 386 if ((argc == 2) && (strcmp( argv[1] , "-bs" ) == 0)) 387 { 388 giet_fat_dump( DUMP_BS , NULL , 0 ); 389 } 390 else if ((argc == 2) && (strcmp( argv[1] , "-fs" ) == 0)) 391 { 392 giet_fat_dump( DUMP_FS , NULL , 0 ); 393 } 394 else if ((argc == 3) && (strcmp( argv[1] , "-fat" ) == 0)) 395 { 396 giet_fat_dump( DUMP_FAT , NULL , atoi( argv[2] ) ); 397 } 398 else if ((argc == 4) && (strcmp( argv[1] , "-file" ) == 0)) 399 { 400 giet_fat_dump( DUMP_FILE , argv[2] , atoi( argv[3] ) ); 401 } 402 else if ((argc == 4) && (strcmp( argv[1] , "-dir" ) == 0)) 403 { 404 giet_fat_dump( DUMP_DIR , argv[2] , atoi( argv[3] ) ); 405 } 406 else 407 { 408 giet_tty_printf(" usage : dump [-bs] [-fs] [-fat block] " 409 "[-file pathname block] [-dir pathname block]\n"); 410 return; 411 } 412 } 413 414 389 415 //////////////////////////////////////////////////////////////////// 390 416 struct command_t cmd[] = … … 393 419 { "context", "display a thread context", cmd_context }, 394 420 { "cp", "replicate a file in file system", cmd_cp }, 421 { "dump", "display content of disk sector", cmd_dump }, 395 422 { "exec", "start an application", cmd_exec }, 396 423 { "help", "list available commands", cmd_help },
Note: See TracChangeset
for help on using the changeset viewer.