public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] save_restore: Check whether path is writable
Date: Wed, 26 Oct 2022 15:08:00 +0200	[thread overview]
Message-ID: <Y1kxMHBpEhb4SvUb@yuki> (raw)
In-Reply-To: <3f3dca4e-79d9-9e5b-293f-f27c6644dec8@suse.cz>

Hi!
> > For optional path, if test can't read/write it (b/o of no root privileges),
> > I think library shouldn't try to save it - then that would also skip
> > attempt to restore it.
> 
> There are be two different kinds of optional paths, though:
> 1) paths that sometimes don't exist but must be written to if they do
> 2) paths that may be left alone if they exist and already contain the 
> right value (otherwise TCONF)

Alternatively we can cleanup the interface, we moved from a single
string to a structure so we can add more fields, what about adding flags
that would describe one single attribute of the file instead of
clobbering several different characteristics of the file into a single
character?

We can then do something as:

struct tst_save_restore {
	const char *path;
	const char *val;
	/* the test needs the file to exist -> TCONF on missing */
	int required:1;
	/* write the value even if the file already contains it */
	int rewrite:1;
	...
};

This makes the inteface orthogonal and much easier to reason about.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2022-10-26 13:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-21 15:57 [LTP] [PATCH] save_restore: Check whether path is writable Martin Doucha
2022-10-21 20:34 ` Petr Vorel
2022-10-24  7:16   ` Jan Stancek
2022-10-25 16:13     ` Martin Doucha
2022-10-26 11:29       ` Jan Stancek
2022-10-26 13:10         ` Cyril Hrubis
2022-10-26 13:27         ` Martin Doucha
2022-10-26 13:08       ` Cyril Hrubis [this message]
2022-10-26 20:49         ` Petr Vorel

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=Y1kxMHBpEhb4SvUb@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=mdoucha@suse.cz \
    /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