ret = llistxattr(file_name, xattr_list, XATTR_LIST_MAX);
if (ret < 0) {
+ if(errno == ENOTSUP)
+ return 0;
fprintf(stderr, "get a list of xattr failed for %s\n",
file_name);
return ret;
ret = getxattr(file_name, cur_name, cur_value, XATTR_SIZE_MAX);
if (ret < 0) {
- fprintf(stderr, "get a xattr value failed for %s\n",
- cur_name);
+ if(errno == ENOTSUP)
+ return 0;
+ fprintf(stderr, "get a xattr value failed for %s attr %s\n",
+ file_name, cur_name);
+ return ret;
}
ret = btrfs_insert_xattr_item(trans, root, cur_name,
return ret;
}
-
static int custom_alloc_extent(struct btrfs_root *root, u64 num_bytes,
u64 hint_byte, struct btrfs_key *ins)
{
cur_inum, cur_file->d_name);
if (ret) {
fprintf(stderr, "add_xattr_item failed\n");
- goto fail;
+ if(ret != -ENOTSUP)
+ goto fail;
}
if (S_ISDIR(st.st_mode)) {
u64 chunk_size;
u64 meta_type = BTRFS_BLOCK_GROUP_METADATA;
u64 data_type = BTRFS_BLOCK_GROUP_DATA;
- u64 minimum_data_chunk_size = 64 * 1024 * 1024;
+ u64 minimum_data_chunk_size = 8 * 1024 * 1024;
u64 i;
int ret;
char path[512];
char *file_name = "temp_file";
FILE *file;
- u64 minimum_data_size = 256 * 1024 * 1024; /* 256MB */
u64 default_chunk_size = 8 * 1024 * 1024; /* 8MB */
u64 allocated_meta_size = 8 * 1024 * 1024; /* 8MB */
u64 allocated_total_size = 20 * 1024 * 1024; /* 20MB */
*num_of_meta_chunks_ret = num_of_meta_chunks;
- if (total_size < minimum_data_size)
- total_size = minimum_data_size;
-
return total_size;
}
char *source_dir = NULL;
int source_dir_set = 0;
- char *output = "output.img";
u64 num_of_meta_chunks = 0;
u64 size_of_data = 0;
+ u64 source_dir_size = 0;
char *pretty_buf;
while(1) {
fprintf(stderr, "Illegal nodesize %u\n", nodesize);
exit(1);
}
- if (source_dir_set)
- ac++;
ac = ac - optind;
if (ac == 0)
print_usage();
block_count = dev_block_count;
} else {
ac = 0;
- file = output;
- fd = open_target(output);
+ file = av[optind++];
+ fd = open_target(file);
if (fd < 0) {
fprintf(stderr, "unable to open the %s\n", file);
exit(1);
}
first_file = file;
- block_count = size_sourcedir(source_dir, sectorsize,
+ source_dir_size = size_sourcedir(source_dir, sectorsize,
&num_of_meta_chunks, &size_of_data);
+ if(block_count < source_dir_size)
+ block_count = source_dir_size;
ret = zero_output_file(fd, block_count, sectorsize);
if (ret) {
fprintf(stderr, "unable to zero the output file\n");