From nobody Thu May 15 03:26:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1515077918023799.2025664610625; Thu, 4 Jan 2018 06:58:38 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A57D38B12C; Thu, 4 Jan 2018 14:58:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FDBA609A8; Thu, 4 Jan 2018 14:58:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4A9BC3FAE3; Thu, 4 Jan 2018 14:58:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w04EwRhd026570 for ; Thu, 4 Jan 2018 09:58:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 101D9608F5; Thu, 4 Jan 2018 14:58:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7D6060C23 for ; Thu, 4 Jan 2018 14:58:23 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B094D100096; Thu, 4 Jan 2018 15:58:21 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 4 Jan 2018 15:58:08 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/5] util: add virFileReadHeaderQuiet wrapper around virFileReadHeaderFD X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 04 Jan 2018 14:58:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Signed-off-by: Paolo Bonzini Signed-off-by: Jiri Denemark --- src/libvirt_private.syms | 1 + src/util/virfile.c | 19 +++++++++++++++++++ src/util/virfile.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6662c8dac1..8d583e3e74 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1760,6 +1760,7 @@ virFileReadAll; virFileReadAllQuiet; virFileReadBufQuiet; virFileReadHeaderFD; +virFileReadHeaderQuiet; virFileReadLimFD; virFileReadLink; virFileReadValueBitmap; diff --git a/src/util/virfile.c b/src/util/virfile.c index 82cb36dbca..5e9bd2007a 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1367,6 +1367,25 @@ virFileReadHeaderFD(int fd, int maxlen, char **buf) } =20 =20 +int +virFileReadHeaderQuiet(const char *path, + int maxlen, + char **buf) +{ + int fd; + int len; + + fd =3D open(path, O_RDONLY); + if (fd < 0) + return -1; + + len =3D virFileReadHeaderFD(fd, maxlen, buf); + VIR_FORCE_CLOSE(fd); + + return len; +} + + /* A wrapper around saferead_lim that maps a failure due to exceeding the maximum size limitation to EOVERFLOW. */ int diff --git a/src/util/virfile.h b/src/util/virfile.h index b9b6b3c223..cd2a3867c2 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -131,6 +131,8 @@ int virFileDeleteTree(const char *dir); =20 int virFileReadHeaderFD(int fd, int maxlen, char **buf) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(3); +int virFileReadHeaderQuiet(const char *path, int maxlen, char **buf) + ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); int virFileReadLimFD(int fd, int maxlen, char **buf) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(3); int virFileReadAll(const char *path, int maxlen, char **buf) --=20 2.15.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list