[03/17] unix: Unify id and ino prints

Submitted by Cyrill Gorcunov on April 27, 2018, 11:34 a.m.

Details

Message ID 20180427113505.20616-4-gorcunov@gmail.com
State New
Series "unix: Add support for ghost unix sockets"
Headers show

Commit Message

Cyrill Gorcunov April 27, 2018, 11:34 a.m.
Most of them already in hex form, lets do the same for the rest.
Also incoming connections are identified by inode number
so use hex for them as well for consistency.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 criu/sk-unix.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 4b02f4d4c338..68b0c5573ea5 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -121,7 +121,7 @@  static void show_one_unix(char *act, const struct unix_sk_desc *sk)
 		int i;
 
 		for (i = 0; i < sk->nr_icons; i++)
-			pr_debug("\t\ticon: %4d\n", sk->icons[i]);
+			pr_debug("\t\ticon: %#x\n", sk->icons[i]);
 	}
 }
 
@@ -141,7 +141,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 %#x.\n"
 				"Only stream/dgram/seqpacket are supported.\n",
 				sk->type, sk->sd.ino);
 		return 0;
@@ -153,7 +153,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 %#x\n",
 				sk->state, sk->sd.ino);
 		return 0;
 	}
@@ -269,7 +269,7 @@  static int resolve_rel_name(u32 id, struct unix_sk_desc *sk, const struct fd_par
 		return -ENOENT;
 	}
 
-	pr_debug("Resolving relative name %s for socket %x\n",
+	pr_debug("Resolving relative name %s for socket %#x\n",
 		 sk->name, sk->sd.ino);
 
 	for (i = 0; i < ARRAY_SIZE(dirs); i++) {
@@ -457,7 +457,7 @@  static int dump_one_unix_fd(int lfd, u32 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 %u:%d -> %u:%d\n",
+			pr_warn("Shutdown mismatch %#x:%d -> %#x:%d\n",
 					ue->ino, ue->shutdown, peer->sd.ino, peer->shutdown);
 		}
 	} else if (ue->state == TCP_ESTABLISHED) {
@@ -492,7 +492,7 @@  static int dump_one_unix_fd(int lfd, u32 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 %d\n", ue->ino);
+				"non-listening socket %#x\n", ue->ino);
 			goto err;
 		}
 
@@ -729,7 +729,7 @@  static int unix_collect_one(const struct unix_diag_msg *m,
 			e->next = *chain;
 			*chain = e;
 
-			pr_debug("\t\tCollected icon %d\n", d->icons[i]);
+			pr_debug("\t\tCollected icon %#x\n", d->icons[i]);
 
 			e->peer_ino	= n;
 			e->sk_desc	= d;
@@ -1003,11 +1003,11 @@  int unix_note_scm_rights(int id_for, uint32_t *file_ids, int *fds, int n_ids)
 
 	ui = find_queuer_for(id_for);
 	if (!ui) {
-		pr_err("Can't find sender for %d\n", id_for);
+		pr_err("Can't find sender for %#x\n", id_for);
 		return -1;
 	}
 
-	pr_info("Found queuer for %d -> %d\n", id_for, ui->ue->id);
+	pr_info("Found queuer for %#x -> %#x\n", id_for, ui->ue->id);
 	/*
 	 * This is the task that will restore this socket
 	 */
@@ -1028,7 +1028,7 @@  int unix_note_scm_rights(int id_for, uint32_t *file_ids, int *fds, int n_ids)
 			return -1;
 		}
 
-		pr_info("scm: add file %d -> %d\n", tgt->id, vpid(owner));
+		pr_info("scm: add file %#x -> %d\n", tgt->id, vpid(owner));
 		sfle = xmalloc(sizeof(*sfle));
 		if (!sfle)
 			return -1;
@@ -1582,13 +1582,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 %#x 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 %#x\n",
 					ui->ue->ino);
 			return -1;
 		}

Comments

Andrei Vagin May 3, 2018, 5:07 a.m.
On Fri, Apr 27, 2018 at 02:34:51PM +0300, Cyrill Gorcunov wrote:
> Most of them already in hex form, lets do the same for the rest.
> Also incoming connections are identified by inode number
> so use hex for them as well for consistency.

I would prefer to print ino in the decimal format to be consistent with
ss, ls, stat

> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>  criu/sk-unix.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/criu/sk-unix.c b/criu/sk-unix.c
> index 4b02f4d4c338..68b0c5573ea5 100644
> --- a/criu/sk-unix.c
> +++ b/criu/sk-unix.c
> @@ -121,7 +121,7 @@ static void show_one_unix(char *act, const struct unix_sk_desc *sk)
>  		int i;
>  
>  		for (i = 0; i < sk->nr_icons; i++)
> -			pr_debug("\t\ticon: %4d\n", sk->icons[i]);
> +			pr_debug("\t\ticon: %#x\n", sk->icons[i]);
>  	}
>  }
>  
> @@ -141,7 +141,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 %#x.\n"
>  				"Only stream/dgram/seqpacket are supported.\n",
>  				sk->type, sk->sd.ino);
>  		return 0;
> @@ -153,7 +153,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 %#x\n",
>  				sk->state, sk->sd.ino);
>  		return 0;
>  	}
> @@ -269,7 +269,7 @@ static int resolve_rel_name(u32 id, struct unix_sk_desc *sk, const struct fd_par
>  		return -ENOENT;
>  	}
>  
> -	pr_debug("Resolving relative name %s for socket %x\n",
> +	pr_debug("Resolving relative name %s for socket %#x\n",
>  		 sk->name, sk->sd.ino);
>  
>  	for (i = 0; i < ARRAY_SIZE(dirs); i++) {
> @@ -457,7 +457,7 @@ static int dump_one_unix_fd(int lfd, u32 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 %u:%d -> %u:%d\n",
> +			pr_warn("Shutdown mismatch %#x:%d -> %#x:%d\n",
>  					ue->ino, ue->shutdown, peer->sd.ino, peer->shutdown);
>  		}
>  	} else if (ue->state == TCP_ESTABLISHED) {
> @@ -492,7 +492,7 @@ static int dump_one_unix_fd(int lfd, u32 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 %d\n", ue->ino);
> +				"non-listening socket %#x\n", ue->ino);
>  			goto err;
>  		}
>  
> @@ -729,7 +729,7 @@ static int unix_collect_one(const struct unix_diag_msg *m,
>  			e->next = *chain;
>  			*chain = e;
>  
> -			pr_debug("\t\tCollected icon %d\n", d->icons[i]);
> +			pr_debug("\t\tCollected icon %#x\n", d->icons[i]);
>  
>  			e->peer_ino	= n;
>  			e->sk_desc	= d;
> @@ -1003,11 +1003,11 @@ int unix_note_scm_rights(int id_for, uint32_t *file_ids, int *fds, int n_ids)
>  
>  	ui = find_queuer_for(id_for);
>  	if (!ui) {
> -		pr_err("Can't find sender for %d\n", id_for);
> +		pr_err("Can't find sender for %#x\n", id_for);
>  		return -1;
>  	}
>  
> -	pr_info("Found queuer for %d -> %d\n", id_for, ui->ue->id);
> +	pr_info("Found queuer for %#x -> %#x\n", id_for, ui->ue->id);
>  	/*
>  	 * This is the task that will restore this socket
>  	 */
> @@ -1028,7 +1028,7 @@ int unix_note_scm_rights(int id_for, uint32_t *file_ids, int *fds, int n_ids)
>  			return -1;
>  		}
>  
> -		pr_info("scm: add file %d -> %d\n", tgt->id, vpid(owner));
> +		pr_info("scm: add file %#x -> %d\n", tgt->id, vpid(owner));
>  		sfle = xmalloc(sizeof(*sfle));
>  		if (!sfle)
>  			return -1;
> @@ -1582,13 +1582,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 %#x 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 %#x\n",
>  					ui->ue->ino);
>  			return -1;
>  		}
> -- 
> 2.14.3
>
Cyrill Gorcunov May 3, 2018, 7:15 a.m.
On Wed, May 02, 2018 at 10:07:30PM -0700, Andrey Vagin wrote:
> On Fri, Apr 27, 2018 at 02:34:51PM +0300, Cyrill Gorcunov wrote:
> > Most of them already in hex form, lets do the same for the rest.
> > Also incoming connections are identified by inode number
> > so use hex for them as well for consistency.
> 
> I would prefer to print ino in the decimal format to be consistent with
> ss, ls, stat

These are external tools while in our logs we use hex form a lot.
I think better to have unified form first for the whole file and
then if needed we could move them all into dec form instead of
the mess we have now.