From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 540475A026F for ; Sat, 24 Jun 2023 07:10:29 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Qp2HP1yVyz4x2c; Sat, 24 Jun 2023 15:10:25 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1687583425; bh=g+Lop2LnQ4qkIouUXw78NSOZoknhizSc2qVV4P/WL7w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Mzkd6EvQYCg0qKBojU3aAcI/TsfbdRA4Nn+cTm9YfeCm6okGJtio44Uoj/ZK73wb4 INsXpE5P3Dm4BV1uBOnGWTwKpwG5E3i1O4t5U8kN/PegKoNOc+9z4UK9zLkOX5Sj32 YKUD4FDm2i8UXJL3Fwb2Rn1YqIwoTpnWSCoVsfZQ= Date: Sat, 24 Jun 2023 11:57:15 +1000 From: David Gibson To: Paul Holzinger Subject: Re: [PATCH] pasta: include errno in error message Message-ID: References: <20230623102350.106830-1-pholzing@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="S92amm4kqi3pDX7d" Content-Disposition: inline In-Reply-To: <20230623102350.106830-1-pholzing@redhat.com> Message-ID-Hash: P22VABEKAVR33FZ2AEOZ3PKT4VZQ43GZ X-Message-ID-Hash: P22VABEKAVR33FZ2AEOZ3PKT4VZQ43GZ X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --S92amm4kqi3pDX7d Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 23, 2023 at 12:23:50PM +0200, Paul Holzinger wrote: > When the open() or setns() calls fails pasta exits early and prints an > error. However it did not include the errno so it was impossible to know > why the syscall failed. >=20 > Signed-off-by: Paul Holzinger Reviewed-by: David Gibson > --- > pasta.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/pasta.c b/pasta.c > index 13ab18b..27809d2 100644 > --- a/pasta.c > +++ b/pasta.c > @@ -136,14 +136,14 @@ void pasta_open_ns(struct ctx *c, const char *netns) > =20 > nfd =3D open(netns, O_RDONLY | O_CLOEXEC); > if (nfd < 0) > - die("Couldn't open network namespace %s", netns); > + die("Couldn't open network namespace %s: %s", netns, strerror(errno)); > =20 > c->pasta_netns_fd =3D nfd; > =20 > NS_CALL(ns_check, c); > =20 > if (c->pasta_netns_fd < 0) > - die("Couldn't switch to pasta namespaces"); > + die("Couldn't switch to pasta namespaces: %s", strerror(errno)); > =20 > if (!c->no_netns_quit) { > char buf[PATH_MAX] =3D { 0 }; > @@ -261,7 +261,7 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t g= id, > =20 > NS_CALL(pasta_wait_for_ns, c); > if (c->pasta_netns_fd < 0) > - die("Failed to join network namespace"); > + die("Failed to join network namespace: %s", strerror(errno)); > } > =20 > /** --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --S92amm4kqi3pDX7d Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmSWTV4ACgkQzQJF27ox 2Ge4Eg/+LMnL3YZ/rNB1mx4oisjAr912MCctZKxiFYlQN8ln1m3vOS1U+BdKritR 90Gg3Y2bwe7xvvq2eEzNoapOnq1IxSDT7Sg5CaEJ2UpcmLdyAhljnKRasgYATJa1 KdavzCAdX3Ri4Z+eL4wP5cX9Vxsl63EiTFKkctRQkYwfmhp3K9w583uw3SfIatAu IpYDotdvpZl1uN0uvpgRyUvy/QgoTV9RUrjIAwksphYB/b+Cv2bPStT8XuWhM+UU KKycke14br1fC1KlBHjqihQi0DuG4kJuxWWcUEIjYaIRHkQrLEuAU02YRiL670CA nyXid8A8cd+B7aeVFwt1PB6/7MwaURcSoWaC7Y3lcpXdDs1nN8d+gfK7Ri1wc74C CkmhT5NrHx4xXL3IjZiKzumxX5KMSBR3DsGQRl9LVZNtApFK6/S5NHLKmFiBdZmy szzCO0XJfVTQ2F+aP5VS/ilee5puDnPHRzysGxwuADhkFGTPuhd+efpbmtpLTdFH XAIw48k8fWciHMdAOX9sto7u1WPTdUzqU8GwCbSZdO2FLW6GH59z16rUz9XxxXr9 OBTT6gs+/LevEQZ7t6yho2ZvEXR1025XstFpEg2FHLQdJG5OG7NRy8hSB7Aq1aZ5 LoFvIpqYBsHyHicP/u2Fdilr+VBUAVdsk/INw32ZrMNWsO9x5vU= =CJ92 -----END PGP SIGNATURE----- --S92amm4kqi3pDX7d--