[LTP] [PATCH] save_restore: Check whether path is writable

Cyril Hrubis chrubis@suse.cz
Wed Oct 26 15:08:00 CEST 2022


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


More information about the ltp mailing list