Generated by following semantic patch and manually tweaked.
<SmPL>
@@
struct btrfs_ioctl_search_header *SH;
@@
(
- SH->objectid
+ btrfs_search_header_objectid(SH)
|
- SH->offset
+ btrfs_search_header_offset(SH)
|
- SH->transid
+ btrfs_search_header_transid(SH)
|
- SH->len
+ btrfs_search_header_len(SH)
|
- SH->type
+ btrfs_search_header_type(SH)
)
</SmPL>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=112131
Reported-and-tested-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
sh = (struct btrfs_ioctl_search_header *)(args.buf +
off);
off += sizeof(*sh);
- if (sh->type == BTRFS_BLOCK_GROUP_ITEM_KEY) {
+ if (btrfs_search_header_type(sh)
+ == BTRFS_BLOCK_GROUP_ITEM_KEY) {
struct btrfs_block_group_item *bg;
if (im) {
(args.buf + off);
bgflags = btrfs_block_group_flags(bg);
bgused = btrfs_block_group_used(bg);
-
+
printf("found block group %lld len %lld "
- "flags %lld\n", sh->objectid,
- sh->offset, bgflags);
+ "flags %lld\n",
+ btrfs_search_header_objectid(sh),
+ btrfs_search_header_offset(sh),
+ bgflags);
if (!(bgflags & flags)) {
/* skip this block group */
- sk->min_objectid = sh->objectid +
- sh->offset;
+ sk->min_objectid =
+ btrfs_search_header_objectid(sh) +
+ btrfs_search_header_offset(sh);
sk->min_type = 0;
sk->min_offset = 0;
break;
}
im = gdImageCreate(width,
- (sh->offset / 4096 + 799) / width);
+ (btrfs_search_header_offset(sh)
+ / 4096 + 799) / width);
black = gdImageColorAllocate(im, 0, 0, 0);
colors[j] = black;
init_colors(im, colors);
- bgstart = sh->objectid;
- bglen = sh->offset;
+ bgstart = btrfs_search_header_objectid(sh);
+ bglen = btrfs_search_header_offset(sh);
bgend = bgstart + bglen;
snprintf(name, sizeof(name), "bg%d.png", bgnum);
areas = 0;
saved_len = 0;
}
- if (im && sh->type == BTRFS_EXTENT_ITEM_KEY) {
+ if (im && btrfs_search_header_type(sh)
+ == BTRFS_EXTENT_ITEM_KEY) {
int c;
struct btrfs_extent_item *item;
(args.buf + off);
if (use_color)
- c = colors[get_color(item, sh->len)];
+ c = colors[get_color(item,
+ btrfs_search_header_len(sh))];
else
c = black;
- if (sh->objectid > bgend) {
+ if (btrfs_search_header_objectid(sh) > bgend) {
printf("WARN: extent %lld is without "
- "block group\n", sh->objectid);
+ "block group\n",
+ btrfs_search_header_objectid(sh));
goto skip;
}
- if (sh->objectid == bgend) {
- saved_extent = sh->objectid;
- saved_len = sh->offset;
+ if (btrfs_search_header_objectid(sh) == bgend) {
+ saved_extent =
+ btrfs_search_header_objectid(sh);
+ saved_len =
+ btrfs_search_header_offset(sh);
saved_color = c;
goto skip;
}
- px = (sh->objectid - bgstart) / 4096;
- for (j = 0; j < sh->offset / 4096; ++j) {
+ px = (btrfs_search_header_objectid(sh)
+ - bgstart) / 4096;
+ for (j = 0;
+ j < btrfs_search_header_offset(sh) / 4096;
+ ++j) {
int x = (px + j) % width;
int y = (px + j) / width;
gdImageSetPixel(im, x, y, c);
}
- if (sh->objectid != last_end)
+ if (btrfs_search_header_objectid(sh) != last_end)
++areas;
- last_end = sh->objectid + sh->offset;
+ last_end = btrfs_search_header_objectid(sh)
+ + btrfs_search_header_offset(sh);
skip:;
}
- off += sh->len;
+ off += btrfs_search_header_len(sh);
/*
* record the mins in sk so we can make sure the
* next search doesn't repeat this root
*/
- sk->min_objectid = sh->objectid;
- sk->min_type = sh->type;
- sk->min_offset = sh->offset;
+ sk->min_objectid = btrfs_search_header_objectid(sh);
+ sk->min_type = btrfs_search_header_type(sh);
+ sk->min_offset = btrfs_search_header_offset(sh);
}
sk->nr_items = 4096;
off = 0;
sh = (struct btrfs_ioctl_search_header *)(args.buf + off);
- if (sh->type == BTRFS_INODE_REF_KEY) {
+ if (btrfs_search_header_type(sh) == BTRFS_INODE_REF_KEY) {
struct btrfs_inode_ref *ref;
- dirid = sh->offset;
+ dirid = btrfs_search_header_offset(sh);
ref = (struct btrfs_inode_ref *)(sh + 1);
namelen = btrfs_stack_inode_ref_name_len(ref);
sh = (struct btrfs_ioctl_search_header *)args.buf;
- if (sh->type == BTRFS_DIR_ITEM_KEY) {
+ if (btrfs_search_header_type(sh) == BTRFS_DIR_ITEM_KEY) {
struct btrfs_dir_item *di;
int name_len;
char *name;
int flags = 0;
char *name = NULL;
- if (sh->objectid == *cache_ino) {
+ if (btrfs_search_header_objectid(sh) == *cache_ino) {
name = *cache_full_name;
} else if (*cache_full_name) {
free(*cache_full_name);
*cache_full_name = NULL;
}
if (!name) {
- name = ino_resolve(fd, sh->objectid, cache_dirid,
+ name = ino_resolve(fd, btrfs_search_header_objectid(sh),
+ cache_dirid,
cache_dir_name);
*cache_full_name = name;
- *cache_ino = sh->objectid;
+ *cache_ino = btrfs_search_header_objectid(sh);
}
if (!name)
return -EIO;
printf("unhandled extent type %d for inode %llu "
"file offset %llu gen %llu\n",
type,
- (unsigned long long)sh->objectid,
- (unsigned long long)sh->offset,
+ (unsigned long long)btrfs_search_header_objectid(sh),
+ (unsigned long long)btrfs_search_header_offset(sh),
(unsigned long long)found_gen);
return -EIO;
}
printf("inode %llu file offset %llu len %llu disk start %llu "
"offset %llu gen %llu flags ",
- (unsigned long long)sh->objectid,
- (unsigned long long)sh->offset,
+ (unsigned long long)btrfs_search_header_objectid(sh),
+ (unsigned long long)btrfs_search_header_offset(sh),
(unsigned long long)len,
(unsigned long long)disk_start,
(unsigned long long)disk_offset,
return 1;
}
- off += sh->len;
+ off += btrfs_search_header_len(sh);
- sk->min_objectid = sh->objectid;
- sk->min_type = sh->type;
- sk->min_offset = sh->offset+1;
+ sk->min_objectid = btrfs_search_header_objectid(sh);
+ sk->min_type = btrfs_search_header_type(sh);
+ sk->min_offset = btrfs_search_header_offset(sh)+1;
}
if (!sk->min_offset) /* overflow */
off);
off += sizeof(*sh);
extent = (struct btrfs_dev_extent *)(args.buf + off);
- off += sh->len;
+ off += btrfs_search_header_len(sh);
- sk->min_objectid = sh->objectid;
- sk->min_type = sh->type;
- sk->min_offset = sh->offset + 1;
+ sk->min_objectid = btrfs_search_header_objectid(sh);
+ sk->min_type = btrfs_search_header_type(sh);
+ sk->min_offset = btrfs_search_header_offset(sh) + 1;
- if (sh->objectid != devid ||
- sh->type != BTRFS_DEV_EXTENT_KEY)
+ if (btrfs_search_header_objectid(sh) != devid ||
+ btrfs_search_header_type(sh) != BTRFS_DEV_EXTENT_KEY)
continue;
len = btrfs_stack_dev_extent_length(extent);
min_size += len;
- ret = add_dev_extent(&extents, sh->offset,
- sh->offset + len - 1, 0);
+ ret = add_dev_extent(&extents,
+ btrfs_search_header_offset(sh),
+ btrfs_search_header_offset(sh) + len - 1, 0);
if (!ret && last_pos != (u64)-1 &&
- last_pos != sh->offset)
+ last_pos != btrfs_search_header_offset(sh))
ret = add_dev_extent(&holes, last_pos,
- sh->offset - 1, 1);
+ btrfs_search_header_offset(sh) - 1, 1);
if (ret) {
error("add device extent: %s", strerror(-ret));
ret = 1;
goto out;
}
- last_pos = sh->offset + len;
+ last_pos = btrfs_search_header_offset(sh) + len;
}
if (sk->min_type != BTRFS_DEV_EXTENT_KEY ||
sh = (struct btrfs_ioctl_search_header*)(args.buf + off);
off += sizeof(*sh);
- if (sh->type == BTRFS_ORPHAN_ITEM_KEY) {
+ if (btrfs_search_header_type(sh)
+ == BTRFS_ORPHAN_ITEM_KEY) {
if (idx >= count) {
u64 *newids;
return -ENOMEM;
*ids = newids;
}
- (*ids)[idx] = sh->offset;
+ (*ids)[idx] = btrfs_search_header_offset(sh);
idx++;
}
- off += sh->len;
+ off += btrfs_search_header_len(sh);
- sk->min_objectid = sh->objectid;
- sk->min_type = sh->type;
- sk->min_offset = sh->offset;
+ sk->min_objectid = btrfs_search_header_objectid(sh);
+ sk->min_type = btrfs_search_header_type(sh);
+ sk->min_offset = btrfs_search_header_offset(sh);
}
if (sk->min_offset < (u64)-1)
sk->min_offset++;
off);
off += sizeof(*sh);
- if (sh->type == BTRFS_QGROUP_STATUS_KEY) {
+ if (btrfs_search_header_type(sh)
+ == BTRFS_QGROUP_STATUS_KEY) {
struct btrfs_qgroup_status_item *si;
u64 flags;
(args.buf + off);
flags = btrfs_stack_qgroup_status_flags(si);
print_status_flag_warning(flags);
- } else if (sh->type == BTRFS_QGROUP_INFO_KEY) {
+ } else if (btrfs_search_header_type(sh)
+ == BTRFS_QGROUP_INFO_KEY) {
info = (struct btrfs_qgroup_info_item *)
(args.buf + off);
a1 = btrfs_stack_qgroup_info_generation(info);
a5 =
btrfs_stack_qgroup_info_exclusive_compressed
(info);
- add_qgroup(qgroup_lookup, sh->offset, a1, a2,
- a3, a4, a5, 0, 0, 0, 0, 0,
- NULL, NULL);
- } else if (sh->type == BTRFS_QGROUP_LIMIT_KEY) {
+ add_qgroup(qgroup_lookup,
+ btrfs_search_header_offset(sh), a1,
+ a2, a3, a4, a5, 0, 0, 0, 0, 0, NULL,
+ NULL);
+ } else if (btrfs_search_header_type(sh)
+ == BTRFS_QGROUP_LIMIT_KEY) {
limit = (struct btrfs_qgroup_limit_item *)
(args.buf + off);
(limit);
a5 = btrfs_stack_qgroup_limit_rsv_exclusive
(limit);
- add_qgroup(qgroup_lookup, sh->offset, 0, 0,
- 0, 0, 0, a1, a2, a3, a4, a5,
+ add_qgroup(qgroup_lookup,
+ btrfs_search_header_offset(sh), 0,
+ 0, 0, 0, 0, a1, a2, a3, a4, a5,
NULL, NULL);
- } else if (sh->type == BTRFS_QGROUP_RELATION_KEY) {
- if (sh->offset < sh->objectid)
+ } else if (btrfs_search_header_type(sh)
+ == BTRFS_QGROUP_RELATION_KEY) {
+ if (btrfs_search_header_offset(sh)
+ < btrfs_search_header_objectid(sh))
goto skip;
bq = qgroup_tree_search(qgroup_lookup,
- sh->offset);
+ btrfs_search_header_offset(sh));
if (!bq)
goto skip;
bq1 = qgroup_tree_search(qgroup_lookup,
- sh->objectid);
+ btrfs_search_header_objectid(sh));
if (!bq1)
goto skip;
- add_qgroup(qgroup_lookup, sh->offset, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, bq, bq1);
+ add_qgroup(qgroup_lookup,
+ btrfs_search_header_offset(sh), 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, bq, bq1);
} else
goto done;
skip:
- off += sh->len;
+ off += btrfs_search_header_len(sh);
/*
* record the mins in sk so we can make sure the
* next search doesn't repeat this root
*/
- sk->min_type = sh->type;
- sk->min_offset = sh->offset;
- sk->min_objectid = sh->objectid;
+ sk->min_type = btrfs_search_header_type(sh);
+ sk->min_offset = btrfs_search_header_offset(sh);
+ sk->min_objectid = btrfs_search_header_objectid(sh);
}
sk->nr_items = 4096;
/*
off += sizeof(*sh);
item = (struct btrfs_root_item *)(args.buf + off);
- off += sh->len;
+ off += btrfs_search_header_len(sh);
- sk->min_objectid = sh->objectid;
- sk->min_type = sh->type;
- sk->min_offset = sh->offset;
+ sk->min_objectid = btrfs_search_header_objectid(sh);
+ sk->min_type = btrfs_search_header_type(sh);
+ sk->min_offset = btrfs_search_header_offset(sh);
- if (sh->objectid > root_id)
+ if (btrfs_search_header_objectid(sh) > root_id)
break;
- if (sh->objectid == root_id &&
- sh->type == BTRFS_ROOT_ITEM_KEY) {
- if (sh->len > buf_len) {
+ if (btrfs_search_header_objectid(sh) == root_id &&
+ btrfs_search_header_type(sh) == BTRFS_ROOT_ITEM_KEY) {
+ if (btrfs_search_header_len(sh) > buf_len) {
/* btrfs-progs is too old for kernel */
fprintf(stderr,
"ERROR: buf for read_root_item_raw() is too small, get newer btrfs tools!\n");
return -EOVERFLOW;
}
- memcpy(buf, item, sh->len);
- *read_len = sh->len;
+ memcpy(buf, item, btrfs_search_header_len(sh));
+ *read_len = btrfs_search_header_len(sh);
found = 1;
}
}
}
search_header = (struct btrfs_ioctl_search_header *)search_arg.buf;
backref_item = (struct btrfs_root_ref *)(search_header + 1);
- if (search_header->offset != BTRFS_FS_TREE_OBJECTID) {
+ if (btrfs_search_header_offset(search_header)
+ != BTRFS_FS_TREE_OBJECTID) {
int sub_ret;
sub_ret = btrfs_subvolid_resolve_sub(fd, path, path_len,
- search_header->offset);
+ btrfs_search_header_offset(search_header));
if (sub_ret)
return sub_ret;
if (*path_len < 1)
int len;
memset(&ino_lookup_arg, 0, sizeof(ino_lookup_arg));
- ino_lookup_arg.treeid = search_header->offset;
+ ino_lookup_arg.treeid =
+ btrfs_search_header_offset(search_header);
ino_lookup_arg.objectid =
btrfs_stack_root_ref_dirid(backref_item);
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_lookup_arg);
off);
off += sizeof(*sh);
- if ((sh->objectid != 5 &&
- sh->objectid < BTRFS_FIRST_FREE_OBJECTID) ||
- sh->objectid > BTRFS_LAST_FREE_OBJECTID)
+ if ((btrfs_search_header_objectid(sh) != 5 &&
+ btrfs_search_header_objectid(sh)
+ < BTRFS_FIRST_FREE_OBJECTID) ||
+ btrfs_search_header_objectid(sh)
+ > BTRFS_LAST_FREE_OBJECTID) {
goto skip;
+ }
- if (sh->type == BTRFS_ROOT_ITEM_KEY) {
+ if (btrfs_search_header_type(sh)
+ == BTRFS_ROOT_ITEM_KEY) {
/* older kernels don't have uuids+times */
- if (sh->len < sizeof(root_item)) {
+ if (btrfs_search_header_len(sh)
+ < sizeof(root_item)) {
root_item_valid = 0;
goto skip;
}
memcpy(&root_item, root_item_ptr,
sizeof(root_item));
root_item_valid = 1;
- } else if (sh->type == BTRFS_ROOT_BACKREF_KEY ||
+ } else if (btrfs_search_header_type(sh)
+ == BTRFS_ROOT_BACKREF_KEY ||
root_item_valid) {
if (!root_item_valid)
goto skip;
path = btrfs_list_path_for_root(mnt_fd,
- sh->objectid);
+ btrfs_search_header_objectid(sh));
if (!path)
path = strdup("");
if (IS_ERR(path)) {
fprintf(stderr, "ERROR: unable to "
"resolve path "
"for root %llu\n",
- sh->objectid);
+ btrfs_search_header_objectid(sh));
goto out;
}
si = calloc(1, sizeof(*si));
- si->root_id = sh->objectid;
+ si->root_id = btrfs_search_header_objectid(sh);
memcpy(si->uuid, root_item.uuid,
BTRFS_UUID_SIZE);
memcpy(si->parent_uuid, root_item.parent_uuid,
}
skip:
- off += sh->len;
+ off += btrfs_search_header_len(sh);
/*
* record the mins in sk so we can make sure the
* next search doesn't repeat this root
*/
- sk->min_objectid = sh->objectid;
- sk->min_offset = sh->offset;
- sk->min_type = sh->type;
+ sk->min_objectid = btrfs_search_header_objectid(sh);
+ sk->min_offset = btrfs_search_header_offset(sh);
+ sk->min_type = btrfs_search_header_type(sh);
}
sk->nr_items = 4096;
if (sk->min_offset < (u64)-1)
goto out;
}
search_header = (struct btrfs_ioctl_search_header *)(search_arg.buf);
- item_size = search_header->len;
+ item_size = btrfs_search_header_len(search_header);
if ((item_size & (sizeof(u64) - 1)) || item_size == 0) {
printf("btrfs: uuid item with illegal size %lu!\n",
(unsigned long)item_size);