[CRIU] [PATCH 5/6] unix sockets: add protobuf "pretty show" array
Kinsbursky Stanislav
skinsbursky at openvz.org
Fri Jul 27 10:06:53 EDT 2012
This patch also adds support for "pretty show" call
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
sk-unix.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 76 insertions(+), 1 deletions(-)
diff --git a/sk-unix.c b/sk-unix.c
index 1963096..fa5a816 100644
--- a/sk-unix.c
+++ b/sk-unix.c
@@ -445,6 +445,78 @@ static struct unix_sk_info *find_unix_sk_by_ino(int ino)
return NULL;
}
+static void show_sk_unix_name(void *ptr, void *arg)
+{
+ ProtobufCBinaryData *name = ptr;
+
+ if (name->len == 0)
+ return;
+
+ if (!name)
+ return;
+
+ if (!name->data[0])
+ name->data[0] = '@';
+ pr_msg("--> %s", name->data);
+}
+
+static void show_sk_unix_uflags(void *ptr, void *arg)
+{
+ pr_msg("uflags %#x ", *(unsigned int *)ptr);
+}
+
+static void show_sk_unix_flags(void *ptr, void *arg)
+{
+ pr_msg("flags %#x ", *(unsigned int *)ptr);
+}
+
+static void show_sk_unix_peer(void *ptr, void *arg)
+{
+ pr_msg("peer %#x\n", *(unsigned int *)ptr);
+}
+
+static void show_sk_unix_backlog(void *ptr, void *arg)
+{
+ pr_msg("backlog %4d ", *(unsigned int *)ptr);
+}
+
+static void show_sk_unix_state(void *ptr, void *arg)
+{
+ pr_msg("state %s ", skstate2s(*(u32 *)ptr));
+}
+
+static void show_sk_unix_type(void *ptr, void *arg)
+{
+ pr_msg("type %s ", sktype2s(*(u32 *)ptr));
+}
+
+static void show_sk_unix_ino(void *ptr, void *arg)
+{
+ pr_msg("ino %#x ", *(unsigned int *)ptr);
+}
+
+static void show_sk_unix_id(void *ptr, void *arg)
+{
+ pr_msg("id %#x ", *(unsigned int *)ptr);
+}
+
+extern pb_pr_field_t fown_pretty_array[];
+extern pb_pr_field_t socket_ops_pretty_array[];
+
+pb_pr_field_t unix_sk_pretty_array[] = {
+ [0] = show_sk_unix_id,
+ [1] = show_sk_unix_ino,
+ [2] = show_sk_unix_type,
+ [3] = show_sk_unix_state,
+ [4] = show_sk_unix_flags,
+ [5] = show_sk_unix_uflags,
+ [6] = show_sk_unix_backlog,
+ [7] = show_sk_unix_peer,
+ [8] = PTR_TO_PRETTY_ARRAY(fown_pretty_array),
+ [9] = PTR_TO_PRETTY_ARRAY(socket_ops_pretty_array),
+ [10] = show_sk_unix_name,
+};
+
void show_unixsk_pretty(int fd, struct cr_options *o)
{
UnixSkEntry *ue;
@@ -480,7 +552,10 @@ out:
void show_unixsk(int fd, struct cr_options *o)
{
- pb_show_plain(fd, unix_sk_entry);
+ if (o->show_pretty)
+ pb_show_plain_pretty(fd, unix_sk_entry, unix_sk_pretty_array);
+ else
+ pb_show_plain(fd, unix_sk_entry);
}
struct unix_conn_job {
More information about the CRIU
mailing list