mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 06:45:35 +00:00
protobuf: use pretty output for unix sockets
New custom specificator: 'S': output as string (unprintable characters replaced by dots) Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
eb63547a9b
commit
768d88f228
16
protobuf.c
16
protobuf.c
@@ -4,6 +4,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <google/protobuf-c/protobuf-c.h>
|
||||
|
||||
@@ -289,6 +290,21 @@ static int pb_show_pretty(pb_pr_field_t *field)
|
||||
case '%':
|
||||
pr_msg(field->fmt, *(long *)field->data);
|
||||
break;
|
||||
case 'S':
|
||||
{
|
||||
ProtobufCBinaryData *name = (ProtobufCBinaryData *)field->data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < name->len; i++) {
|
||||
char c = (char)name->data[i];
|
||||
|
||||
if (isprint(c))
|
||||
pr_msg("%c", c);
|
||||
else if (c != 0)
|
||||
pr_msg(".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'A':
|
||||
{
|
||||
char addr[INET_ADDR_LEN] = "<unknown>";
|
||||
|
30
sk-unix.c
30
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:S");
|
||||
}
|
||||
|
||||
static int post_open_unix_sk(struct file_desc *d, int fd)
|
||||
|
Reference in New Issue
Block a user