Re: [LTP] [PATCH v5 1/2] tst_safe_macros.h: Add SAFE_STATVFS

Wei Gao via ltp
2025-04-10T05:39:52Z

On Thu, Feb 27, 2025 at 05:27:17PM +0100, Petr Vorel wrote:
> Hi Wei,
>
> > +++ b/include/tst_safe_macros.h
> > @@ -429,6 +429,27 @@ static inline int safe_statfs(const char *file, const int lineno,
> > #define SAFE_STATFS(path, buf) \
> > safe_statfs(__FILE__, __LINE__, (path), (buf))
>
> > +static inline int safe_statvfs(const char *file, const int lineno,
> > + const char *path, struct statvfs *buf)
> > +{
> > + int rval;
> > +
> > + rval = statvfs(path, buf);
> > +
> > + if (rval == -1) {
> > + tst_brk_(file, lineno, TBROK | TERRNO,
> > + "statvfs(%s,%p) failed", path, buf);
> > + } else if (rval) {
> > + tst_brk_(file, lineno, TBROK | TERRNO,
> > + "Invalid statvfs(%s,%p) return value %d", path, buf,
> > + rval);
> > + }
>
> @Wei We usually add only function signature to headers, the rest goes into
> lib/tst_safe_macros.c. The only exception are functions in
> include/tst_safe_macros_inline.h due off_t or structs which contain it, which is
> not this case.
>
> Besides following ioctl_fiemap01.c it could be used also in libs/swap/libswap.c
> and lib/tst_fill_fs.c, where we don't even check return code. Not that many
> cases but probably useful.
>
> FYI fstatvfs() with TBROK is used in fsync02.c not sure if to add it as well.
Sure, i can take a look once above patch merged, thanks for your information.
>
> Kind regards,
> Petr