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:
- Vs cannot open the source file unistd. H under Windows
- Analysis of compilation errors of “error conflicting types for function”
- error: aggregate value used where an integer was expected
- Error c2371: ‘xxx’: redefinition; different basic types solutions
- FRP installation error:. / FRPC: cannot execute binary file: exec format error
- Brief introduction of Linux MMAP and solution of bus error
- Gradlew compilation error: mips64el Linux Android strip
- On the coercion of C language
- Error in `./a.out‘: free(): invalid next size (fast): 0x0000000001da8010
- Error:No toolchains found in the NDK toolchains folder for ABI with prefix: mipsel-linux-android
- Error resolution of ‘string’ does not name a type
- How do you set, clear and toggle a single bit in C?
- Module in linux driver_ platform_ Learning driver macro
- E: sub process / usr / bin / dpkg returned an error code (2) solution under Ubuntu
- gcc /usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory
- Call unity with lightmap and light probes in shader
- Linux error deletion libc.so.6 how to recover
- Alpine Linux executable file crash report error / lib / x86 not found_ 64 Linux GNU / libc.so solution
- C language write() function analysis: write failed bad address
- Netinet / in. H Linux / in. H problem