/*
* Copyright (c) 2016 Jeff Mahoney <jeffm@suse.com>
+ * Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include DEF_MPERS_TYPE(struct_btrfs_ioctl_dev_replace_args)
#include DEF_MPERS_TYPE(struct_btrfs_ioctl_send_args)
#include DEF_MPERS_TYPE(struct_btrfs_ioctl_received_subvol_args)
+#include DEF_MPERS_TYPE(struct_btrfs_ioctl_vol_args_v2)
# include <linux/btrfs.h>
struct_btrfs_ioctl_send_args;
typedef struct btrfs_ioctl_received_subvol_args
struct_btrfs_ioctl_received_subvol_args;
+typedef struct btrfs_ioctl_vol_args_v2
+ struct_btrfs_ioctl_vol_args_v2;
#endif /* HAVE_LINUX_BTRFS_H */
#ifdef HAVE_LINUX_BTRFS_H
+#include "print_fields.h"
#include <linux/fs.h>
/*
{
tprintf(", %s=%" PRIu64, name, value);
if (value == UINT64_MAX)
- tprints(" /* UINT64_MAX */");
+ tprints_comment("UINT64_MAX");
}
#define print_member_u64(obj, name) print_u64(#name, obj->name)
}
static void
-btrfs_print_balance(struct tcb *tcp, const long arg, bool out)
+btrfs_print_balance(struct tcb *const tcp, const kernel_ulong_t arg, bool out)
{
struct btrfs_ioctl_balance_args balance_args;
static void
btrfs_print_key_type(uint32_t type)
{
- const char *str = xlookup(btrfs_key_types, type);
tprintf("%u", type);
- if (str)
- tprintf(" /* %s */", str);
+ tprints_comment(xlookup(btrfs_key_types, type));
}
static void
btrfs_print_objectid(uint64_t objectid)
{
- const char *str = xlookup(btrfs_tree_objectids, objectid);
tprintf("%" PRIu64, objectid);
- if (str)
- tprintf(" /* %s */", str);
+ tprints_comment(xlookup(btrfs_tree_objectids, objectid));
}
static void
static bool
print_uint64(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
{
- tprintf("%" PRIu64, * (uint64_t *) elem_buf);
+ tprintf("%" PRIu64, *(uint64_t *) elem_buf);
return true;
}
static void
-btrfs_print_qgroup_inherit(struct tcb *tcp, const uint64_t qgi_addr)
+btrfs_print_qgroup_inherit(struct tcb *const tcp, const kernel_ulong_t qgi_addr)
{
struct btrfs_qgroup_inherit inherit;
if (umove_or_printaddr(tcp, qgi_addr, &inherit))
return;
- tprintf("{flags=");
+ tprints("{flags=");
printflags64(btrfs_qgroup_inherit_flags, inherit.flags,
"BTRFS_QGROUP_INHERIT_???");
tprintf(", num_qgroups=%" PRI__u64 ", num_ref_copies=%" PRI__u64
if (value) {
tprintf(", %s=%" PRIu64, name, value);
if (value == UINT64_MAX)
- tprints(" /* UINT64_MAX */");
+ tprints_comment("UINT64_MAX");
}
}
#define print_key_value(tcp, key, name) \
uint64_t buf_addr, uint64_t buf_size, bool print_size)
{
if (entering(tcp)) {
- tprintf("{key={tree_id=");
+ tprints("{key={tree_id=");
btrfs_print_objectid(key->tree_id);
if (key->min_objectid != BTRFS_FIRST_FREE_OBJECTID ||
print_objectid_callback(struct tcb *tcp, void *elem_buf,
size_t elem_size, void *data)
{
- btrfs_print_objectid(* (uint64_t *) elem_buf);
+ btrfs_print_objectid(*(uint64_t *) elem_buf);
return true;
}
}
MPERS_PRINTER_DECL(int, btrfs_ioctl,
- struct tcb *tcp, const unsigned int code, const long arg)
+ struct tcb *const tcp, const unsigned int code,
+ const kernel_ulong_t arg)
{
switch (code) {
/* Take no arguments; command only. */
tprintf("%" PRIu64, (uint64_t) args.len);
if (args.len == UINT64_MAX)
- tprints(" /* UINT64_MAX */");
+ tprints_comment("UINT64_MAX");
tprints(", flags=");
printflags64(btrfs_defrag_flags, args.flags,
if (valid)
tprintf("uuid=%s, ", uuid);
tprintf("bytes_used=%" PRI__u64
- ", total_bytes=%" PRI__u64 ", path=",
+ ", total_bytes=%" PRI__u64,
args.bytes_used, args.total_bytes);
- print_quoted_string((const char *)args.path, sizeof(args.path),
- QUOTE_0_TERMINATED);
+ PRINT_FIELD_CSTRING(", ", args, path);
tprints("}");
break;
}
(uint64_t) args.start.srcdevid,
(uint64_t) args.start.cont_reading_from_srcdev_mode);
- str = (const char*) args.start.srcdev_name;
- print_quoted_string(str,
- sizeof(args.start.srcdev_name),
- QUOTE_0_TERMINATED);
+ str = (const char *) args.start.srcdev_name;
+ print_quoted_cstring(str,
+ sizeof(args.start.srcdev_name));
tprints(", tgtdev_name=");
- str = (const char*) args.start.tgtdev_name;
- print_quoted_string(str,
- sizeof(args.start.tgtdev_name),
- QUOTE_0_TERMINATED);
+ str = (const char *) args.start.tgtdev_name;
+ print_quoted_cstring(str,
+ sizeof(args.start.tgtdev_name));
tprints("}");
}
printxval64(btrfs_dev_replace_results, args.result,
"BTRFS_IOCTL_DEV_REPLACE_RESULT_???");
if (args.cmd == BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS) {
- char buf[sizeof("HH:MM:SS") + 1];
- time_t time;
tprints(", ");
printxval64(btrfs_dev_replace_state,
args.status.replace_state,
"BTRFS_IOCTL_DEV_REPLACE_STATE_???");
- tprintf(", progress_1000=%" PRIu64 " /* ",
+ tprintf(", progress_1000=%" PRIu64,
(uint64_t) args.status.progress_1000);
+
if (args.status.progress_1000 <= 1000)
- tprintf("%" PRIu64 ".%.2" PRIu64 "%%",
- (uint64_t) args.status.progress_1000 / 10,
- (uint64_t) args.status.progress_1000 % 10);
- else
- tprints("???");
- tprints(" */ ,");
-
- time = args.status.time_started;
- strftime(buf, sizeof(buf), "%T",
- localtime(&time));
- tprintf("time_started=%" PRIu64" /* %s */, ",
- (uint64_t) args.status.time_started, buf);
-
- time = args.status.time_stopped;
- strftime(buf, sizeof(buf), "%T",
- localtime(&time));
- tprintf("time_stopped=%" PRIu64" /* %s */, ",
- (uint64_t) args.status.time_stopped, buf);
-
- tprintf("num_write_errors=%" PRIu64
+ tprintf_comment("%u.%u%%",
+ (unsigned) args.status.progress_1000 / 10,
+ (unsigned) args.status.progress_1000 % 10);
+
+ tprintf(", time_started=%" PRIu64,
+ (uint64_t) args.status.time_started);
+ tprints_comment(sprinttime(args.status.time_started));
+
+ tprintf(", time_stopped=%" PRIu64,
+ (uint64_t) args.status.time_stopped);
+ tprints_comment(sprinttime(args.status.time_stopped));
+
+ tprintf(", num_write_errors=%" PRIu64
", num_uncorrectable_read_errors=%" PRIu64,
(uint64_t) args.status.num_write_errors,
(uint64_t) args.status.num_uncorrectable_read_errors);
if (umove_or_printaddr(tcp, arg, &flarg))
break;
- tprints("[ /* supported */ ");
+ tprints("[");
btrfs_print_features(&flarg[0]);
+ tprints_comment("supported");
- tprints(", /* safe to set */ ");
+ tprints(", ");
btrfs_print_features(&flarg[1]);
+ tprints_comment("safe to set");
- tprints(", /* safe to clear */ ");
+ tprints(", ");
btrfs_print_features(&flarg[2]);
+ tprints_comment("safe to clear");
tprints("]");
break;
char uuid[UUID_STRING_SIZE+1];
uint32_t nodesize, sectorsize, clone_alignment;
#ifndef HAVE_STRUCT_BTRFS_IOCTL_FS_INFO_ARGS_NODESIZE
- __u32 *reserved32;
+ uint32_t *reserved32;
#endif
if (entering(tcp))
sectorsize = args.sectorsize,
clone_alignment = args.clone_alignment;
#else
- reserved32 = (__u32 *) (void *) args.reserved;
+ reserved32 = (void *) args.reserved;
nodesize = reserved32[0];
sectorsize = reserved32[1];
clone_alignment = reserved32[2];
tprints("...");
break;
}
- const char *name = xlookup(btrfs_dev_stats_values, i);
- if (name)
- tprintf("/* %s */ ", name);
tprintf("%" PRI__u64, args.values[i]);
+ tprints_comment(xlookup(btrfs_dev_stats_values, i));
}
tprints("]}");
break;
tprints(", ");
}
- tprints("name=");
- print_quoted_string(args.name, sizeof(args.name),
- QUOTE_0_TERMINATED);
+ PRINT_FIELD_CSTRING("", args, name);
tprints("}");
break;
}
args.start);
tprintf("%" PRI__u64, args.end);
if (args.end == UINT64_MAX)
- tprints(" /* UINT64_MAX */");
+ tprints_comment("UINT64_MAX");
tprints(", flags=");
printflags64(btrfs_scrub_flags, args.flags,
"BTRFS_SCRUB_???");
tprints("...");
else {
uint64_t record;
- print_array(tcp, (unsigned long) args.clone_sources,
+ print_array(tcp, ptr_to_kulong(args.clone_sources),
args.clone_sources_count,
&record, sizeof(record),
umoven_or_printaddr,
tprints("{fd=");
printfd(tcp, args.fd);
- tprints(", name=");
- print_quoted_string(args.name, sizeof(args.name),
- QUOTE_0_TERMINATED);
+ PRINT_FIELD_CSTRING(", ", args, name);
tprints("}");
break;
}
case BTRFS_IOC_SNAP_CREATE_V2:
case BTRFS_IOC_SUBVOL_CREATE_V2: { /* code is W, but is actually RW */
- struct btrfs_ioctl_vol_args_v2 args;
+ struct_btrfs_ioctl_vol_args_v2 args;
if (entering(tcp))
tprints(", ");
printflags64(btrfs_snap_flags_v2, args.flags,
"BTRFS_SUBVOL_???");
if (args.flags & BTRFS_SUBVOL_QGROUP_INHERIT) {
- tprintf(", size=%" PRI__u64 ", qgroup_inherit=",
- args.size);
+ tprintf(", size=%" PRIu64 ", qgroup_inherit=",
+ (uint64_t) args.size);
btrfs_print_qgroup_inherit(tcp,
- (unsigned long)args.qgroup_inherit);
+ ptr_to_kulong(args.qgroup_inherit));
}
- tprintf(", name=");
- print_quoted_string(args.name, sizeof(args.name),
- QUOTE_0_TERMINATED);
+ PRINT_FIELD_CSTRING(", ", args, name);
tprints("}");
return 0;
}
- tprintf("{transid=%" PRI__u64 "}", args.transid);
+ tprintf("{transid=%" PRIu64 "}", (uint64_t) args.transid);
break;
}
tprints(", ");
if (umove_or_printaddr(tcp, arg, &label))
break;
- print_quoted_string(label, sizeof(label), QUOTE_0_TERMINATED);
+ print_quoted_cstring(label, sizeof(label));
break;
}
default:
return RVAL_DECODED;
};
- return RVAL_DECODED | 1;
+ return RVAL_IOCTL_DECODED;
}
#endif /* HAVE_LINUX_BTRFS_H */