summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/pwdgrp.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-14 11:09:39 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-20 10:30:21 +0100
commit80055514bbe2d79268ea3987751cd01ddb711123 (patch)
tree41d7b28702669c9c872802c397eb7b5d2e997837 /cpukit/libcsupport/src/pwdgrp.c
parentlibcsupport: Split passwd/group support (diff)
downloadrtems-80055514bbe2d79268ea3987751cd01ddb711123.tar.bz2
libcsupport: Use pthread_once()
Diffstat (limited to 'cpukit/libcsupport/src/pwdgrp.c')
-rw-r--r--cpukit/libcsupport/src/pwdgrp.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/cpukit/libcsupport/src/pwdgrp.c b/cpukit/libcsupport/src/pwdgrp.c
index d8e1947b3f..c10cbab719 100644
--- a/cpukit/libcsupport/src/pwdgrp.c
+++ b/cpukit/libcsupport/src/pwdgrp.c
@@ -31,22 +31,21 @@
#include <string.h>
#include <limits.h>
#include <ctype.h>
+#include <pthread.h>
#include <rtems/seterr.h>
#include "pwdgrp.h"
+static pthread_once_t pwdgrp_once = PTHREAD_ONCE_INIT;
+
/**
* Initialize useable but dummy databases
*/
-void _libcsupport_pwdgrp_init(void)
+static void pwdgrp_init(void)
{
FILE *fp;
- static char etc_passwd_initted = 0;
- if (etc_passwd_initted)
- return;
- etc_passwd_initted = 1;
mkdir("/etc", 0777);
/*
@@ -76,6 +75,11 @@ void _libcsupport_pwdgrp_init(void)
}
}
+void _libcsupport_pwdgrp_init(void)
+{
+ pthread_once(&pwdgrp_once, pwdgrp_init);
+}
+
/**
* Extract a string value from the database
*/