diff options
author | Austin Foxley <austinf@cetoncorp.com> | 2009-09-21 18:25:22 -0700 |
---|---|---|
committer | Austin Foxley <austinf@cetoncorp.com> | 2009-09-21 18:25:22 -0700 |
commit | e2784760e51ec0de62bbee61d27a85147460ece0 (patch) | |
tree | 0d1541dc5f16424d5a097929e0aaaa8c762a1056 /libc/inet/hostid.c | |
parent | a894902293392cdae3a614ae3ff065ca3a7b9f75 (diff) | |
download | uClibc-alpine-e2784760e51ec0de62bbee61d27a85147460ece0.tar.bz2 uClibc-alpine-e2784760e51ec0de62bbee61d27a85147460ece0.tar.xz |
not-cancel: use *_not_cancel variants directly
add a no threads version of not-cancel.h to fallback on
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'libc/inet/hostid.c')
-rw-r--r-- | libc/inet/hostid.c | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c index caacef84d..86be79645 100644 --- a/libc/inet/hostid.c +++ b/libc/inet/hostid.c @@ -14,9 +14,7 @@ #include <netdb.h> #include <fcntl.h> #include <unistd.h> -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ #include <not-cancel.h> -#endif #define HOSTID "/etc/hostid" @@ -28,17 +26,10 @@ int sethostid(long int new_id) int ret; if (geteuid() || getuid()) return __set_errno(EPERM); -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ if ((fd=open_not_cancel(HOSTID,O_CREAT|O_WRONLY,0644))<0) return -1; ret = write_not_cancel(fd,(void *)&new_id,sizeof(new_id)) == sizeof(new_id) ? 0 : -1; close_not_cancel_no_status (fd); -#else - 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); -#endif return ret; } #endif @@ -52,7 +43,6 @@ 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... */ -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ if ((fd =open_not_cancel_2 (HOSTID, O_RDONLY)) >= 0 && read_not_cancel (fd, (void *) &id, sizeof (id))) { @@ -60,14 +50,6 @@ long int gethostid(void) return id; } if (fd >= 0) close_not_cancel_no_status (fd); -#else - if ((fd=open(HOSTID,O_RDONLY))>=0 && read(fd,(void *)&id,sizeof(id))) - { - close (fd); - return id; - } - if (fd >= 0) close (fd); -#endif /* Try some methods of returning a unique 32 bit id. Clearly IP * numbers, if on the internet, will have a unique address. If they |