}
if (S_ISREG(src->st_mode)) {
btrfs_set_stack_inode_size(dst, (u64)src->st_size);
- if (src->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info))
+ if (src->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info) &&
+ src->st_size < sectorsize)
btrfs_set_stack_inode_nbytes(dst, src->st_size);
else {
blocks = src->st_size / sectorsize;
cur_name_len = strlen(cur_name);
next_location += cur_name_len + 1;
- ret = getxattr(file_name, cur_name, cur_value, XATTR_SIZE_MAX);
+ ret = lgetxattr(file_name, cur_name, cur_value, XATTR_SIZE_MAX);
if (ret < 0) {
if (errno == ENOTSUP)
return 0;
if (st->st_size % sectorsize)
blocks += 1;
- if (st->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info)) {
+ if (st->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info) &&
+ st->st_size < sectorsize) {
char *buffer = malloc(st->st_size);
if (!buffer) {
ino_t parent_inum, cur_inum;
ino_t highest_inum = 0;
const char *parent_dir_name;
- char real_path[PATH_MAX];
struct btrfs_path path;
struct extent_buffer *leaf;
struct btrfs_key root_dir_key;
if (!dir_entry)
return -ENOMEM;
dir_entry->dir_name = dir_name;
- dir_entry->path = realpath(dir_name, real_path);
+ dir_entry->path = realpath(dir_name, NULL);
if (!dir_entry->path) {
error("realpath failed for %s: %s", dir_name, strerror(errno));
ret = -1;
}
free_namelist(files, count);
+ free(parent_dir_entry->path);
free(parent_dir_entry);
index_cnt = 2;
dir_entry = list_entry(dir_head.list.next,
struct directory_name_entry, list);
list_del(&dir_entry->list);
+ free(dir_entry->path);
free(dir_entry);
}
out:
}
static int ftw_add_entry_size(const char *fpath, const struct stat *st,
- int type)
+ int type, struct FTW *ftwbuf)
{
/*
* Failed to read the directory, mostly due to EPERM. Abort ASAP, so
fs_block_size = sectorsize;
ftw_data_size = 0;
ftw_meta_nr_inode = 0;
- ret = ftw(dir_name, ftw_add_entry_size, 10);
+
+ /*
+ * Symbolic link is not followed when creating files, so no need to
+ * follow them here.
+ */
+ ret = nftw(dir_name, ftw_add_entry_size, 10, FTW_PHYS);
if (ret < 0) {
error("ftw subdir walk of %s failed: %s", dir_name,
strerror(errno));