diff options
-rw-r--r-- | libc/misc/utmp/utent.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c index 6e1567865..87fe42b16 100644 --- a/libc/misc/utmp/utent.c +++ b/libc/misc/utmp/utent.c @@ -21,8 +21,8 @@ #include <string.h> #include <utmp.h> #include <not-cancel.h> - #include <bits/uClibc_mutex.h> + __UCLIBC_MUTEX_STATIC(utmplock, PTHREAD_MUTEX_INITIALIZER); /* Some global crap */ @@ -32,7 +32,7 @@ static const char default_file_name[] = _PATH_UTMP; static const char *static_ut_name = default_file_name; /* This function must be called with the LOCK held */ -static void __setutent(void) +static void __setutent_unlocked(void) { if (static_fd < 0) { static_fd = open_not_cancel_2(static_ut_name, O_RDWR | O_CLOEXEC); @@ -54,19 +54,19 @@ static void __setutent(void) void setutent(void) { __UCLIBC_MUTEX_LOCK(utmplock); - __setutent(); + __setutent_unlocked(); __UCLIBC_MUTEX_UNLOCK(utmplock); } #else -strong_alias(__setutent,setutent) +strong_alias(__setutent_unlocked,setutent) #endif libc_hidden_def(setutent) /* This function must be called with the LOCK held */ -static struct utmp *__getutent(void) +static struct utmp *__getutent_unlocked(void) { if (static_fd < 0) { - __setutent(); + __setutent_unlocked(); if (static_fd < 0) { return NULL; } @@ -84,12 +84,12 @@ struct utmp *getutent(void) struct utmp *ret; __UCLIBC_MUTEX_LOCK(utmplock); - ret = __getutent(); + ret = __getutent_unlocked(); __UCLIBC_MUTEX_UNLOCK(utmplock); return ret; } #else -strong_alias(__getutent,getutent) +strong_alias(__getutent_unlocked,getutent) #endif libc_hidden_def(getutent) @@ -105,7 +105,7 @@ strong_alias(__endutent,endutent) libc_hidden_def(endutent) /* This function must be called with the LOCK held */ -static struct utmp *__getutid(const struct utmp *utmp_entry) +static struct utmp *__getutid_unlocked(const struct utmp *utmp_entry) { struct utmp *lutmp; unsigned type; @@ -115,7 +115,7 @@ static struct utmp *__getutid(const struct utmp *utmp_entry) type = utmp_entry->ut_type - 1; type /= 4; - while ((lutmp = __getutent()) != NULL) { + while ((lutmp = __getutent_unlocked()) != NULL) { if (type == 0 && lutmp->ut_type == utmp_entry->ut_type) { /* one of RUN_LVL, BOOT_TIME, NEW_TIME, OLD_TIME */ return lutmp; @@ -134,12 +134,12 @@ struct utmp *getutid(const struct utmp *utmp_entry) struct utmp *ret; __UCLIBC_MUTEX_LOCK(utmplock); - ret = __getutid(utmp_entry); + ret = __getutid_unlocked(utmp_entry); __UCLIBC_MUTEX_UNLOCK(utmplock); return ret; } #else -strong_alias(__getutid,getutid) +strong_alias(__getutid_unlocked,getutid) #endif libc_hidden_def(getutid) @@ -148,7 +148,7 @@ static struct utmp *__getutline(const struct utmp *utmp_entry) struct utmp *lutmp; __UCLIBC_MUTEX_LOCK(utmplock); - while ((lutmp = __getutent()) != NULL) { + while ((lutmp = __getutent_unlocked()) != NULL) { if (lutmp->ut_type == USER_PROCESS || lutmp->ut_type == LOGIN_PROCESS) { if (strncmp(lutmp->ut_line, utmp_entry->ut_line, sizeof(lutmp->ut_line)) == 0) { break; @@ -168,7 +168,7 @@ static struct utmp *__pututline(const struct utmp *utmp_entry) the file pointer where they want it, everything will work out. */ lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR); - if (__getutid(utmp_entry) != NULL) + if (__getutid_unlocked(utmp_entry) != NULL) lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR); else lseek(static_fd, (off_t) 0, SEEK_END); |