mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-04 23:29:20 +00:00
btrfs-progs: subvol list: copy btrfs_list_alloc_comparer_set from btrfs-list.c
There's only one caller of btrfs_list_alloc_comparer_set so move it there. Also move the definitions of BTRFS_LIST_* to the header so they can be used by both btrfs-list and subvolume.c. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
fb0bfb967f
commit
acefefce61
21
btrfs-list.c
21
btrfs-list.c
@ -34,9 +34,6 @@
|
|||||||
#include "btrfs-list.h"
|
#include "btrfs-list.h"
|
||||||
#include "common/rbtree-utils.h"
|
#include "common/rbtree-utils.h"
|
||||||
|
|
||||||
#define BTRFS_LIST_NFILTERS_INCREASE (2 * BTRFS_LIST_FILTER_MAX)
|
|
||||||
#define BTRFS_LIST_NCOMPS_INCREASE (2 * BTRFS_LIST_COMP_MAX)
|
|
||||||
|
|
||||||
/* we store all the roots we find in an rbtree so that we can
|
/* we store all the roots we find in an rbtree so that we can
|
||||||
* search for them later.
|
* search for them later.
|
||||||
*/
|
*/
|
||||||
@ -224,24 +221,6 @@ static int btrfs_list_get_sort_item(char *sort_name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct btrfs_list_comparer_set *btrfs_list_alloc_comparer_set(void)
|
|
||||||
{
|
|
||||||
struct btrfs_list_comparer_set *set;
|
|
||||||
int size;
|
|
||||||
|
|
||||||
size = sizeof(struct btrfs_list_comparer_set) +
|
|
||||||
BTRFS_LIST_NCOMPS_INCREASE * sizeof(struct btrfs_list_comparer);
|
|
||||||
set = calloc(1, size);
|
|
||||||
if (!set) {
|
|
||||||
fprintf(stderr, "memory allocation failed\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
set->total = BTRFS_LIST_NCOMPS_INCREASE;
|
|
||||||
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int btrfs_list_setup_comparer(struct btrfs_list_comparer_set **comp_set,
|
static int btrfs_list_setup_comparer(struct btrfs_list_comparer_set **comp_set,
|
||||||
enum btrfs_list_comp_enum comparer, int is_descending)
|
enum btrfs_list_comp_enum comparer, int is_descending)
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
#include "ioctl.h"
|
#include "ioctl.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#define BTRFS_LIST_NFILTERS_INCREASE (2 * BTRFS_LIST_FILTER_MAX)
|
||||||
|
#define BTRFS_LIST_NCOMPS_INCREASE (2 * BTRFS_LIST_COMP_MAX)
|
||||||
|
|
||||||
enum btrfs_list_layout {
|
enum btrfs_list_layout {
|
||||||
BTRFS_LIST_LAYOUT_DEFAULT = 0,
|
BTRFS_LIST_LAYOUT_DEFAULT = 0,
|
||||||
BTRFS_LIST_LAYOUT_TABLE,
|
BTRFS_LIST_LAYOUT_TABLE,
|
||||||
@ -157,7 +160,6 @@ void btrfs_list_setup_print_column(enum btrfs_list_column_enum column);
|
|||||||
struct btrfs_list_filter_set *btrfs_list_alloc_filter_set(void);
|
struct btrfs_list_filter_set *btrfs_list_alloc_filter_set(void);
|
||||||
void btrfs_list_setup_filter(struct btrfs_list_filter_set **filter_set,
|
void btrfs_list_setup_filter(struct btrfs_list_filter_set **filter_set,
|
||||||
enum btrfs_list_filter_enum filter, u64 data);
|
enum btrfs_list_filter_enum filter, u64 data);
|
||||||
struct btrfs_list_comparer_set *btrfs_list_alloc_comparer_set(void);
|
|
||||||
|
|
||||||
int btrfs_list_subvols_print(int fd, struct btrfs_list_filter_set *filter_set,
|
int btrfs_list_subvols_print(int fd, struct btrfs_list_filter_set *filter_set,
|
||||||
struct btrfs_list_comparer_set *comp_set,
|
struct btrfs_list_comparer_set *comp_set,
|
||||||
|
@ -69,6 +69,24 @@ static const char * const cmd_subvol_list_usage[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct btrfs_list_comparer_set *btrfs_list_alloc_comparer_set(void)
|
||||||
|
{
|
||||||
|
struct btrfs_list_comparer_set *set;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
size = sizeof(struct btrfs_list_comparer_set) +
|
||||||
|
BTRFS_LIST_NCOMPS_INCREASE * sizeof(struct btrfs_list_comparer);
|
||||||
|
set = calloc(1, size);
|
||||||
|
if (!set) {
|
||||||
|
fprintf(stderr, "memory allocation failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
set->total = BTRFS_LIST_NCOMPS_INCREASE;
|
||||||
|
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
static int cmd_subvol_list(const struct cmd_struct *cmd, int argc, char **argv)
|
static int cmd_subvol_list(const struct cmd_struct *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct btrfs_list_filter_set *filter_set;
|
struct btrfs_list_filter_set *filter_set;
|
||||||
|
Loading…
Reference in New Issue
Block a user