From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.com>
Cc: helena.anna.dubel@intel.com, tomasz.ossowski@intel.com,
rafael.j.wysocki@intel.com, daniel.niestepski@intel.com,
ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] rfim: add new test for verifying RFIM sysfs interface
Date: Wed, 17 Jun 2026 10:52:18 +0200 [thread overview]
Message-ID: <ajJgQmumLAfPLWGk@yuki.lan> (raw)
In-Reply-To: <6a31618c.7f42fb59.24bb2.63c5@mx.google.com>
Hi!
> > +static void check_read_only(const char *path)
> > +{
> > + tst_res(TDEBUG, "Checking whether %s is read-only", path);
> > +
> > + if (access(path, F_OK)) {
> > + tst_res(TFAIL | TERRNO, "%s does not exist", path);
> > + return;
> > + }
> > +
> > + int fd = open(path, O_RDONLY);
> > +
> > + if (fd == -1) {
> > + tst_res(TFAIL | TERRNO, "%s can't be read", path);
> > + return;
> > + }
> > + close(fd);
> > +
> > + fd = open(path, O_WRONLY);
> > + if (fd != -1) {
> > + close(fd);
> > + tst_res(TFAIL, "%s is writable", path);
> > + return;
> > + }
> > +
> > + tst_res(TPASS, "%s is read-only", path);
> > +}
>
> This function can be easily replaced by access().
>
> TST_EXP_PASS(access(path, R_OK));
> TST_EXP_FAIL(access(path, W_OK), ..);
This depends on where the error from kernel is supposed to be returned
from. For files that are generated by kernel such as /sys/ and /proc/
the permission bits can be all enabled but you may still get EPERM when
you actually open the file and kernel decides that this file shouldn't
be readable in the open() syscall handler for the particular file.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-06-17 8:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 11:42 [LTP] [PATCH] rfim: add new test for verifying RFIM sysfs interface Piotr Kubaj
2026-06-16 14:28 ` [LTP] " linuxtestproject.agent
2026-06-16 14:45 ` [LTP] [PATCH] " Andrea Cervesato via ltp
2026-06-17 7:32 ` Andrea Cervesato via ltp
2026-06-17 8:52 ` Cyril Hrubis [this message]
2026-06-17 9:24 ` Andrea Cervesato via ltp
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=ajJgQmumLAfPLWGk@yuki.lan \
--to=chrubis@suse.cz \
--cc=andrea.cervesato@suse.com \
--cc=daniel.niestepski@intel.com \
--cc=helena.anna.dubel@intel.com \
--cc=ltp@lists.linux.it \
--cc=rafael.j.wysocki@intel.com \
--cc=tomasz.ossowski@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.