[CRIU] [PATCH] protobuf: use pretty output for unix sockets

Kinsbursky Stanislav skinsbursky at openvz.org
Mon Aug 20 12:05:34 EDT 2012


From: Stanislav Kinsbursky <skinsbursky at openvz.org>

New custom specificator:

'U': output as unix socket address

Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
 protobuf.c |   11 +++++++++++
 sk-unix.c  |   30 +-----------------------------
 2 files changed, 12 insertions(+), 29 deletions(-)
-------------- next part --------------
diff --git a/protobuf.c b/protobuf.c
index c800fd5..701e173 100644
--- a/protobuf.c
+++ b/protobuf.c
@@ -289,6 +289,17 @@ static int pb_show_pretty(pb_pr_field_t *field)
 	case '%':
 		pr_msg(field->fmt, *(long *)field->data);
 		break;
+	case 'U':
+		{
+			ProtobufCBinaryData *name = (ProtobufCBinaryData *)field->data;
+
+			if (name->len) {
+				if (!name->data[0])
+					name->data[0] = '@';
+				pr_msg(" --> %s", name->data);
+			}
+			break;
+		}
 	case 'A':
 		{
 			char addr[INET_ADDR_LEN] = "<unknown>";
diff --git a/sk-unix.c b/sk-unix.c
index 830d69d..7bbc66b 100644
--- a/sk-unix.c
+++ b/sk-unix.c
@@ -451,35 +451,7 @@ static struct unix_sk_info *find_unix_sk_by_ino(int ino)
 
 void show_unixsk(int fd, struct cr_options *o)
 {
-	UnixSkEntry *ue;
-	int ret = 0;
-
-	pr_img_head(CR_FD_UNIXSK);
-
-	while (1) {
-		ret = pb_read_one_eof(fd, &ue, PB_UNIXSK);
-		if (ret <= 0)
-			goto out;
-
-		pr_msg("id %#x ino %#x type %s state %s namelen %4d backlog %4d peer %#x flags %#x uflags %#x",
-			ue->id, ue->ino, sktype2s(ue->type), skstate2s(ue->state),
-			(int)ue->name.len, ue->backlog, ue->peer, ue->flags, ue->uflags);
-
-		if (ue->name.len) {
-			if (!ue->name.data[0])
-				ue->name.data[0] = '@';
-			pr_msg(" --> %s\n", ue->name.data);
-		} else
-			pr_msg("\n");
-		show_fown_cont(ue->fown);
-		pr_msg("\n");
-
-		if (ue->opts)
-			show_socket_opts(ue->opts);
-		unix_sk_entry__free_unpacked(ue, NULL);
-	}
-out:
-	pr_img_tail(CR_FD_UNIXSK);
+	pb_show_plain_pretty(fd, PB_UNIXSK, "1:%#x 2:%#x 3:%d 4:%d 5:%d 6:%d 7:%d 8:%d 11:U");
 }
 
 static int post_open_unix_sk(struct file_desc *d, int fd)


More information about the CRIU mailing list