int main (int argc, char *argv []) { int i; ctxt_t c = NULL; buf_t tmp = NULL; if (argc < 3) { fprintf (stderr, "usage: %s fs blkno ... blkno\n", argv [0]) ; exit (1) ; } c = e2_ctxt_init (argv [1], MAXBUF) ; if (c == NULL) { perror ("e2_ctxt_init") ; exit (1) ; } for( i = 2 ; i < argc ; i++) { tmp = e2_buffer_get(c, atoi(argv[i])); printf("%s", (char *) e2_buffer_data(tmp)); e2_buffer_put(c, tmp); } e2_buffer_stats(c); e2_ctxt_close (c) ; exit (0) ; }
int main (int argc, char *argv []) { if (argc != 3) { fprintf (stderr, "usage: %s fs inode\n", argv [0]) ; exit (1) ; } int j; ctxt_t c ; inum_t i=atoi(argv[2])-1; pblk_t bNum; buf_t b; struct ext2_inode *e2in; c = e2_ctxt_init (argv [1], MAXBUF) ; if (c == NULL) { perror ("e2_ctxt_init") ; exit (1) ; } if((bNum=e2_inode_to_pblk(c,i))<0) { fprintf(stderr,"Numero d'erreur invalide\n"); exit(EXIT_FAILURE); } b=e2_buffer_get(c,bNum); e2in=e2_inode_read(c,i,b); printf("%d:size\n",e2in->i_size); for(j=0;j<e2in->i_blocks;j++) { bNum=e2_inode_lblk_to_pblk(c,e2in,j); if(bNum!=0) printf("%d:bloc %d\n",bNum,j); else break; } e2_buffer_put(c,b); e2_ctxt_close (c) ; exit (0) ; }