summaryrefslogtreecommitdiff
path: root/libc/inet/hostid.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/inet/hostid.c')
-rw-r--r--libc/inet/hostid.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c
index bc9576e74..4ac4a811f 100644
--- a/libc/inet/hostid.c
+++ b/libc/inet/hostid.c
@@ -1,7 +1,8 @@
-#define geteuid __geteuid
-#define getuid __getuid
-#define gethostbyname __gethostbyname
-#define gethostname __gethostname
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#define __FORCE_GLIBC
#include <features.h>
@@ -14,6 +15,15 @@
#include <fcntl.h>
#include <unistd.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(open)
+libc_hidden_proto(close)
+libc_hidden_proto(read)
+libc_hidden_proto(write)
+libc_hidden_proto(getuid)
+libc_hidden_proto(geteuid)
+libc_hidden_proto(gethostbyname)
+libc_hidden_proto(gethostname)
#define HOSTID "/etc/hostid"
@@ -23,10 +33,10 @@ int sethostid(long int new_id)
int ret;
if (geteuid() || getuid()) return __set_errno(EPERM);
- if ((fd=__open(HOSTID,O_CREAT|O_WRONLY,0644))<0) return -1;
- ret = __write(fd,(void *)&new_id,sizeof(new_id)) == sizeof(new_id)
+ if ((fd=open(HOSTID,O_CREAT|O_WRONLY,0644))<0) return -1;
+ ret = write(fd,(void *)&new_id,sizeof(new_id)) == sizeof(new_id)
? 0 : -1;
- __close (fd);
+ close (fd);
return ret;
}
@@ -39,12 +49,12 @@ long int gethostid(void)
* It is not an error if we cannot read this file. It is not even an
* error if we cannot read all the bytes, we just carry on trying...
*/
- if ((fd=__open(HOSTID,O_RDONLY))>=0 && __read(fd,(void *)&id,sizeof(id)))
+ if ((fd=open(HOSTID,O_RDONLY))>=0 && read(fd,(void *)&id,sizeof(id)))
{
- __close (fd);
+ close (fd);
return id;
}
- if (fd >= 0) __close (fd);
+ if (fd >= 0) close (fd);
/* Try some methods of returning a unique 32 bit id. Clearly IP
* numbers, if on the internet, will have a unique address. If they
@@ -70,7 +80,7 @@ long int gethostid(void)
*/
return 0;
else {
- __memcpy((char *) &in, (char *) hp->h_addr, hp->h_length);
+ memcpy((char *) &in, (char *) hp->h_addr, hp->h_length);
/* Just so it doesn't look exactly like the IP addr */
return(in.s_addr<<16|in.s_addr>>16);