Exemplo n.º 1
0
int init_ext_introspection(int fd, int fs) {
	char *buf;
	int i;
	struct ext_superblock_t superblock;
	//struct sinode_t *sinode;
	// get initialized time
	time_t before, after;
	before = time(NULL);

	if (posix_memalign((void **) &buf, DOM0BLOCKSIZE, DOM0BLOCKSIZE) != 0) {
		return -1;
	}
	
	if (get_superblock(&superblock, fd, buf, DOM0BLOCKSIZE, fs)) {
		printf("get superblock error.\n");
	}

	free(buf);

	dump_superblock(&superblock);

	after = time(NULL);
	after -= before ;//prevent warning
	printf("time consumed:%lu\n", after);

	return 0;
}
Exemplo n.º 2
0
static int load_and_dump_sb(char *filename, int fd, u64 sb_bytenr, int full,
		int force)
{
	u8 super_block_data[BTRFS_SUPER_INFO_SIZE];
	struct btrfs_super_block *sb;
	u64 ret;

	sb = (struct btrfs_super_block *)super_block_data;

	ret = pread64(fd, super_block_data, BTRFS_SUPER_INFO_SIZE, sb_bytenr);
	if (ret != BTRFS_SUPER_INFO_SIZE) {
		/* check if the disk if too short for further superblock */
		if (ret == 0 && errno == 0)
			return 0;

		fprintf(stderr,
		   "ERROR: Failed to read the superblock on %s at %llu\n",
		   filename, (unsigned long long)sb_bytenr);
		fprintf(stderr,
		   "ERROR: error = '%s', errno = %d\n", strerror(errno), errno);
		return 1;
	}
	printf("superblock: bytenr=%llu, device=%s\n", sb_bytenr, filename);
	printf("---------------------------------------------------------\n");
	if (btrfs_super_magic(sb) != BTRFS_MAGIC && !force) {
		fprintf(stderr,
		    "ERROR: bad magic on superblock on %s at %llu\n",
		    filename, (unsigned long long)sb_bytenr);
	} else {
		dump_superblock(sb, full);
	}
	return 0;
}
Exemplo n.º 3
0
Arquivo: TP8.c Projeto: ABeaujet/ASEa
void testsVblocks(){
    initTestIndx();
    dump_superblock();
    printf("print_inode(2) : %d\n", print_inode(1));
    unsigned int testBlock = vblock_of_fblock(1, 100, false);
    printf("vblock_of_fblock(1, 100) = %u\n", testBlock);
    printf("Volume %s plein\n", (isVolFull() == 0) ? "NON ":"");
    printf("Espace restant : %d/%d (1 bloc reserve au superbloc)\n", volFreeSpace(), MBR.volumes[currentVol].size);
    disp_freelist();
}