From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Dmitry V. Levin" Subject: Re: [PATCH 2/4] drm: Add dispatcher and driver identification for DRM Date: Wed, 10 Jun 2015 02:10:34 +0300 Message-ID: <20150609231034.GE3210@altlinux.org> References: <1433849204-4125-1-git-send-email-patrik.jakobsson@linux.intel.com> <1433849204-4125-3-git-send-email-patrik.jakobsson@linux.intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1600599337==" Return-path: Received: from pegasus3.altlinux.org (pegasus3.altlinux.org [194.107.17.103]) by gabe.freedesktop.org (Postfix) with ESMTP id 41B9C6E410 for ; Tue, 9 Jun 2015 16:10:35 -0700 (PDT) In-Reply-To: <1433849204-4125-3-git-send-email-patrik.jakobsson@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Patrik Jakobsson Cc: intel-gfx@lists.freedesktop.org, strace-devel@lists.sourceforge.net List-Id: intel-gfx@lists.freedesktop.org --===============1600599337== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="xJK8B5Wah2CMJs8h" Content-Disposition: inline --xJK8B5Wah2CMJs8h Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 09, 2015 at 01:26:42PM +0200, Patrik Jakobsson wrote: [...] > +static int drm_get_driver_name(struct tcb *tcp, char *name, size_t bufsi= ze) > +{ > + char path[PATH_MAX]; > + char link[PATH_MAX]; > + int ret; > + > + ret =3D getfdpath(tcp, tcp->u_arg[0], path, PATH_MAX - 1); > + if (!ret) > + return ret; The return code of getfdpath() is essentially the return code of readlink(), so the check should be the same as after readlink() below. > + > + snprintf(link, PATH_MAX, "/sys/class/drm/%s/device/driver", > + basename(path)); > + > + ret =3D readlink(link, path, PATH_MAX - 1); > + if (ret < 0) > + return ret; > + > + path[ret] =3D '\0'; > + strncpy(name, basename(path), bufsize); > + > + return 0; > +} --=20 ldv --xJK8B5Wah2CMJs8h Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlV3cmoACgkQfKvmrJ41Nh5lmQCguwB5urqedIQnomtJR7TKVz1C iMoAn3o3snttSe9C9QRZmZAYEZ+rUvDu =OltZ -----END PGP SIGNATURE----- --xJK8B5Wah2CMJs8h-- --===============1600599337== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9pbnRlbC1nZngK --===============1600599337==--