From patchwork Mon Feb 8 21:49:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1437933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=nsDwD/EV; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DZKT02Cttz9sRf for ; Tue, 9 Feb 2021 08:50:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A57D23950408; Mon, 8 Feb 2021 21:50:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A57D23950408 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1612821010; bh=/C+FoUgPYBLdYcvprsVUOgWSqNnHsjOWcWdrOarjPNo=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=nsDwD/EV2WHTkld7JNbRW9mq596ntvAGXL3aaPkfPxDEf7oYbH9nawaTWeijDbyub oI7O+1AW0REzMQCAjyB9/IvJb4C8nQznYC/qHUdTrYF+/7hBCs/Y8ihd5xxyrNjqUR NNhQXJ5r5DoJ1Uv1mmXw/XtNlARg1q03fsJPdDSY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by sourceware.org (Postfix) with ESMTPS id D7C32393C865 for ; Mon, 8 Feb 2021 21:50:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D7C32393C865 Received: by mail-qk1-x733.google.com with SMTP id u20so16080833qku.7 for ; Mon, 08 Feb 2021 13:50:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/C+FoUgPYBLdYcvprsVUOgWSqNnHsjOWcWdrOarjPNo=; b=s6onv+ZW4KjiCvnPcFIXbJmvszxezzQTzTSk+3qlAzqnMVP9McYSYGCOuVzW00rpFd avMYW+QB2qt2ga/exAXHFaaTNBQXAMyISx7Yos+hHZ9zhhtpO9rNdnjwygLvHDHGriwf tE3+elBh/EcQnVr8y8m49AkUNBPP3LcGGvqxraSn+cD0asTqs5Gehvr2RViO+owGTBAi clMq+/BFWg8kj2d2hlpK/aZgtdvNEUJOxOaQY1LpAnemfKEebGF9X3oqAN1cbEvMT+gv rshYrF7Rmlp5VmRSXwUdcQyOkIEz7BwFHfd2AjVjHH1GPp0y7obAEpr0i/2XqPRNGCny UsRA== X-Gm-Message-State: AOAM533fDB8E6PcvDsUS2O2A02KR3UWa9gknMOnTlRYdRpvs+ZXsXJj6 tglooezwcidzAlxZZDreDnrw8svtM2MCtw== X-Google-Smtp-Source: ABdhPJzYotpMt1IBexzuayQ97XyHD7Oeli1+Ns9so/Oy1GmO2gKUN7bGD4GbEdUtGBsSm+tx8XeM5g== X-Received: by 2002:a05:620a:10a2:: with SMTP id h2mr19128744qkk.463.1612821007249; Mon, 08 Feb 2021 13:50:07 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id e15sm12720078qtq.43.2021.02.08.13.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 13:50:06 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 07/10] linux: Consolidate statvfs implementations Date: Mon, 8 Feb 2021 18:49:33 -0300 Message-Id: <20210208214936.1502047-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210208214936.1502047-1-adhemerval.zanella@linaro.org> References: <20210208214936.1502047-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" There is no need to handle ENOSYS on fstatfs64 call, required only for alpha (where is already fallbacks to fstatfs). Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell --- include/sys/statvfs.h | 3 +- sysdeps/unix/sysv/linux/alpha/statvfs.c | 1 - sysdeps/unix/sysv/linux/alpha/statvfs64.c | 1 - sysdeps/unix/sysv/linux/statvfs.c | 9 ++-- sysdeps/unix/sysv/linux/statvfs64.c | 54 +++++++------------ sysdeps/unix/sysv/linux/wordsize-64/statvfs.c | 5 -- .../unix/sysv/linux/wordsize-64/statvfs64.c | 1 - 7 files changed, 26 insertions(+), 48 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/alpha/statvfs.c delete mode 100644 sysdeps/unix/sysv/linux/alpha/statvfs64.c delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statvfs.c delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h index 4cd1977c35..d7fe33119a 100644 --- a/include/sys/statvfs.h +++ b/include/sys/statvfs.h @@ -3,8 +3,7 @@ #ifndef _ISOMAC /* Now define the internal interfaces. */ -extern int __statvfs64 (const char *__file, struct statvfs64 *__buf) - attribute_hidden; +extern int __statvfs64 (const char *__file, struct statvfs64 *__buf); extern int __fstatvfs64 (int __fildes, struct statvfs64 *__buf) attribute_hidden; diff --git a/sysdeps/unix/sysv/linux/alpha/statvfs.c b/sysdeps/unix/sysv/linux/alpha/statvfs.c deleted file mode 100644 index 78069e96f4..0000000000 --- a/sysdeps/unix/sysv/linux/alpha/statvfs.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/alpha/statvfs64.c b/sysdeps/unix/sysv/linux/alpha/statvfs64.c deleted file mode 100644 index c80e17751d..0000000000 --- a/sysdeps/unix/sysv/linux/alpha/statvfs64.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/statvfs.c b/sysdeps/unix/sysv/linux/statvfs.c index 8895694e5d..f165899711 100644 --- a/sysdeps/unix/sysv/linux/statvfs.c +++ b/sysdeps/unix/sysv/linux/statvfs.c @@ -16,11 +16,13 @@ License along with the GNU C Library; if not, see . */ -#include -#include +#include #include -#include "internal_statvfs.h" +#include +#include +#include +#if !STATFS_IS_STATFS64 int __statvfs (const char *file, struct statvfs *buf) { @@ -38,3 +40,4 @@ __statvfs (const char *file, struct statvfs *buf) } weak_alias (__statvfs, statvfs) libc_hidden_weak (statvfs) +#endif diff --git a/sysdeps/unix/sysv/linux/statvfs64.c b/sysdeps/unix/sysv/linux/statvfs64.c index b03a88816c..3d29908afa 100644 --- a/sysdeps/unix/sysv/linux/statvfs64.c +++ b/sysdeps/unix/sysv/linux/statvfs64.c @@ -16,49 +16,33 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include -#include +#define __statvfs __statvfs_disable +#define statvfs statvfs_disable +#include #include -#include "internal_statvfs.h" -#include +#include +#include +#include /* Return information about the filesystem on which FILE resides. */ int __statvfs64 (const char *file, struct statvfs64 *buf) { struct statfs64 fsbuf; - int res = __statfs64 (file, &fsbuf); + if (__statfs64 (file, &fsbuf) < 0) + return -1; -#ifndef __ASSUME_STATFS64 - if (res < 0 && errno == ENOSYS) - { - struct statvfs buf32; + /* Convert the result. */ + __internal_statvfs64 (file, buf, &fsbuf, -1); - res = statvfs (file, &buf32); - if (res == 0) - { - buf->f_bsize = buf32.f_bsize; - buf->f_frsize = buf32.f_frsize; - buf->f_blocks = buf32.f_blocks; - buf->f_bfree = buf32.f_bfree; - buf->f_bavail = buf32.f_bavail; - buf->f_files = buf32.f_files; - buf->f_ffree = buf32.f_ffree; - buf->f_favail = buf32.f_favail; - buf->f_fsid = buf32.f_fsid; - buf->f_flag = buf32.f_flag; - buf->f_namemax = buf32.f_namemax; - memcpy (buf->__f_spare, buf32.__f_spare, sizeof (buf32.__f_spare)); - } - } -#endif - - if (res == 0) - /* Convert the result. */ - __internal_statvfs64 (file, buf, &fsbuf, -1); - - return res; + return 0; } weak_alias (__statvfs64, statvfs64) + +#undef __statvfs +#undef statvfs + +#if STATFS_IS_STATFS64 +weak_alias (__statvfs64, __statvfs) +weak_alias (__statvfs64, statvfs) +#endif diff --git a/sysdeps/unix/sysv/linux/wordsize-64/statvfs.c b/sysdeps/unix/sysv/linux/wordsize-64/statvfs.c deleted file mode 100644 index 1e1c96333b..0000000000 --- a/sysdeps/unix/sysv/linux/wordsize-64/statvfs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define __statvfs64(file, buf) __no_statvfs64(file, buf) -#define statvfs64(file, buf) no_statvfs64(file, buf) -#include "../statvfs.c" -strong_alias (__statvfs, __statvfs64) -weak_alias (__statvfs, statvfs64) diff --git a/sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c b/sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c deleted file mode 100644 index 510015e420..0000000000 --- a/sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c +++ /dev/null @@ -1 +0,0 @@ -/* statvfs64 is the same as statvfs. */