Changeset 661
- Timestamp:
- Jul 24, 2015, 3:21:35 PM (9 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/transpose/main.c
r589 r661 137 137 giet_proctime() ); 138 138 139 // diplay disk content140 giet_fat_list( "/" );141 giet_fat_list( "/misc" );142 giet_fat_list( "/home" );143 giet_fat_list( "/build" );144 giet_fat_list( "/build/kernel" );145 giet_fat_list( "/build/transpose" );146 147 139 global_init_ok = 1; 148 140 } … … 505 497 } 506 498 507 // display disk content499 // clean up 508 500 if ( (x==0) && (y == 0) && (lpid == 0) ) 509 501 { 510 giet_fat_list( "/" );511 giet_fat_list( "/misc" );512 giet_fat_list( "/home" );513 giet_fat_list( "/build" );514 giet_fat_list( "/build/kernel" );515 giet_fat_list( "/build/transpose" );516 517 502 giet_fat_remove( "/home/lena_transposed" , 0 ); 518 503 giet_fat_remove( "/home/lena_restored" , 0 ); 519 504 520 505 giet_fat_remove( "/home" , 1 ); 521 522 giet_fat_list( "/" );523 giet_fat_list( "/misc" );524 giet_fat_list( "/home" );525 giet_fat_list( "/build" );526 giet_fat_list( "/build/kernel" );527 giet_fat_list( "/build/transpose" );528 506 } 529 507 -
soft/giet_vm/giet_fat32/fat32.c
r658 r661 4348 4348 4349 4349 4350 /////////////////////////////////////////////////////////////////////////////////4351 // The following function implements the giet_fat_list() system call.4352 // It displays the content of a directory identified by the "pathname" argument.4353 // It returns an error code if the pathname is not a directory.4354 /////////////////////////////////////////////////////////////////////////////////4355 // Returns 0 if success.4356 // Returns a negative value if error:4357 // -1 : "FAT not initialised4358 // -2 : "Directory not found"4359 // -3 : "Name in path too long4360 // -4 : "Not a directory"4361 // -5 : "Cannot access directory"4362 /////////////////////////////////////////////////////////////////////////////////4363 int _fat_list( char* pathname )4364 {4365 fat_inode_t* inode;4366 4367 // checking FAT initialised4368 if( _fat.initialised != FAT_INITIALISED )4369 {4370 _printf("\n[FAT ERROR] in _fat_list() : FAT not initialised\n");4371 return -1;4372 }4373 4374 #if GIET_DEBUG_FAT4375 unsigned int procid = _get_procid();4376 unsigned int x = procid >> (Y_WIDTH + P_WIDTH);4377 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);4378 unsigned int p = procid & ((1<<P_WIDTH)-1);4379 if ( _get_proctime() > GIET_DEBUG_FAT )4380 _printf("\n[DEBUG FAT] _fat_list() : P[%d,%d,%d] enters for path <%s>\n",4381 x, y, p, pathname );4382 #endif4383 4384 // get inode4385 unsigned int code = _get_inode_from_path( pathname , &inode );4386 4387 if ( (code == 1) || (code == 2) )4388 {4389 _printf("\n[FAT ERROR] in _fat_list() : directory <%s> not found\n", pathname );4390 return -2;4391 }4392 if ( code == 3 )4393 {4394 _printf("\n[FAT ERROR] in _fat_list() : name too long in path <%s>\n", pathname );4395 return -3;4396 }4397 4398 // check found inode is a directory4399 if ( inode->is_dir == 0 )4400 {4401 _printf("\n[FAT ERROR] in _fat_list() : <%s> is not a directory\n", pathname );4402 return -4;4403 }4404 4405 #if GIET_DEBUG_FAT4406 if ( _get_proctime() > GIET_DEBUG_FAT )4407 _printf("\n[DEBUG FAT] _fat_list() : P[%d,%d,%d] found inode for path <%s>\n",4408 x, y, p, pathname );4409 #endif4410 4411 // scan directory up to end of directory / two embedded loops :4412 // - loop on the clusters allocated to the directory4413 // - loop on the directory entries in each 4 Kbytes buffer4414 unsigned char* buffer;4415 fat_cache_desc_t* pdesc;4416 unsigned int cluster_id = 0; // cluster index in directory4417 unsigned int offset = 0; // position in scanned buffer4418 unsigned int lfn = 0; // number of lfn entries4419 unsigned int nb_entries = 0; // number of directory entries4420 unsigned int done = 0; // end of directory found4421 unsigned int attr; // ATTR field value4422 unsigned int ord; // ORD field value4423 char lfn1[16]; // temporary buffer for string in LFN14424 char lfn2[16]; // temporary buffer for string in LFN24425 char lfn3[16]; // temporary buffer for string in LFN34426 char name[36]; // directory entry full name4427 unsigned int cluster; // directory entry cluster index4428 unsigned int size; // directory entry size4429 unsigned int is_dir; // directory entry is a directory4430 unsigned int is_vid; // directory entry is volume_id4431 4432 // TODO : define a method to transfer this information to user mode4433 _printf("\n<%s> cluster = %x / lba = %x\n", pathname ,4434 inode->cluster , _cluster_to_lba( inode->cluster) );4435 4436 while ( done == 0 )4437 {4438 // get one 4 Kytes buffer4439 if ( _get_buffer_from_cache( inode,4440 cluster_id,4441 &pdesc ) )4442 {4443 _printf("\n[FAT ERROR] in _fat_list() : cannot access <%s>\n", pathname );4444 return -5;4445 }4446 buffer = pdesc->buffer;4447 4448 // scan this 4 Kbytes buffer4449 while ( (offset < 4096) && (done == 0) )4450 {4451 attr = _read_entry( DIR_ATTR , buffer + offset , 0 );4452 ord = _read_entry( LDIR_ORD , buffer + offset , 0 );4453 4454 if (ord == NO_MORE_ENTRY) // no more entry in directory => break4455 {4456 done = 1;4457 }4458 else if ( ord == FREE_ENTRY ) // free entry => skip4459 {4460 offset = offset + 32;4461 }4462 else if ( attr == ATTR_LONG_NAME_MASK ) // LFN entry => get partial names4463 {4464 unsigned int seq = ord & 0x3;4465 lfn = (seq > lfn) ? seq : lfn;4466 if ( seq == 1 ) _get_name_from_long( buffer + offset, lfn1 );4467 else if ( seq == 2 ) _get_name_from_long( buffer + offset, lfn2 );4468 else if ( seq == 3 ) _get_name_from_long( buffer + offset, lfn3 );4469 offset = offset + 32;4470 }4471 else // NORMAL entry4472 {4473 if ( lfn == 0 )4474 {4475 _get_name_from_short( buffer + offset , name );4476 }4477 else if ( lfn == 1 )4478 {4479 _strcpy( name , lfn1 );4480 }4481 else if ( lfn == 2 )4482 {4483 _strcpy( name , lfn1 );4484 _strcpy( name + 13 , lfn2 );4485 }4486 else if ( lfn == 3 )4487 {4488 _strcpy( name , lfn1 );4489 _strcpy( name + 13 , lfn2 );4490 _strcpy( name + 26 , lfn3 );4491 }4492 4493 is_dir = ((attr & ATTR_DIRECTORY) == ATTR_DIRECTORY);4494 is_vid = ((attr & ATTR_VOLUME_ID) == ATTR_VOLUME_ID);4495 size = (_read_entry( DIR_FILE_SIZE , buffer + offset , 1 ) ) ;4496 cluster = (_read_entry( DIR_FST_CLUS_HI , buffer + offset , 1 ) << 16) |4497 (_read_entry( DIR_FST_CLUS_LO , buffer + offset , 1 ) ) ;4498 4499 if ( is_vid == 0 )4500 {4501 // TODO : define a method to transfer this information to user mode4502 if (is_dir) _printf(" DIR | size = %X | cluster = %X | %s\n",4503 size , cluster, name );4504 else _printf(" FILE | size = %X | cluster = %X | %s\n",4505 size , cluster, name );4506 nb_entries++;4507 }4508 4509 offset = offset + 32;4510 lfn = 0;4511 }4512 } // end loop on directory entries4513 4514 if ( done == 0 )4515 {4516 cluster_id++;4517 offset = 0;4518 }4519 } // end loop on buffers4520 4521 // TODO : define a method to transfer this information to user mode4522 _printf(" total = %d entries\n", nb_entries );4523 4524 return 0;4525 } // end _fat_list()4526 4527 4528 4529 4530 4531 4350 /////////////////////////////////////////////////////////////////////////////// 4532 4351 // This functiond load a file identified by the "pathname" argument into the -
soft/giet_vm/giet_fat32/fat32.h
r658 r661 275 275 fat_dirent_t* entry ); // directory entry 276 276 277 extern int _fat_list( char* pathname ); // path from root278 279 277 extern int _fat_load_no_cache( char* pathname, // path from root 280 278 unsigned int buffer_vbase, // buffer base -
soft/giet_vm/giet_kernel/sys_handler.c
r658 r661 180 180 &_fat_rename, /* 0x27 */ 181 181 &_fat_mkdir, /* 0x28 */ 182 &_fat_ list,/* 0x29 */183 &_fat_ opendir,/* 0x2A */184 &_fat_ closedir,/* 0x2B */185 &_ fat_readdir,/* 0x2C */182 &_fat_opendir, /* 0x29 */ 183 &_fat_closedir, /* 0x2A */ 184 &_fat_readdir, /* 0x2B */ 185 &_sys_ukn, /* 0x2C */ 186 186 &_sys_ukn, /* 0x2D */ 187 187 &_sys_ukn, /* 0x2E */ -
soft/giet_vm/giet_libs/stdio.c
r659 r661 1080 1080 } 1081 1081 1082 /////////////////////////////////////1083 int giet_fat_list( char* pathname )1084 {1085 return sys_call( SYSCALL_FAT_LIST,1086 (unsigned int)pathname,1087 0, 0, 0 );1088 }1089 1090 1082 1091 1083 -
soft/giet_vm/giet_libs/stdio.h
r659 r661 59 59 #define SYSCALL_FAT_RENAME 0x27 60 60 #define SYSCALL_FAT_MKDIR 0x28 61 #define SYSCALL_FAT_ LIST0x2962 #define SYSCALL_FAT_ OPENDIR0x2A63 #define SYSCALL_FAT_ CLOSEDIR0x2B64 #define SYSCALL_FAT_READDIR0x2C61 #define SYSCALL_FAT_OPENDIR 0x29 62 #define SYSCALL_FAT_CLOSEDIR 0x2A 63 #define SYSCALL_FAT_READDIR 0x2B 64 // 0x2C 65 65 // 0x2D 66 66 // 0x2E … … 348 348 fat_dirent_t* entry ); 349 349 350 extern int giet_fat_list( char* pathname );351 352 350 ////////////////////////////////////////////////////////////////////////// 353 351 // Miscelaneous system calls
Note: See TracChangeset
for help on using the changeset viewer.