Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1698737pxy; Thu, 29 Apr 2021 12:27:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiy02b3hz1Z/V7jNlaSowqID7GYtVCzPJ1FA7ohB/yjjhguIo0dcccUVjP5KvjySnFEeYo X-Received: by 2002:a17:907:b16:: with SMTP id h22mr115133ejl.308.1619724419863; Thu, 29 Apr 2021 12:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619724419; cv=none; d=google.com; s=arc-20160816; b=BB6zuHdJ/QFSe2kZWPTzQBlo6yjKvMsB+yMgjp9LCqMoZGwVAklcUNJDhkBcNyyKcn 1Jeci5/t1w2Xk5yoqeTwESqIaoKb7fOSpmXcbQ+Y4hLTVe5fJ1dABsLy5bEOdBW5Akzo lM2c+yW32QEJqKPC0Ye8hBUTcwDM4kdWD/KcJBskKH8n10WT5AzOzSZYvlg8Hzxp/35j EJ9MSz7ED50hqou69Oa1fxIoDbfgxOgMF9VaUGx3JoTZNDmgqls3FdDKaA6Ne3sNSUPn I3DZE91JhoPzz9HzjANV2/cknSUA1Ftyk4yHI0PHyLEik8bPqlJ+is34HmAJLhFyRILR /ZUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=lneqwX+dzGZ1u826su0AXxbuk9GjDopbRrrh6SBJZ40=; b=D1hD0q77VlUM3hvFdd/splwiEwlhAZH6NLWZK48/vClsFfhjFiZ2g/y0TaTukwU93E 2/bZp5OnB0CXmWJ+cP2YtNtEE62ZzlObdq6R3lusaxJoide1biUPbfkuWFeKC8/kH87n fLCx31fkzxp1pPlF0A6UtV6FjdXCArpW8T1TbvR9jMEn0jLvdZCFwXEsg0mlUuY7ZFsu U7+YDyGKbzzOF/jI1vNSF+vrZgUnuOthTMSRfrHUvU+x0efYwO6md6JslbRGwbPbtyjG UY6HwcqJbN2uIwi4MEZ4191ybtSOT8mKkgLsSI+K9bki+e8pVq6Cgftv6ho0CdK9aNxU Bp1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ZIWCS7S/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs19si947770ejb.238.2021.04.29.12.26.35; Thu, 29 Apr 2021 12:26:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ZIWCS7S/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231631AbhD2TYs (ORCPT + 99 others); Thu, 29 Apr 2021 15:24:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234176AbhD2TUQ (ORCPT ); Thu, 29 Apr 2021 15:20:16 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46047C06138B; Thu, 29 Apr 2021 12:19:28 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id t18so10447261wry.1; Thu, 29 Apr 2021 12:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to; bh=lneqwX+dzGZ1u826su0AXxbuk9GjDopbRrrh6SBJZ40=; b=ZIWCS7S//pL+fNsSrNILgdQ/tFgW0YSqzLXiSmSWAmGAxDDikw/gf7EDKKXBZDIJ1X AtJ92G20fm+Q1UtXYfcIBK3KyQPIrEq5y5qWwyQv3fWKA388q4U00ympDThqFmZl3x0N hbJz8UBnkjICOp4Xr/qfeNZS9U5mW2rRjGVRkr48cUVRQ+kD6dNdRVRuTqIKEr+of4Uk fhgtKA5Vtu0d3bos/+wUWMWb7uo/kEDmngHEcvDXrNxXQ5ensae4GKCsBXzqWb8Y9H2B PwF8+4B7+d4DTEiDraFFtKUPq3ezYWsP1hw0f2qKP0pRsIE0L0t+GGfUMc2hEnDaF2lO GB5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to; bh=lneqwX+dzGZ1u826su0AXxbuk9GjDopbRrrh6SBJZ40=; b=XQDFXqbUIVVHbzb94cDqs4r28k5O3UHe6SAdC8fonpMKwv9ppU0UgSeWwZG5hEEnQz dgx3yG04CJvX+cfr4KfLX8eYQ07mVJ+2VbakRa4q+uLIWAze/P8h3lFUDTGj7AGg0z5A r8Hc7zLElf4kUfzoJwK9GAb/eDlW7MfsbqwYUfBwRpEDtZfd7+hvKXxzYgle7CFl8KC3 G9feWZfM8SDpxEgpBA3Id5wPbQM7J9brvcHHXWN16vwNzaf92Svi+BDuadqClx6PZHiZ LLtZL+pwFhVGQc6a941QBL7slZLq+qeoNlxparLAWsc3VPGaFb+UhtY2nHoIUw1sltYP iVrw== X-Gm-Message-State: AOAM531cNDY0EyRonPI+WMhDBDxv97fFEqXG9TW80hjgTaeM8eP+G68K iTSUOzH32CnpU2CwDF9CFePHqdYUSddmkw== X-Received: by 2002:adf:d0c9:: with SMTP id z9mr1449899wrh.175.1619723966995; Thu, 29 Apr 2021 12:19:26 -0700 (PDT) Received: from pevik ([62.201.25.198]) by smtp.gmail.com with ESMTPSA id y11sm1266901wmi.41.2021.04.29.12.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Apr 2021 12:19:26 -0700 (PDT) Date: Thu, 29 Apr 2021 21:19:24 +0200 From: Petr Vorel To: Heiko Thiery Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Hemminger Subject: Re: [PATCH] lib/fs: fix issue when {name, open}_to_handle_at() is not implemented Message-ID: Reply-To: Petr Vorel References: <20210422084612.26374-1-heiko.thiery@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210422084612.26374-1-heiko.thiery@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > With commit d5e6ee0dac64b64e the usage of functions name_to_handle_at() and > open_by_handle_at() are introduced. But these function are not available > e.g. in uclibc-ng < 1.0.35. To have a backward compatibility check for the > availability in the configure script and in case of absence do a direct > syscall. LGTM, thanks for implementing it. I'd consider to check only one of the functions (very unlikely only one will be supported). > Signed-off-by: Heiko Thiery > --- > configure | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > lib/fs.c | 25 ++++++++++++++++++++++++ > 2 files changed, 83 insertions(+) > diff --git a/configure b/configure > index 2c363d3b..f1be9977 100755 > --- a/configure > +++ b/configure > @@ -202,6 +202,58 @@ EOF > rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest > } > +check_name_to_handle_at() > +{ > + nit: empty line. > + cat >$TMPDIR/name_to_handle_at_test.c < +#include > +#include > +#include > +int main(int argc, char **argv) > +{ > + struct file_handle *fhp; > + int mount_id, flags, dirfd; > + char *pathname; > + name_to_handle_at(dirfd, pathname, fhp, &mount_id, flags); > + return 0; > +} > +EOF > + > + if $CC -I$INCLUDE -o $TMPDIR/name_to_handle_at_test $TMPDIR/name_to_handle_at_test.c >/dev/null 2>&1; then > + echo "IP_CONFIG_NAME_TO_HANDLE_AT:=y" >>$CONFIG > + echo "yes" > + echo "CFLAGS += -DHAVE_NAME_TO_HANDLE_AT" >>$CONFIG > + else > + echo "no" > + fi > + rm -f $TMPDIR/name_to_handle_at_test.c $TMPDIR/name_to_handle_at_test > +} > + > +check_open_by_handle_at() > +{ > + nit: empty line. > + cat >$TMPDIR/open_by_handle_at_test.c < +#include > +#include > +#include > +int main(int argc, char **argv) > +{ > + struct file_handle *fhp; > + int mount_fd; > + open_by_handle_at(mount_fd, fhp, O_RDONLY); > + return 0; > +} > +EOF > + if $CC -I$INCLUDE -o $TMPDIR/open_by_handle_at_test $TMPDIR/open_by_handle_at_test.c >/dev/null 2>&1; then > + echo "IP_CONFIG_OPEN_BY_HANDLE_AT:=y" >>$CONFIG > + echo "yes" > + echo "CFLAGS += -DHAVE_OPEN_BY_HANDLE_AT" >>$CONFIG > + else > + echo "no" > + fi > + rm -f $TMPDIR/open_by_handle_at_test.c $TMPDIR/open_by_handle_at_test > +} > + > check_ipset() > { > cat >$TMPDIR/ipsettest.c < @@ -492,6 +544,12 @@ fi > echo -n "libc has setns: " > check_setns > +echo -n "libc has name_to_handle_at: " > +check_name_to_handle_at > + > +echo -n "libc has open_by_handle_at: " > +check_open_by_handle_at > + > echo -n "SELinux support: " > check_selinux > diff --git a/lib/fs.c b/lib/fs.c > index ee0b130b..c561d85b 100644 > --- a/lib/fs.c > +++ b/lib/fs.c > @@ -30,6 +30,31 @@ > /* if not already mounted cgroup2 is mounted here for iproute2's use */ > #define MNT_CGRP2_PATH "/var/run/cgroup2" > + > +#if (!defined HAVE_NAME_TO_HANDLE_AT && !defined HAVE_OPEN_BY_HANDLE_AT) > +struct file_handle { > + unsigned handle_bytes; > + int handle_type; > + unsigned char f_handle[]; > +}; > +#endif > + > +#ifndef HAVE_NAME_TO_HANDLE_AT > +int name_to_handle_at(int dirfd, const char *pathname, > + struct file_handle *handle, int *mount_id, int flags) > +{ > + return syscall(name_to_handle_at, 5, dirfd, pathname, handle, > + mount_id, flags); > +} > +#endif > + > +#ifndef HAVE_OPEN_BY_HANDLE_AT > +int open_by_handle_at(int mount_fd, struct file_handle *handle, int flags) > +{ > + return syscall(open_by_handle_at, 3, mount_fd, handle, flags); > +} > +#endif > + > /* return mount path of first occurrence of given fstype */ > static char *find_fs_mount(const char *fs_to_find) > {