Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
	FILE *f;
	struct superblock sb;
	struct inode inode;

	if (argc < 3) {
		printf("Usage: %s <image file> <inode #>\n", argv[0]);
		return 1;
	}

	f = fopen(argv[1], "r");
	if (f == NULL) {
		perror("fopen");
		return 1;
	}

	if (get_superblock(f, &sb))
		return 1;

	// Fetch the specified inode
	if (get_inode(&sb, strtoul(argv[2], NULL, 0), &inode))
		return 1;

	// Print out the data contained in the inode
	if (print_inode_data(&sb, &inode))
		return 1;

	fclose(f);
	return 0;
}
Ejemplo n.º 2
0
void print_inode_by_number(ext2_filesystem_t *fs, uint32_t inode, 
    bool print_data, uint32_t data, bool list, bool blocks)
{
	int rc;
	ext2_inode_ref_t *inode_ref;
	
	printf("Inode %u\n", inode);
	
	rc = ext2_filesystem_get_inode_ref(fs, inode, &inode_ref);
	if (rc != EOK) {
		printf("  Failed getting inode ref\n");
		return;
	}
	
	print_inode(fs, inode_ref->inode, blocks);
	if (print_data) {
		print_inode_data(fs, inode_ref->inode, data);
	}
	
	if (list && ext2_inode_is_type(fs->superblock, inode_ref->inode,
	    EXT2_INODE_MODE_DIRECTORY)) {
		print_directory_contents(fs, inode_ref);
	}
	
	rc = ext2_filesystem_put_inode_ref(inode_ref);
	if (rc != EOK) {
		printf("  Failed putting inode ref\n");
	}
}