X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Futil.c;h=fada69cf1a981893f85998ac2da465865a2d0074;hp=eefd66e8cdb4b5e630213d5b4bd5b46365ae4457;hb=871c44a747a8bf4465cbfda445216e9ac66d4a40;hpb=ef2df9f41541a62fb7876b98701ab072b41325e2 diff --git a/src/util.c b/src/util.c index eefd66e8c..fada69cf1 100644 --- a/src/util.c +++ b/src/util.c @@ -61,6 +61,20 @@ #include "exit-status.h" #include "hashmap.h" +size_t page_size(void) { + static __thread size_t pgsz = 0; + long r; + + if (pgsz) + return pgsz; + + assert_se((r = sysconf(_SC_PAGESIZE)) > 0); + + pgsz = (size_t) r; + + return pgsz; +} + bool streq_ptr(const char *a, const char *b) { /* Like streq(), but tries to make sense of NULL pointers */ @@ -3524,7 +3538,7 @@ int touch(const char *path) { assert(path); - if ((fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0666)) < 0) + if ((fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0644)) < 0) return -errno; close_nointr_nofail(fd); @@ -3991,7 +4005,7 @@ int detect_container(const char **id) { fclose(f); if (id) - *id = "ns"; + *id = "pidns"; return 1; }