From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1880AA00C4; Thu, 4 Jun 2020 23:07:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 57E731D603; Thu, 4 Jun 2020 23:07:20 +0200 (CEST) Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id 55AE11D9E for ; Thu, 4 Jun 2020 23:07:18 +0200 (CEST) Received: from 2606-a000-111b-4634-0000-0000-0000-1bf2.inf6.spectrum.com ([2606:a000:111b:4634::1bf2] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1jgx4u-0001oV-8Z; Thu, 04 Jun 2020 17:07:12 -0400 Date: Thu, 4 Jun 2020 17:07:07 -0400 From: Neil Horman To: Dmitry Kozlyuk Cc: dev@dpdk.org, Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , Thomas Monjalon , Anatoly Burakov , Bruce Richardson Message-ID: <20200604210707.GA789657@hmswarspite.think-freely.org> References: <20200525003720.6410-1-dmitry.kozliuk@gmail.com> <20200602230329.17838-1-dmitry.kozliuk@gmail.com> <20200602230329.17838-3-dmitry.kozliuk@gmail.com> <20200603120759.GA426574@hmswarspite.think-freely.org> <20200603153403.2e58ef90@sovereign> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200603153403.2e58ef90@sovereign> X-Spam-Score: -2.9 (--) X-Spam-Status: No Subject: Re: [dpdk-dev] [PATCH v6 02/11] eal: introduce internal wrappers for file operations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Jun 03, 2020 at 03:34:03PM +0300, Dmitry Kozlyuk wrote: > On Wed, 3 Jun 2020 08:07:59 -0400 > Neil Horman wrote: > > [snip] > > > +int > > > +eal_file_create(const char *path) > > > +{ > > > + int ret; > > > + > > > + ret = open(path, O_CREAT | O_RDWR, 0600); > > > + if (ret < 0) > > > + rte_errno = errno; > > > + > > > + return ret; > > > +} > > > + > > You don't need this call if you support the oflags option in the open call > > below. > > See below. > > > > +int > > > +eal_file_open(const char *path, bool writable) > > > +{ > > > + int ret, flags; > > > + > > > + flags = writable ? O_RDWR : O_RDONLY; > > > + ret = open(path, flags); > > > + if (ret < 0) > > > + rte_errno = errno; > > > + > > > + return ret; > > > +} > > > + > > why are you changing this api from the posix file format (with oflags > > specified). As far as I can see both unix and windows platforms support that > > There is a number of caveats, which IMO make this approach better: > > 1. Filesystem permissions on Windows are complicated. Supporting anything > other than 0600 would add a lot of code, while EAL doesn't really need it. > Microsoft's open() takes not permission bits, but a set of flags. > > 2. Restricted interface prevents EAL developers from accidentally using > features not supported on all platforms via a seemingly rich API. > > 3. Microsoft CRT (the one Clang is using) deprecates open() in favor of > _sopen_s() and issues a warning, and we're targeting -Werror. Disabling all > such warnings (_CRT_SECURE_NO_DEPRECATE) doesn't seem right when CRT vendor > encourages using alternatives. This is the primary reason for open() > wrappers in v6. > that seems a bit shortsighted to me. By creating wrappers that restrict functionality to the least common demoninator of supported platforms restricts what all platforms are capable of. For example, theres no reason that the eal library shouldn't be able to open a file O_TRUNC or O_SYNC just because its complex to do it on a single platform. The API should be written to support the full range of functionality on all platforms, and the individual implementations should write the code to make that happen, or return an error that its unsupported on this particular platform. I'm not saying that you have to implement everything now, but you shouldn't restrict the API from being able to do so in the future. Otherwise, in the future, if someone wants to implement O_TRUNC support (just to site an example), they're going to have to make a change to the API above, and alter the implementation for all the platforms anyway. You may as well make the API robust enough to support that now. Neil > -- > Dmitry Kozlyuk >