summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-10-22 08:00:16 +0200
committerMichal Idziorek <m.i@gmx.at>2014-10-22 08:00:16 +0200
commitd272f7fda985b266588af8ba6091c97e44862287 (patch)
tree1833c63d9c301b4684e3e44d46ff9e90fcef11c6 /fs
parent27a5147baf83f07e0f9cc53c56356a5d2152a5ee (diff)
reading root inode
Diffstat (limited to 'fs')
-rw-r--r--fs/ext2.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/fs/ext2.c b/fs/ext2.c
index f96d4f0..38ea06b 100644
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -71,7 +71,6 @@ typedef struct ext2_dir_struct
uint8_t name_length_low;
uint8_t name_length_high;
// name follows
- char name[10]; // TODO: load dynamiccaly N chars!
}ext2_dir;
typedef struct ext2_inode_struct
@@ -91,7 +90,7 @@ typedef struct ext2_inode_struct
uint32_t indirect3;
uint32_t gen_num;
uint32_t later1; // will be implemented later by the fooldriver
- uint32_t later2;
+ uint32_t size_high;
uint32_t frag;
uint32_t os_spec2[3];
}ext2_inode;
@@ -163,15 +162,27 @@ int main()
printf("---------- root ---------\n");
printf("uid/gid: %i/%i\n",inode.user_id,inode.group_id);
printf("hardlinks: %i\n",inode.hardlink_count);
+ printf("size low/high: %i/%i\n",inode.size_low,inode.size_high);
printf("direct block pointer 0: %i\n\n",inode.direct_pointer[0]);
// read dir
- ext2_dir dir;
+ char buf[256];
fseek(stdin,block_size*inode.direct_pointer[0],SEEK_SET);
- fread(&dir,sizeof(dir),1,stdin);
- printf("inode: %i\n",dir.inode);
- printf("total size: %i\n",dir.size);
- printf("name: %s\n\n",dir.name);
+
+ int pos=0;
+ while(pos<inode.size_low)
+ {
+ ext2_dir dir;
+ fread(&dir,sizeof(dir),1,stdin);
+ printf("inode: %i\n",dir.inode);
+ printf("total size: %i\n",dir.size);
+ printf("length low/high: %i/%i\n\n",dir.name_length_low,dir.name_length_high);
+ int l=fread(buf,sizeof(char),dir.name_length_low,stdin);
+ buf[l]=0;
+ printf("name: %s\n\n",buf);
+ fseek(stdin,dir.size-8-dir.name_length_low,SEEK_CUR);
+ pos+=dir.size;
+ }
puts("");