summaryrefslogtreecommitdiff
path: root/libc/misc/mntent/mntent.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-06-18 06:39:18 +0000
committerEric Andersen <andersen@codepoet.org>2002-06-18 06:39:18 +0000
commit18a62cd735142472903533b749e44f18e11719d5 (patch)
treeeb874dce6d08b5fe42b2ffd264edecc157d68054 /libc/misc/mntent/mntent.c
parentb9e9d181dfd86a154aa2c710d5e6b9c284b01894 (diff)
Fix locking. Kill
Diffstat (limited to 'libc/misc/mntent/mntent.c')
-rw-r--r--libc/misc/mntent/mntent.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/libc/misc/mntent/mntent.c b/libc/misc/mntent/mntent.c
index 82a7e70d1..b1d27de2c 100644
--- a/libc/misc/mntent/mntent.c
+++ b/libc/misc/mntent/mntent.c
@@ -3,13 +3,22 @@
#include <string.h>
#include <mntent.h>
-
-/* Reentrant version of the above function. */
+#ifdef __UCLIBC_HAS_THREADS__
+#include <pthread.h>
+static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
+# define LOCK pthread_mutex_lock(&mylock)
+# define UNLOCK pthread_mutex_unlock(&mylock);
+#else
+# define LOCK
+# define UNLOCK
+#endif
+
+/* Reentrant version of getmntent. */
struct mntent *getmntent_r (FILE *filep,
struct mntent *mnt, char *buff, int bufsize)
{
- char *cp, *sep = " \t\n";
- static char *ptrptr = 0;
+ char *cp, *ptrptr;
+ const char *sep = " \t\n";
if (!filep || !mnt || !buff)
return NULL;
@@ -55,9 +64,13 @@ struct mntent *getmntent_r (FILE *filep,
struct mntent *getmntent(FILE * filep)
{
+ struct mntent *tmp;
static char buff[BUFSIZ];
static struct mntent mnt;
- return(getmntent_r(filep, &mnt, buff, sizeof buff));
+ LOCK;
+ tmp = getmntent_r(filep, &mnt, buff, sizeof buff);
+ UNLOCK;
+ return(tmp);
}
int addmntent(FILE * filep, const struct mntent *mnt)