summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/common
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r--libc/sysdeps/linux/common/Makefile1
-rw-r--r--libc/sysdeps/linux/common/__syscall_fcntl.c17
-rw-r--r--libc/sysdeps/linux/common/bits/errno.h2
-rw-r--r--libc/sysdeps/linux/common/bits/ipc.h16
-rw-r--r--libc/sysdeps/linux/common/bits/sem.h19
-rw-r--r--libc/sysdeps/linux/common/bits/sigthread.h12
-rw-r--r--libc/sysdeps/linux/common/bits/stat.h16
-rw-r--r--libc/sysdeps/linux/common/ioperm.c6
-rw-r--r--libc/sysdeps/linux/common/pread_write.c4
-rw-r--r--libc/sysdeps/linux/common/ssp.c73
-rw-r--r--libc/sysdeps/linux/common/umount.c15
-rw-r--r--libc/sysdeps/linux/common/xstatconv.c73
12 files changed, 151 insertions, 103 deletions
diff --git a/libc/sysdeps/linux/common/Makefile b/libc/sysdeps/linux/common/Makefile
index 5e17cc9fc..84b29ac53 100644
--- a/libc/sysdeps/linux/common/Makefile
+++ b/libc/sysdeps/linux/common/Makefile
@@ -28,6 +28,7 @@ endif
ifneq ($(strip $(UCLIBC_HAS_SSP)),y)
SRCS := $(filter-out ssp.c,$(SRCS))
endif
+ssp.o: CFLAGS += $(SSP_DISABLE_FLAGS)
OBJS = $(patsubst %.c,%.o, $(SRCS))
diff --git a/libc/sysdeps/linux/common/__syscall_fcntl.c b/libc/sysdeps/linux/common/__syscall_fcntl.c
index 62568522b..0a5812976 100644
--- a/libc/sysdeps/linux/common/__syscall_fcntl.c
+++ b/libc/sysdeps/linux/common/__syscall_fcntl.c
@@ -11,10 +11,12 @@
#include <stdarg.h>
#include <fcntl.h>
-#define __NR___syscall_fcntl __NR_fcntl
#ifdef __UCLIBC_HAS_LFS__
-static inline
+extern int __libc_fcntl64(int fd, int cmd, long arg);
#endif
+
+#define __NR___syscall_fcntl __NR_fcntl
+static inline
_syscall3(int, __syscall_fcntl, int, fd, int, cmd, long, arg);
int __libc_fcntl(int fd, int cmd, ...)
@@ -22,13 +24,18 @@ int __libc_fcntl(int fd, int cmd, ...)
long arg;
va_list list;
+ va_start(list, cmd);
+ arg = va_arg(list, long);
+ va_end(list);
+
if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
+#ifdef __UCLIBC_HAS_LFS__
+ return __libc_fcntl64(fd, cmd, arg);
+#else
__set_errno(ENOSYS);
return -1;
+#endif
}
- va_start(list, cmd);
- arg = va_arg(list, long);
- va_end(list);
return (__syscall_fcntl(fd, cmd, arg));
}
diff --git a/libc/sysdeps/linux/common/bits/errno.h b/libc/sysdeps/linux/common/bits/errno.h
index d31dca8aa..cb9c2ee43 100644
--- a/libc/sysdeps/linux/common/bits/errno.h
+++ b/libc/sysdeps/linux/common/bits/errno.h
@@ -37,7 +37,7 @@ extern int errno;
/* Function to get address of global `errno' variable. */
extern int *__errno_location (void) __THROW __attribute__ ((__const__));
-# if defined _LIBC && !defined(__set_errno)
+# if defined _LIBC
/* We wouldn't need a special macro anymore but it is history. */
# define __set_errno(val) ((errno) = (val))
# endif /* _LIBC */
diff --git a/libc/sysdeps/linux/common/bits/ipc.h b/libc/sysdeps/linux/common/bits/ipc.h
index 7cd2fd0c5..f1a043fe5 100644
--- a/libc/sysdeps/linux/common/bits/ipc.h
+++ b/libc/sysdeps/linux/common/bits/ipc.h
@@ -38,19 +38,19 @@
/* Special key values. */
#define IPC_PRIVATE ((__key_t) 0) /* Private key. */
+
/* Data structure used to pass permission information to IPC operations. */
struct ipc_perm
{
- __key_t __key; /* Key. */
- __uid_t uid; /* Owner's user ID. */
- __gid_t gid; /* Owner's group ID. */
- __uid_t cuid; /* Creator's user ID. */
- __gid_t cgid; /* Creator's group ID. */
- unsigned short int mode; /* Read/write permission. */
+ __key_t __key; /* Key. */
+ __uid_t uid; /* Owner's user ID. */
+ __gid_t gid; /* Owner's group ID. */
+ __uid_t cuid; /* Creator's user ID. */
+ __gid_t cgid; /* Creator's group ID. */
+ unsigned short int mode; /* Read/write permission. */
unsigned short int __pad1;
- unsigned short int __seq; /* Sequence number. */
+ unsigned short int __seq; /* Sequence number. */
unsigned short int __pad2;
unsigned long int __unused1;
unsigned long int __unused2;
};
-
diff --git a/libc/sysdeps/linux/common/bits/sem.h b/libc/sysdeps/linux/common/bits/sem.h
index f900136f0..6193501e2 100644
--- a/libc/sysdeps/linux/common/bits/sem.h
+++ b/libc/sysdeps/linux/common/bits/sem.h
@@ -36,15 +36,16 @@
/* Data structure describing a set of semaphores. */
-struct semid_ds {
- struct ipc_perm sem_perm; /* permissions .. see ipc.h */
- __kernel_time_t sem_otime; /* last semop time */
- __kernel_time_t sem_ctime; /* last change time */
- struct sem *sem_base; /* ptr to first semaphore in array */
- struct sem_queue *sem_pending; /* pending operations to be processed */
- struct sem_queue **sem_pending_last; /* last pending operation */
- struct sem_undo *undo; /* undo requests on this array */
- unsigned short sem_nsems; /* no. of semaphores in array */
+struct semid_ds
+{
+ struct ipc_perm sem_perm; /* operation permission struct */
+ __time_t sem_otime; /* last semop() time */
+ unsigned long int __unused1;
+ __time_t sem_ctime; /* last time changed by semctl() */
+ unsigned long int __unused2;
+ unsigned long int sem_nsems; /* number of semaphores in set */
+ unsigned long int __unused3;
+ unsigned long int __unused4;
};
/* The user should define a union like the following to use it for arguments
diff --git a/libc/sysdeps/linux/common/bits/sigthread.h b/libc/sysdeps/linux/common/bits/sigthread.h
index 960bde18a..0a634ac68 100644
--- a/libc/sysdeps/linux/common/bits/sigthread.h
+++ b/libc/sysdeps/linux/common/bits/sigthread.h
@@ -1,18 +1,18 @@
/* Signal handling function for threaded programs.
- Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
+ 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.
The GNU C 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
- Lesser General Public License for more details.
+ Library General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
+ You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
@@ -33,6 +33,6 @@ extern int pthread_sigmask (int __how,
__sigset_t *__restrict __oldmask)__THROW;
/* Send signal SIGNO to the given thread. */
-extern int pthread_kill (pthread_t __threadid, int __signo) __THROW;
+extern int pthread_kill (pthread_t __thread_id, int __signo) __THROW;
#endif /* bits/sigthread.h */
diff --git a/libc/sysdeps/linux/common/bits/stat.h b/libc/sysdeps/linux/common/bits/stat.h
index 3ecec4a47..3e8e77f65 100644
--- a/libc/sysdeps/linux/common/bits/stat.h
+++ b/libc/sysdeps/linux/common/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -63,11 +63,11 @@ struct stat
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
#endif
__time_t st_atime; /* Time of last access. */
- unsigned long int __unused1;
+ unsigned long int st_atimensec; /* Nscecs of last access. */
__time_t st_mtime; /* Time of last modification. */
- unsigned long int __unused2;
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
__time_t st_ctime; /* Time of last status change. */
- unsigned long int __unused3;
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
#ifndef __USE_FILE_OFFSET64
unsigned long int __unused4;
unsigned long int __unused5;
@@ -94,11 +94,11 @@ struct stat64
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
__time_t st_atime; /* Time of last access. */
- unsigned long int __unused1;
+ unsigned long int st_atimensec; /* Nscecs of last access. */
__time_t st_mtime; /* Time of last modification. */
- unsigned long int __unused2;
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
__time_t st_ctime; /* Time of last status change. */
- unsigned long int __unused3;
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
__ino64_t st_ino; /* File serial number. */
};
#endif
@@ -107,6 +107,8 @@ struct stat64
/* Tell code we have these members. */
#define _STATBUF_ST_BLKSIZE
#define _STATBUF_ST_RDEV
+/* Nanosecond resolution time values are supported. */
+#define _STATBUF_ST_NSEC
/* Encoding of the file mode. */
diff --git a/libc/sysdeps/linux/common/ioperm.c b/libc/sysdeps/linux/common/ioperm.c
index 8afba049e..874577a64 100644
--- a/libc/sysdeps/linux/common/ioperm.c
+++ b/libc/sysdeps/linux/common/ioperm.c
@@ -8,12 +8,12 @@
*/
#include "syscalls.h"
-# if defined __ARCH_HAS_MMU__ && defined __NR_ioperm
+#if defined __ARCH_HAS_MMU__ && defined __NR_ioperm
_syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on);
-# else
+#else
int ioperm(unsigned long from, unsigned long num, int turn_on)
{
__set_errno(ENOSYS);
return -1;
}
-# endif
+#endif
diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c
index bf04be41f..05eff4bc9 100644
--- a/libc/sysdeps/linux/common/pread_write.c
+++ b/libc/sysdeps/linux/common/pread_write.c
@@ -186,7 +186,9 @@ weak_alias (__libc_pread64, pread64)
#ifndef __NR_pwrite
ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
{
- return(__fake_pread_write(fd, buf, count, offset, 1));
+ /* we won't actually be modifying the buffer,
+ *just cast it to get rid of warnings */
+ return(__fake_pread_write(fd, (void*)buf, count, offset, 1));
}
weak_alias (__libc_pwrite, pwrite)
diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c
index ecfc67e5e..31833cbb9 100644
--- a/libc/sysdeps/linux/common/ssp.c
+++ b/libc/sysdeps/linux/common/ssp.c
@@ -20,6 +20,10 @@
# include <config.h>
#endif
+#ifdef __SSP__
+# error ssp.c has to be built w/ -fno-stack-protector
+#endif
+
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
@@ -30,29 +34,38 @@
#include <sys/syslog.h>
#include <sys/time.h>
#ifdef __SSP_USE_ERANDOM__
-#include <sys/sysctl.h>
+# include <sys/sysctl.h>
#endif
#ifdef __PROPOLICE_BLOCK_SEGV__
-#define SSP_SIGTYPE SIGSEGV
+# define SSP_SIGTYPE SIGSEGV
#elif __PROPOLICE_BLOCK_KILL__
-#define SSP_SIGTYPE SIGKILL
+# define SSP_SIGTYPE SIGKILL
#else
-#define SSP_SIGTYPE SIGABRT
+# define SSP_SIGTYPE SIGABRT
#endif
-/* prototypes */
-extern int __libc_open (__const char *file, int oflag, mode_t mode);
-extern ssize_t __libc_read(int fd, void *buf, size_t count);
-extern int __libc_close (int fd);
-
unsigned long __guard = 0UL;
+/* Use of __* functions from the rest of glibc here avoids
+ * initialisation problems for executables preloaded with
+ * libraries that overload the associated standard library
+ * functions.
+ */
+#ifdef __UCLIBC__
+extern int __libc_open(__const char *file, int flags, ...);
+extern ssize_t __libc_read(int fd, void *buf, size_t count);
+extern int __libc_close(int fd);
+#else
+# define __libc_open(file, flags) __open(file, flags)
+# define __libc_read(fd, buf, count) __read(fd, buf, count)
+# define __libc_close(fd) __close(fd)
+#endif
+
void __guard_setup(void) __attribute__ ((constructor));
void __guard_setup(void)
{
size_t size;
- struct timeval tv;
if (__guard != 0UL)
return;
@@ -61,18 +74,20 @@ void __guard_setup(void)
__guard = 0xFF0A0D00UL;
#ifndef __SSP_QUICK_CANARY__
-#ifdef __SSP_USE_ERANDOM__
- int mib[3];
- /* Random is another depth in Linux, hence an array of 3. */
- mib[0] = CTL_KERN;
- mib[1] = KERN_RANDOM;
- mib[2] = RANDOM_ERANDOM;
-
- size = sizeof(unsigned long);
- if (__sysctl(mib, 3, &__guard, &size, NULL, 0) != (-1))
- if (__guard != 0UL)
- return;
-#endif
+# ifdef __SSP_USE_ERANDOM__
+ {
+ int mib[3];
+ /* Random is another depth in Linux, hence an array of 3. */
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_RANDOM;
+ mib[2] = RANDOM_ERANDOM;
+
+ size = sizeof(unsigned long);
+ if (__sysctl(mib, 3, &__guard, &size, NULL, 0) != (-1))
+ if (__guard != 0UL)
+ return;
+ }
+# endif /* ifdef __SSP_USE_ERANDOM__ */
/*
* Attempt to open kernel pseudo random device if one exists before
* opening urandom to avoid system entropy depletion.
@@ -80,9 +95,9 @@ void __guard_setup(void)
{
int fd;
-#ifdef __SSP_USE_ERANDOM__
+# ifdef __SSP_USE_ERANDOM__
if ((fd = __libc_open("/dev/erandom", O_RDONLY)) == (-1))
-#endif
+# endif
fd = __libc_open("/dev/urandom", O_RDONLY);
if (fd != (-1)) {
size = __libc_read(fd, (char *) &__guard, sizeof(__guard));
@@ -91,13 +106,15 @@ void __guard_setup(void)
return;
}
}
-#endif
+#endif /* ifndef __SSP_QUICK_CANARY__ */
/* Everything failed? Or we are using a weakened model of the
* terminator canary */
-
- gettimeofday(&tv, NULL);
- __guard ^= tv.tv_usec ^ tv.tv_sec;
+ {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ __guard ^= tv.tv_usec ^ tv.tv_sec;
+ }
}
void __stack_smash_handler(char func[], int damaged __attribute__ ((unused)));
diff --git a/libc/sysdeps/linux/common/umount.c b/libc/sysdeps/linux/common/umount.c
index d8e890d8b..158aefc5f 100644
--- a/libc/sysdeps/linux/common/umount.c
+++ b/libc/sysdeps/linux/common/umount.c
@@ -9,26 +9,33 @@
#include "syscalls.h"
-#ifdef __NR_umount /* Some newer archs only have umount2 */
+
+/* arch provides umount() syscall */
+#ifdef __NR_umount
+
#include <sys/mount.h>
_syscall1(int, umount, const char *, specialfile);
+
+/* arch provides umount2() syscall */
#elif defined __NR_umount2
-/* No umount syscall, but umount2 is available.... Try to
- * emulate umount() using umount2() */
#define __NR___syscall_umount2 __NR_umount2
-static inline _syscall2(int, umount2, const char *, special_file, int, flags);
+static inline _syscall2(int, __syscall_umount2, const char *, special_file, int, flags);
int umount(const char *special_file)
{
return (__syscall_umount2(special_file, 0));
}
+
+/* arch doesn't provide any umount syscall !? */
#else
+
int umount(const char *special_file)
{
__set_errno(ENOSYS);
return -1;
}
+
#endif
diff --git a/libc/sysdeps/linux/common/xstatconv.c b/libc/sysdeps/linux/common/xstatconv.c
index fc25c43db..df6ebaa2b 100644
--- a/libc/sysdeps/linux/common/xstatconv.c
+++ b/libc/sysdeps/linux/common/xstatconv.c
@@ -34,42 +34,53 @@
void __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
{
- /* Convert to current kernel version of `struct stat'. */
- buf->st_dev = kbuf->st_dev;
- buf->st_ino = kbuf->st_ino;
- buf->st_mode = kbuf->st_mode;
- buf->st_nlink = kbuf->st_nlink;
- buf->st_uid = kbuf->st_uid;
- buf->st_gid = kbuf->st_gid;
- buf->st_rdev = kbuf->st_rdev;
- buf->st_size = kbuf->st_size;
- buf->st_blksize = kbuf->st_blksize;
- buf->st_blocks = kbuf->st_blocks;
- buf->st_atime = kbuf->st_atime;
- buf->st_mtime = kbuf->st_mtime;
- buf->st_ctime = kbuf->st_ctime;
+ /* Convert to current kernel version of `struct stat'. */
+ buf->st_dev = kbuf->st_dev;
+ buf->st_ino = kbuf->st_ino;
+ buf->st_mode = kbuf->st_mode;
+ buf->st_nlink = kbuf->st_nlink;
+ buf->st_uid = kbuf->st_uid;
+ buf->st_gid = kbuf->st_gid;
+ buf->st_rdev = kbuf->st_rdev;
+ buf->st_size = kbuf->st_size;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_blocks = kbuf->st_blocks;
+ buf->st_atime = kbuf->st_atime;
+ buf->st_mtime = kbuf->st_mtime;
+ buf->st_ctime = kbuf->st_ctime;
+#ifdef STAT_HAVE_NSEC
+ buf->st_atimensec = kbuf->st_atime_nsec;
+ buf->st_mtimensec = kbuf->st_mtime_nsec;
+ buf->st_ctimensec = kbuf->st_ctime_nsec;
+#endif
}
-#if defined __UCLIBC_HAS_LFS__
+#if defined(__UCLIBC_HAS_LFS__)
+
void __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
{
- /* Convert to current kernel version of `struct stat64'. */
- buf->st_dev = kbuf->st_dev;
- buf->st_ino = kbuf->st_ino;
+ /* Convert to current kernel version of `struct stat64'. */
+ buf->st_dev = kbuf->st_dev;
+ buf->st_ino = kbuf->st_ino;
#ifdef _HAVE_STAT64___ST_INO
- buf->__st_ino = kbuf->__st_ino;
+ buf->__st_ino = kbuf->__st_ino;
#endif
- buf->st_mode = kbuf->st_mode;
- buf->st_nlink = kbuf->st_nlink;
- buf->st_uid = kbuf->st_uid;
- buf->st_gid = kbuf->st_gid;
- buf->st_rdev = kbuf->st_rdev;
- buf->st_size = kbuf->st_size;
- buf->st_blksize = kbuf->st_blksize;
- buf->st_blocks = kbuf->st_blocks;
- buf->st_atime = kbuf->st_atime;
- buf->st_mtime = kbuf->st_mtime;
- buf->st_ctime = kbuf->st_ctime;
-}
+ buf->st_mode = kbuf->st_mode;
+ buf->st_nlink = kbuf->st_nlink;
+ buf->st_uid = kbuf->st_uid;
+ buf->st_gid = kbuf->st_gid;
+ buf->st_rdev = kbuf->st_rdev;
+ buf->st_size = kbuf->st_size;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_blocks = kbuf->st_blocks;
+ buf->st_atime = kbuf->st_atime;
+ buf->st_mtime = kbuf->st_mtime;
+ buf->st_ctime = kbuf->st_ctime;
+#ifdef STAT_HAVE_NSEC
+ buf->st_atimensec = kbuf->st_atime_nsec;
+ buf->st_mtimensec = kbuf->st_mtime_nsec;
+ buf->st_ctimensec = kbuf->st_ctime_nsec;
#endif
+}
+#endif /* __UCLIBC_HAS_LFS__ */