[v5,19/21] unix: Use decimal format for inode printing

Submitted by Cyrill Gorcunov on May 10, 2018, 2:57 p.m.

Details

Message ID 20180510145801.12322-20-gorcunov@gmail.com
State New
Series "Add support of deleted unix sockets"
Headers show

Commit Message

Cyrill Gorcunov May 10, 2018, 2:57 p.m.
For debug sake, to unify with helpers tools such
as ss, stat and etc.

Requested-by: Andrey Vagin <avagin@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 criu/sk-unix.c | 66 +++++++++++++++++++++++++++++-----------------------------
 1 file changed, 33 insertions(+), 33 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 1ee4d6da075a..3af2806c72f8 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -123,20 +123,20 @@  static struct unix_sk_listen_icon *lookup_unix_listen_icons(int peer_ino)
 
 static void show_one_unix(char *act, const struct unix_sk_desc *sk)
 {
-	pr_debug("\t%s: ino %#x peer_ino %#x family %4d type %4d state %2d name %s\n",
+	pr_debug("\t%s: ino %d peer_ino %d family %4d type %4d state %2d name %s\n",
 		act, sk->sd.ino, sk->peer_ino, sk->sd.family, sk->type, sk->state, sk->name);
 
 	if (sk->nr_icons) {
 		int i;
 
 		for (i = 0; i < sk->nr_icons; i++)
-			pr_debug("\t\ticon: %#x\n", sk->icons[i]);
+			pr_debug("\t\ticon: %d\n", sk->icons[i]);
 	}
 }
 
 static void show_one_unix_img(const char *act, const UnixSkEntry *e)
 {
-	pr_info("\t%s: id %#x ino %#x peer %#x type %d state %d name %d bytes\n",
+	pr_info("\t%s: id %#x ino %d peer %d type %d state %d name %d bytes\n",
 		act, e->id, e->ino, e->peer, e->type, e->state, (int)e->name.len);
 }
 
@@ -150,7 +150,7 @@  static int can_dump_unix_sk(const struct unix_sk_desc *sk)
 	if (sk->type != SOCK_STREAM &&
 	    sk->type != SOCK_DGRAM &&
 	    sk->type != SOCK_SEQPACKET) {
-		pr_err("Unsupported type (%d) on socket %#x.\n"
+		pr_err("Unsupported type (%d) on socket %d.\n"
 				"Only stream/dgram/seqpacket are supported.\n",
 				sk->type, sk->sd.ino);
 		return 0;
@@ -162,7 +162,7 @@  static int can_dump_unix_sk(const struct unix_sk_desc *sk)
 	case TCP_CLOSE:
 		break;
 	default:
-		pr_err("Unknown state %d for unix socket %#x\n",
+		pr_err("Unknown state %d for unix socket %d\n",
 				sk->state, sk->sd.ino);
 		return 0;
 	}
@@ -278,7 +278,7 @@  static int resolve_rel_name(uint32_t id, struct unix_sk_desc *sk, const struct f
 		return -ENOENT;
 	}
 
-	pr_debug("Resolving relative name %s for socket %#x\n",
+	pr_debug("Resolving relative name %s for socket %d\n",
 		 sk->name, sk->sd.ino);
 
 	for (i = 0; i < ARRAY_SIZE(dirs); i++) {
@@ -351,7 +351,7 @@  static int dump_one_unix_fd(int lfd, uint32_t id, const struct fd_parms *p)
 
 	sk = (struct unix_sk_desc *)lookup_socket(p->stat.st_ino, PF_UNIX, 0);
 	if (IS_ERR_OR_NULL(sk)) {
-		pr_err("Unix socket %#x not found\n", (int)p->stat.st_ino);
+		pr_err("Unix socket %d not found\n", (int)p->stat.st_ino);
 		goto err;
 	}
 
@@ -419,7 +419,7 @@  static int dump_one_unix_fd(int lfd, uint32_t id, const struct fd_parms *p)
 	if (ue->peer) {
 		peer = (struct unix_sk_desc *)lookup_socket(ue->peer, PF_UNIX, 0);
 		if (IS_ERR_OR_NULL(peer)) {
-			pr_err("Unix socket %#x without peer %#x\n",
+			pr_err("Unix socket %d without peer %d\n",
 					ue->ino, ue->peer);
 			goto err;
 		}
@@ -430,7 +430,7 @@  static int dump_one_unix_fd(int lfd, uint32_t id, const struct fd_parms *p)
 		 */
 		if (peer->peer_ino != ue->ino) {
 			if (!peer->name) {
-				pr_err("Unix socket %#x with unreachable peer %#x (%#x/%s)\n",
+				pr_err("Unix socket %d with unreachable peer %d (%d/%s)\n",
 				       ue->ino, ue->peer, peer->peer_ino, peer->name);
 				goto err;
 			}
@@ -465,7 +465,7 @@  static int dump_one_unix_fd(int lfd, uint32_t id, const struct fd_parms *p)
 			 * to check both ends on read()/write(). Thus mismatched sockets behave
 			 * the same way as matched.
 			 */
-			pr_warn("Shutdown mismatch %#x:%d -> %#x:%d\n",
+			pr_warn("Shutdown mismatch %d:%d -> %d:%d\n",
 					ue->ino, ue->shutdown, peer->sd.ino, peer->shutdown);
 		}
 	} else if (ue->state == TCP_ESTABLISHED) {
@@ -484,7 +484,7 @@  static int dump_one_unix_fd(int lfd, uint32_t id, const struct fd_parms *p)
 				goto dump;
 			}
 
-			pr_err("Dangling connection %#x\n", ue->ino);
+			pr_err("Dangling connection %d\n", ue->ino);
 			goto err;
 		}
 
@@ -500,13 +500,13 @@  static int dump_one_unix_fd(int lfd, uint32_t id, const struct fd_parms *p)
 		/* e->sk_desc is _never_ NULL */
 		if (e->sk_desc->state != TCP_LISTEN) {
 			pr_err("In-flight connection on "
-				"non-listening socket %#x\n", ue->ino);
+				"non-listening socket %d\n", ue->ino);
 			goto err;
 		}
 
 		ue->peer = e->sk_desc->sd.ino;
 
-		pr_debug("\t\tFixed inflight socket %#x peer %#x)\n",
+		pr_debug("\t\tFixed inflight socket %d peer %d)\n",
 				ue->ino, ue->peer);
 	}
 dump:
@@ -614,7 +614,7 @@  static int unix_resolve_name(int lfd, uint32_t id, struct unix_sk_desc *d,
 	} else if ((st.st_ino != d->vfs_ino) ||
 		   !phys_stat_dev_match(st.st_dev, d->vfs_dev, ns, name)) {
 		pr_info("unix: Dropping path %s for unlinked bound "
-			"sk %#x.%#x real %#x.%#x\n",
+			"sk %#x.%d real %#x.%d\n",
 			name, (int)st.st_dev, (int)st.st_ino,
 			(int)d->vfs_dev, (int)d->vfs_ino);
 		deleted = true;
@@ -657,7 +657,7 @@  static int unix_process_name(struct unix_sk_desc *d, const struct unix_diag_msg
 		struct unix_diag_vfs *uv;
 
 		if (!tb[UNIX_DIAG_VFS]) {
-			pr_err("Bound socket w/o inode %#x\n", m->udiag_ino);
+			pr_err("Bound socket w/o inode %d\n", m->udiag_ino);
 			goto skip;
 		}
 
@@ -737,7 +737,7 @@  static int unix_collect_one(const struct unix_diag_msg *m,
 			e->next = *chain;
 			*chain = e;
 
-			pr_debug("\t\tCollected icon %#x\n", d->icons[i]);
+			pr_debug("\t\tCollected icon %d\n", d->icons[i]);
 
 			e->peer_ino	= n;
 			e->sk_desc	= d;
@@ -1122,7 +1122,7 @@  static int shutdown_unix_sk(int sk, struct unix_sk_info *ui)
 		return -1;
 	}
 
-	pr_debug("Socket %#x is shut down %d\n", ue->ino, how);
+	pr_debug("Socket %d is shut down %d\n", ue->ino, how);
 	return 0;
 }
 
@@ -1280,7 +1280,7 @@  static int post_open_standalone(struct file_desc *d, int fd)
 	memset(&addr, 0, sizeof(addr));
 	addr.sun_family = AF_UNIX;
 
-	pr_info("\tConnect %#x to %#x\n", ui->ue->ino, peer->ue->ino);
+	pr_info("\tConnect %d to %d\n", ui->ue->ino, peer->ue->ino);
 
 	if (prep_unix_sk_cwd(peer, &cwd_fd, NULL, &ns_fd))
 		return -1;
@@ -1309,7 +1309,7 @@  static int post_open_standalone(struct file_desc *d, int fd)
 	}
 
 	if (connect(fd, (struct sockaddr *)&addr, sizeof(addr.sun_family) + len) < 0) {
-		pr_perror("Can't connect %#x socket", ui->ue->ino);
+		pr_perror("Can't connect %d socket", ui->ue->ino);
 		goto err_revert_and_exit;
 	}
 	ui->is_connected = true;
@@ -1344,7 +1344,7 @@  static int keep_deleted(struct unix_sk_info *ui, struct sockaddr_un *addr)
 			return -1;
 		}
 		ui->fdstore_id = fdstore_add(fd);
-		pr_debug("ghost: %#x fdstore_id %d %s\n",
+		pr_debug("ghost: %d fdstore_id %d %s\n",
 			 ui->ue->ino, ui->fdstore_id, ui->ue->name.data);
 		close(fd);
 		return ui->fdstore_id;
@@ -1385,7 +1385,7 @@  static int bind_unix_sk(int sk, struct unix_sk_info *ui)
 	if (ui->name[0] && prep_unix_sk_cwd(ui, &cwd_fd, NULL, &ns_fd))
 		return -1;
 
-	pr_debug("bind_unix_sk: id %#x ino %#x addr %s\n",
+	pr_debug("bind_unix_sk: id %#x ino %d addr %s\n",
 		 ui->ue->id, ui->ue->ino, ui->name);
 	ret = bind(sk, (struct sockaddr *)&addr,
 			sizeof(addr.sun_family) + ui->ue->name.len);
@@ -1461,7 +1461,7 @@  static int post_open_interconnected_master(struct unix_sk_info *ui)
 
 static void pr_info_opening(const char *prefix, struct unix_sk_info *ui, struct fdinfo_list_entry *fle)
 {
-	pr_info("Opening %s (stage %d id %#x ino %#x peer %#x)\n",
+	pr_info("Opening %s (stage %d id %#x ino %d peer %d)\n",
 		prefix, fle->stage, ui->ue->id, ui->ue->ino, ui->ue->peer);
 }
 
@@ -1602,13 +1602,13 @@  static int open_unixsk_standalone(struct unix_sk_info *ui, int *new_fd)
 		int ret, sks[2];
 
 		if (ui->ue->type != SOCK_STREAM) {
-			pr_err("Non-stream socket %#x in established state\n",
+			pr_err("Non-stream socket %d in established state\n",
 					ui->ue->ino);
 			return -1;
 		}
 
 		if (ui->ue->shutdown != SK_SHUTDOWN__BOTH) {
-			pr_err("Wrong shutdown/peer state for %#x\n",
+			pr_err("Wrong shutdown/peer state for %d\n",
 					ui->ue->ino);
 			return -1;
 		}
@@ -1684,7 +1684,7 @@  static int open_unixsk_standalone(struct unix_sk_info *ui, int *new_fd)
 		return -1;
 
 	if (ui->ue->state == TCP_LISTEN) {
-		pr_info("\tPutting %#x into listen state\n", ui->ue->ino);
+		pr_info("\tPutting %d into listen state\n", ui->ue->ino);
 		if (listen(sk, ui->ue->backlog) < 0) {
 			pr_perror("Can't make usk listen");
 			return -1;
@@ -1784,12 +1784,12 @@  static void unlink_sk(struct unix_sk_info *ui)
 
 	ret = unlinkat(AT_FDCWD, ui->name, 0) ? -1 : 0;
 	if (ret < 0 && errno != ENOENT) {
-		pr_warn("Can't unlink socket %#x peer %#x (name %s dir %s)\n",
+		pr_warn("Can't unlink socket %d peer %d (name %s dir %s)\n",
 			ui->ue->ino, ui->ue->peer,
 			ui->name ? (ui->name[0] ? ui->name : &ui->name[1]) : "-",
 			ui->name_dir ? ui->name_dir : "-");
 	} else if (ret == 0) {
-		pr_debug("Unlinked socket %#x peer %#x (name %s dir %s)\n",
+		pr_debug("Unlinked socket %d peer %d (name %s dir %s)\n",
 			 ui->ue->ino, ui->ue->peer,
 			 ui->name ? (ui->name[0] ? ui->name : &ui->name[1]) : "-",
 			 ui->name_dir ? ui->name_dir : "-");
@@ -1898,7 +1898,7 @@  int unix_resolve_ghost_addr(void)
 		size_t newnamelen;
 		char *newname;
 
-		pr_debug("ghost: ino %#x peer %#x address %s\n",
+		pr_debug("ghost: ino %d peer %d address %s\n",
 			 ui->ue->ino, ui->peer ? ui->peer->ue->ino : 0,
 			 ui->name);
 
@@ -1925,7 +1925,7 @@  int unix_resolve_ghost_addr(void)
 			if (ui == t || t->peer != ui)
 				continue;
 
-			pr_debug("\t\tghost: connected to us %#x -> %#x\n",
+			pr_debug("\t\tghost: connected to us %d -> %d\n",
 				 t->ue->ino, ui->ue->ino);
 
 			if (!(ui->flags & USK_GHOST_FDSTORE))
@@ -1966,7 +1966,7 @@  static int collect_one_unixsk(void *o, ProtobufCMessage *base, struct cr_img *i)
 		uname = "-";
 	}
 
-	pr_info(" `- Got %#x peer %#x (name %s%.*s dir %s)\n",
+	pr_info(" `- Got %d peer %d (name %s%.*s dir %s)\n",
 		ui->ue->ino, ui->ue->peer,
 		prefix, ulen, uname,
 		ui->name_dir ? ui->name_dir : "-");
@@ -1981,7 +1981,7 @@  static int collect_one_unixsk(void *o, ProtobufCMessage *base, struct cr_img *i)
 
 	if (ui->ue->deleted) {
 		if (!ui->name || !ui->ue->name.len || !ui->name[0]) {
-			pr_err("No name present, ino %#x\n", ui->ue->ino);
+			pr_err("No name present, ino %d\n", ui->ue->ino);
 			return -1;
 		}
 
@@ -2103,14 +2103,14 @@  static int fixup_unix_peer(struct unix_sk_info *ui)
 	struct unix_sk_info *peer = ui->peer;
 
 	if (!peer) {
-		pr_err("FATAL: Peer %#x unresolved for %#x\n",
+		pr_err("FATAL: Peer %d unresolved for %d\n",
 				ui->ue->peer, ui->ue->ino);
 		return -1;
 	}
 
 	if (peer != ui && peer->peer == ui &&
 			!(ui->flags & (USK_PAIR_MASTER | USK_PAIR_SLAVE))) {
-		pr_info("Connected %#x -> %#x (%#x) flags %#x\n",
+		pr_info("Connected %d -> %d (%d) flags %#x\n",
 				ui->ue->ino, ui->ue->peer, peer->ue->ino, ui->flags);
 		/* socketpair or interconnected sockets */
 		if (interconnected_pair(ui, peer))