Makronix/Linux: stat and patch read glibc's struct stat and dirent

Two of NetBSD's programs reach for members glibc does not have; both
are guarded so the NetBSD build of them is unchanged.

-usrc/usr.bin/stat/stat.c: HAVE_STRUCT_STAT_ST_GEN and the birth-time
members are not asked for under __GLIBC__ (glibc's struct stat has
neither), so the columns are skipped instead of failing to compile.

-usr.bin/patch/backupfile.c: strlen(dp->d_name) instead of d_namlen;
glibc's struct dirent has no d_namlen, and on NetBSD the two are the
same value.

Measured: both compile in the phone's build against glibc
(mobile/build/logs/mxsrc-usrbin5-2026-11-12.log:11325 stat.c,
build/logs/mxsrc-usrbin5-...:1101 patch/backupfile.c); usr.bin as a whole
is still red on other programs, which is t0015.
This commit is contained in:
lotherk committed 2026-11-12 12:36:41 +00:00
1 parent fb63438d49
commit 53b852bb25
2 files changed
+5 -1

No files matched your search

+2 -1
View File
@@ -114,7 +114,8 @@ max_backup_version(const char *file, const char *dir)
file_name_length = strlen(file);
while ((dp = readdir(dirp)) != NULL) {
if (dp->d_namlen <= file_name_length)
/* Makronix: strlen, not d_namlen -- glibc's dirent has none */
if (strlen(dp->d_name) <= file_name_length)
continue;
this_version = version_number(file, dp->d_name, file_name_length);
+3
View File
@@ -42,9 +42,12 @@ __RCSID("$NetBSD: stat.c,v 1.55 2025/05/15 19:11:44 nia Exp $");
#if ! HAVE_NBTOOL_CONFIG_H
#define HAVE_STRUCT_STAT_ST_FLAGS 1
/* Makronix: glibc's struct stat has no generation and no birth time */
#ifndef __GLIBC__
#define HAVE_STRUCT_STAT_ST_GEN 1
#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
#define HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC 1
#endif
#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
#define HAVE_DEVNAME 1
#endif /* HAVE_NBTOOL_CONFIG_H */