As it's impossible to get the current umask without modifying it at the
same time, initialize the current umask at the program start and keep
the loaded value internally. Add isc_os_umask() function to access the
starttime umask.
#pragma once
/*! \file isc/os.h */
+#include <sys/stat.h>
#include <isc/lang.h>
#include <isc/types.h>
unsigned long
isc_os_cacheline(void);
/*%<
- * Return L1 caheline size of the CPU.
+ * Return L1 cacheline size of the CPU.
* If L1 cache is greater than ISC_OS_CACHELINE_SIZE, ensure it is used
* instead of constant. Is common on ppc64le architecture.
*/
+mode_t
+isc_os_umask(void);
+/*%<
+ * Return umask of the current process as initialized at the program start
+ */
+
ISC_LANG_ENDDECLS
*/
#include <inttypes.h>
+#include <sys/stat.h>
#include <isc/os.h>
#include <isc/types.h>
static unsigned int isc__os_ncpus = 0;
static unsigned long isc__os_cacheline = ISC_OS_CACHELINE_SIZE;
+static mode_t isc__os_umask = 0;
#ifdef HAVE_SYSCONF
}
}
+static void
+umask_initialize(void) {
+ isc__os_umask = umask(0);
+ (void)umask(isc__os_umask);
+}
+
unsigned int
isc_os_ncpus(void) {
return (isc__os_ncpus);
return (isc__os_cacheline);
}
+mode_t
+isc_os_umask(void) {
+ return (isc__os_umask);
+}
+
void
isc__os_initialize(void) {
+ umask_initialize();
ncpus_initialize();
#if defined(HAVE_SYSCONF) && defined(_SC_LEVEL1_DCACHE_LINESIZE)
long s = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);