summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/strnlen.c1
-rw-r--r--sysdeps/ia64/strlen.S4
-rw-r--r--sysdeps/posix/posix_fallocate.c43
-rw-r--r--sysdeps/posix/posix_fallocate64.c47
-rw-r--r--sysdeps/posix/sigignore.c2
-rw-r--r--sysdeps/posix/signal.c1
-rw-r--r--sysdeps/posix/sigset.c1
-rw-r--r--sysdeps/posix/sysv_signal.c2
-rw-r--r--sysdeps/s390/s390-64/bcopy.S12
-rw-r--r--sysdeps/unix/sysv/linux/dl-execstack.c24
-rw-r--r--sysdeps/unix/sysv/linux/ia64/has_cpuclock.c10
-rw-r--r--sysdeps/unix/sysv/linux/if_index.c9
-rw-r--r--sysdeps/unix/sysv/linux/ifaddrs.c166
-rw-r--r--sysdeps/unix/sysv/linux/netlinkaccess.h3
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c8
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c6
-rw-r--r--sysdeps/unix/sysv/linux/sleep.c1
-rw-r--r--sysdeps/unix/sysv/linux/sys/quota.h89
-rw-r--r--sysdeps/unix/sysv/linux/sysctl.c1
-rw-r--r--sysdeps/unix/sysv/linux/system.c1
20 files changed, 319 insertions, 112 deletions
diff --git a/sysdeps/generic/strnlen.c b/sysdeps/generic/strnlen.c
index c83520e349..6e526bbeba 100644
--- a/sysdeps/generic/strnlen.c
+++ b/sysdeps/generic/strnlen.c
@@ -158,3 +158,4 @@ __strnlen (const char *str, size_t maxlen)
return char_ptr - str;
}
weak_alias (__strnlen, strnlen)
+libc_hidden_def (strnlen)
diff --git a/sysdeps/ia64/strlen.S b/sysdeps/ia64/strlen.S
index a05b054ed8..e765f2f433 100644
--- a/sysdeps/ia64/strlen.S
+++ b/sysdeps/ia64/strlen.S
@@ -73,7 +73,7 @@ ENTRY(strlen)
ld8 val1 = [str], 8;;
nop.b 0
nop.b 0
-l2: ld8.s val2 = [str], 8 // don't bomb out here
+.l2: ld8.s val2 = [str], 8 // don't bomb out here
czx1.r pos0 = val1
;;
cmp.ne p6, p0 = 8, pos0
@@ -81,7 +81,7 @@ l2: ld8.s val2 = [str], 8 // don't bomb out here
chk.s val2, .recovery
.back:
mov val1 = val2
- br.cond.dptk l2
+ br.cond.dptk .l2
.foundit:
sub tmp = str, origadd // tmp = crt address - orig
add len = len, pos0;;
diff --git a/sysdeps/posix/posix_fallocate.c b/sysdeps/posix/posix_fallocate.c
index 838e7a004a..cbaeb49487 100644
--- a/sysdeps/posix/posix_fallocate.c
+++ b/sysdeps/posix/posix_fallocate.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2003, 2005 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
@@ -29,9 +29,8 @@ posix_fallocate (int fd, __off_t offset, __off_t len)
{
struct stat64 st;
struct statfs f;
- size_t step;
- /* `off_tī is a signed type. Therefore we can determine whether
+ /* `off_t' is a signed type. Therefore we can determine whether
OFFSET + LEN is too large if it is a negative value. */
if (offset < 0 || len < 0)
return EINVAL;
@@ -47,24 +46,48 @@ posix_fallocate (int fd, __off_t offset, __off_t len)
if (! S_ISREG (st.st_mode))
return ENODEV;
+ if (len == 0)
+ {
+ if (st.st_size < offset)
+ {
+ int ret = __ftruncate (fd, offset);
+
+ if (ret != 0)
+ ret = errno;
+ return ret;
+ }
+ return 0;
+ }
+
/* We have to know the block size of the filesystem to get at least some
sort of performance. */
if (__fstatfs (fd, &f) != 0)
return errno;
- /* Align OFFSET to block size and adjust LEN. */
- step = (offset + f.f_bsize - 1) % ~f.f_bsize;
- offset += step;
+ /* Try to play safe. */
+ if (f.f_bsize == 0)
+ f.f_bsize = 512;
/* Write something to every block. */
- while (len > step)
+ for (offset += (len - 1) % f.f_bsize; len > 0; offset += f.f_bsize)
{
- len -= step;
+ len -= f.f_bsize;
+
+ if (offset < st.st_size)
+ {
+ unsigned char c;
+ ssize_t rsize = __pread (fd, &c, 1, offset);
+
+ if (rsize < 0)
+ return errno;
+ /* If there is a non-zero byte, the block must have been
+ allocated already. */
+ else if (rsize == 1 && c != 0)
+ continue;
+ }
if (__pwrite (fd, "", 1, offset) != 1)
return errno;
-
- offset += step;
}
return 0;
diff --git a/sysdeps/posix/posix_fallocate64.c b/sysdeps/posix/posix_fallocate64.c
index 0eba4161a5..64ca9ae83d 100644
--- a/sysdeps/posix/posix_fallocate64.c
+++ b/sysdeps/posix/posix_fallocate64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2003, 2004, 2005 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
@@ -29,9 +29,8 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
{
struct stat64 st;
struct statfs64 f;
- size_t step;
- /* `off64_tī is a signed type. Therefore we can determine whether
+ /* `off64_t' is a signed type. Therefore we can determine whether
OFFSET + LEN is too large if it is a negative value. */
if (offset < 0 || len < 0)
return EINVAL;
@@ -47,24 +46,48 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
if (! S_ISREG (st.st_mode))
return ENODEV;
+ if (len == 0)
+ {
+ if (st.st_size < offset)
+ {
+ int ret = __ftruncate64 (fd, offset);
+
+ if (ret != 0)
+ ret = errno;
+ return ret;
+ }
+ return 0;
+ }
+
/* We have to know the block size of the filesystem to get at least some
sort of performance. */
if (__fstatfs64 (fd, &f) != 0)
return errno;
- /* Align OFFSET to block size and adjust LEN. */
- step = (offset + f.f_bsize - 1) % ~f.f_bsize;
- offset += step;
+ /* Try to play safe. */
+ if (f.f_bsize == 0)
+ f.f_bsize = 512;
/* Write something to every block. */
- while (len > step)
+ for (offset += (len - 1) % f.f_bsize; len > 0; offset += f.f_bsize)
{
- len -= step;
-
- if (__pwrite64 (fd, "", 1, offset) != 1)
+ len -= f.f_bsize;
+
+ if (offset < st.st_size)
+ {
+ unsigned char c;
+ ssize_t rsize = __libc_pread64 (fd, &c, 1, offset);
+
+ if (rsize < 0)
+ return errno;
+ /* If there is a non-zero byte, the block must have been
+ allocated already. */
+ else if (rsize == 1 && c != 0)
+ continue;
+ }
+
+ if (__libc_pwrite64 (fd, "", 1, offset) != 1)
return errno;
-
- offset += step;
}
return 0;
diff --git a/sysdeps/posix/sigignore.c b/sysdeps/posix/sigignore.c
index 361a19e0dc..4fff563197 100644
--- a/sysdeps/posix/sigignore.c
+++ b/sysdeps/posix/sigignore.c
@@ -22,6 +22,8 @@
#define __need_NULL
#include <stddef.h>
#include <signal.h>
+#include <string.h> /* For the real memset prototype. */
+
int
sigignore (sig)
diff --git a/sysdeps/posix/signal.c b/sysdeps/posix/signal.c
index 9a8efee043..076d120e35 100644
--- a/sysdeps/posix/signal.c
+++ b/sysdeps/posix/signal.c
@@ -19,6 +19,7 @@
#include <errno.h>
#include <signal.h>
+#include <string.h> /* For the real memset prototype. */
sigset_t _sigintr attribute_hidden; /* Set by siginterrupt. */
diff --git a/sysdeps/posix/sigset.c b/sysdeps/posix/sigset.c
index 873c1cb1e6..e995c73898 100644
--- a/sysdeps/posix/sigset.c
+++ b/sysdeps/posix/sigset.c
@@ -20,6 +20,7 @@
#define __need_NULL
#include <stddef.h>
#include <signal.h>
+#include <string.h> /* For the real memset prototype. */
/* Set the disposition for SIG. */
diff --git a/sysdeps/posix/sysv_signal.c b/sysdeps/posix/sysv_signal.c
index ca2e84f372..9908051206 100644
--- a/sysdeps/posix/sysv_signal.c
+++ b/sysdeps/posix/sysv_signal.c
@@ -18,6 +18,8 @@
#include <errno.h>
#include <signal.h>
+#include <string.h> /* For the real memset prototype. */
+
/* Tolerate non-threads versions of Posix */
#ifndef SA_ONESHOT
diff --git a/sysdeps/s390/s390-64/bcopy.S b/sysdeps/s390/s390-64/bcopy.S
index ff7966723b..f0df54c340 100644
--- a/sysdeps/s390/s390-64/bcopy.S
+++ b/sysdeps/s390/s390-64/bcopy.S
@@ -59,14 +59,10 @@ ENTRY(__bcopy)
jo .L6
br %r14
.L7: # destructive overlay, can not use mvcle
- lgr %r1,%r2 # bcopy is called with source,dest
- lgr %r2,%r3 # memmove with dest,source! Oh, well...
- lgr %r3,%r1
-#ifdef PIC
- jg memmove@PLT
-#else
- jg memmove
-#endif
+ lgr %r1,%r2 # bcopy is called with source,dest
+ lgr %r2,%r3 # memmove with dest,source! Oh, well...
+ lgr %r3,%r1
+ jg HIDDEN_BUILTIN_JUMPTARGET(memmove)
END(__bcopy)
diff --git a/sysdeps/unix/sysv/linux/dl-execstack.c b/sysdeps/unix/sysv/linux/dl-execstack.c
index 6ef9679045..0a5b83b69c 100644
--- a/sysdeps/unix/sysv/linux/dl-execstack.c
+++ b/sysdeps/unix/sysv/linux/dl-execstack.c
@@ -24,6 +24,7 @@
#include <stdbool.h>
#include <stackinfo.h>
#include <caller.h>
+#include <sysdep.h>
#include "kernel-features.h"
@@ -38,6 +39,7 @@ _dl_make_stack_executable (void **stack_endp)
/* This gives us the highest/lowest page that needs to be changed. */
uintptr_t page = ((uintptr_t) *stack_endp
& -(intptr_t) GLRO(dl_pagesize));
+ int result = 0;
/* Challenge the caller. */
if (__builtin_expect (__check_caller (RETURN_ADDRESS (0),
@@ -60,7 +62,10 @@ _dl_make_stack_executable (void **stack_endp)
no_growsupdown = true;
else
# endif
- return errno;
+ {
+ result = errno;
+ goto out;
+ }
}
#endif
@@ -85,7 +90,10 @@ _dl_make_stack_executable (void **stack_endp)
else
{
if (errno != ENOMEM) /* Unexpected failure mode. */
- return errno;
+ {
+ result = errno;
+ goto out;
+ }
if (size == GLRO(dl_pagesize))
/* We just tried to mprotect the top hole page and failed.
@@ -108,7 +116,10 @@ _dl_make_stack_executable (void **stack_endp)
else
{
if (errno != ENOMEM) /* Unexpected failure mode. */
- return errno;
+ {
+ result = errno;
+ goto out;
+ }
if (size == GLRO(dl_pagesize))
/* We just tried to mprotect the lowest hole page and failed.
@@ -133,6 +144,11 @@ _dl_make_stack_executable (void **stack_endp)
/* Remember that we changed the permission. */
GL(dl_stack_flags) |= PF_X;
- return 0;
+ out:
+#ifdef check_consistency
+ check_consistency ();
+#endif
+
+ return result;
}
rtld_hidden_def (_dl_make_stack_executable)
diff --git a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
index ee19161272..883508a562 100644
--- a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
+++ b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
@@ -21,7 +21,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
-
+#include <not-cancel.h>
static int itc_usable;
@@ -31,18 +31,18 @@ has_cpuclock (void)
if (__builtin_expect (itc_usable == 0, 0))
{
int newval = 1;
- int fd = open ("/proc/sal/itc_drift", O_RDONLY);
+ int fd = open_not_cancel_2 ("/proc/sal/itc_drift", O_RDONLY);
if (__builtin_expect (fd != -1, 1))
{
char buf[16];
/* We expect the file to contain a single digit followed by
a newline. If the format changes we better not rely on
the file content. */
- if (read (fd, buf, sizeof buf) != 2 || buf[0] != '0'
- || buf[1] != '\n')
+ if (read_not_cancel (fd, buf, sizeof buf) != 2
+ || buf[0] != '0' || buf[1] != '\n')
newval = -1;
- close (fd);
+ close_not_cancel_no_status (fd);
}
itc_usable = newval;
diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c
index 377ccf5199..f434bbe7d1 100644
--- a/sysdeps/unix/sysv/linux/if_index.c
+++ b/sysdeps/unix/sysv/linux/if_index.c
@@ -188,12 +188,8 @@ if_nameindex_netlink (void)
/* Tell the kernel that we wish to get a list of all
- active interfaces. */
- if (__netlink_sendreq (&nh, RTM_GETLINK) < 0)
- goto exit_close;
-
- /* Collect all data for every interface. */
- if (__netlink_receive (&nh) < 0)
+ active interfaces. Collect all data for every interface. */
+ if (__netlink_request (&nh, RTM_GETLINK) < 0)
goto exit_free;
/* Count the interfaces. */
@@ -290,7 +286,6 @@ if_nameindex_netlink (void)
exit_free:
__netlink_free_handle (&nh);
- exit_close:
__netlink_close (&nh);
return idx;
diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c
index 8a052e212d..6f43475ca9 100644
--- a/sysdeps/unix/sysv/linux/ifaddrs.c
+++ b/sysdeps/unix/sysv/linux/ifaddrs.c
@@ -17,6 +17,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <alloca.h>
#include <assert.h>
#include <errno.h>
#include <ifaddrs.h>
@@ -24,6 +25,7 @@
#include <netinet/in.h>
#include <netpacket/packet.h>
#include <stdbool.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
@@ -84,7 +86,7 @@ __netlink_free_handle (struct netlink_handle *h)
}
-int
+static int
__netlink_sendreq (struct netlink_handle *h, int type)
{
struct
@@ -114,15 +116,39 @@ __netlink_sendreq (struct netlink_handle *h, int type)
int
-__netlink_receive (struct netlink_handle *h)
+__netlink_request (struct netlink_handle *h, int type)
{
struct netlink_res *nlm_next;
- char buf[4096];
- struct iovec iov = { buf, sizeof (buf) };
+ struct netlink_res **new_nlm_list;
+ static volatile size_t buf_size = 4096;
+ char *buf;
struct sockaddr_nl nladdr;
struct nlmsghdr *nlmh;
- int read_len;
+ ssize_t read_len;
bool done = false;
+ bool use_malloc = false;
+
+ if (__netlink_sendreq (h, type) < 0)
+ return -1;
+
+ size_t this_buf_size = buf_size;
+ if (__libc_use_alloca (this_buf_size))
+ buf = alloca (this_buf_size);
+ else
+ {
+ buf = malloc (this_buf_size);
+ if (buf != NULL)
+ use_malloc = true;
+ else
+ goto out_fail;
+ }
+
+ struct iovec iov = { buf, this_buf_size };
+
+ if (h->nlm_list != NULL)
+ new_nlm_list = &h->end_ptr->next;
+ else
+ new_nlm_list = &h->nlm_list;
while (! done)
{
@@ -136,33 +162,66 @@ __netlink_receive (struct netlink_handle *h)
read_len = TEMP_FAILURE_RETRY (__recvmsg (h->fd, &msg, 0));
if (read_len < 0)
- return -1;
+ goto out_fail;
- if (msg.msg_flags & MSG_TRUNC)
- return -1;
+ if (nladdr.nl_pid != 0)
+ continue;
- nlm_next = (struct netlink_res *) malloc (sizeof (struct netlink_res)
- + read_len);
- if (nlm_next == NULL)
- return -1;
- nlm_next->next = NULL;
- nlm_next->nlh = memcpy (nlm_next + 1, buf, read_len);
- nlm_next->size = read_len;
- nlm_next->seq = h->seq;
- if (h->nlm_list == NULL)
- h->nlm_list = nlm_next;
- else
- h->end_ptr->next = nlm_next;
- h->end_ptr = nlm_next;
+ if (__builtin_expect (msg.msg_flags & MSG_TRUNC, 0))
+ {
+ if (this_buf_size >= SIZE_MAX / 2)
+ goto out_fail;
+
+ nlm_next = *new_nlm_list;
+ while (nlm_next != NULL)
+ {
+ struct netlink_res *tmpptr;
+
+ tmpptr = nlm_next->next;
+ free (nlm_next);
+ nlm_next = tmpptr;
+ }
+ *new_nlm_list = NULL;
+
+ if (__libc_use_alloca (2 * this_buf_size))
+ buf = extend_alloca (buf, this_buf_size, 2 * this_buf_size);
+ else
+ {
+ this_buf_size *= 2;
+
+ char *new_buf = realloc (use_malloc ? buf : NULL, this_buf_size);
+ if (new_buf == NULL)
+ goto out_fail;
+ new_buf = buf;
+ use_malloc = true;
+ }
+ buf_size = this_buf_size;
+
+ iov.iov_base = buf;
+ iov.iov_len = this_buf_size;
+
+ /* Increase sequence number, so that we can distinguish
+ between old and new request messages. */
+ h->seq++;
+
+ if (__netlink_sendreq (h, type) < 0)
+ goto out_fail;
+
+ continue;
+ }
+
+ size_t count = 0;
+ size_t remaining_len = read_len;
for (nlmh = (struct nlmsghdr *) buf;
- NLMSG_OK (nlmh, (size_t) read_len);
- nlmh = (struct nlmsghdr *) NLMSG_NEXT (nlmh, read_len))
+ NLMSG_OK (nlmh, remaining_len);
+ nlmh = (struct nlmsghdr *) NLMSG_NEXT (nlmh, remaining_len))
{
- if (nladdr.nl_pid != 0 || (pid_t) nlmh->nlmsg_pid != h->pid
+ if ((pid_t) nlmh->nlmsg_pid != h->pid
|| nlmh->nlmsg_seq != h->seq)
continue;
+ ++count;
if (nlmh->nlmsg_type == NLMSG_DONE)
{
/* We found the end, leave the loop. */
@@ -176,11 +235,38 @@ __netlink_receive (struct netlink_handle *h)
errno = EIO;
else
errno = -nlerr->error;
- return -1;
+ goto out_fail;
}
}
+
+ /* If there was nothing with the expected nlmsg_pid and nlmsg_seq,
+ there is no point to record it. */
+ if (count == 0)
+ continue;
+
+ nlm_next = (struct netlink_res *) malloc (sizeof (struct netlink_res)
+ + read_len);
+ if (nlm_next == NULL)
+ goto out_fail;
+ nlm_next->next = NULL;
+ nlm_next->nlh = memcpy (nlm_next + 1, buf, read_len);
+ nlm_next->size = read_len;
+ nlm_next->seq = h->seq;
+ if (h->nlm_list == NULL)
+ h->nlm_list = nlm_next;
+ else
+ h->end_ptr->next = nlm_next;
+ h->end_ptr = nlm_next;
}
+
+ if (use_malloc)
+ free (buf);
return 0;
+
+out_fail:
+ if (use_malloc)
+ free (buf);
+ return -1;
}
@@ -268,7 +354,7 @@ getifaddrs (struct ifaddrs **ifap)
unsigned int i, newlink, newaddr, newaddr_idx;
int *map_newlink_data;
size_t ifa_data_size = 0; /* Size to allocate for all ifa_data. */
- char *ifa_data_ptr; /* Pointer to the unused part of memory for
+ char *ifa_data_ptr; /* Pointer to the unused part of memory for
ifa_data. */
int result = 0;
@@ -288,28 +374,20 @@ getifaddrs (struct ifaddrs **ifap)
#endif
/* Tell the kernel that we wish to get a list of all
- active interfaces. */
- if (__netlink_sendreq (&nh, RTM_GETLINK) < 0)
- {
- result = -1;
- goto exit_close;
- }
- /* Collect all data for every interface. */
- if (__netlink_receive (&nh) < 0)
+ active interfaces, collect all data for every interface. */
+ if (__netlink_request (&nh, RTM_GETLINK) < 0)
{
result = -1;
goto exit_free;
}
-
/* Now ask the kernel for all addresses which are assigned
- to an interface. Since we store the addresses after the
- interfaces in the list, we will later always find the
- interface before the corresponding addresses. */
+ to an interface and collect all data for every interface.
+ Since we store the addresses after the interfaces in the
+ list, we will later always find the interface before the
+ corresponding addresses. */
++nh.seq;
- if (__netlink_sendreq (&nh, RTM_GETADDR) < 0
- /* Collect all data for every interface. */
- || __netlink_receive (&nh) < 0)
+ if (__netlink_request (&nh, RTM_GETADDR) < 0)
{
result = -1;
goto exit_free;
@@ -327,7 +405,7 @@ getifaddrs (struct ifaddrs **ifap)
continue;
/* Walk through all entries we got from the kernel and look, which
- message type they contain. */
+ message type they contain. */
for (nlh = nlp->nlh; NLMSG_OK (nlh, size); nlh = NLMSG_NEXT (nlh, size))
{
/* Check if the message is what we want. */
@@ -423,7 +501,7 @@ getifaddrs (struct ifaddrs **ifap)
/* Interfaces are stored in the first "newlink" entries
of our list, starting in the order as we got from the
kernel. */
- ifa_index = map_newlink (ifim->ifi_index - 1, ifas,
+ ifa_index = map_newlink (ifim->ifi_index - 1, ifas,
map_newlink_data, newlink);
ifas[ifa_index].ifa.ifa_flags = ifim->ifi_flags;
@@ -767,8 +845,6 @@ getifaddrs (struct ifaddrs **ifap)
exit_free:
__netlink_free_handle (&nh);
-
- exit_close:
__netlink_close (&nh);
return result;
diff --git a/sysdeps/unix/sysv/linux/netlinkaccess.h b/sysdeps/unix/sysv/linux/netlinkaccess.h
index 6672e714ff..f0b8e364bc 100644
--- a/sysdeps/unix/sysv/linux/netlinkaccess.h
+++ b/sysdeps/unix/sysv/linux/netlinkaccess.h
@@ -55,8 +55,7 @@ extern int __no_netlink_support attribute_hidden;
extern int __netlink_open (struct netlink_handle *h);
extern void __netlink_close (struct netlink_handle *h);
extern void __netlink_free_handle (struct netlink_handle *h);
-extern int __netlink_sendreq (struct netlink_handle *h, int type);
-extern int __netlink_receive (struct netlink_handle *h);
+extern int __netlink_request (struct netlink_handle *h, int type);
#endif /* netlinkaccess.h */
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c
index e79d74cb75..069f94bd9d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997,1998,1999,2000,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2002, 2005 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
@@ -28,7 +28,7 @@
#ifdef __NR_ftruncate64
#ifndef __ASSUME_TRUNCATE64_SYSCALL
/* The variable is shared between all wrappers around *truncate64 calls. */
-extern int have_no_truncate64;
+extern int __have_no_truncate64;
#endif
@@ -39,7 +39,7 @@ __ftruncate64 (fd, length)
off64_t length;
{
#ifndef __ASSUME_TRUNCATE64_SYSCALL
- if (! have_no_truncate64)
+ if (! __have_no_truncate64)
#endif
{
#ifndef __ASSUME_TRUNCATE64_SYSCALL
@@ -57,7 +57,7 @@ __ftruncate64 (fd, length)
#ifndef __ASSUME_TRUNCATE64_SYSCALL
__set_errno (saved_errno);
- have_no_truncate64 = 1;
+ __have_no_truncate64 = 1;
#endif
}
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c
index ce8ebc2a97..01698a419f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c
@@ -29,7 +29,7 @@
#ifdef __NR_truncate64
#ifndef __ASSUME_TRUNCATE64_SYSCALL
/* The variable is shared between all wrappers around *truncate64 calls. */
-int have_no_truncate64;
+int __have_no_truncate64;
#endif
@@ -40,7 +40,7 @@ truncate64 (path, length)
off64_t length;
{
#ifndef __ASSUME_TRUNCATE64_SYSCALL
- if (! have_no_truncate64)
+ if (! __have_no_truncate64)
#endif
{
#ifndef __ASSUME_TRUNCATE64_SYSCALL
@@ -58,7 +58,7 @@ truncate64 (path, length)
#ifndef __ASSUME_TRUNCATE64_SYSCALL
__set_errno (saved_errno);
- have_no_truncate64 = 1;
+ __have_no_truncate64 = 1;
#endif
}
diff --git a/sysdeps/unix/sysv/linux/sleep.c b/sysdeps/unix/sysv/linux/sleep.c
index d94e4f62fd..4f2b8acc55 100644
--- a/sysdeps/unix/sysv/linux/sleep.c
+++ b/sysdeps/unix/sysv/linux/sleep.c
@@ -21,6 +21,7 @@
#include <errno.h>
#include <time.h>
#include <signal.h>
+#include <string.h> /* For the real memset prototype. */
#include <unistd.h>
#include <sys/param.h>
diff --git a/sysdeps/unix/sysv/linux/sys/quota.h b/sysdeps/unix/sysv/linux/sys/quota.h
index a8baf40a91..be2810e0c7 100644
--- a/sysdeps/unix/sysv/linux/sys/quota.h
+++ b/sysdeps/unix/sysv/linux/sys/quota.h
@@ -41,6 +41,14 @@
#include <sys/types.h>
/*
+ * Select between different incompatible quota versions.
+ * Default to the version used by Linux kernel version 2.4.22
+ * or later. */
+#ifndef _LINUX_QUOTA_VERSION
+# define _LINUX_QUOTA_VERSION 2
+#endif
+
+/*
* Convert diskblocks to blocks and the other way around.
* currently only to fool the BSD source. :-)
*/
@@ -94,21 +102,33 @@
#define SUBCMDSHIFT 8
#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
-#define Q_QUOTAON 0x0100 /* enable quotas */
-#define Q_QUOTAOFF 0x0200 /* disable quotas */
-#define Q_GETQUOTA 0x0300 /* get limits and usage */
-#define Q_SETQUOTA 0x0400 /* set limits and usage */
-#define Q_SETUSE 0x0500 /* set usage */
-#define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */
-#define Q_SETQLIM 0x0700 /* set limits */
-#define Q_GETSTATS 0x0800 /* get collected stats */
-#define Q_RSQUASH 0x1000 /* set root_squash option */
+#if _LINUX_QUOTA_VERSION < 2
+# define Q_QUOTAON 0x0100 /* enable quotas */
+# define Q_QUOTAOFF 0x0200 /* disable quotas */
+# define Q_GETQUOTA 0x0300 /* get limits and usage */
+# define Q_SETQUOTA 0x0400 /* set limits and usage */
+# define Q_SETUSE 0x0500 /* set usage */
+# define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */
+# define Q_SETQLIM 0x0700 /* set limits */
+# define Q_GETSTATS 0x0800 /* get collected stats */
+# define Q_RSQUASH 0x1000 /* set root_squash option */
+#else
+# define Q_SYNC 0x800001 /* sync disk copy of a filesystems quotas */
+# define Q_QUOTAON 0x800002 /* turn quotas on */
+# define Q_QUOTAOFF 0x800003 /* turn quotas off */
+# define Q_GETFMT 0x800004 /* get quota format used on given filesystem */
+# define Q_GETINFO 0x800005 /* get information about quota files */
+# define Q_SETINFO 0x800006 /* set information about quota files */
+# define Q_GETQUOTA 0x800007 /* get user quota structure */
+# define Q_SETQUOTA 0x800008 /* set user quota structure */
+#endif
/*
* The following structure defines the format of the disk quota file
* (as it appears on disk) - the file is an array of these structures
* indexed by user or group number.
*/
+#if _LINUX_QUOTA_VERSION < 2
struct dqblk
{
u_int32_t dqb_bhardlimit; /* absolute limit on disk blks alloc */
@@ -120,13 +140,45 @@ struct dqblk
time_t dqb_btime; /* time limit for excessive disk use */
time_t dqb_itime; /* time limit for excessive files */
};
+#else
+
+/* Flags that indicate which fields in dqblk structure are valid. */
+#define QIF_BLIMITS 1
+#define QIF_SPACE 2
+#define QIF_ILIMITS 4
+#define QIF_INODES 8
+#define QIF_BTIME 16
+#define QIF_ITIME 32
+#define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
+#define QIF_USAGE (QIF_SPACE | QIF_INODES)
+#define QIF_TIMES (QIF_BTIME | QIF_ITIME)
+#define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
+
+struct dqblk
+ {
+ u_int64_t dqb_bhardlimit; /* absolute limit on disk quota blocks alloc */
+ u_int64_t dqb_bsoftlimit; /* preferred limit on disk quota blocks */
+ u_int64_t dqb_curspace; /* current quota block count */
+ u_int64_t dqb_ihardlimit; /* maximum # allocated inodes */
+ u_int64_t dqb_isoftlimit; /* preferred inode limit */
+ u_int64_t dqb_curinodes; /* current # allocated inodes */
+ u_int64_t dqb_btime; /* time limit for excessive disk use */
+ u_int64_t dqb_itime; /* time limit for excessive files */
+ u_int32_t dqb_valid; /* bitmask of QIF_* constants */
+ };
+#endif
/*
* Shorthand notation.
*/
#define dq_bhardlimit dq_dqb.dqb_bhardlimit
#define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
-#define dq_curblocks dq_dqb.dqb_curblocks
+#if _LINUX_QUOTA_VERSION < 2
+# define dq_curblocks dq_dqb.dqb_curblocks
+#else
+# define dq_curspace dq_dqb.dqb_curspace
+# define dq_valid dq_dqb.dqb_valid
+#endif
#define dq_ihardlimit dq_dqb.dqb_ihardlimit
#define dq_isoftlimit dq_dqb.dqb_isoftlimit
#define dq_curinodes dq_dqb.dqb_curinodes
@@ -135,6 +187,7 @@ struct dqblk
#define dqoff(UID) ((loff_t)((UID) * sizeof (struct dqblk)))
+#if _LINUX_QUOTA_VERSION < 2
struct dqstats
{
u_int32_t lookups;
@@ -147,6 +200,22 @@ struct dqstats
u_int32_t free_dquots;
u_int32_t syncs;
};
+#else
+
+/* Flags that indicate which fields in dqinfo structure are valid. */
+# define IIF_BGRACE 1
+# define IIF_IGRACE 2
+# define IIF_FLAGS 4
+# define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
+
+struct dqinfo
+ {
+ u_int64_t dqi_bgrace;
+ u_int64_t dqi_igrace;
+ u_int32_t dqi_flags;
+ u_int32_t dqi_valid;
+ };
+#endif
__BEGIN_DECLS
diff --git a/sysdeps/unix/sysv/linux/sysctl.c b/sysdeps/unix/sysv/linux/sysctl.c
index 7e601acf2c..1cdeb12638 100644
--- a/sysdeps/unix/sysv/linux/sysctl.c
+++ b/sysdeps/unix/sysv/linux/sysctl.c
@@ -18,6 +18,7 @@
02111-1307 USA. */
#include <errno.h>
+#include <string.h> /* For the real memset prototype. */
#include <sys/sysctl.h>
#include <sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/system.c b/sysdeps/unix/sysv/linux/system.c
index 3fdff04c22..688487cb9f 100644
--- a/sysdeps/unix/sysv/linux/system.c
+++ b/sysdeps/unix/sysv/linux/system.c
@@ -18,6 +18,7 @@
#include <sched.h>
#include <signal.h>
+#include <string.h> /* For the real memset prototype. */
#include <sysdep.h>
#include <unistd.h>
#include <sys/wait.h>