#include "lib/label/label.h"
#include "lib/activate/activate.h"
-typedef enum {
+enum {
CMDLOG = 1,
FULL = 2,
LVS = 4,
PVSEGS = 512,
LABEL = 1024,
DEVTYPES = 2048
-} report_type_t;
+};
typedef enum {
REPORT_HEADINGS_UNKNOWN = -1,
*/
struct selection_handle {
struct dm_report *selection_rh;
- report_type_t orig_report_type;
- report_type_t report_type;
+ unsigned orig_report_type;
+ unsigned report_type;
int selected;
};
int report_format_init(struct cmd_context *cmd);
void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
- report_type_t *report_type, const char *separator,
+ unsigned *report_type, const char *separator,
int aligned, int buffered, report_headings_t headings,
int field_prefixes, int quoted, int columns_as_rows,
const char *selection, int multiple_output);
-int report_get_single_selection(struct cmd_context *cmd, report_type_t report_type, const char **selection);
-void *report_init_for_selection(struct cmd_context *cmd, report_type_t *report_type,
+int report_get_single_selection(struct cmd_context *cmd, unsigned report_type, const char **selection);
+void *report_init_for_selection(struct cmd_context *cmd, unsigned *report_type,
const char *selection);
-int report_get_prefix_and_desc(report_type_t report_type_id,
+int report_get_prefix_and_desc(unsigned report_type_id,
const char **report_prefix,
const char **report_desc);
int report_for_selection(struct cmd_context *cmd,
#define REPORT_IDX_FULL_START REPORT_IDX_FULL_VGS
struct single_report_args {
- report_type_t report_type;
+ unsigned report_type;
+ int args_are_pvs;
char report_prefix[32];
const char *report_name;
- int args_are_pvs;
const char *keys;
const char *options;
const char *fields_to_compact;
int argc;
char **argv;
dm_report_group_type_t report_group_type;
- report_type_t report_type;
+ unsigned report_type;
report_headings_t headings;
int aligned;
int buffered;
static int _get_final_report_type(struct report_args *args,
struct single_report_args *single_args,
- report_type_t report_type,
+ unsigned report_type,
int *lv_info_needed,
int *lv_segment_status_needed,
- report_type_t *final_report_type)
+ unsigned *final_report_type)
{
/* Do we need to acquire LV device info in addition? */
*lv_info_needed = (report_type & (LVSINFO | LVSINFOSTATUS)) ? 1 : 0;
}
static int _report_all_in_vg(struct cmd_context *cmd, struct processing_handle *handle,
- struct volume_group *vg, report_type_t type,
+ struct volume_group *vg, unsigned report_type,
int do_lv_info, int do_lv_seg_status)
{
int r = ECMD_FAILED;
- switch (type) {
+ switch (report_type) {
case VGS:
r = _vgs_single(cmd, vg->name, vg, handle);
break;
&_pvsegs_single);
break;
default:
- log_error(INTERNAL_ERROR "_report_all_in_vg: incorrect report type");
+ log_error(INTERNAL_ERROR "_report_all_in_vg: incorrect report type %u.",
+ report_type);
break;
}
}
static int _report_all_in_lv(struct cmd_context *cmd, struct processing_handle *handle,
- struct logical_volume *lv, report_type_t type,
+ struct logical_volume *lv, unsigned report_type,
int do_lv_info, int do_lv_seg_status)
{
int r = ECMD_FAILED;
- switch (type) {
+ switch (report_type) {
case LVS:
r = _do_lvs_with_info_and_status_single(cmd, lv, do_lv_info, do_lv_seg_status, handle);
break;
&_segs_single);
break;
default:
- log_error(INTERNAL_ERROR "_report_all_in_lv: incorrect report type");
+ log_error(INTERNAL_ERROR "_report_all_in_lv: incorrect report type %u.",
+ report_type);
break;
}
}
static int _report_all_in_pv(struct cmd_context *cmd, struct processing_handle *handle,
- struct physical_volume *pv, report_type_t type,
+ struct physical_volume *pv, unsigned report_type,
int do_lv_info, int do_lv_seg_status)
{
int r = ECMD_FAILED;
return r;
}
- switch (type) {
+ switch (report_type) {
case PVS:
r = _pvs_single(cmd, pv->vg, pv, handle);
break;
&_pvsegs_sub_single);
break;
default:
- log_error(INTERNAL_ERROR "_report_all_in_pv: incorrect report type");
+ log_error(INTERNAL_ERROR "_report_all_in_pv: incorrect report type %u.",
+ report_type);
break;
}
struct logical_volume *lv)
{
struct selection_handle *sh = parent_handle->selection_handle;
- report_type_t initial_report_type = sh->report_type;
+ unsigned initial_report_type = sh->report_type;
struct report_args args = {0};
struct single_report_args *single_args = &args.single_args[REPORT_IDX_SINGLE];
int do_lv_info, do_lv_seg_status;
r = _report_all_in_pv(cmd, handle, pv, sh->report_type, do_lv_info, do_lv_seg_status);
break;
default:
- log_error(INTERNAL_ERROR "report_for_selection: incorrect report type");
+ log_error(INTERNAL_ERROR "report_for_selection: incorrect report type %u",
+ sh->orig_report_type);
break;
}
#define _get_report_idx(report_type,single_report_type) \
((((report_type) != FULL) && ((report_type) == single_report_type)) ? REPORT_IDX_SINGLE : REPORT_IDX_FULL_ ## single_report_type)
-static report_idx_t _get_report_idx_from_name(report_type_t report_type, const char *name)
+static report_idx_t _get_report_idx_from_name(unsigned report_type, const char *name)
{
report_idx_t idx;
: _get_report_idx(report_type, LVS);
else {
idx = REPORT_IDX_NULL;
- log_error("Unknonwn report specifier in "
- "report option list: %s.", name);
+ log_error("Unknown report specifier in report option list: %s.",
+ name);
}
return idx;
}
-static int _should_process_report_idx(report_type_t report_type, int allow_single, report_idx_t idx)
+static int _should_process_report_idx(unsigned report_type, int allow_single, report_idx_t idx)
{
if (((idx == REPORT_IDX_LOG) && (report_type != CMDLOG)) ||
((idx == REPORT_IDX_SINGLE) && !allow_single) ||
}
static int _do_report_get_selection(struct cmd_context *cmd,
- report_type_t report_type,
+ unsigned report_type,
int allow_single,
struct report_args *args,
const char **last_selection)
args, NULL) ? ECMD_PROCESSED : ECMD_FAILED;
}
-int report_get_single_selection(struct cmd_context *cmd, report_type_t report_type, const char **selection)
+int report_get_single_selection(struct cmd_context *cmd, unsigned report_type, const char **selection)
{
return _do_report_get_selection(cmd, report_type, 1, NULL, selection);
}
struct report_args *args, struct single_report_args *single_args)
{
void *orig_custom_handle = handle->custom_handle;
- report_type_t report_type = single_args->report_type;
+ unsigned report_type = single_args->report_type;
void *report_handle = NULL;
int lv_info_needed;
int lv_segment_status_needed;
return 1;
}
-static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t report_type)
+static int _report(struct cmd_context *cmd, int argc, char **argv, unsigned report_type)
{
struct report_args args = {0};
struct single_report_args *single_args = &args.single_args[REPORT_IDX_SINGLE];
int lvs(struct cmd_context *cmd, int argc, char **argv)
{
- report_type_t type;
-
- if (arg_is_set(cmd, segments_ARG))
- type = SEGS;
- else
- type = LVS;
+ unsigned type = (arg_is_set(cmd, segments_ARG)) ? SEGS : LVS;
return _report(cmd, argc, argv, type);
}
int pvs(struct cmd_context *cmd, int argc, char **argv)
{
- report_type_t type;
+ unsigned type = (arg_is_set(cmd, segments_ARG)) ? PVSEGS : LABEL;
/*
* Without -a, command only looks at PVs and can use hints,
cmd->use_hints = 0;
}
- if (arg_is_set(cmd, segments_ARG))
- type = PVSEGS;
- else
- type = LABEL;
-
return _report(cmd, argc, argv, type);
}