summaryrefslogtreecommitdiff
path: root/src/shared/util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-09-19 22:21:09 +0200
committerLennart Poettering <lennart@poettering.net>2012-09-19 22:21:09 +0200
commit7d5e9c0f60cddf01ec803012cbdc02d2f55b78c1 (patch)
treeecb5dc336ce9e0ecf6d5e3b6757b0a10f7f1e692 /src/shared/util.h
parent57f3067825d9361d7487f272bfaff3b36c684c62 (diff)
util: define union dirent_storage and make use of it everywhere
Make sure to allocate enough space for readdir_r(). https://bugzilla.redhat.com/show_bug.cgi?id=858754
Diffstat (limited to 'src/shared/util.h')
-rw-r--r--src/shared/util.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/shared/util.h b/src/shared/util.h
index 2429339f5b..e5728bd87e 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -35,6 +35,7 @@
#include <sys/stat.h>
#include <dirent.h>
#include <sys/resource.h>
+#include <stddef.h>
#include "macro.h"
@@ -46,6 +47,12 @@ typedef struct dual_timestamp {
usec_t monotonic;
} dual_timestamp;
+union dirent_storage {
+ struct dirent de;
+ uint8_t storage[offsetof(struct dirent, d_name) +
+ ((NAME_MAX + 1 + sizeof(long)) & ~(sizeof(long) - 1))];
+};
+
#define MSEC_PER_SEC 1000ULL
#define USEC_PER_SEC 1000000ULL
#define USEC_PER_MSEC 1000ULL