From nobody Thu May 16 03:11:32 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1710408953188905.9734056648095; Thu, 14 Mar 2024 02:35:53 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DB70981E; Thu, 14 Mar 2024 05:35:51 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8FB631B76; Thu, 14 Mar 2024 05:34:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6BC9F1AC3; Thu, 14 Mar 2024 05:34:33 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0264B1ADA for ; Thu, 14 Mar 2024 05:34:32 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-uVDlFsWtPiuKTs-HUwVlbA-1; Thu, 14 Mar 2024 05:34:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D07A11C02D35 for ; Thu, 14 Mar 2024 09:34:30 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 782832166B4F for ; Thu, 14 Mar 2024 09:34:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: uVDlFsWtPiuKTs-HUwVlbA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/2] virusbmock: Switch to VIR_MOCK_REAL_INIT() Date: Thu, 14 Mar 2024 10:34:27 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: OC3PBQWND7T75XQQ3CZZO6LQI7EB7CZW X-Message-ID-Hash: OC3PBQWND7T75XQQ3CZZO6LQI7EB7CZW X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1710408953426100001 Since virusbmock was written 10 years ago, back when we didn't have virmock.h and its helpers, it open codes symbol resolution (VIR_MOCK_REAL_INIT). With a bit of cleanup (e.g. renaming realopen to real_open and so on) it can use virmock.h provided macros. And while at it, drop include of virusb.h - there is no compelling reason for it include the file. The mock just redirects paths passed to open()/opendir(). Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina --- tests/virusbmock.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/virusbmock.c b/tests/virusbmock.c index 971d98aa9a..570f7c28eb 100644 --- a/tests/virusbmock.c +++ b/tests/virusbmock.c @@ -24,25 +24,21 @@ #include #include =20 -#include "virusb.h" +#include "virmock.h" =20 #define USB_SYSFS "/sys/bus/usb" #define FAKE_USB_SYSFS "virusbtestdata/sys_bus_usb" =20 -static int (*realopen)(const char *pathname, int flags, ...); -static DIR *(*realopendir)(const char *name); +static int (*real_open)(const char *pathname, int flags, ...); +static DIR *(*real_opendir)(const char *name); =20 static void init_syms(void) { - if (realopen) + if (real_open) return; =20 - realopen =3D dlsym(RTLD_NEXT, "open"); - realopendir =3D dlsym(RTLD_NEXT, "opendir"); - if (!realopen || !realopendir) { - fprintf(stderr, "Error getting symbols"); - abort(); - } + VIR_MOCK_REAL_INIT(open); + VIR_MOCK_REAL_INIT(opendir); } =20 static char *get_fake_path(const char *real_path) @@ -66,7 +62,7 @@ DIR *opendir(const char *name) =20 path =3D get_fake_path(name); =20 - return realopendir(path); + return real_opendir(path); } =20 int open(const char *pathname, int flags, ...) @@ -91,6 +87,6 @@ int open(const char *pathname, int flags, ...) va_end(ap); } =20 - ret =3D realopen(path, flags, mode); + ret =3D real_open(path, flags, mode); return ret; } --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 16 03:11:32 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1710409031243684.019395783801; Thu, 14 Mar 2024 02:37:11 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F3EBA1122; Thu, 14 Mar 2024 05:37:09 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3E38518A9; Thu, 14 Mar 2024 05:34:42 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 303981ADA; Thu, 14 Mar 2024 05:34:35 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id BC8961A6A for ; Thu, 14 Mar 2024 05:34:33 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-41-9PYLWJZDPbGjaMhMwsxhzA-1; Thu, 14 Mar 2024 05:34:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8607B81A261 for ; Thu, 14 Mar 2024 09:34:31 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11F282166B4F for ; Thu, 14 Mar 2024 09:34:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 9PYLWJZDPbGjaMhMwsxhzA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 2/2] tests: mock __open_2() Date: Thu, 14 Mar 2024 10:34:28 +0100 Message-ID: <0cc071384ff5a8b66e8a351ed618069c7a196d4e.1710408049.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 4YOMNPBTY6B26AB7IOW4FXFB4KIUNYAQ X-Message-ID-Hash: 4YOMNPBTY6B26AB7IOW4FXFB4KIUNYAQ X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1710409031702100001 As of commit [1] glibc may overwrite a call to open() with call to __open_2() (if only two arguments are provided and the code is compiled with clang). But since we are not mocking the latter our test suite is broken as tests try to access paths outside of our repo. 1: https://sourceware.org/git/?p=3Dglibc.git;a=3Dcommit;h=3D86889e22db329ab= ac618c6a41f86c84657a15324 Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina --- meson.build | 13 +++++++++++++ tests/nssmock.c | 26 +++++++++++++++++++++++++ tests/qemusecuritymock.c | 24 +++++++++++++++++++++++ tests/vircgroupmock.c | 42 ++++++++++++++++++++++++++++++++++++++++ tests/virfilewrapper.c | 18 +++++++++++++++++ tests/virmock.h | 4 ++++ tests/virpcimock.c | 17 ++++++---------- tests/virtestmock.c | 20 +++++++++++++++++++ tests/virusbmock.c | 22 +++++++++++++++++++++ 9 files changed, 175 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 9842886bbb..b1b55b0d25 100644 --- a/meson.build +++ b/meson.build @@ -604,6 +604,12 @@ stat_functions =3D [ =20 functions +=3D stat_functions =20 +open_functions =3D [ + '__open_2', +] + +functions +=3D open_functions + foreach function : functions if cc.has_function(function) conf.set('WITH_@0@'.format(function.to_upper()), 1) @@ -618,6 +624,13 @@ foreach function : stat_functions endforeach =20 =20 +foreach function : open_functions + if cc.has_header_symbol('fcntl.h', function) + conf.set('WITH_@0@_DECL'.format(function.to_upper()), 1) + endif +endforeach + + # various header checks =20 headers =3D [ diff --git a/tests/nssmock.c b/tests/nssmock.c index 9ead6d8f97..3493119f3b 100644 --- a/tests/nssmock.c +++ b/tests/nssmock.c @@ -29,6 +29,9 @@ # include "configmake.h" =20 static int (*real_open)(const char *path, int flags, ...); +# if WITH___OPEN_2 +static int (*real___open_2)(const char *path, int flags); +# endif static DIR * (*real_opendir)(const char *name); static int (*real_access)(const char *path, int mode); =20 @@ -44,6 +47,9 @@ init_syms(void) return; =20 VIR_MOCK_REAL_INIT(open); +# if WITH___OPEN_2 + VIR_MOCK_REAL_INIT(__open_2); +# endif VIR_MOCK_REAL_INIT(opendir); VIR_MOCK_REAL_INIT(access); } @@ -90,6 +96,26 @@ open(const char *path, int flags, ...) return ret; } =20 +# if WITH___OPEN_2 +int +__open_2(const char *path, int flags) +{ + int ret; + char *newpath =3D NULL; + + init_syms(); + + if (STRPREFIX(path, LEASEDIR) && + getrealpath(&newpath, path) < 0) + return -1; + + ret =3D real___open_2(newpath ? newpath : path, flags); + + free(newpath); + return ret; +} +# endif + DIR * opendir(const char *path) { diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c index a6f9d6b917..80d59536b1 100644 --- a/tests/qemusecuritymock.c +++ b/tests/qemusecuritymock.c @@ -58,6 +58,9 @@ =20 static int (*real_chown)(const char *path, uid_t uid, gid_t gid); static int (*real_open)(const char *path, int flags, ...); +#if WITH___OPEN_2 +static int (*real___open_2)(const char *path, int flags); +#endif static int (*real_close)(int fd); #ifdef WITH_SELINUX static int (*real_setfilecon_raw)(const char *path, const char *context); @@ -112,6 +115,9 @@ init_syms(void) =20 VIR_MOCK_REAL_INIT(chown); VIR_MOCK_REAL_INIT(open); +#if WITH___OPEN_2 + VIR_MOCK_REAL_INIT(__open_2); +#endif VIR_MOCK_REAL_INIT(close); #ifdef WITH_SELINUX VIR_MOCK_REAL_INIT(setfilecon_raw); @@ -324,6 +330,24 @@ open(const char *path, int flags, ...) } =20 =20 +#if WITH___OPEN_2 +int +__open_2(const char *path, int flags) +{ + int ret; + + init_syms(); + + if (getenv(ENVVAR)) { + ret =3D 42; /* Some dummy FD */ + } else { + ret =3D real___open_2(path, flags); + } + + return ret; +} +#endif + int close(int fd) { diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c index 777d60b152..d922f30f34 100644 --- a/tests/vircgroupmock.c +++ b/tests/vircgroupmock.c @@ -30,6 +30,9 @@ # include "vircgroupv2devices.h" =20 static int (*real_open)(const char *path, int flags, ...); +# if WITH___OPEN_2 +static int (*real___open_2)(const char *path, int flags); +# endif static FILE *(*real_fopen)(const char *path, const char *mode); static int (*real_access)(const char *path, int mode); static int (*real_mkdir)(const char *path, mode_t mode); @@ -302,6 +305,9 @@ static void init_syms(void) VIR_MOCK_REAL_INIT(access); VIR_MOCK_REAL_INIT(mkdir); VIR_MOCK_REAL_INIT(open); +# if WITH___OPEN_2 + VIR_MOCK_REAL_INIT(__open_2); +# endif } =20 =20 @@ -589,6 +595,42 @@ int open(const char *path, int flags, ...) return ret; } =20 +# if WITH___OPEN_2 +int +__open_2(const char *path, int flags) +{ + int ret; + char *newpath =3D NULL; + + init_syms(); + + if (STREQ(path, SYSFS_CPU_PRESENT)) { + init_sysfs(); + if (asprintf(&newpath, "%s/%s", + fakesysfscgroupdir, + SYSFS_CPU_PRESENT_MOCKED) < 0) { + errno =3D ENOMEM; + return -1; + } + } + + if (STRPREFIX(path, SYSFS_CGROUP_PREFIX)) { + init_sysfs(); + if (asprintf(&newpath, "%s%s", + fakesysfscgroupdir, + path + strlen(SYSFS_CGROUP_PREFIX)) < 0) { + errno =3D ENOMEM; + return -1; + } + } + + ret =3D real___open_2(newpath ? newpath : path, flags); + + free(newpath); + return ret; +} +# endif + bool virCgroupV2DevicesAvailable(virCgroup *group G_GNUC_UNUSED) { diff --git a/tests/virfilewrapper.c b/tests/virfilewrapper.c index 9cdfcfdc3f..908f7142c2 100644 --- a/tests/virfilewrapper.c +++ b/tests/virfilewrapper.c @@ -38,6 +38,9 @@ static const char **prefixes; =20 /* TODO: callbacks */ static int (*real_open)(const char *path, int flags, ...); +# if WITH___OPEN_2 +static int (*real___open_2)(const char *path, int flags); +# endif static FILE *(*real_fopen)(const char *path, const char *mode); static int (*real_access)(const char *path, int mode); static int (*real_mkdir)(const char *path, mode_t mode); @@ -54,6 +57,9 @@ static void init_syms(void) VIR_MOCK_REAL_INIT(access); VIR_MOCK_REAL_INIT(mkdir); VIR_MOCK_REAL_INIT(open); +# if WITH___OPEN_2 + VIR_MOCK_REAL_INIT(__open_2); +# endif # if defined(__APPLE__) && defined(__x86_64__) VIR_MOCK_REAL_INIT_ALIASED(opendir, "opendir$INODE64"); # else @@ -176,6 +182,18 @@ int open(const char *path, int flags, ...) return real_open(newpath ? newpath : path, flags, mode); } =20 +# if WITH___OPEN_2 +int +__open_2(const char *path, int flags) +{ + g_autofree char *newpath =3D NULL; + + PATH_OVERRIDE(newpath, path); + + return real___open_2(newpath ? newpath : path, flags); +} +# endif + DIR *opendir(const char *path) { g_autofree char *newpath =3D NULL; diff --git a/tests/virmock.h b/tests/virmock.h index 300ba17174..178d0a15f0 100644 --- a/tests/virmock.h +++ b/tests/virmock.h @@ -27,6 +27,10 @@ =20 #include "internal.h" =20 +#ifndef WITH___OPEN_2_DECL +int __open_2 (const char *__path, int __oflag); +#endif + #define VIR_MOCK_COUNT_ARGS(...) VIR_MOCK_ARG27(__VA_ARGS__, 26, 25, 24, 2= 3, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,= 2, 1) #define VIR_MOCK_ARG27(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, = _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, = ...) _27 #define VIR_MOCK_ARG_PASTE(a, b, ...) a##b(__VA_ARGS__) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 2f98b0cf13..5b923c63ce 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -36,9 +36,9 @@ =20 static int (*real_access)(const char *path, int mode); static int (*real_open)(const char *path, int flags, ...); -# ifdef __GLIBC__ +# if WITH___OPEN_2 static int (*real___open_2)(const char *path, int flags); -# endif /* ! __GLIBC__ */ +# endif /* ! WITH___OPEN_2 */ static int (*real_close)(int fd); static DIR * (*real_opendir)(const char *name); static char *(*real_virFileCanonicalizePath)(const char *path); @@ -945,9 +945,9 @@ init_syms(void) =20 VIR_MOCK_REAL_INIT(access); VIR_MOCK_REAL_INIT(open); -# ifdef __GLIBC__ +# if WITH___OPEN_2 VIR_MOCK_REAL_INIT(__open_2); -# endif /* ! __GLIBC__ */ +# endif /* WITH___OPEN_2 */ VIR_MOCK_REAL_INIT(close); # if defined(__APPLE__) && defined(__x86_64__) VIR_MOCK_REAL_INIT_ALIASED(opendir, "opendir$INODE64"); @@ -1110,12 +1110,7 @@ open(const char *path, int flags, ...) } =20 =20 -# ifdef __GLIBC__ -/* in some cases this function may not be present in headers, so we need - * a declaration to silence the compiler */ -int -__open_2(const char *path, int flags); - +# if WITH___OPEN_2 int __open_2(const char *path, int flags) { @@ -1139,7 +1134,7 @@ __open_2(const char *path, int flags) =20 return ret; } -# endif /* ! __GLIBC__ */ +# endif /* WITH___OPEN_2 */ =20 DIR * opendir(const char *path) diff --git a/tests/virtestmock.c b/tests/virtestmock.c index 19559aee7a..5b25b380e5 100644 --- a/tests/virtestmock.c +++ b/tests/virtestmock.c @@ -29,6 +29,9 @@ #include "virfile.h" =20 static int (*real_open)(const char *path, int flags, ...); +#if WITH___OPEN_2 +static int (*real___open_2)(const char *path, int flags); +#endif static FILE *(*real_fopen)(const char *path, const char *mode); static int (*real_access)(const char *path, int mode); static int (*real_connect)(int fd, const struct sockaddr *addr, socklen_t = addrlen); @@ -44,6 +47,9 @@ static void init_syms(void) return; =20 VIR_MOCK_REAL_INIT(open); +#if WITH___OPEN_2 + VIR_MOCK_REAL_INIT(__open_2); +#endif VIR_MOCK_REAL_INIT(fopen); VIR_MOCK_REAL_INIT(access); VIR_MOCK_REAL_INIT(connect); @@ -153,6 +159,20 @@ int open(const char *path, int flags, ...) return ret; } =20 + +#if WITH___OPEN_2 +int +__open_2(const char *path, int flags) +{ + init_syms(); + + CHECK_PATH(path); + + return real___open_2(path, flags); +} +#endif + + FILE *fopen(const char *path, const char *mode) { init_syms(); diff --git a/tests/virusbmock.c b/tests/virusbmock.c index 570f7c28eb..e148296b7c 100644 --- a/tests/virusbmock.c +++ b/tests/virusbmock.c @@ -30,6 +30,9 @@ #define FAKE_USB_SYSFS "virusbtestdata/sys_bus_usb" =20 static int (*real_open)(const char *pathname, int flags, ...); +#if WITH___OPEN_2 +static int (*real___open_2)(const char *path, int flags); +#endif static DIR *(*real_opendir)(const char *name); =20 static void init_syms(void) @@ -38,6 +41,9 @@ static void init_syms(void) return; =20 VIR_MOCK_REAL_INIT(open); +#if WITH___OPEN_2 + VIR_MOCK_REAL_INIT(__open_2); +#endif VIR_MOCK_REAL_INIT(opendir); } =20 @@ -90,3 +96,19 @@ int open(const char *pathname, int flags, ...) ret =3D real_open(path, flags, mode); return ret; } + +#if WITH___OPEN_2 +int +__open_2(const char *pathname, int flags) +{ + g_autofree char *path =3D NULL; + + init_syms(); + + path =3D get_fake_path(pathname); + if (!path) + return -1; + + return real_open(path, flags); +} +#endif --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org