From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B28003856DE8 for ; Thu, 23 Jun 2022 09:29:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B28003856DE8 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-169-2n7SQ3m0MgSnH6ZrKfjqWg-1; Thu, 23 Jun 2022 05:29:35 -0400 X-MC-Unique: 2n7SQ3m0MgSnH6ZrKfjqWg-1 Received: by mail-ej1-f72.google.com with SMTP id qk8-20020a1709077f8800b00722fcbfdcf7so1232274ejc.2 for ; Thu, 23 Jun 2022 02:29:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wnMHnchliOYG8niBKJNKOyuJMy3+zQou0bIDgbjhtUo=; b=VReHTPwEZJmBcrlDR6eBQEimlBj7e6dnqlgRq+WHB0b5BlWdousiASOX6zonOuIbdz mRKRI4+NScQ5AO9Tt4yNGo47m+vTIcUt2pWNQpCDYaBA6zN1u3owYpm8eDxbUm/cqP6B KGpuSnVXopoz6HQWNEHf4m0RqRfPuUZTaUrP5PZdiEeqD0rVRQZmtHJ8VQsnoTATW4DW mq3z+tv+IcCoxsbXIiM7FvIGrALdRQYbJgy0/23HSsxX3DlH2zotlo/stJ2Pm5ljSbx1 mgMH0D8haQ8vznSBun3EY4uglx1mdIk2MICzq02lFXPgSH99gXL6180e8EQQusEemKxr cbnA== X-Gm-Message-State: AJIora/WGQ6UPiYtgiNNxiOtgtiladdOabCmLllNOcNZqj+5Y8DWkzbl UXfSvcF+PfsuPcXvrIKsR9plO+3fH9nGZCpwopjiWN1tKUfKna3XV64d7ItPkbdn57NQC0BOC/P PiQ9HzxPfUTlfLeJ6b45NBXwT5IBKUvk= X-Received: by 2002:a17:906:65c8:b0:713:ee3e:254d with SMTP id z8-20020a17090665c800b00713ee3e254dmr7410316ejn.0.1655976574650; Thu, 23 Jun 2022 02:29:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tX1qeB9X46Sdr4vrErxn+Mj3TjFeAwdW1pNEi+4MMQFBXjFnrmIbBK5odRBzujiAVe6yuzdP0tzgVRFFrSSDs= X-Received: by 2002:a17:906:65c8:b0:713:ee3e:254d with SMTP id z8-20020a17090665c800b00713ee3e254dmr7410307ejn.0.1655976574503; Thu, 23 Jun 2022 02:29:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Thu, 23 Jun 2022 10:29:23 +0100 Message-ID: Subject: Re: [PATCH] libstdc++-v3: check for openat To: Alexandre Oliva Cc: gcc Patches , "libstdc++" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2022 09:29:39 -0000 On Thu, 23 Jun 2022 at 05:41, Alexandre Oliva wrote: > > On Jun 22, 2022, Jonathan Wakely wrote: > > > Otherwise, if rterms defines HAVE_DIRFD this function will return a > > file descriptor and a filename (not a full path) but then > > _Dir_base::openat doesn't use ::openat and so ignores the file > > descriptor, and needs a full path. > > Yuck. It does. This may explain some of the fails I've observed and > not looked into yet. Yes, that's what I was thinking too. > How about introducing an internal wrapper class that can hold a ref to > base path or an fd for a dir, or an iterator that could resolve to > either, and that can be passed around instead of a dirfd that assumes > openat, enabling uses of openat where available and falling back to > paths otherwise? I don't have much of a sense of all the uses involved, > but given the AFAICT impossibility of turning a dirfd into a pathname > (even in non-pathological cases of removed or out-of-chroot dirfds), > ISTM this wrapper class could demand base paths or CWD in the > !HAVE_OPENAT case, and enable both uses otherwise, offering some > additional type safety that the current abstraction doesn't. > > Does that make sense to you? I don't think that quite works. I think what we want is more like: struct multipath /* need better name */ { int fd; const char* filename; const char* pathname; }; I already prototyped something like this, let me finish it off and send the patch.