From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by sourceware.org (Postfix) with ESMTPS id AD7B53857808 for ; Thu, 17 Jun 2021 11:08:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AD7B53857808 Received: by mail-qk1-x72a.google.com with SMTP id f70so2615096qke.13 for ; Thu, 17 Jun 2021 04:08:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Zwihc1QFkwkqgsqIJIFjH5HLJMGWQZG+Nb8b8s0xB5E=; b=MS5ZsO7Ov2snTPCmiLNNZ9pX+dShkokSjYyBGxQGBhf4zl5zvDU2s70xOLPJpDuRT6 joSkKGrccbxemePKPrCd7Y9scPszSYuXSgsbhp4GUT3tagHpDTs0K5DjAVT2dYMFar+G GBabwT7C6BgvYIkhEohciFh7JQpdXA6tMPM3MmWfUJez/pVpKf8FwKo0o7hXvlBluoKw v5onMeKNu+dSG4O/utNEe+9Xf1Z1PGtQUK1xGI2q2rHKCulu91JQFeCsDSmSmHm9QxPw mA/O0uxJBlpClPpDstcBAexnwocIer7xVg9obP6Vpo9f//n0EwzfL0ZKdM/dU22AEXoH L6tQ== X-Gm-Message-State: AOAM5323WS0dn36kmMnnWbDy2IJtCM6ub0KpQIOI5wcM/4nG0eU6kIgz z+eiL3D6ryOX0ZjzuC6pL7n6rxXEgBkYJQ== X-Google-Smtp-Source: ABdhPJzSVg06IcMzpPugJ9Q8C+zBda7QtgKE82amJUnAXTO+FN7kP/gfiDpCYVczYASRyusHRw9gpg== X-Received: by 2002:a05:620a:1249:: with SMTP id a9mr3191106qkl.114.1623928109100; Thu, 17 Jun 2021 04:08:29 -0700 (PDT) Received: from [192.168.1.4] ([177.194.59.218]) by smtp.gmail.com with ESMTPSA id v16sm1471404qkj.10.2021.06.17.04.08.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Jun 2021 04:08:28 -0700 (PDT) Subject: Re: [PATCH 03/35] rt: Replace generic stub of shm_open with the posix version To: Florian Weimer , libc-alpha@sourceware.org References: From: Adhemerval Zanella Message-ID: <3bcb1e4c-7490-5fef-143a-3a6311c05f35@linaro.org> Date: Thu, 17 Jun 2021 08:08:26 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, 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-List-Received-Date: Thu, 17 Jun 2021 11:08:31 -0000 On 03/06/2021 20:15, Florian Weimer via Libc-alpha wrote: > Result of: git mv -f sysdeps/posix/shm_open.c rt > and manual removal of the _POSIX_MAPPED_FILES preprocessor condition. LGTM, thanks. Reviewed-by: Adhemerval Zanella > --- > rt/shm_open.c | 34 ++++++++++++++++++---- > sysdeps/posix/shm_open.c | 62 ---------------------------------------- > 2 files changed, 29 insertions(+), 67 deletions(-) > delete mode 100644 sysdeps/posix/shm_open.c > > diff --git a/rt/shm_open.c b/rt/shm_open.c > index e2bd25978a..a89aac4102 100644 > --- a/rt/shm_open.c > +++ b/rt/shm_open.c > @@ -1,4 +1,5 @@ > -/* Copyright (C) 2000-2021 Free Software Foundation, Inc. > +/* shm_open -- open a POSIX shared memory object. Generic POSIX file version. > + Copyright (C) 2001-2021 Free Software Foundation, Inc. > This file is part of the GNU C Library. > > The GNU C Library is free software; you can redistribute it and/or > @@ -16,13 +17,36 @@ > . */ > > #include > -#include > +#include > +#include > +#include > +#include > > /* Open shared memory object. */ > int > shm_open (const char *name, int oflag, mode_t mode) > { > - __set_errno (ENOSYS); > - return -1; > + struct shmdir_name dirname; > + if (__shm_get_name (&dirname, name, false) != 0) > + { > + __set_errno (EINVAL); > + return -1; > + } > + > + oflag |= O_NOFOLLOW | O_CLOEXEC; > + > + /* Disable asynchronous cancellation. */ > + int state; > + pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state); > + > + int fd = open (dirname.name, oflag, mode); > + if (fd == -1 && __glibc_unlikely (errno == EISDIR)) > + /* It might be better to fold this error with EINVAL since > + directory names are just another example for unsuitable shared > + object names and the standard does not mention EISDIR. */ > + __set_errno (EINVAL); > + > + pthread_setcancelstate (state, NULL); > + > + return fd; > } > -stub_warning (shm_open) > diff --git a/sysdeps/posix/shm_open.c b/sysdeps/posix/shm_open.c > deleted file mode 100644 > index 1817c52f7f..0000000000 > --- a/sysdeps/posix/shm_open.c > +++ /dev/null > @@ -1,62 +0,0 @@ > -/* shm_open -- open a POSIX shared memory object. Generic POSIX file version. > - Copyright (C) 2001-2021 Free Software Foundation, Inc. > - This file is part of the GNU C Library. > - > - The GNU C Library is free software; you can redistribute it and/or > - modify it under the terms of the GNU Lesser General Public > - License as published by the Free Software Foundation; either > - version 2.1 of the License, or (at your option) any later version. > - > - The GNU C Library is distributed in the hope that it will be useful, > - but WITHOUT ANY WARRANTY; without even the implied warranty of > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - Lesser General Public License for more details. > - > - You should have received a copy of the GNU Lesser General Public > - License along with the GNU C Library; if not, see > - . */ > - > -#include > - > -#if ! _POSIX_MAPPED_FILES > - > -# include > - > -#else > - > -# include > -# include > -# include > -# include > - > - > -/* Open shared memory object. */ > -int > -shm_open (const char *name, int oflag, mode_t mode) > -{ > - struct shmdir_name dirname; > - if (__shm_get_name (&dirname, name, false) != 0) > - { > - __set_errno (EINVAL); > - return -1; > - } > - > - oflag |= O_NOFOLLOW | O_CLOEXEC; > - > - /* Disable asynchronous cancellation. */ > - int state; > - pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state); > - > - int fd = open (dirname.name, oflag, mode); > - if (fd == -1 && __glibc_unlikely (errno == EISDIR)) > - /* It might be better to fold this error with EINVAL since > - directory names are just another example for unsuitable shared > - object names and the standard does not mention EISDIR. */ > - __set_errno (EINVAL); > - > - pthread_setcancelstate (state, NULL); > - > - return fd; > -} > - > -#endif /* _POSIX_MAPPED_FILES */ >