From: Petr Vorel <pvorel@suse.cz>
To: Dai Shili <daisl.fnst@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] syscalls/write06: Add new test
Date: Mon, 20 Dec 2021 10:53:30 +0100 [thread overview]
Message-ID: <YcBSmpdWBnx/L/XY@pevik> (raw)
In-Reply-To: <1640028184-20297-1-git-send-email-daisl.fnst@fujitsu.com>
Hi Dai,
> Like pwrite04.c, test the write() system call with O_APPEND.
...
> +++ b/testcases/kernel/syscalls/write/write06.c
> @@ -0,0 +1,95 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2021 FUJITSU LIMITED. All rights reserved.
> + * Author: Dai Shili <daisl.fnst@fujitsu.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * Test the write() system call with O_APPEND.
> + *
> + * The full description of O_APPEND is in open(2) man-pages:
> + * O_APPEND
> + * The file is opened in append mode. Before each write(2), the
nit: FYI this formatting will be lost in our metadata.
(To see the output, you can run make metadata/ and check docparse/metadata.html
or docparse/metadata.pdf.)
...
> +static void verify_write(void)
> +{
> + off_t off;
> + struct stat statbuf;
> +
> + fd = SAFE_OPEN(DATA_FILE, O_RDWR | O_CREAT | O_TRUNC);
> + SAFE_WRITE(1, fd, write_buf[0], K2);
> + SAFE_CLOSE(fd);
> +
> + fd = SAFE_OPEN(DATA_FILE, O_RDWR | O_APPEND);
Quite often I get EACCES when running the test. It's strange that not always.
$ ./write06
tst_buffers.c:55: TINFO: Test is using guarded buffers
tst_test.c:1423: TINFO: Timeout per run is 0h 05m 00s
write06.c:45: TBROK: open(write06_file,1026,4162714000) failed: EACCES (13)
IMHO this depends on umask (0022) in my case.
Obviously specifying permissions as it's in pwrite04.c fixes the problem:
@@ -38,7 +38,7 @@ static void verify_write(void)
off_t off;
struct stat statbuf;
- fd = SAFE_OPEN(DATA_FILE, O_RDWR | O_CREAT | O_TRUNC);
+ fd = SAFE_OPEN(DATA_FILE, O_RDWR | O_CREAT | O_TRUNC, 0666);
SAFE_WRITE(1, fd, write_buf[0], K2);
SAFE_CLOSE(fd);
(pwrite04.c specifies permission in both SAFE_OPEN(), but it's obviously enough
to put it just in the first one, which uses O_CREAT).
Also Cyril noted using permissions in review of v1 patch:
https://lore.kernel.org/ltp/Ya9my0FdHXLqvkJr@yuki/
Otherwise LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2021-12-20 9:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-06 21:17 [LTP] [PATCH] syscalls/write06: Add new test Dai Shili
2021-12-07 13:51 ` Cyril Hrubis
2021-12-08 8:38 ` daisl.fnst
2021-12-10 10:57 ` Cyril Hrubis
2021-12-20 19:23 ` [LTP] [PATCH v2] " Dai Shili
2021-12-20 9:53 ` Petr Vorel [this message]
2021-12-21 20:03 ` [LTP] [PATCH v3] " Dai Shili
2021-12-21 19:44 ` Petr Vorel
2021-12-23 1:42 ` xuyang2018.jy
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=YcBSmpdWBnx/L/XY@pevik \
--to=pvorel@suse.cz \
--cc=daisl.fnst@fujitsu.com \
--cc=ltp@lists.linux.it \
/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