Skip to content

Commit 235be72

Browse files
committed
modify ls
1 parent 6144595 commit 235be72

File tree

10 files changed

+43
-23
lines changed

10 files changed

+43
-23
lines changed

EXT2

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit d91f9bfd6f2280d7a1f797c7b7557c6400d3a6a7

disksim.o

2.45 KB
Binary file not shown.

entrylist.o

1.98 KB
Binary file not shown.

ext2.c

+32-16
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,10 @@ int insert_entry(UINT32 inode_num, EXT2_NODE * retEntry)
519519

520520
data_read(entry.fs, entry.location.group, entry.location.block, sector);
521521
printf("새로운 엔트리 추가 끝1\n");
522+
printf("retEntry->entry : %s\n", retEntry->entry.name);
522523
//ent[entry.location.offset] = retEntry->entry;
523524
memcpy(&ent[entry.location.offset], &retEntry->entry, sizeof(EXT2_DIR_ENTRY));
525+
printf("ent[offset] : %s\n", ent[entry.location.offset].name);
524526
printf("새로운 엔트리 추가 끝2\n");
525527
data_write(entry.fs, entry.location.group, entry.location.block, sector);
526528
printf("새로운 엔트리 추가 끝3\n");
@@ -672,7 +674,7 @@ int data_read(EXT2_FILESYSTEM * fs, SECTOR group, SECTOR block, BYTE* sector)
672674
{printf("2\n");
673675
return EXT2_ERROR;}
674676

675-
blockLocation =1+ group* sector_num_per_group + block;
677+
blockLocation = 1+group* sector_num_per_group + block;
676678
printf("blocklocation:%d\n", blockLocation);
677679
printf("aa\n");
678680
fs->disk->read_sector(fs->disk,blockLocation ,sector);
@@ -687,7 +689,7 @@ int data_write(EXT2_FILESYSTEM * fs, SECTOR group, SECTOR block, BYTE* sector)
687689
if(group<0 || group>NUMBER_OF_GROUPS)
688690
return EXT2_ERROR;
689691

690-
blockLocation = 1+group* sector_num_per_group +17 + block;
692+
blockLocation = 1+group* sector_num_per_group + block;
691693

692694

693695
fs->disk->write_sector(fs->disk,blockLocation ,sector);
@@ -708,6 +710,8 @@ str++;
708710
}
709711
}
710712

713+
714+
711715
int format_name(EXT2_FILESYSTEM* fs, char* name)
712716
{
713717
INT32 length = strlen(name);
@@ -966,7 +970,12 @@ int get_inode(EXT2_FILESYSTEM * fs, const UINT32 inode, INODE *inodeBuffer)
966970
printf("1\n");
967971

968972
// 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+
970979

971980
return EXT2_SUCCESS;
972981
}
@@ -1305,9 +1314,11 @@ int ext2_read_dir(EXT2_NODE* dir, EXT2_NODE_ADD adder, void* list)
13051314
int entriesPerSector = (MAX_SECTOR_SIZE/sizeof(EXT2_DIR_ENTRY));
13061315
INODE* inodeBuffer;
13071316
inodeBuffer = (INODE *)sector ;
1308-
printf("%d\n",dir->entry.inode);
1317+
1318+
printf("%d\n",dir->entry.inode);
13091319
get_inode(dir->fs,dir->entry.inode,inodeBuffer);
13101320
printf("%d\n",dir->entry.inode);
1321+
13111322
int inodeGroup = dir->entry.inode/ (dir->fs->sb.inode_per_group+1); // 몇번째 아이노드 그룹인지
13121323
printf("hello world\n");
13131324
if(dir->entry.inode==2)// 루트 디렉토리일경우
@@ -1353,20 +1364,25 @@ int read_dir_from_sector(EXT2_FILESYSTEM* fs, BYTE* sector, EXT2_NODE_ADD adder,
13531364

13541365
for( i=0; i<entriesPerSector ; i++)
13551366
{
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 ;
13591370
else if(dir->name[0]==DIR_ENTRY_NO_MORE)
1360-
break;
1361-
else
1362-
{
1371+
{
1372+
printf("nomore\n");
1373+
break;
1374+
}
13631375

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 ++;
13701386
}
13711387
return (i == entriesPerSector ? 0:1);
13721388
}

ext2.o

30.9 KB
Binary file not shown.

ext2_shell.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ int ext2_entry_to_shell_entry(EXT2_FILESYSTEM* fs, const EXT2_NODE* ext2_entry,
251251
{
252252
EXT2_NODE* entry = (EXT2_NODE*)shell_entry->pdata;
253253
INODE inodeBuffer;
254-
BYTE* str = "/";
254+
//BYTE* str = "/";
255+
BYTE str [MAX_NAME_LENGTH];
256+
str[0]="/";
255257

256258
ZeroMemory(shell_entry, sizeof(SHELL_ENTRY));
257259

@@ -265,12 +267,13 @@ int ext2_entry_to_shell_entry(EXT2_FILESYSTEM* fs, const EXT2_NODE* ext2_entry,
265267
if (ext2_entry->entry.name[0] != '.' && inode == 2);
266268
else {
267269
printf("1\n");
268-
str = shell_entry->name;
270+
*str = shell_entry->name;
269271
printf("ddfsf \n");
270-
str = my_strncpy(str, ext2_entry->entry.name, 8);
272+
memcpy(&str[1], ext2_entry->entry.name, MAX_NAME_LENGTH);
271273

272-
printf("ddfsf \n");
273-
/* if (ext2_entry->entry.name[8] != 0x20)
274+
printf("str : %s\n", str);
275+
printf("ext2_entry->entry.name; : %s\n", ext2_entry->entry.name);
276+
/*if (ext2_entry->entry.name[8] != 0x20)
274277
{ printf("ddfsf \n");
275278
276279
str = my_strncpy(str, ".", 1);
@@ -323,7 +326,7 @@ int fs_read_dir(DISK_OPERATIONS* disk, SHELL_FS_OPERATIONS* fsOprs, const SHELL_
323326
shell_entry_to_ext2_entry(parent, &entry);
324327
printf("before reading directory \n");
325328
ext2_read_dir(&entry, adder, list);
326-
printf("after reading directory \n");
329+
printf("after reading directory \n");
327330
return EXT2_SUCCESS;
328331
}
329332

ext2_shell.o

13.3 KB
Binary file not shown.

shell

49.6 KB
Binary file not shown.

shell.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ int shell_cmd_cat(int argc, char* argv[])
558558

559559
int shell_cmd_ls(int argc, char* argv[])
560560
{
561-
SHELL_ENTRY_LIST list;
561+
SHELL_ENTRY_LIST list = {0, };
562562
SHELL_ENTRY_LIST_ITEM* current;
563563

564564
if (argc > 2)

shell.o

19.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)