mirror of
https://github.com/kdave/btrfs-progs
synced 2025-05-10 03:47:55 +00:00
add defrag ioctl
This commit is contained in:
parent
330f6227aa
commit
0528b69c15
@ -77,6 +77,12 @@ int main(int ac, char **av)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
command = BTRFS_IOC_SNAP_CREATE;
|
command = BTRFS_IOC_SNAP_CREATE;
|
||||||
|
} else if (strcmp(av[i], "-d") == 0) {
|
||||||
|
if (i >= ac - 1) {
|
||||||
|
fprintf(stderr, "-d requires an arg");
|
||||||
|
print_usage();
|
||||||
|
}
|
||||||
|
command = BTRFS_IOC_DEFRAG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (command == 0) {
|
if (command == 0) {
|
||||||
@ -102,7 +108,10 @@ int main(int ac, char **av)
|
|||||||
perror("open");
|
perror("open");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
if (name)
|
||||||
strcpy(args.name, name);
|
strcpy(args.name, name);
|
||||||
|
else
|
||||||
|
args.name[0] = '\0';
|
||||||
ret = ioctl(fd, command, &args);
|
ret = ioctl(fd, command, &args);
|
||||||
printf("ioctl returns %d\n", ret);
|
printf("ioctl returns %d\n", ret);
|
||||||
return 0;
|
return 0;
|
||||||
|
2
ioctl.h
2
ioctl.h
@ -28,6 +28,6 @@ struct btrfs_ioctl_vol_args {
|
|||||||
|
|
||||||
#define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
|
#define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
|
||||||
struct btrfs_ioctl_vol_args)
|
struct btrfs_ioctl_vol_args)
|
||||||
#define BTRFS_IOC_ADD_DISK _IOW(BTRFS_IOCTL_MAGIC, 2, \
|
#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
|
||||||
struct btrfs_ioctl_vol_args)
|
struct btrfs_ioctl_vol_args)
|
||||||
#endif
|
#endif
|
||||||
|
1
mkfs.c
1
mkfs.c
@ -225,6 +225,7 @@ int mkfs(int fd, char *pathname, u64 num_blocks, u32 blocksize)
|
|||||||
btrfs_set_inode_nblocks(inode_item, 1);
|
btrfs_set_inode_nblocks(inode_item, 1);
|
||||||
btrfs_set_inode_mode(inode_item, S_IFDIR | 0755);
|
btrfs_set_inode_mode(inode_item, S_IFDIR | 0755);
|
||||||
|
|
||||||
|
// memset(&root_item, 0, sizeof(root_item));
|
||||||
btrfs_set_root_dirid(&root_item, 0);
|
btrfs_set_root_dirid(&root_item, 0);
|
||||||
btrfs_set_root_refs(&root_item, 1);
|
btrfs_set_root_refs(&root_item, 1);
|
||||||
btrfs_set_disk_key_offset(&item.key, 0);
|
btrfs_set_disk_key_offset(&item.key, 0);
|
||||||
|
10
print-tree.c
10
print-tree.c
@ -96,6 +96,16 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l)
|
|||||||
(unsigned long long)btrfs_root_blocknr(ri),
|
(unsigned long long)btrfs_root_blocknr(ri),
|
||||||
(unsigned long long)btrfs_root_dirid(ri),
|
(unsigned long long)btrfs_root_dirid(ri),
|
||||||
btrfs_root_refs(ri));
|
btrfs_root_refs(ri));
|
||||||
|
if (1 || btrfs_root_refs(ri) == 0) {
|
||||||
|
struct btrfs_key drop_key;
|
||||||
|
btrfs_disk_key_to_cpu(&drop_key,
|
||||||
|
&ri->drop_progress);
|
||||||
|
printf("\t\tdrop key %Lu %x %Lu level %d\n",
|
||||||
|
(unsigned long long)drop_key.objectid,
|
||||||
|
drop_key.flags,
|
||||||
|
(unsigned long long)drop_key.offset,
|
||||||
|
ri->drop_level);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BTRFS_EXTENT_ITEM_KEY:
|
case BTRFS_EXTENT_ITEM_KEY:
|
||||||
ei = btrfs_item_ptr(l, i, struct btrfs_extent_item);
|
ei = btrfs_item_ptr(l, i, struct btrfs_extent_item);
|
||||||
|
Loading…
Reference in New Issue
Block a user