Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

un peu avancé sur les indirections

  • Loading branch information...
commit 98cae3ee955faed821262f61e7695fe2d40f0bd5 1 parent 7265ef0
@KaneRoot authored
Showing with 21 additions and 10 deletions.
  1. +21 −10 ls5/fse/tp_fse/tp3src/e2fs.c
View
31 ls5/fse/tp_fse/tp3src/e2fs.c
@@ -272,15 +272,6 @@ struct ext2_inode *e2_inode_read (ctxt_t c, inum_t i, buf_t b)
{
printf("LE BLOC DATA EST NULL\n");
}
-// else
-// {
-// if( memcpy(inode, (b->data + (((i-1)%(1024 << c->sb.s_log_block_size)/sizeof(struct ext2_inode)) * sizeof(struct ext2_inode))), sizeof(struct ext2_inode)) == -1)
-// {
-// errno = 1;
-// free(inode);
-// return (struct ext2_inode*) NULL;
-// }
-// }
int nombre_inodes_par_bloc = (1024 << c->sb.s_log_block_size) / sizeof(struct ext2_inode);
@@ -291,6 +282,26 @@ struct ext2_inode *e2_inode_read (ctxt_t c, inum_t i, buf_t b)
/* numero de bloc physique correspondant au bloc logique blkno de l'inode in */
pblk_t e2_inode_lblk_to_pblk (ctxt_t c, struct ext2_inode *in, lblk_t blkno)
{
- return 0;
+ int taille_bloc = (1024 << c->sb.s_log_block_size);
+ int nb_blocs_max = 12 + taille_bloc + taille_bloc * taille_bloc + taille_bloc * taille_bloc * taille_bloc;
+
+ /* Assez clairement, si blkno > au nb max de blocs pour un fichier, il y a un soucis */
+ if(blkno > nb_blocs_max || blkno > in->i_blocks)
+ {
+ return 0;
+ }
+ if( blkno < 12)
+ return in->i_block[blkno];
+ else if ( blkno < taille_bloc + 11)
+ {
+ buf_t b = e2_block_fetch(c, in->i_block[12]);
+
+
+ }
+ else if ( blkno < (taille_bloc*taille_bloc) + 11)
+ {
+ }
+
+ return ;
}
Please sign in to comment.
Something went wrong with that request. Please try again.