linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Eryu Guan <guan@eryu.me>
Cc: Eryu Guan <guaneryu@gmail.com>, Icenowy Zheng <icenowy@aosc.io>,
	Chengguang Xu <cgxu519@mykernel.net>,
	Xiao Yang <yangx.jy@cn.fujitsu.com>,
	Miklos Szeredi <miklos@szeredi.hu>,
	overlayfs <linux-unionfs@vger.kernel.org>,
	fstests <fstests@vger.kernel.org>
Subject: Re: [PATCH 2/4] src/t_immutable: factor out some helpers
Date: Sun, 24 Jan 2021 17:29:33 +0200	[thread overview]
Message-ID: <CAOQ4uxgohiok+9FUG_Xw0NWpDczBD1Gn2ApWMiuhB-O6=Tterw@mail.gmail.com> (raw)
In-Reply-To: <20210124150918.GB2350@desktop>

On Sun, Jan 24, 2021 at 5:09 PM Eryu Guan <guan@eryu.me> wrote:
>
> On Sat, Jan 16, 2021 at 06:56:17PM +0200, Amir Goldstein wrote:
> > Reduce boilerplate code.
> > define _GNU_SOURCE needed for asprintf.
> >
> > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > ---
> >  src/t_immutable.c | 221 ++++++++++++++++++++++------------------------
> >  1 file changed, 104 insertions(+), 117 deletions(-)
> >
> > diff --git a/src/t_immutable.c b/src/t_immutable.c
> > index 86c567ed..b6a76af0 100644
> > --- a/src/t_immutable.c
> > +++ b/src/t_immutable.c
> > @@ -8,6 +8,9 @@
> >
> >  #define TEST_UTIME
> >
> > +#ifndef _GNU_SOURCE
> > +#define _GNU_SOURCE
> > +#endif
> >  #include <stdio.h>
> >  #include <stdlib.h>
> >  #include <string.h>
> > @@ -1895,13 +1898,66 @@ static int check_test_area(const char *dir)
> >       return 0;
> >  }
> >
> > +static int create_dir(char **ppath, const char *fmt, const char *dir)
> > +{
> > +     const char *path;
> > +     struct stat st;
> > +
> > +     if (asprintf(ppath, fmt, dir) == -1) {
> > +       return -1;
> > +     }
> > +     path = *ppath;
> > +     if (stat(path, &st) == 0) {
> > +       fprintf(stderr, "%s: Test area directory %s must not exist for test area creation.\n",
> > +               __progname, path);
> > +       return 1;
>
> Other places return -1 but 1 is returned here, should be -1 as well?
>

It is a semantically different return value.

-1 are error cases, 1 means already existing, so the caller that requested to
create the dir could treat this as success.
I did not end up implementing the 'allow_existing' feature in this way, but I
see no reason to change the return value, because future implementation
could make use of this distinction. Unless you insist.

Thanks,
Amir.

  reply	other threads:[~2021-01-24 15:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-16 16:56 [PATCH 0/4] Tests for overlayfs immutable/append-only files Amir Goldstein
2021-01-16 16:56 ` [PATCH 1/4] overlay/030: Update comment w.r.t upstream kernel Amir Goldstein
2021-01-16 16:56 ` [PATCH 2/4] src/t_immutable: factor out some helpers Amir Goldstein
2021-01-24 15:09   ` Eryu Guan
2021-01-24 15:29     ` Amir Goldstein [this message]
2021-01-25 12:35       ` Eryu Guan
2021-01-16 16:56 ` [PATCH 3/4] src/t_immutable: Allow setting flags on existing files Amir Goldstein
2021-01-24 15:14   ` Eryu Guan
2021-01-24 15:32     ` Amir Goldstein
2021-01-25 12:46       ` Eryu Guan
2021-01-25 13:17         ` Amir Goldstein
2021-01-16 16:56 ` [PATCH 4/4] overlay: Test lost immutable/append-only flags on copy-up Amir Goldstein
2021-01-25 13:24   ` Amir Goldstein
2021-01-26  8:47     ` Miklos Szeredi
2021-01-27  2:57     ` Eryu Guan
2021-01-28  6:45       ` Amir Goldstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOQ4uxgohiok+9FUG_Xw0NWpDczBD1Gn2ApWMiuhB-O6=Tterw@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=cgxu519@mykernel.net \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=guaneryu@gmail.com \
    --cc=icenowy@aosc.io \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=yangx.jy@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).