From b18fb09eb97debf3dd8a871b9b222895a0eb803b Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Sat, 24 Aug 2013 04:00:32 +0400 Subject: [PATCH] show: Replace one-line show_foo calls with args array We have generic do_pb_show() call and tons of show_foo routines, that just call one with proper args. Compact the code by putting the args into array and calling the do_pb_show() in one place. Signed-off-by: Pavel Emelyanov --- cr-show.c | 254 ++++++++++++++++++------------------------- eventfd.c | 9 +- eventpoll.c | 14 +-- fsnotify.c | 28 +---- image-desc.c | 116 ++++++++++---------- image.c | 7 -- include/cr-show.h | 64 +++-------- include/crtools.h | 1 - include/eventfd.h | 1 - include/eventpoll.h | 2 - include/fsnotify.h | 4 - include/image-desc.h | 17 ++- include/ipc_ns.h | 4 - include/magic.h | 16 +-- include/mount.h | 1 - include/net.h | 2 - include/signalfd.h | 1 - include/sk-inet.h | 2 - include/sk-packet.h | 1 - include/sk-queue.h | 1 - include/sockets.h | 5 - include/stats.h | 1 - include/uts_ns.h | 1 - ipc_ns.c | 30 +---- mount.c | 9 +- namespaces.c | 5 +- net.c | 5 - signalfd.c | 5 - sk-inet.c | 5 - sk-netlink.c | 9 +- sk-packet.c | 5 - sk-queue.c | 7 +- sk-tcp.c | 5 - sk-unix.c | 5 - stats.c | 6 - tty.c | 4 +- tun.c | 5 - uts_ns.c | 5 - 38 files changed, 212 insertions(+), 450 deletions(-) diff --git a/cr-show.c b/cr-show.c index 59bfef88e..e34736ebf 100644 --- a/cr-show.c +++ b/cr-show.c @@ -54,11 +54,6 @@ static LIST_HEAD(pstree_list); -void show_files(int fd_files) -{ - pb_show_plain_pretty(fd_files, PB_FDINFO, "flags:%#o fd:%d"); -} - void show_fown_cont(void *p) { FownEntry *fown = p; @@ -66,82 +61,12 @@ void show_fown_cont(void *p) fown->uid, fown->euid, fown->signum, fown->pid_type, fown->pid); } -void show_ns_files(int fd) -{ - pb_show_plain(fd, PB_NS_FILE); -} - -void show_reg_files(int fd_reg_files) -{ - pb_show_plain(fd_reg_files, PB_REG_FILE); -} - -void show_remap_files(int fd) -{ - pb_show_plain(fd, PB_REMAP_FPATH); -} - -void show_ghost_file(int fd) -{ - pb_show_vertical(fd, PB_GHOST_FILE); -} - static void pipe_data_handler(int fd, void *obj) { PipeDataEntry *e = obj; print_image_data(fd, e->bytes, opts.show_pages_content); } -void show_pipes_data(int fd) -{ - pb_show_plain_payload(fd, PB_PIPE_DATA, pipe_data_handler); -} - -void show_pipes(int fd_pipes) -{ - pb_show_plain(fd_pipes, PB_PIPE); -} - -void show_fifo_data(int fd) -{ - show_pipes_data(fd); -} - -void show_fifo(int fd) -{ - pb_show_plain(fd, PB_FIFO); -} - -void show_tty(int fd) -{ - pb_show_plain(fd, PB_TTY_FILE); -} - -void show_tty_info(int fd) -{ - pb_show_plain(fd, PB_TTY_INFO); -} - -void show_file_locks(int fd) -{ - pb_show_plain(fd, PB_FILE_LOCK); -} - -void show_fs(int fd_fs) -{ - pb_show_vertical(fd_fs, PB_FS); -} - -void show_vmas(int fd_vma) -{ - pb_show_plain(fd_vma, PB_VMA); -} - -void show_rlimit(int fd) -{ - pb_show_plain(fd, PB_RLIMIT); -} - static int nice_width_for(unsigned long addr) { int ret = 3; @@ -223,11 +148,6 @@ static void show_pagemaps(int fd, void *obj) pb_show_plain_pretty(fd, PB_PAGEMAP, "nr_pages:%u"); } -void show_pagemap(int fd) -{ - do_pb_show_plain(fd, PB_PAGEMAP_HEAD, 1, show_pagemaps, NULL); -} - void show_siginfo(int fd) { int ret; @@ -250,26 +170,6 @@ void show_siginfo(int fd) pr_img_tail(CR_FD_SIGNAL); } -void show_sigacts(int fd_sigacts) -{ - pb_show_plain(fd_sigacts, PB_SIGACT); -} - -void show_itimers(int fd) -{ - pb_show_plain_pretty(fd, PB_ITIMER, "*:%Lu"); -} - -void show_posix_timers(int fd) -{ - pb_show_plain_pretty(fd, PB_POSIX_TIMER, "*:%d 5:%Lu 7:%Lu 8:%lu 9:%Lu 10:%Lu"); -} - -void show_creds(int fd) -{ - pb_show_vertical(fd, PB_CREDS); -} - static int pstree_item_from_pb(PstreeEntry *e, struct pstree_item *item) { int i; @@ -309,11 +209,6 @@ void show_collect_pstree(int fd, int collect) collect ? pstree_handler : NULL, "*:%d"); } -void show_pstree(int fd) -{ - show_collect_pstree(fd, 0); -} - static inline char *task_state_str(int state) { switch (state) { @@ -370,21 +265,6 @@ void show_thread_info(ThreadInfoX86 *thread_info) show_core_regs(thread_info->gpregs); } -void show_core(int fd_core) -{ - pb_show_vertical(fd_core, PB_CORE); -} - -void show_ids(int fd_ids) -{ - pb_show_vertical(fd_ids, PB_IDS); -} - -void show_mm(int fd_mm) -{ - pb_show_vertical(fd_mm, PB_MM); -} - static struct { u32 magic; u32 mask; @@ -405,44 +285,120 @@ static void try_hint_magic(u32 magic) pr_msg("This can be %s\n", magic_hints[i].hint); } +#define SHOW_PLAIN(name) { name##_MAGIC, PB_##name, false, NULL, NULL, } +/* nothing special behind this -S, just to avoid heavy patching */ +#define SHOW_PLAINS(name) { name##S_MAGIC, PB_##name, false, NULL, NULL, } +#define SHOW_VERT(name) { name##_MAGIC, PB_##name, true, NULL, NULL, } + +static struct show_image_info show_infos[] = { + SHOW_VERT(INVENTORY), + SHOW_VERT(CORE), + SHOW_VERT(IDS), + SHOW_VERT(CREDS), + SHOW_VERT(UTSNS), + SHOW_VERT(IPC_VAR), + SHOW_VERT(FS), + SHOW_VERT(GHOST_FILE), + + SHOW_PLAINS(REG_FILE), + SHOW_PLAINS(NS_FILE), + SHOW_PLAIN(EVENTFD_FILE), + SHOW_PLAIN(EVENTPOLL_FILE), + SHOW_PLAIN(EVENTPOLL_TFD), + SHOW_PLAIN(SIGNALFD), + SHOW_PLAIN(INOTIFY_FILE), + SHOW_PLAIN(INOTIFY_WD), + SHOW_PLAIN(FANOTIFY_FILE), + SHOW_PLAIN(FANOTIFY_MARK), + SHOW_PLAINS(VMA), + SHOW_PLAINS(PIPE), + SHOW_PLAIN(FIFO), + SHOW_PLAIN(SIGACT), + SHOW_PLAIN(NETLINK_SK), + SHOW_PLAIN(REMAP_FPATH), + SHOW_PLAINS(MNT), + SHOW_PLAINS(TTY_FILE), + SHOW_PLAIN(TTY_INFO), + SHOW_PLAINS(FILE_LOCK), + SHOW_PLAIN(RLIMIT), + SHOW_PLAIN(TUNFILE), + + { TCP_STREAM_MAGIC, PB_TCP_STREAM, true, NULL, "1:%u 2:%u 3:%u 4:%u", }, + { STATS_MAGIC, PB_STATS, true, NULL, "1.1:%u 1.2:%u 1.3:%u 1.4:%u 1.5:%Lu 1.6:%Lu 1.7:%Lu", }, + { FDINFO_MAGIC, PB_FDINFO, false, NULL, "flags:%#o fd:%d", }, + { UNIXSK_MAGIC, PB_UNIX_SK, false, NULL, "1:%#x 2:%#x 3:%d 4:%d 5:%d 6:%d 7:%d 8:%#x 11:S", }, + { INETSK_MAGIC, PB_INET_SK, false, NULL, "1:%#x 2:%#x 3:%d 4:%d 5:%d 6:%d 7:%d 8:%d 9:%2x 11:A 12:A", }, + { PACKETSK_MAGIC, PB_PACKET_SOCK, false, NULL, "5:%d", }, + { ITIMERS_MAGIC, PB_ITIMER, false, NULL, "*:%Lu", }, + { POSIX_TIMERS_MAGIC, PB_POSIX_TIMER, false, NULL, "*:%d 5:%Lu 7:%Lu 8:%lu 9:%Lu 10:%Lu", }, + { NETDEV_MAGIC, PB_NETDEV, false, NULL, "2:%d", }, + + { PAGEMAP_MAGIC, PB_PAGEMAP_HEAD, true, show_pagemaps, NULL, }, + { PIPES_DATA_MAGIC, PB_PIPE_DATA, false, pipe_data_handler, NULL, }, + { FIFO_DATA_MAGIC, PB_PIPE_DATA, false, pipe_data_handler, NULL, }, + { SK_QUEUES_MAGIC, PB_SK_QUEUES, false, sk_queue_data_handler, NULL, }, + { IPCNS_SHM_MAGIC, PB_IPC_SHM, false, ipc_shm_handler, NULL, }, + { IPCNS_SEM_MAGIC, PB_IPC_SEM, false, ipc_sem_handler, NULL, }, + { IPCNS_MSG_MAGIC, PB_IPCNS_MSG_ENT, false, ipc_msg_handler, NULL, }, + + { } +}; + static int cr_parse_file(void) { u32 magic; - int fd = -1, ret = -1, i; + int ret = -1, fd; fd = open(opts.show_dump_file, O_RDONLY); if (fd < 0) { pr_perror("Can't open %s", opts.show_dump_file); - goto err; + goto out; } if (read_img(fd, &magic) < 0) - goto err; + goto out; - for (i = 0; i < CR_FD_MAX; i++) - if (fdset_template[i].magic == magic) - break; - - if (i == CR_FD_MAX) { - pr_err("Unknown magic %#x in %s\n", - magic, opts.show_dump_file); - try_hint_magic(magic); - goto err; - } - - if (!fdset_template[i].show) { - pr_err("No handler for %#x/%s\n", - magic, opts.show_dump_file); - goto err; - } - - fdset_template[i].show(fd); - ret = 0; -err: + ret = cr_parse_fd(fd, magic); +out: close_safe(&fd); return ret; } +int cr_parse_fd(int fd, u32 magic) +{ + int ret = 0, i; + + if (magic == PSTREE_MAGIC) { + show_collect_pstree(fd, 0); + goto out; + } + + if (magic == SIGNAL_MAGIC || magic == PSIGNAL_MAGIC) { + show_siginfo(fd); + goto out; + } + + for (i = 0; show_infos[i].magic; i++) { + struct show_image_info *si; + + si = &show_infos[i]; + if (si->magic != magic) + continue; + + do_pb_show_plain(fd, si->pb_type, si->single, + si->payload, si->fmt); + goto out; + } + + ret = -1; + pr_err("Unknown magic %#x in %s\n", + magic, opts.show_dump_file); + try_hint_magic(magic); + +out: + return ret; +} + static int cr_show_pstree_item(struct pstree_item *item) { int ret = -1, i; @@ -456,7 +412,7 @@ static int cr_show_pstree_item(struct pstree_item *item) pr_msg("Task %d:\n", item->pid.virt); pr_msg("----------------------------------------\n"); - show_core(fdset_fd(cr_fdset, CR_FD_CORE)); + cr_parse_fd(fdset_fd(cr_fdset, CR_FD_CORE), CORE_MAGIC); if (item->nr_threads > 1) { int fd_th; @@ -473,7 +429,7 @@ static int cr_show_pstree_item(struct pstree_item *item) pr_msg("Thread %d.%d:\n", item->pid.virt, item->threads[i].virt); pr_msg("----------------------------------------\n"); - show_core(fd_th); + cr_parse_fd(fd_th, CORE_MAGIC); close_safe(&fd_th); } } @@ -481,12 +437,11 @@ static int cr_show_pstree_item(struct pstree_item *item) pr_msg("Resources for %d:\n", item->pid.virt); pr_msg("----------------------------------------\n"); for (i = _CR_FD_TASK_FROM + 1; i < _CR_FD_TASK_TO; i++) - if ((i != CR_FD_CORE) && (i != CR_FD_IDS) && - fdset_template[i].show) { + if ((i != CR_FD_CORE) && (i != CR_FD_IDS)) { pr_msg("* "); pr_msg(fdset_template[i].fmt, item->pid.virt); pr_msg(":\n"); - fdset_template[i].show(fdset_fd(cr_fdset, i)); + cr_parse_fd(fdset_fd(cr_fdset, i), fdset_template[i].magic); } if (pb_read_one(fdset_fd(cr_fdset, CR_FD_IDS), &ids, PB_IDS) > 0) { @@ -496,7 +451,7 @@ static int cr_show_pstree_item(struct pstree_item *item) pr_msg(fdset_template[CR_FD_FDINFO].fmt, ids->files_id); pr_msg(":\n"); - show_files(i); + cr_parse_fd(i, FDINFO_MAGIC); close(i); } @@ -559,7 +514,6 @@ static int cr_show_all(void) if (fd < 0) goto out; - show_sk_queues(fd); close(fd); pid = list_first_entry(&pstree_list, struct pstree_item, sibling)->pid.virt; diff --git a/eventfd.c b/eventfd.c index 81be66d47..aab1976ff 100644 --- a/eventfd.c +++ b/eventfd.c @@ -44,11 +44,6 @@ static void pr_info_eventfd(char *action, EventfdFileEntry *efe) action, efe->id, efe->flags, efe->counter); } -void show_eventfds(int fd) -{ - pb_show_plain(fd, PB_EVENTFD_FILE); -} - struct eventfd_dump_arg { u32 id; const struct fd_parms *p; @@ -70,7 +65,7 @@ static int dump_eventfd_entry(union fdinfo_entries *e, void *arg) e->efd.fown = (FownEntry *)&da->p->fown; pr_info_eventfd("Dumping ", &e->efd); - return pb_write_one(fdset_fd(glob_fdset, CR_FD_EVENTFD), + return pb_write_one(fdset_fd(glob_fdset, CR_FD_EVENTFD_FILE), &e->efd, PB_EVENTFD_FILE); } @@ -127,7 +122,7 @@ static int collect_one_efd(void *obj, ProtobufCMessage *msg) } struct collect_image_info eventfd_cinfo = { - .fd_type = CR_FD_EVENTFD, + .fd_type = CR_FD_EVENTFD_FILE, .pb_type = PB_EVENTFD_FILE, .priv_size = sizeof(struct eventfd_file_info), .collect = collect_one_efd, diff --git a/eventpoll.c b/eventpoll.c index 477fcad71..e80597cd3 100644 --- a/eventpoll.c +++ b/eventpoll.c @@ -56,16 +56,6 @@ static void pr_info_eventpoll(char *action, EventpollFileEntry *e) pr_info("%seventpoll: id %#08x flags %#04x\n", action, e->id, e->flags); } -void show_eventpoll_tfd(int fd) -{ - pb_show_plain(fd, PB_EVENTPOLL_TFD); -} - -void show_eventpoll(int fd) -{ - pb_show_plain(fd, PB_EVENTPOLL_FILE); -} - static int dump_eventpoll_entry(union fdinfo_entries *e, void *arg) { EventpollTfdEntry *efd = &e->epl; @@ -85,7 +75,7 @@ static int dump_one_eventpoll(int lfd, u32 id, const struct fd_parms *p) e.fown = (FownEntry *)&p->fown; pr_info_eventpoll("Dumping ", &e); - if (pb_write_one(fdset_fd(glob_fdset, CR_FD_EVENTPOLL), + if (pb_write_one(fdset_fd(glob_fdset, CR_FD_EVENTPOLL_FILE), &e, PB_EVENTPOLL_FILE)) return -1; @@ -193,7 +183,7 @@ static int collect_one_epoll(void *o, ProtobufCMessage *msg) } struct collect_image_info epoll_cinfo = { - .fd_type = CR_FD_EVENTPOLL, + .fd_type = CR_FD_EVENTPOLL_FILE, .pb_type = PB_EVENTPOLL_FILE, .priv_size = sizeof(struct eventpoll_file_info), .collect = collect_one_epoll, diff --git a/fsnotify.c b/fsnotify.c index fe5d6caaf..15a733e8f 100644 --- a/fsnotify.c +++ b/fsnotify.c @@ -77,26 +77,6 @@ int is_fanotify_link(int lfd) return is_anon_link_type(lfd, "[fanotify]"); } -void show_inotify_wd(int fd_inotify_wd) -{ - pb_show_plain(fd_inotify_wd, PB_INOTIFY_WD); -} - -void show_inotify(int fd_inotify) -{ - pb_show_plain(fd_inotify, PB_INOTIFY_FILE); -} - -void show_fanotify_mark(int fd) -{ - pb_show_plain(fd, PB_FANOTIFY_MARK); -} - -void show_fanotify(int fd) -{ - pb_show_plain(fd, PB_FANOTIFY_FILE); -} - static int dump_inotify_entry(union fdinfo_entries *e, void *arg) { InotifyWdEntry *we = &e->ify; @@ -119,7 +99,7 @@ static int dump_one_inotify(int lfd, u32 id, const struct fd_parms *p) ie.fown = (FownEntry *)&p->fown; pr_info("id 0x%08x flags 0x%08x\n", ie.id, ie.flags); - if (pb_write_one(fdset_fd(glob_fdset, CR_FD_INOTIFY), &ie, PB_INOTIFY_FILE)) + if (pb_write_one(fdset_fd(glob_fdset, CR_FD_INOTIFY_FILE), &ie, PB_INOTIFY_FILE)) return -1; return parse_fdinfo(lfd, FD_TYPES__INOTIFY, dump_inotify_entry, &id); @@ -187,7 +167,7 @@ static int dump_one_fanotify(int lfd, u32 id, const struct fd_parms *p) fe.faflags = fsn_params.faflags; fe.evflags = fsn_params.evflags; - return pb_write_one(fdset_fd(glob_fdset, CR_FD_FANOTIFY), &fe, PB_FANOTIFY_FILE); + return pb_write_one(fdset_fd(glob_fdset, CR_FD_FANOTIFY_FILE), &fe, PB_FANOTIFY_FILE); } const struct fdtype_ops fanotify_dump_ops = { @@ -460,7 +440,7 @@ static int collect_one_inotify(void *o, ProtobufCMessage *msg) } struct collect_image_info inotify_cinfo = { - .fd_type = CR_FD_INOTIFY, + .fd_type = CR_FD_INOTIFY_FILE, .pb_type = PB_INOTIFY_FILE, .priv_size = sizeof(struct fsnotify_file_info), .collect = collect_one_inotify, @@ -479,7 +459,7 @@ static int collect_one_fanotify(void *o, ProtobufCMessage *msg) } struct collect_image_info fanotify_cinfo = { - .fd_type = CR_FD_FANOTIFY, + .fd_type = CR_FD_FANOTIFY_FILE, .pb_type = PB_FANOTIFY_FILE, .priv_size = sizeof(struct fsnotify_file_info), .collect = collect_one_fanotify, diff --git a/image-desc.c b/image-desc.c index 46256c2ae..1cf79fb7e 100644 --- a/image-desc.c +++ b/image-desc.c @@ -11,74 +11,72 @@ * for more details. */ -#define FD_ENTRY(_name, _fmt, _show) \ +#define FD_ENTRY(_name, _fmt) \ [CR_FD_##_name] = { \ .fmt = _fmt ".img", \ .magic = _name##_MAGIC, \ - .show = _show, \ } struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = { - FD_ENTRY(INVENTORY, "inventory", show_inventory), - FD_ENTRY(FDINFO, "fdinfo-%d", show_files), - FD_ENTRY(PAGEMAP, "pagemap-%ld", show_pagemap), - FD_ENTRY(SHMEM_PAGEMAP, "pagemap-shmem-%ld", show_pagemap), - FD_ENTRY(REG_FILES, "reg-files", show_reg_files), - FD_ENTRY(NS_FILES, "ns-files", show_ns_files), - FD_ENTRY(EVENTFD, "eventfd", show_eventfds), - FD_ENTRY(EVENTPOLL, "eventpoll", show_eventpoll), - FD_ENTRY(EVENTPOLL_TFD, "eventpoll-tfd", show_eventpoll_tfd), - FD_ENTRY(SIGNALFD, "signalfd", show_signalfd), - FD_ENTRY(INOTIFY, "inotify", show_inotify), - FD_ENTRY(INOTIFY_WD, "inotify-wd", show_inotify_wd), - FD_ENTRY(FANOTIFY, "fanotify", show_fanotify), - FD_ENTRY(FANOTIFY_MARK, "fanotify-mark", show_fanotify_mark), - FD_ENTRY(CORE, "core-%d", show_core), - FD_ENTRY(IDS, "ids-%d", show_ids), - FD_ENTRY(MM, "mm-%d", show_mm), - FD_ENTRY(VMAS, "vmas-%d", show_vmas), - FD_ENTRY(PIPES, "pipes", show_pipes), - FD_ENTRY(PIPES_DATA, "pipes-data", show_pipes_data), - FD_ENTRY(FIFO, "fifo", show_fifo), - FD_ENTRY(FIFO_DATA, "fifo-data", show_fifo_data), - FD_ENTRY(PSTREE, "pstree", show_pstree), - FD_ENTRY(SIGACT, "sigacts-%d", show_sigacts), - FD_ENTRY(UNIXSK, "unixsk", show_unixsk), - FD_ENTRY(INETSK, "inetsk", show_inetsk), - FD_ENTRY(PACKETSK, "packetsk", show_packetsk), - FD_ENTRY(NETLINKSK, "netlinksk", show_netlinksk), - FD_ENTRY(SK_QUEUES, "sk-queues", show_sk_queues), - FD_ENTRY(ITIMERS, "itimers-%d", show_itimers), - FD_ENTRY(POSIX_TIMERS, "posix-timers-%d", show_posix_timers), - FD_ENTRY(CREDS, "creds-%d", show_creds), - FD_ENTRY(UTSNS, "utsns-%d", show_utsns), - FD_ENTRY(IPCNS_VAR, "ipcns-var-%d", show_ipc_var), - FD_ENTRY(IPCNS_SHM, "ipcns-shm-%d", show_ipc_shm), - FD_ENTRY(IPCNS_MSG, "ipcns-msg-%d", show_ipc_msg), - FD_ENTRY(IPCNS_SEM, "ipcns-sem-%d", show_ipc_sem), - FD_ENTRY(FS, "fs-%d", show_fs), - FD_ENTRY(REMAP_FPATH, "remap-fpath", show_remap_files), - FD_ENTRY(GHOST_FILE, "ghost-file-%x", show_ghost_file), - FD_ENTRY(TCP_STREAM, "tcp-stream-%x", show_tcp_stream), - FD_ENTRY(MOUNTPOINTS, "mountpoints-%d", show_mountpoints), - FD_ENTRY(NETDEV, "netdev-%d", show_netdevices), - FD_ENTRY(IFADDR, "ifaddr-%d", show_raw_image), - FD_ENTRY(ROUTE, "route-%d", show_raw_image), - FD_ENTRY(TMPFS, "tmpfs-%d.tar.gz", show_raw_image), - FD_ENTRY(TTY, "tty", show_tty), - FD_ENTRY(TTY_INFO, "tty-info", show_tty_info), - FD_ENTRY(FILE_LOCKS, "filelocks-%d", show_file_locks), - FD_ENTRY(RLIMIT, "rlimit-%d", show_rlimit), - FD_ENTRY(PAGES, "pages-%u", NULL), - FD_ENTRY(PAGES_OLD, "pages-%d", NULL), - FD_ENTRY(SHM_PAGES_OLD, "pages-shmem-%ld", NULL), - FD_ENTRY(SIGNAL, "signal-s-%d", show_siginfo), /* shared signals */ - FD_ENTRY(PSIGNAL, "signal-p-%d", show_siginfo), /* private signals */ - FD_ENTRY(TUNFILE, "tunfile", show_tunfile), + FD_ENTRY(INVENTORY, "inventory"), + FD_ENTRY(FDINFO, "fdinfo-%d"), + FD_ENTRY(PAGEMAP, "pagemap-%ld"), + FD_ENTRY(SHMEM_PAGEMAP, "pagemap-shmem-%ld"), + FD_ENTRY(REG_FILES, "reg-files"), + FD_ENTRY(NS_FILES, "ns-files"), + FD_ENTRY(EVENTFD_FILE, "eventfd"), + FD_ENTRY(EVENTPOLL_FILE,"eventpoll"), + FD_ENTRY(EVENTPOLL_TFD, "eventpoll-tfd"), + FD_ENTRY(SIGNALFD, "signalfd"), + FD_ENTRY(INOTIFY_FILE, "inotify"), + FD_ENTRY(INOTIFY_WD, "inotify-wd"), + FD_ENTRY(FANOTIFY_FILE, "fanotify"), + FD_ENTRY(FANOTIFY_MARK, "fanotify-mark"), + FD_ENTRY(CORE, "core-%d"), + FD_ENTRY(IDS, "ids-%d"), + FD_ENTRY(MM, "mm-%d"), + FD_ENTRY(VMAS, "vmas-%d"), + FD_ENTRY(PIPES, "pipes"), + FD_ENTRY(PIPES_DATA, "pipes-data"), + FD_ENTRY(FIFO, "fifo"), + FD_ENTRY(FIFO_DATA, "fifo-data"), + FD_ENTRY(PSTREE, "pstree"), + FD_ENTRY(SIGACT, "sigacts-%d"), + FD_ENTRY(UNIXSK, "unixsk"), + FD_ENTRY(INETSK, "inetsk"), + FD_ENTRY(PACKETSK, "packetsk"), + FD_ENTRY(NETLINK_SK, "netlinksk"), + FD_ENTRY(SK_QUEUES, "sk-queues"), + FD_ENTRY(ITIMERS, "itimers-%d"), + FD_ENTRY(POSIX_TIMERS, "posix-timers-%d"), + FD_ENTRY(CREDS, "creds-%d"), + FD_ENTRY(UTSNS, "utsns-%d"), + FD_ENTRY(IPC_VAR, "ipcns-var-%d"), + FD_ENTRY(IPCNS_SHM, "ipcns-shm-%d"), + FD_ENTRY(IPCNS_MSG, "ipcns-msg-%d"), + FD_ENTRY(IPCNS_SEM, "ipcns-sem-%d"), + FD_ENTRY(FS, "fs-%d"), + FD_ENTRY(REMAP_FPATH, "remap-fpath"), + FD_ENTRY(GHOST_FILE, "ghost-file-%x"), + FD_ENTRY(TCP_STREAM, "tcp-stream-%x"), + FD_ENTRY(MNTS, "mountpoints-%d"), + FD_ENTRY(NETDEV, "netdev-%d"), + FD_ENTRY(IFADDR, "ifaddr-%d"), + FD_ENTRY(ROUTE, "route-%d"), + FD_ENTRY(TMPFS, "tmpfs-%d.tar.gz"), + FD_ENTRY(TTY_FILES, "tty"), + FD_ENTRY(TTY_INFO, "tty-info"), + FD_ENTRY(FILE_LOCKS, "filelocks-%d"), + FD_ENTRY(RLIMIT, "rlimit-%d"), + FD_ENTRY(PAGES, "pages-%u"), + FD_ENTRY(PAGES_OLD, "pages-%d"), + FD_ENTRY(SHM_PAGES_OLD, "pages-shmem-%ld"), + FD_ENTRY(SIGNAL, "signal-s-%d"), + FD_ENTRY(PSIGNAL, "signal-p-%d"), + FD_ENTRY(TUNFILE, "tunfile"), [CR_FD_STATS] = { .fmt = "stats-%s", .magic = STATS_MAGIC, - .show = show_stats, }, }; diff --git a/image.c b/image.c index 8abc8727f..1d12b4ad9 100644 --- a/image.c +++ b/image.c @@ -95,13 +95,6 @@ void kill_inventory(void) fdset_template[CR_FD_INVENTORY].fmt, 0); } -void show_inventory(int fd) -{ - pb_show_vertical(fd, PB_INVENTORY); -} - -void show_raw_image(int fd) {}; - static struct cr_fdset *alloc_cr_fdset(int nr) { struct cr_fdset *cr_fdset; diff --git a/include/cr-show.h b/include/cr-show.h index 6d6ee2d12..968b5bf63 100644 --- a/include/cr-show.h +++ b/include/cr-show.h @@ -1,56 +1,20 @@ #ifndef __CR_SHOW_H__ #define __CR_SHOW_H__ +#include + +struct show_image_info { + u32 magic; + int pb_type; + bool single; + void (*payload)(int, void *); + char *fmt; +}; -extern void show_files(int fd); -extern void show_pagemap(int fd); -extern void show_reg_files(int fd); -extern void show_ns_files(int fd); -extern void show_core(int fd); -extern void show_ids(int fd); -extern void show_mm(int fd); -extern void show_vmas(int fd); -extern void show_pipes(int fd); -extern void show_pipes_data(int fd); -extern void show_fifo(int fd); -extern void show_fifo_data(int fd); -extern void show_pstree(int fd); -extern void show_sigacts(int fd); extern void show_siginfo(int fd); -extern void show_itimers(int fd); -extern void show_posix_timers(int fd); -extern void show_creds(int fd); -extern void show_fs(int fd); -extern void show_remap_files(int fd); -extern void show_ghost_file(int fd); extern void show_fown_cont(void *p); -extern void show_eventfds(int fd); -extern void show_tty(int fd); -extern void show_tty_info(int fd); -extern void show_file_locks(int fd); -extern void show_rlimit(int fd); -extern void show_inventory(int fd); -extern void show_raw_image(int fd); -extern void show_eventpoll(int fd); -extern void show_eventpoll_tfd(int fd); -extern void show_signalfd(int fd); -extern void show_inotify(int fd); -extern void show_inotify_wd(int fd); -extern void show_fanotify(int fd); -extern void show_fanotify_mark(int fd); -extern void show_unixsk(int fd); -extern void show_inetsk(int fd); -extern void show_packetsk(int fd); -extern void show_netlinksk(int fd); -extern void show_sk_queues(int fd); -extern void show_utsns(int fd); -extern void show_ipc_var(int fd); -extern void show_ipc_shm(int fd); -extern void show_ipc_msg(int fd); -extern void show_ipc_sem(int fd); -extern void show_tcp_stream(int fd); -extern void show_mountpoints(int fd); -extern void show_netdevices(int fd); -extern void show_stats(int fd); -extern void show_tunfile(int fd); - +extern void sk_queue_data_handler(int fd, void *obj); +extern void ipc_shm_handler(int fd, void *obj); +extern void ipc_msg_handler(int fd, void *obj); +extern void ipc_sem_handler(int fd, void *obj); +extern int cr_parse_fd(int fd, u32 magic); #endif /* __CR_SHOW_H__ */ diff --git a/include/crtools.h b/include/crtools.h index 65ed1669b..7319992b3 100644 --- a/include/crtools.h +++ b/include/crtools.h @@ -74,7 +74,6 @@ extern int close_service_fd(enum sfd_type type); extern bool is_service_fd(int fd, enum sfd_type type); extern bool is_any_service_fd(int fd); -void show_posix_timers(int fd); int check_img_inventory(void); int write_img_inventory(void); void kill_inventory(void); diff --git a/include/eventfd.h b/include/eventfd.h index f4014eb90..5666e50c1 100644 --- a/include/eventfd.h +++ b/include/eventfd.h @@ -12,6 +12,5 @@ extern int is_eventfd_link(int lfd); extern const struct fdtype_ops eventfd_dump_ops; extern struct collect_image_info eventfd_cinfo; -extern void show_eventfds(int fd); #endif /* __CR_EVENTFD_H__ */ diff --git a/include/eventpoll.h b/include/eventpoll.h index 913db606a..e67a2e5e6 100644 --- a/include/eventpoll.h +++ b/include/eventpoll.h @@ -13,7 +13,5 @@ extern int is_eventpoll_link(int lfd); extern const struct fdtype_ops eventpoll_dump_ops; extern struct collect_image_info epoll_tfd_cinfo; extern struct collect_image_info epoll_cinfo; -extern void show_eventpoll(int fd); -extern void show_eventpoll_tfd(int fd); #endif /* __CR_EVENTPOLL_H__ */ diff --git a/include/fsnotify.h b/include/fsnotify.h index 7fd247b80..eb33370b8 100644 --- a/include/fsnotify.h +++ b/include/fsnotify.h @@ -23,9 +23,5 @@ extern struct collect_image_info inotify_cinfo; extern struct collect_image_info inotify_mark_cinfo; extern struct collect_image_info fanotify_cinfo; extern struct collect_image_info fanotify_mark_cinfo; -extern void show_inotify_wd(int fd); -extern void show_inotify(int fd); -extern void show_fanotify_mark(int fd); -extern void show_fanotify(int fd); #endif /* __CR_FSNOTIFY_H__ */ diff --git a/include/image-desc.h b/include/image-desc.h index a8f4dbeda..cb46b893c 100644 --- a/include/image-desc.h +++ b/include/image-desc.h @@ -33,11 +33,11 @@ enum { _CR_FD_NS_FROM, CR_FD_UTSNS, - CR_FD_IPCNS_VAR, + CR_FD_IPC_VAR, CR_FD_IPCNS_SHM, CR_FD_IPCNS_MSG, CR_FD_IPCNS_SEM, - CR_FD_MOUNTPOINTS, + CR_FD_MNTS, CR_FD_NETDEV, CR_FD_IFADDR, CR_FD_ROUTE, @@ -56,21 +56,21 @@ enum { CR_FD_INETSK, CR_FD_UNIXSK, CR_FD_PACKETSK, - CR_FD_NETLINKSK, + CR_FD_NETLINK_SK, CR_FD_PIPES, CR_FD_PIPES_DATA, CR_FD_FIFO, CR_FD_FIFO_DATA, - CR_FD_TTY, + CR_FD_TTY_FILES, CR_FD_TTY_INFO, CR_FD_REMAP_FPATH, - CR_FD_EVENTFD, - CR_FD_EVENTPOLL, + CR_FD_EVENTFD_FILE, + CR_FD_EVENTPOLL_FILE, CR_FD_EVENTPOLL_TFD, CR_FD_SIGNALFD, - CR_FD_INOTIFY, + CR_FD_INOTIFY_FILE, CR_FD_INOTIFY_WD, - CR_FD_FANOTIFY, + CR_FD_FANOTIFY_FILE, CR_FD_FANOTIFY_MARK, CR_FD_TUNFILE, _CR_FD_GLOB_TO, @@ -89,7 +89,6 @@ enum { struct cr_fd_desc_tmpl { const char *fmt; /* format for the name */ u32 magic; /* magic in the header */ - void (*show)(int fd); }; extern struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX]; diff --git a/include/ipc_ns.h b/include/ipc_ns.h index 7761d3f48..0942f30df 100644 --- a/include/ipc_ns.h +++ b/include/ipc_ns.h @@ -3,10 +3,6 @@ #include "crtools.h" -extern void show_ipc_var(int fd); -extern void show_ipc_shm(int fd); -extern void show_ipc_msg(int fd); -extern void show_ipc_sem(int fd); extern int dump_ipc_ns(int ns_pid, const struct cr_fdset *fdset); extern int prepare_ipc_ns(int pid); diff --git a/include/magic.h b/include/magic.h index 5fe773cf4..02d74be30 100644 --- a/include/magic.h +++ b/include/magic.h @@ -42,7 +42,7 @@ #define SK_QUEUES_MAGIC 0x56264026 /* Suzdal */ #define UTSNS_MAGIC 0x54473203 /* Smolensk */ #define CREDS_MAGIC 0x54023547 /* Kozelsk */ -#define IPCNS_VAR_MAGIC 0x53115007 /* Samara */ +#define IPC_VAR_MAGIC 0x53115007 /* Samara */ #define IPCNS_SHM_MAGIC 0x46283044 /* Odessa */ #define IPCNS_MSG_MAGIC 0x55453737 /* Moscow */ #define IPCNS_SEM_MAGIC 0x59573019 /* St. Petersburg */ @@ -52,23 +52,23 @@ #define REMAP_FPATH_MAGIC 0x59133954 /* Vologda */ #define GHOST_FILE_MAGIC 0x52583605 /* Oryol */ #define TCP_STREAM_MAGIC 0x51465506 /* Orenburg */ -#define EVENTFD_MAGIC 0x44523722 /* Anapa */ -#define EVENTPOLL_MAGIC 0x45023858 /* Krasnodar */ +#define EVENTFD_FILE_MAGIC 0x44523722 /* Anapa */ +#define EVENTPOLL_FILE_MAGIC 0x45023858 /* Krasnodar */ #define EVENTPOLL_TFD_MAGIC 0x44433746 /* Novorossiysk */ #define SIGNALFD_MAGIC 0x57323820 /* Uglich */ -#define INOTIFY_MAGIC 0x48424431 /* Volgograd */ +#define INOTIFY_FILE_MAGIC 0x48424431 /* Volgograd */ #define INOTIFY_WD_MAGIC 0x54562009 /* Svetlogorsk (Rauschen) */ -#define MOUNTPOINTS_MAGIC 0x55563928 /* Petushki */ +#define MNTS_MAGIC 0x55563928 /* Petushki */ #define NETDEV_MAGIC 0x57373951 /* Yaroslavl */ -#define TTY_MAGIC 0x59433025 /* Pushkin */ +#define TTY_FILES_MAGIC 0x59433025 /* Pushkin */ #define TTY_INFO_MAGIC 0x59453036 /* Kolpino */ #define FILE_LOCKS_MAGIC 0x54323616 /* Kaluga */ #define RLIMIT_MAGIC 0x57113925 /* Rostov */ -#define FANOTIFY_MAGIC 0x55096122 /* Chelyabinsk */ +#define FANOTIFY_FILE_MAGIC 0x55096122 /* Chelyabinsk */ #define FANOTIFY_MARK_MAGIC 0x56506035 /* Yekaterinburg */ #define SIGNAL_MAGIC 0x59255647 /* Berezniki */ #define PSIGNAL_MAGIC SIGNAL_MAGIC -#define NETLINKSK_MAGIC 0x58005614 /* Perm */ +#define NETLINK_SK_MAGIC 0x58005614 /* Perm */ #define NS_FILES_MAGIC 0x61394011 /* Nyandoma */ #define TUNFILE_MAGIC 0x57143751 /* Kalyazin */ diff --git a/include/mount.h b/include/mount.h index 1a0151752..b86114c10 100644 --- a/include/mount.h +++ b/include/mount.h @@ -12,7 +12,6 @@ extern struct fstype *find_fstype_by_name(char *fst); struct cr_fdset; extern int dump_mnt_ns(int pid, struct cr_fdset *); -extern void show_mountpoints(int fd); int prepare_mnt_ns(int pid); extern int pivot_root(const char *new_root, const char *put_old); diff --git a/include/net.h b/include/net.h index d0715fe46..7792ba2cb 100644 --- a/include/net.h +++ b/include/net.h @@ -3,8 +3,6 @@ #include "list.h" -void show_netdevices(int fd); - struct cr_fdset; int dump_net_ns(int pid, struct cr_fdset *); int prepare_net_ns(int pid); diff --git a/include/signalfd.h b/include/signalfd.h index e33d891e9..b36f9ac2f 100644 --- a/include/signalfd.h +++ b/include/signalfd.h @@ -5,7 +5,6 @@ struct cr_fdset; struct fd_parms; extern int is_signalfd_link(int lfd); extern const struct fdtype_ops signalfd_dump_ops; -extern void show_signalfd(int fd); extern struct collect_image_info signalfd_cinfo; #endif /* __CR_SIGNALFD_H__ */ diff --git a/include/sk-inet.h b/include/sk-inet.h index c2ba9ac75..a3dff732e 100644 --- a/include/sk-inet.h +++ b/include/sk-inet.h @@ -76,8 +76,6 @@ int restore_one_tcp(int sk, struct inet_sk_info *si); #define SK_EST_PARAM "tcp-established" -void show_tcp_stream(int fd); - int check_tcp(void); extern int rst_tcp_socks_add(int fd, bool reuseaddr); diff --git a/include/sk-packet.h b/include/sk-packet.h index a6c449284..915e5ec9a 100644 --- a/include/sk-packet.h +++ b/include/sk-packet.h @@ -10,7 +10,6 @@ struct fd_parms; struct vma_area; extern struct collect_image_info packet_sk_cinfo; -void show_packetsk(int fd); int dump_socket_map(struct vma_area *vma); int get_socket_fd(int pid, VmaEntry *vma); diff --git a/include/sk-queue.h b/include/sk-queue.h index 17ece7215..4a82571e1 100644 --- a/include/sk-queue.h +++ b/include/sk-queue.h @@ -8,7 +8,6 @@ extern int read_sk_queues(void); extern int dump_sk_queue(int sock_fd, int sock_id); -extern void show_sk_queues(int fd); extern int restore_sk_queue(int fd, unsigned int peer_id); #endif /* __CR_SK_QUEUE_H__ */ diff --git a/include/sockets.h b/include/sockets.h index 3dd727377..b318172cb 100644 --- a/include/sockets.h +++ b/include/sockets.h @@ -43,11 +43,6 @@ extern int resolve_unix_peers(void); extern struct collect_image_info netlink_sk_cinfo; -extern void show_unixsk(int fd); -extern void show_inetsk(int fd); -extern void show_sk_queues(int fd); -extern void show_netlinksk(int fd); - extern char *skfamily2s(u32 f); extern char *sktype2s(u32 t); extern char *skproto2s(u32 p); diff --git a/include/stats.h b/include/stats.h index 8bbdb7bd9..c6178f2da 100644 --- a/include/stats.h +++ b/include/stats.h @@ -1,6 +1,5 @@ #ifndef __CR_STATS_H__ #define __CR_STATS_H__ -void show_stats(int fd); enum { TIME_FREEZING, diff --git a/include/uts_ns.h b/include/uts_ns.h index 0fa3aac91..792d43bf7 100644 --- a/include/uts_ns.h +++ b/include/uts_ns.h @@ -4,7 +4,6 @@ #include "crtools.h" int dump_uts_ns(int ns_pid, struct cr_fdset *fdset); -void show_utsns(int fd); int prepare_utsns(int pid); extern struct ns_desc uts_ns_desc; diff --git a/ipc_ns.c b/ipc_ns.c index e0167a888..6d05bfaf6 100644 --- a/ipc_ns.c +++ b/ipc_ns.c @@ -433,7 +433,7 @@ static int dump_ipc_data(const struct cr_fdset *fdset) { int ret; - ret = dump_ipc_var(fdset_fd(fdset, CR_FD_IPCNS_VAR)); + ret = dump_ipc_var(fdset_fd(fdset, CR_FD_IPC_VAR)); if (ret < 0) return ret; ret = dump_ipc_shm(fdset_fd(fdset, CR_FD_IPCNS_SHM)); @@ -464,7 +464,7 @@ int dump_ipc_ns(int ns_pid, const struct cr_fdset *fdset) return 0; } -static void ipc_sem_handler(int fd, void *obj) +void ipc_sem_handler(int fd, void *obj) { IpcSemEntry *e = obj; u16 *values; @@ -482,18 +482,13 @@ static void ipc_sem_handler(int fd, void *obj) pr_msg_ipc_sem_array(e->nsems, values); } -void show_ipc_sem(int fd) -{ - pb_show_plain_payload(fd, PB_IPC_SEM, ipc_sem_handler); -} - static void ipc_msg_data_handler(int fd, void *obj) { IpcMsg *e = obj; print_image_data(fd, round_up(e->msize, sizeof(u64)), opts.show_pages_content); } -static void ipc_msg_handler(int fd, void *obj) +void ipc_msg_handler(int fd, void *obj) { IpcMsgEntry *e = obj; int msg_nr = 0; @@ -504,27 +499,12 @@ static void ipc_msg_handler(int fd, void *obj) } -void show_ipc_msg(int fd) -{ - pb_show_plain_payload(fd, PB_IPCNS_MSG_ENT, ipc_msg_handler); -} - -static void ipc_shm_handler(int fd, void *obj) +void ipc_shm_handler(int fd, void *obj) { IpcShmEntry *e = obj; print_image_data(fd, round_up(e->size, sizeof(u32)), opts.show_pages_content); } -void show_ipc_shm(int fd) -{ - pb_show_plain_payload(fd, PB_IPC_SHM, ipc_shm_handler); -} - -void show_ipc_var(int fd) -{ - pb_show_vertical(fd, PB_IPC_VAR); -} - static int prepare_ipc_sem_values(int fd, const IpcSemEntry *sem) { int ret, size; @@ -894,7 +874,7 @@ static int prepare_ipc_var(int pid) IpcVarEntry *var; pr_info("Restoring IPC variables\n"); - fd = open_image(CR_FD_IPCNS_VAR, O_RSTR, pid); + fd = open_image(CR_FD_IPC_VAR, O_RSTR, pid); if (fd < 0) return -1; diff --git a/mount.c b/mount.c index a4533bf83..c95099277 100644 --- a/mount.c +++ b/mount.c @@ -540,7 +540,7 @@ int dump_mnt_ns(int ns_pid, struct cr_fdset *fdset) pr_info("Dumping mountpoints\n"); - img_fd = fdset_fd(fdset, CR_FD_MOUNTPOINTS); + img_fd = fdset_fd(fdset, CR_FD_MNTS); do { struct mount_info *n = pm->next; @@ -771,7 +771,7 @@ static int populate_mnt_ns(int ns_pid) pr_info("Populating mount namespace\n"); - img = open_image(CR_FD_MOUNTPOINTS, O_RSTR, ns_pid); + img = open_image(CR_FD_MNTS, O_RSTR, ns_pid); if (img < 0) return -1; @@ -868,11 +868,6 @@ int prepare_mnt_ns(int ns_pid) return ret; } -void show_mountpoints(int fd) -{ - pb_show_plain(fd, PB_MNT); -} - int mntns_collect_root(pid_t pid) { int fd, pfd; diff --git a/namespaces.c b/namespaces.c index f04840620..50d1a4922 100644 --- a/namespaces.c +++ b/namespaces.c @@ -473,14 +473,11 @@ int try_show_namespaces(int ns_pid) for (i = _CR_FD_NS_FROM + 1; i < _CR_FD_NS_TO; i++) { int fd; - if (!fdset_template[i].show) - continue; - fd = fdset_fd(fdset, i); if (fd == -1) continue; - fdset_template[i].show(fdset_fd(fdset, i)); + cr_parse_fd(fd, fdset_template[i].magic); } pr_msg("---[ end of %d namespaces ]---\n", ns_pid); close_cr_fdset(&fdset); diff --git a/net.c b/net.c index 7b68c1bb0..a6419a6ad 100644 --- a/net.c +++ b/net.c @@ -44,11 +44,6 @@ int read_ns_sys_file(char *path, char *buf, int len) return rlen; } -void show_netdevices(int fd) -{ - pb_show_plain_pretty(fd, PB_NETDEV, "2:%d"); -} - int write_netdev_img(NetDeviceEntry *nde, struct cr_fdset *fds) { return pb_write_one(fdset_fd(fds, CR_FD_NETDEV), nde, PB_NETDEV); diff --git a/signalfd.c b/signalfd.c index 432b41452..1c9115744 100644 --- a/signalfd.c +++ b/signalfd.c @@ -31,11 +31,6 @@ struct signalfd_dump_arg { bool dumped; }; -void show_signalfd(int fd) -{ - pb_show_plain(fd, PB_SIGNALFD); -} - static int dump_signalfd_entry(union fdinfo_entries *e, void *arg) { struct signalfd_dump_arg *da = arg; diff --git a/sk-inet.c b/sk-inet.c index 25845efd4..be61fa7c8 100644 --- a/sk-inet.c +++ b/sk-inet.c @@ -621,8 +621,3 @@ int inet_connect(int sk, struct inet_sk_info *ii) return 0; } - -void show_inetsk(int fd) -{ - pb_show_plain_pretty(fd, PB_INET_SK, "1:%#x 2:%#x 3:%d 4:%d 5:%d 6:%d 7:%d 8:%d 9:%2x 11:A 12:A"); -} diff --git a/sk-netlink.c b/sk-netlink.c index 14353f9b4..f519cf4e5 100644 --- a/sk-netlink.c +++ b/sk-netlink.c @@ -65,11 +65,6 @@ int netlink_receive_one(struct nlmsghdr *hdr, void *arg) return sk_collect_one(m->ndiag_ino, PF_NETLINK, &sd->sd); } -void show_netlinksk(int fd) -{ - pb_show_plain(fd, PB_NETLINK_SK); -} - static bool can_dump_netlink_sk(int lfd) { struct pollfd pfd = {lfd, POLLIN, 0}; @@ -146,7 +141,7 @@ static int dump_one_netlink_fd(int lfd, u32 id, const struct fd_parms *p) if (dump_socket_opts(lfd, &skopts)) goto err; - if (pb_write_one(fdset_fd(glob_fdset, CR_FD_NETLINKSK), &ne, PB_NETLINK_SK)) + if (pb_write_one(fdset_fd(glob_fdset, CR_FD_NETLINK_SK), &ne, PB_NETLINK_SK)) goto err; return 0; @@ -235,7 +230,7 @@ static int collect_one_netlink_sk(void *o, ProtobufCMessage *base) } struct collect_image_info netlink_sk_cinfo = { - .fd_type = CR_FD_NETLINKSK, + .fd_type = CR_FD_NETLINK_SK, .pb_type = PB_NETLINK_SK, .priv_size = sizeof(struct netlink_sock_info), .collect = collect_one_netlink_sk, diff --git a/sk-packet.c b/sk-packet.c index 0efebcb81..aa64056b0 100644 --- a/sk-packet.c +++ b/sk-packet.c @@ -42,11 +42,6 @@ struct packet_sock_desc { #define NO_FANOUT ((unsigned int)-1) -void show_packetsk(int fd) -{ - pb_show_plain_pretty(fd, PB_PACKET_SOCK, "5:%d"); -} - static int dump_mreqs(PacketSockEntry *psk, struct packet_sock_desc *sd) { int i; diff --git a/sk-queue.c b/sk-queue.c index ac73a0401..36242587e 100644 --- a/sk-queue.c +++ b/sk-queue.c @@ -170,17 +170,12 @@ err_brk: return ret; } -static void sk_queue_data_handler(int fd, void *obj) +void sk_queue_data_handler(int fd, void *obj) { SkPacketEntry *e = obj; print_image_data(fd, e->length, opts.show_pages_content); } -void show_sk_queues(int fd) -{ - pb_show_plain_payload(fd, PB_SK_QUEUES, sk_queue_data_handler); -} - int restore_sk_queue(int fd, unsigned int peer_id) { struct sk_packet *pkt, *tmp; diff --git a/sk-tcp.c b/sk-tcp.c index 0174c3650..bc9cf854e 100644 --- a/sk-tcp.c +++ b/sk-tcp.c @@ -609,11 +609,6 @@ void rst_unlock_tcp_connections(void) nf_unlock_connection_info(ii); } -void show_tcp_stream(int fd) -{ - do_pb_show_plain(fd, PB_TCP_STREAM, 1, NULL, "1:%u 2:%u 3:%u 4:%u"); -} - int check_tcp(void) { socklen_t optlen; diff --git a/sk-unix.c b/sk-unix.c index 94b9633b5..177bb8ba6 100644 --- a/sk-unix.c +++ b/sk-unix.c @@ -497,11 +497,6 @@ static struct unix_sk_info *find_unix_sk_by_ino(int ino) return NULL; } -void show_unixsk(int fd) -{ - pb_show_plain_pretty(fd, PB_UNIX_SK, "1:%#x 2:%#x 3:%d 4:%d 5:%d 6:%d 7:%d 8:%#x 11:S"); -} - static int shutdown_unix_sk(int sk, struct unix_sk_info *ui) { int how; diff --git a/stats.c b/stats.c index 04cd2c141..af3e57431 100644 --- a/stats.c +++ b/stats.c @@ -89,12 +89,6 @@ void timing_stop(int t) timeval_accumulate(&tm->start, &now, &tm->total); } -void show_stats(int fd) -{ - do_pb_show_plain(fd, PB_STATS, 1, NULL, - "1.1:%u 1.2:%u 1.3:%u 1.4:%u 1.5:%Lu 1.6:%Lu 1.7:%Lu"); -} - static void encode_time(int t, u_int32_t *to) { struct timing *tm; diff --git a/tty.c b/tty.c index 611b30ffa..a1eb73ed5 100644 --- a/tty.c +++ b/tty.c @@ -984,7 +984,7 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg) } struct collect_image_info tty_cinfo = { - .fd_type = CR_FD_TTY, + .fd_type = CR_FD_TTY_FILES, .pb_type = PB_TTY_FILE, .priv_size = sizeof(struct tty_info), .collect = collect_one_tty, @@ -1187,7 +1187,7 @@ static int dump_one_pty(int lfd, u32 id, const struct fd_parms *p) ret = dump_pty_info(lfd, e.tty_info_id, p, major, index); if (!ret) - ret = pb_write_one(fdset_fd(glob_fdset, CR_FD_TTY), &e, PB_TTY_FILE); + ret = pb_write_one(fdset_fd(glob_fdset, CR_FD_TTY_FILES), &e, PB_TTY_FILE); return ret; } diff --git a/tun.c b/tun.c index 08ebcf10d..64ad034c3 100644 --- a/tun.c +++ b/tun.c @@ -388,11 +388,6 @@ struct collect_image_info tunfile_cinfo = { .flags = COLLECT_OPTIONAL, }; -void show_tunfile(int fd) -{ - pb_show_plain(fd, PB_TUNFILE); -} - int dump_tun_link(NetDeviceEntry *nde, struct cr_fdset *fds) { TunLinkEntry tle = TUN_LINK_ENTRY__INIT; diff --git a/uts_ns.c b/uts_ns.c index 985c6442b..d09b546db 100644 --- a/uts_ns.c +++ b/uts_ns.c @@ -65,9 +65,4 @@ out: return ret; } -void show_utsns(int fd) -{ - pb_show_vertical(fd, PB_UTSNS); -} - struct ns_desc uts_ns_desc = NS_DESC_ENTRY(CLONE_NEWUTS, "uts");