summaryrefslogtreecommitdiff
path: root/libc/misc/utmp
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/utmp')
-rw-r--r--libc/misc/utmp/utent.c51
-rw-r--r--libc/misc/utmp/wtent.c54
2 files changed, 55 insertions, 50 deletions
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index 3ad5bc828..c1932d7d7 100644
--- a/libc/misc/utmp/utent.c
+++ b/libc/misc/utmp/utent.c
@@ -20,7 +20,16 @@
#include <string.h>
#include <utmp.h>
-
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strdup)
+libc_hidden_proto(strncmp)
+libc_hidden_proto(read)
+libc_hidden_proto(write)
+libc_hidden_proto(open)
+libc_hidden_proto(fcntl)
+libc_hidden_proto(close)
+libc_hidden_proto(lseek)
+libc_hidden_proto(setutent)
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
@@ -37,47 +46,47 @@ static struct utmp static_utmp;
static const char default_file_name[] = _PATH_UTMP;
static const char *static_ut_name = (const char *) default_file_name;
-void attribute_hidden __setutent(void)
+void setutent(void)
{
int ret;
LOCK;
if (static_fd == -1) {
- if ((static_fd = __open(static_ut_name, O_RDWR)) < 0) {
- if ((static_fd = __open(static_ut_name, O_RDONLY)) < 0) {
+ if ((static_fd = open(static_ut_name, O_RDWR)) < 0) {
+ if ((static_fd = open(static_ut_name, O_RDONLY)) < 0) {
goto bummer;
}
}
/* Make sure the file will be closed on exec() */
- ret = __fcntl(static_fd, F_GETFD, 0);
+ ret = fcntl(static_fd, F_GETFD, 0);
if (ret >= 0) {
- ret = __fcntl(static_fd, F_GETFD, 0);
+ ret = fcntl(static_fd, F_GETFD, 0);
}
if (ret < 0) {
bummer:
UNLOCK;
static_fd = -1;
- __close(static_fd);
+ close(static_fd);
return;
}
}
- __lseek(static_fd, 0, SEEK_SET);
+ lseek(static_fd, 0, SEEK_SET);
UNLOCK;
return;
}
-strong_alias(__setutent,setutent)
+libc_hidden_def(setutent)
static struct utmp *__getutent(int utmp_fd)
{
if (utmp_fd == -1) {
- __setutent();
+ setutent();
}
if (utmp_fd == -1) {
return NULL;
}
LOCK;
- if (__read(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) != sizeof(struct utmp))
+ if (read(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) != sizeof(struct utmp))
{
return NULL;
}
@@ -90,7 +99,7 @@ void endutent(void)
{
LOCK;
if (static_fd != -1) {
- __close(static_fd);
+ close(static_fd);
}
static_fd = -1;
UNLOCK;
@@ -120,7 +129,7 @@ struct utmp attribute_hidden *__getutid (const struct utmp *utmp_entry)
utmp_entry->ut_type == DEAD_PROCESS ||
utmp_entry->ut_type == LOGIN_PROCESS ||
utmp_entry->ut_type == USER_PROCESS) &&
- !__strncmp(lutmp->ut_id, utmp_entry->ut_id, sizeof(lutmp->ut_id)))
+ !strncmp(lutmp->ut_id, utmp_entry->ut_id, sizeof(lutmp->ut_id)))
{
return lutmp;
}
@@ -137,7 +146,7 @@ struct utmp *getutline(const struct utmp *utmp_entry)
while ((lutmp = __getutent(static_fd)) != NULL) {
if ((lutmp->ut_type == USER_PROCESS || lutmp->ut_type == LOGIN_PROCESS) &&
- !__strcmp(lutmp->ut_line, utmp_entry->ut_line))
+ !strcmp(lutmp->ut_line, utmp_entry->ut_line))
{
return lutmp;
}
@@ -151,15 +160,15 @@ struct utmp *pututline (const struct utmp *utmp_entry)
LOCK;
/* Ignore the return value. That way, if they've already positioned
the file pointer where they want it, everything will work out. */
- __lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
+ lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
if (__getutid(utmp_entry) != NULL) {
- __lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
- if (__write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
+ lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
+ if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
return NULL;
} else {
- __lseek(static_fd, (off_t) 0, SEEK_END);
- if (__write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
+ lseek(static_fd, (off_t) 0, SEEK_END);
+ if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
return NULL;
}
@@ -173,7 +182,7 @@ int utmpname (const char *new_ut_name)
if (new_ut_name != NULL) {
if (static_ut_name != default_file_name)
free((char *)static_ut_name);
- static_ut_name = __strdup(new_ut_name);
+ static_ut_name = strdup(new_ut_name);
if (static_ut_name == NULL) {
/* We should probably whine about out-of-memory
* errors here... Instead just reset to the default */
@@ -182,7 +191,7 @@ int utmpname (const char *new_ut_name)
}
if (static_fd != -1)
- __close(static_fd);
+ close(static_fd);
UNLOCK;
return 0;
}
diff --git a/libc/misc/utmp/wtent.c b/libc/misc/utmp/wtent.c
index 35947f19e..0378070e7 100644
--- a/libc/misc/utmp/wtent.c
+++ b/libc/misc/utmp/wtent.c
@@ -1,23 +1,10 @@
-/* wtmp support rubbish (i.e. complete crap)
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
- * Written by Erik Andersen <andersee@debian.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; see the file COPYING.LIB. If not,
- * write to the Free Software Foundation, Inc., 675 Mass Ave,
- * Cambridge, MA 02139, USA. */
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
-#define gettimeofday __gettimeofday
+/* wtmp support rubbish (i.e. complete crap) */
#include <string.h>
#include <sys/time.h>
@@ -27,36 +14,45 @@
#include <fcntl.h>
#include <sys/file.h>
+#if 0
+libc_hidden_proto(memset)
+libc_hidden_proto(strncpy)
+libc_hidden_proto(updwtmp)
+#endif
+libc_hidden_proto(open)
+libc_hidden_proto(write)
+libc_hidden_proto(close)
+libc_hidden_proto(lockf)
+libc_hidden_proto(gettimeofday)
#if 0
/* This is enabled in uClibc/libutil/logwtmp.c */
void logwtmp (const char *line, const char *name, const char *host)
{
struct utmp lutmp;
- __memset (&(lutmp), 0, sizeof (struct utmp));
+ memset (&(lutmp), 0, sizeof (struct utmp));
lutmp.ut_type = (name && *name)? USER_PROCESS : DEAD_PROCESS;
lutmp.ut_pid = __getpid();
- __strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1);
- __strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1);
- __strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1);
+ strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1);
+ strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1);
+ strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1);
gettimeofday(&(lutmp.ut_tv), NULL);
updwtmp(_PATH_WTMP, &(lutmp));
}
#endif
-extern void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
+void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
{
int fd;
- fd = __open(wtmp_file, O_APPEND | O_WRONLY, 0);
+ fd = open(wtmp_file, O_APPEND | O_WRONLY, 0);
if (fd >= 0) {
- if (__lockf(fd, F_LOCK, 0)==0) {
- __write(fd, (const char *) lutmp, sizeof(struct utmp));
- __lockf(fd, F_ULOCK, 0);
- __close(fd);
+ if (lockf(fd, F_LOCK, 0)==0) {
+ write(fd, (const char *) lutmp, sizeof(struct utmp));
+ lockf(fd, F_ULOCK, 0);
+ close(fd);
}
}
}
-