@@ -519,8 +519,10 @@ int insert_entry(UINT32 inode_num, EXT2_NODE * retEntry)
519
519
520
520
data_read (entry .fs , entry .location .group , entry .location .block , sector );
521
521
printf ("새로운 엔트리 추가 끝1\n" );
522
+ printf ("retEntry->entry : %s\n" , retEntry -> entry .name );
522
523
//ent[entry.location.offset] = retEntry->entry;
523
524
memcpy (& ent [entry .location .offset ], & retEntry -> entry , sizeof (EXT2_DIR_ENTRY ));
525
+ printf ("ent[offset] : %s\n" , ent [entry .location .offset ].name );
524
526
printf ("새로운 엔트리 추가 끝2\n" );
525
527
data_write (entry .fs , entry .location .group , entry .location .block , sector );
526
528
printf ("새로운 엔트리 추가 끝3\n" );
@@ -672,7 +674,7 @@ int data_read(EXT2_FILESYSTEM * fs, SECTOR group, SECTOR block, BYTE* sector)
672
674
{printf ("2\n" );
673
675
return EXT2_ERROR ;}
674
676
675
- blockLocation = 1 + group * sector_num_per_group + block ;
677
+ blockLocation = 1 + group * sector_num_per_group + block ;
676
678
printf ("blocklocation:%d\n" , blockLocation );
677
679
printf ("aa\n" );
678
680
fs -> disk -> read_sector (fs -> disk ,blockLocation ,sector );
@@ -687,7 +689,7 @@ int data_write(EXT2_FILESYSTEM * fs, SECTOR group, SECTOR block, BYTE* sector)
687
689
if (group < 0 || group > NUMBER_OF_GROUPS )
688
690
return EXT2_ERROR ;
689
691
690
- blockLocation = 1 + group * sector_num_per_group + 17 + block ;
692
+ blockLocation = 1 + group * sector_num_per_group + block ;
691
693
692
694
693
695
fs -> disk -> write_sector (fs -> disk ,blockLocation ,sector );
@@ -708,6 +710,8 @@ str++;
708
710
}
709
711
}
710
712
713
+
714
+
711
715
int format_name (EXT2_FILESYSTEM * fs , char * name )
712
716
{
713
717
INT32 length = strlen (name );
@@ -966,7 +970,12 @@ int get_inode(EXT2_FILESYSTEM * fs, const UINT32 inode, INODE *inodeBuffer)
966
970
printf ("1\n" );
967
971
968
972
// for문 안써도 됨. offset 계산해서 더해주면 됨
969
- memcpy (inodeBuffer , & inode_table [inode_offset %8 ], sizeof (INODE ));
973
+ for (int i = 1 ; i < (inode_offset % 8 ); i ++ )
974
+ inode_table ++ ;
975
+
976
+
977
+ * inodeBuffer = * inode_table ;
978
+
970
979
971
980
return EXT2_SUCCESS ;
972
981
}
@@ -1305,9 +1314,11 @@ int ext2_read_dir(EXT2_NODE* dir, EXT2_NODE_ADD adder, void* list)
1305
1314
int entriesPerSector = (MAX_SECTOR_SIZE /sizeof (EXT2_DIR_ENTRY ));
1306
1315
INODE * inodeBuffer ;
1307
1316
inodeBuffer = (INODE * )sector ;
1308
- printf ("%d\n" ,dir -> entry .inode );
1317
+
1318
+ printf ("%d\n" ,dir -> entry .inode );
1309
1319
get_inode (dir -> fs ,dir -> entry .inode ,inodeBuffer );
1310
1320
printf ("%d\n" ,dir -> entry .inode );
1321
+
1311
1322
int inodeGroup = dir -> entry .inode / (dir -> fs -> sb .inode_per_group + 1 ); // 몇번째 아이노드 그룹인지
1312
1323
printf ("hello world\n" );
1313
1324
if (dir -> entry .inode == 2 )// 루트 디렉토리일경우
@@ -1353,20 +1364,25 @@ int read_dir_from_sector(EXT2_FILESYSTEM* fs, BYTE* sector, EXT2_NODE_ADD adder,
1353
1364
1354
1365
for ( i = 0 ; i < entriesPerSector ; i ++ )
1355
1366
{
1356
-
1357
- if (dir -> name [0 ]== DIR_ENTRY_FREE )
1358
- continue ;
1367
+ printf ( "dir->name : %s\n" , dir -> name );
1368
+ if (dir -> name [0 ]== DIR_ENTRY_FREE )
1369
+ continue ;
1359
1370
else if (dir -> name [0 ]== DIR_ENTRY_NO_MORE )
1360
- break ;
1361
- else
1362
- {
1371
+ {
1372
+ printf ("nomore\n" );
1373
+ break ;
1374
+ }
1363
1375
1364
- node .fs = fs ;
1365
- node .entry = * dir ;
1366
- node .location .offset = i ;
1367
- adder (fs ,list ,& node );
1368
- }
1369
- dir ++ ;
1376
+ else
1377
+ {
1378
+ node .fs = fs ;
1379
+ node .entry = * dir ;
1380
+ //memcpy(&node.entry, dir, sizeof(EXT2_DIR_ENTRY));
1381
+ node .location .offset = i ;
1382
+ adder (fs ,list ,& node );
1383
+ printf ("adder, list : %s\n" , list );
1384
+ }
1385
+ dir ++ ;
1370
1386
}
1371
1387
return (i == entriesPerSector ? 0 :1 );
1372
1388
}
0 commit comments