UOS LTP compilation ustat test item error

environmental information

$ dpkg -l|grep libc6-dev
ii  libc6-dev:mips64el  2.28.12-1+eagle    mips64el  GNU C Library: Development Libraries and Header Files

Error message

~ltp/testcases/kernel/syscalls/ustat$ make
In file included from ../../../../include/tst_test.h:14,
                 from ustat01.c:9:
/usr/include/mips64el-linux-gnuabi64/bits/ustat.h:24:8: error: redefinition of ‘struct statfs’
 struct ustat
        ^~~~~

It shows that the struct ustat is repeatedly defined.

analysis

In the normal environment, the struct ustat structure is not defined. If you want to use this structure, you need to define it yourself. LTP also provides a custom struct ustat structure
where lapi/ustat. H is defined as follows:

//SPDX-License-Identifier: GPL-2.0-or-later

#ifndef LAPI_USTAT_H__
#define LAPI_USTAT_H__

#include "config.h"
#include <sys/types.h>
#ifdef HAVE_SYS_USTAT_H
# include <sys/ustat.h>
#elif HAVE_LINUX_TYPES_H
# include <linux/types.h>
struct ustat {
        __kernel_daddr_t f_tfree;
        ino_t f_tinode;
        char f_fname[6];
        char f_fpack[6];
};
#endif

#endif /* LAPI_USTAT_H__ */

The header file in the test code contains lapi/ustat. H, so the test code is OK.

#include "config.h"
#include "tst_test.h"

#if defined(HAVE_SYS_USTAT_H) || defined(HAVE_LINUX_TYPES_H)
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>

#include "lapi/syscalls.h"
#include "lapi/ustat.h"

According to the error message, it is displayed in… /… /… /…/include/TST_ Test. H: line 14 of 14.

	...
 14 #include <unistd.h>
	 ...

Line 14 is the header file unistd. H, which is the file of libc6 dev package
file content:

...
/* Move FD's file position to OFFSET bytes from the
   beginning of the file (if WHENCE is SEEK_SET),
   the current position (if WHENCE is SEEK_CUR),
   or the end of the file (if WHENCE is SEEK_END).
   Return the new file position.  */


#define llseek lseek     
#define ustat statfs
#ifndef __USE_FILE_OFFSET64
extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW;
#else
...

There are macro definitions

#define ustat statfs

Simply replacing statfs with ustat leads to the problem of repeatedly defining struct ustat.

Conclusion

After investigation, unistd. H belongs to libc6 dev. the version installed in the current environment is 2.28.12-1 + eagle. These two macros are not added to unistd. H in 2.28.10 and 2.28.14.

#define llseek lseek     
#define ustat statfs

It is speculated that UOS may have modified the source code of glibc. The record of adding these two macros in unistd. H was not found in the public glibc.

Read More: