summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-04 19:20:21 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-04 20:02:50 +0100
commit1c231f56482546725c4dbd3303f70300bd3c63e9 (patch)
treedc0f3ff586db692d961264a23b2b23040c1ce53e /src/shared
parentb5d742138f71e87312541a89aac5657015f50f48 (diff)
logind: make $XDG_RUNTIME_DIR a per-user tmpfs
This way each user allocates from his own pool, with its own size limit. This puts the size limit by default to 10% of the physical RAM size but makes it configurable in logind.conf.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/macro.h2
-rw-r--r--src/shared/util.c12
-rw-r--r--src/shared/util.h10
3 files changed, 23 insertions, 1 deletions
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 5fd67c7aba..08a036b3b9 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -98,7 +98,7 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
return ((l + ali - 1) & ~(ali - 1));
}
-#define ALIGN_TO_PTR(p, ali) ((void*) ALIGN_TO((unsigned long) p))
+#define ALIGN_TO_PTR(p, ali) ((void*) ALIGN_TO((unsigned long) p, ali))
#define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
diff --git a/src/shared/util.c b/src/shared/util.c
index 285a263cdb..10daff3036 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -6291,3 +6291,15 @@ const char* personality_to_string(unsigned long p) {
return NULL;
}
+
+uint64_t physical_memory(void) {
+ long mem;
+
+ /* We return this as uint64_t in case we are running as 32bit
+ * process on a 64bit kernel with huge amounts of memory */
+
+ mem = sysconf(_SC_PHYS_PAGES);
+ assert(mem > 0);
+
+ return (uint64_t) mem * (uint64_t) page_size();
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index 78b1444739..e4300719a3 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -58,6 +58,14 @@
# error Unknown uid_t size
#endif
+#if SIZEOF_GID_T == 4
+# define GID_FMT "%" PRIu32
+#elif SIZEOF_GID_T == 2
+# define GID_FMT "%" PRIu16
+#else
+# error Unknown gid_t size
+#endif
+
#include "macro.h"
#include "time-util.h"
@@ -883,3 +891,5 @@ int fd_warn_permissions(const char *path, int fd);
unsigned long personality_from_string(const char *p);
const char *personality_to_string(unsigned long);
+
+uint64_t physical_memory(void);