Skip to content

Commit 52af7e6

Browse files
committed
Refactor: based, build: Drop struct dirent:d_type check
It was used only for tracing, and masking st_mode is a viable alternative. Signed-off-by: Reid Wahl <[email protected]>
1 parent 468bc50 commit 52af7e6

File tree

2 files changed

+5
-37
lines changed

2 files changed

+5
-37
lines changed

configure.ac

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,9 +1216,6 @@ dnl Structures
12161216
dnl ========================================================================
12171217

12181218
AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[[#include <time.h>]])
1219-
AC_CHECK_MEMBER([struct dirent.d_type],
1220-
AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE,1,[Define this if struct dirent has d_type]),,
1221-
[#include <dirent.h>])
12221219

12231220
dnl ========================================================================
12241221
dnl Functions

daemons/based/based_io.c

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2004-2024 the Pacemaker project contributors
2+
* Copyright 2004-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -86,25 +86,10 @@ retrieveCib(const char *filename, const char *sigfile)
8686
return root;
8787
}
8888

89-
/*
90-
* for OSs without support for direntry->d_type, like Solaris
91-
*/
92-
#ifndef DT_UNKNOWN
93-
# define DT_UNKNOWN 0
94-
# define DT_FIFO 1
95-
# define DT_CHR 2
96-
# define DT_DIR 4
97-
# define DT_BLK 6
98-
# define DT_REG 8
99-
# define DT_LNK 10
100-
# define DT_SOCK 12
101-
# define DT_WHT 14
102-
#endif /*DT_UNKNOWN*/
103-
10489
static int cib_archive_filter(const struct dirent * a)
10590
{
10691
int rc = 0;
107-
/* Looking for regular files (d_type = 8) starting with 'cib-' and not ending in .sig */
92+
// Looking for regular files starting with "cib-" and not ending in .sig
10893
struct stat s;
10994
char *a_path = crm_strdup_printf("%s/%s", cib_root, a->d_name);
11095

@@ -113,23 +98,9 @@ static int cib_archive_filter(const struct dirent * a)
11398
crm_trace("%s - stat failed: %s (%d)", a->d_name, pcmk_rc_str(rc), rc);
11499
rc = 0;
115100

116-
} else if ((s.st_mode & S_IFREG) != S_IFREG) {
117-
unsigned char dtype;
118-
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
119-
dtype = a->d_type;
120-
#else
121-
switch (s.st_mode & S_IFMT) {
122-
case S_IFREG: dtype = DT_REG; break;
123-
case S_IFDIR: dtype = DT_DIR; break;
124-
case S_IFCHR: dtype = DT_CHR; break;
125-
case S_IFBLK: dtype = DT_BLK; break;
126-
case S_IFLNK: dtype = DT_LNK; break;
127-
case S_IFIFO: dtype = DT_FIFO; break;
128-
case S_IFSOCK: dtype = DT_SOCK; break;
129-
default: dtype = DT_UNKNOWN; break;
130-
}
131-
#endif
132-
crm_trace("%s - wrong type (%d)", a->d_name, dtype);
101+
} else if (!S_ISREG(s.st_mode)) {
102+
crm_trace("%s - wrong type (%#o)",
103+
a->d_name, (unsigned int) (s.st_mode & S_IFMT));
133104

134105
} else if(strstr(a->d_name, "cib-") != a->d_name) {
135106
crm_trace("%s - wrong prefix", a->d_name);

0 commit comments

Comments
 (0)