Beispiel #1
0
/* Affiche le fichier reference par l'inode avec l'"ouverture de fichier" */
int main (int argc, char *argv [])
{
    ctxt_t c ;

    if (argc != 3)
    {
			fprintf (stderr, "usage: %s fs inode\n", argv [0]) ;
			exit (1) ;
    }

    c = e2_ctxt_init (argv [1], MAXBUF) ;
    if (c == NULL)
    {
			perror ("e2_ctxt_init") ;
			exit (1) ;
    }
		
		char last_char;

    file_t f=e2_file_open(c,atoi(argv[2]));

		while(( last_char = e2_file_getc(f) ) != -1 ){
			printf("%c",last_char);

		}	
		
		printf("\n");
		e2_file_close(f);
    e2_ctxt_close (c) ;

    exit (0) ;
}
Beispiel #2
0
int main (int argc, char *argv [])
{
    ctxt_t c ;

    if (argc != 3)
    {
	fprintf (stderr, "usage: %s fs blkno\n", argv [0]) ;
	exit (1) ;
    }

    c = e2_ctxt_init (argv [1], MAXBUF) ;
    if (c == NULL)
    {
	perror ("e2_ctxt_init") ;
	exit (1) ;
    }
		void* data=malloc(e2_ctxt_blksize(c));

    /* A REDIGER */
		e2_block_fetch(c,atoi(argv[2]),data);
		
		write(1,data,e2_ctxt_blksize(c));
   	e2_ctxt_close (c) ;
		free(data);
    exit (0) ;
}
Beispiel #3
0
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) ;
}
Beispiel #4
0
Datei: q3.c Projekt: J4g0n/FSE
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) ;
}
Beispiel #5
0
int main (int argc, char *argv [])
{
    ctxt_t c ;
	int dispblkno;
	int retour; 

    if (argc != 3 && argc != 4)
    {
		fprintf (stderr, "usage: %s fs inode [dispblkno]\n", argv [0]) ;
		exit (1) ;
    }

    c = e2_ctxt_init (argv [1], MAXBUF) ;
    if (c == NULL)
    {
		perror ("e2_ctxt_init") ;
		exit (1) ;
    }

	/* par défaut dispblkno = 0 */
	dispblkno = 0;

	/* si on a entré une valeur */
	if(argc == 4)
		dispblkno = atoi(argv[3]);

	retour = e2_cat(c, atoi(argv[2]), dispblkno);
	if( -1 == retour )
	{
		fprintf(stderr, "Erreur : inode < 0 \n");
	}
	else if ( -2 == retour)
	{
		fprintf(stderr, "Erreur : buffer vide\n");
	}

    e2_ctxt_close (c) ;

    exit (0) ;
}
Beispiel #6
0
Datei: q5.c Projekt: J4g0n/FSE
int main (int argc, char *argv [])
{
	if (argc != 3)
	{
		fprintf (stderr, "usage: %s fs inode\n", argv [0]) ;
		exit (1) ;
	}

	ctxt_t c ;
	inum_t in=atoi(argv[2])-1;
	file_t f;
	char car;

	c = e2_ctxt_init (argv [1], MAXBUF) ;
	if (c == NULL)
	{
		perror ("e2_ctxt_init") ;
		exit (1) ;
	}

	if((f=e2_file_open(c,in))==NULL)
	{
		fprintf(stderr,"impossible d'ouvrir le fichier\n");
		exit(EXIT_FAILURE);
	}

	while((car=e2_file_getc(f))!=EOF)
	{
		printf("%c",car);
	}
	printf("\n");

	e2_file_close(f);

	e2_ctxt_close (c) ;

	exit (0) ;
}
Beispiel #7
0
int main (int argc, char *argv [])
{
    ctxt_t c ;

    if (argc != 3 && argc != 4)
    {
	fprintf (stderr, "usage: %s fs inode [dispblkno]\n", argv [0]) ;
	exit (1) ;
    }

    c = e2_ctxt_init (argv [1], MAXBUF) ;
    if (c == NULL)
    {
	perror ("e2_ctxt_init") ;
	exit (1) ;
    }

    /* A REDIGER */

    e2_ctxt_close (c) ;

    exit (0) ;
}