*/
int jt_llog_print_iter(char *logname, long start, long end,
int (record_cb)(const char *record, void *private),
- void *private, bool reverse)
+ void *private, bool reverse, bool raw)
{
struct obd_ioctl_data data = { 0 };
char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
snprintf(endbuf, sizeof(endbuf), "%lu",
end < rec + inc - 1 ? end : rec + inc - 1);
+ data.ioc_u32_1 = raw ? 1 : 0;
/* start and end record numbers are passed as ASCII digits */
data.ioc_inlbuf2 = startbuf;
data.ioc_inllen2 = strlen(startbuf) + 1;
return rc;
}
-static int llog_parse_catalog_start_end(int *argc, char **argv[],
- char **catalog, long *start, long *end)
+static int llog_parse_catalog_options(int *argc, char ***argv, char **catalog,
+ long *start, long *end, int *raw)
{
const struct option long_opts[] = {
/* the --catalog option is not required, just for consistency */
{ .val = 'c', .name = "catalog", .has_arg = required_argument },
{ .val = 'e', .name = "end", .has_arg = required_argument },
{ .val = 'h', .name = "help", .has_arg = no_argument },
+ { .val = 'r', .name = "raw", .has_arg = no_argument },
{ .val = 's', .name = "start", .has_arg = required_argument },
{ .name = NULL } };
char *cmd = (*argv)[0];
return -EINVAL;
/* now process command line arguments*/
- while ((c = getopt_long(*argc, *argv, "c:e:hs:",
+ while ((c = getopt_long(*argc, *argv, "c:e:hrs:",
long_opts, NULL)) != -1) {
switch (c) {
case 'c':
return CMD_HELP;
}
break;
+ case 'r':
+ if (!raw)
+ return CMD_HELP;
+ *raw = 1;
+ break;
case 's':
*start = strtol(optarg, &endp, 0);
if (*endp != '\0') {
{
char *catalog = NULL;
long start = 1, end = -1;
+ int raw = 0;
int rc;
- rc = llog_parse_catalog_start_end(&argc, &argv, &catalog, &start, &end);
+ rc = llog_parse_catalog_options(&argc, &argv, &catalog, &start, &end,
+ &raw);
if (rc)
return rc;
return CMD_INCOMPLETE;
rc = jt_llog_print_iter(catalog, start, end, jt_llog_print_cb,
- NULL, false);
+ NULL, false, !!raw);
llog_default_device(LLOG_DFLT_DEV_RESET);
* The positional arguments option should eventually be phased out.
*/
static int llog_parse_catalog_log_idx(int *argc, char ***argv, const char *opts,
- int max_args, struct obd_ioctl_data *data)
+ struct obd_ioctl_data *data)
{
const struct option long_opts[] = {
/* the --catalog option is not required, just for consistency */
return CMD_INCOMPLETE;
/* Parse catalog file (in inlbuf1) and named parameters */
- rc = llog_parse_catalog_log_idx(&argc, &argv, "c:hi:l:", 3, &data);
+ rc = llog_parse_catalog_log_idx(&argc, &argv, "c:hi:l:", &data);
/*
* Handle old positional parameters if not using named parameters,
char *cmd = argv[0];
int rc;
- rc = llog_parse_catalog_start_end(&argc, &argv, &catalog, &start, &end);
+ rc = llog_parse_catalog_options(&argc, &argv, &catalog, &start,
+ &end, NULL);
if (rc)
return rc;
if (llog_default_device(LLOG_DFLT_MGS_SET))
return CMD_INCOMPLETE;
- rc = llog_parse_catalog_log_idx(&argc, &argv, "c:hl:", 2, &data);
+ rc = llog_parse_catalog_log_idx(&argc, &argv, "c:hl:", &data);
if (rc)
goto err;
for (end = last_index; end > 1; end -= inc) {
start = end - inc > 0 ? end - inc : 1;
rc = jt_llog_print_iter(logname, start, end, llog_search_ost_cb,
- ostname, true);
+ ostname, true, false);
if (rc)
break;
}
for (end = last_index; end > 1; end -= inc) {
start = end - inc > 0 ? end - inc : 1;
rc = jt_llog_print_iter(logname, start, end,
- llog_search_pool_cb, &lpd, true);
+ llog_search_pool_cb, &lpd, true, false);
if (rc) {
if (rc == 1 && lpd.lpd_pool_exists)
rc = lpd.lpd_ost_num ? 1 : 0;
strncpy(lpld.lpld_poolname, poolname,
sizeof(lpld.lpld_poolname) - 1);
snprintf(logname, sizeof(logname), "%s-client", fsname);
- rc = jt_llog_print_iter(logname, 0, -1, llog_poollist_cb, &lpld, false);
+ rc = jt_llog_print_iter(logname, 0, -1, llog_poollist_cb, &lpld, false,
+ false);
if (poolname && poolname[0])
printf("Pool: %s.%s\n", fsname, poolname);