* print_dev_t.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (print_dev_t): New prototype.
* dm.c: Do not include <sys/sysmacros.h>.
(dm_decode_device, dm_print_dev, dm_decode_dm_name_list): Use
print_dev_t function for printing device numbers.
* mknod.c: Do not include <sys/sysmacros.h>.
(decode_mknod): Use print_dev_t function for printing device number.
* print_struct_stat.c: Do not include <sys/sysmacros.h>.
(print_struct_stat): Use print_dev_t function for printing device
numbers.
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
pkeys.c \
poll.c \
prctl.c \
+ print_dev_t.c \
print_mq_attr.c \
print_msgbuf.c \
print_sigevent.c \
extern void print_symbolic_mode_t(unsigned int);
extern void print_numeric_umode_t(unsigned short);
extern void print_numeric_long_umask(unsigned long);
+extern void print_dev_t(unsigned long long dev);
extern void
dumpiov_in_msghdr(struct tcb *, kernel_ulong_t addr, kernel_ulong_t data_size);
# include <linux/dm-ioctl.h>
# include <linux/ioctl.h>
-# include <sys/sysmacros.h>
-
# if DM_VERSION_MAJOR == 4
/* Definitions for command which have been added later */
case DM_LIST_VERSIONS:
break;
default:
- if (ioc->dev)
- tprintf(", dev=makedev(%u, %u)",
- major(ioc->dev), minor(ioc->dev));
+ if (ioc->dev) {
+ tprints(", dev=");
+ print_dev_t(ioc->dev);
+ }
if (ioc->name[0]) {
tprints(", name=");
print_quoted_string(ioc->name, DM_NAME_LEN,
{
uint64_t *dev = (uint64_t *) dev_ptr;
- tprintf("makedev(%u, %u)", major(*dev), minor(*dev));
+ print_dev_t(*dev);
return 1;
}
break;
}
- tprintf("{dev=makedev(%u, %u), name=", major(s.dev),
- minor(s.dev));
+ tprints("{dev=");
+ print_dev_t(s.dev);
+
+ tprints("name=");
printstr_ex(tcp, addr + offset_end, ioc->data_size - offset_end,
QUOTE_0_TERMINATED);
tprints("}");
#include <fcntl.h>
#include <sys/stat.h>
-#include <sys/sysmacros.h>
static void
decode_mknod(struct tcb *tcp, int offset)
case S_IFCHR:
case S_IFBLK:
dev = tcp->u_arg[offset + 2];
- tprintf(", makedev(%u, %u)", major(dev), minor(dev));
+ tprints(", ");
+ print_dev_t(dev);
break;
}
}
--- /dev/null
+/*
+ * Device number printing routine.
+ *
+ * Copyright (c) 2016 The strace developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "defs.h"
+#include <sys/sysmacros.h>
+
+void
+print_dev_t(const unsigned long long dev)
+{
+ tprintf("makedev(%u, %u)", major(dev), minor(dev));
+}
#include "defs.h"
#include <sys/stat.h>
-#include <sys/sysmacros.h>
#include "stat.h"
void
{
tprints("{");
if (!abbrev(tcp)) {
- tprintf("st_dev=makedev(%u, %u), st_ino=%llu, st_mode=",
- (unsigned int) major(st->dev),
- (unsigned int) minor(st->dev),
- st->ino);
+ tprints("st_dev=");
+ print_dev_t(st->dev);
+ tprintf(", st_ino=%llu, st_mode=", st->ino);
print_symbolic_mode_t(st->mode);
tprintf(", st_nlink=%llu, st_uid=%llu, st_gid=%llu",
st->nlink, st->uid, st->gid);
switch (st->mode & S_IFMT) {
case S_IFCHR: case S_IFBLK:
- tprintf(", st_rdev=makedev(%u, %u)",
- (unsigned int) major(st->rdev),
- (unsigned int) minor(st->rdev));
+ tprints(", st_rdev=");
+ print_dev_t(st->rdev);
break;
default:
tprintf(", st_size=%llu", st->size);