2005-12-15 21:13:14 +00:00
|
|
|
/* Copyright (C) 1997-2000, 2003, 2004, 2005 Free Software Foundation, Inc.
|
1999-12-08 23:48:24 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
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 License, or (at your option) any later version.
|
1999-12-08 23:48:24 +00:00
|
|
|
|
|
|
|
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
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1999-12-08 23:48:24 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA. */
|
1999-12-08 23:48:24 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
2000-05-26 20:11:43 +00:00
|
|
|
#include <endian.h>
|
1999-12-08 23:48:24 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <sysdep.h>
|
|
|
|
#include <sys/syscall.h>
|
2000-07-07 02:19:06 +00:00
|
|
|
#include <bp-checks.h>
|
1999-12-08 23:48:24 +00:00
|
|
|
|
2004-12-22 20:10:10 +00:00
|
|
|
#include "kernel-features.h"
|
1999-12-08 23:48:24 +00:00
|
|
|
|
|
|
|
#ifdef __NR_truncate64
|
Update.
1999-12-23 Ulrich Drepper <drepper@cygnus.com>
* locale/programs/ld-monetary.c (monetary_finish): Add cast to
prevent warning.
* locale/programs/ld-collate.c: Implement writing out multibyte
collation data.
* locale/setlocale.c (setlocale): Allow setting LC_COLLATE again.
* locale/localeinfo.h: Declare variables only for currently implemented
collate functionality. Remove FORWARD_CHAR and ELLIPSIS_CHAR.
* locale/lc-collate.c: Define variables only for currently implemented
functionality.
* locale/langinfo.h: Define symbols only for currently implemented
functionality.
* locale/categories.def: Define elements for currently implemented
functionality.
* locale/C-collate.c: Comment out definitions of arrays with symbol
name definitions etc.
(_nl_C_LC_COLLATE): Update for currently defined information.
* intl/libintl.h: Remove dcgettext macro definition.
* intl/gettextP.h: Declare _nl_msg_cat_cntr.
* locale/iso-4217.def: Add NAD. Remove a few obsolete entries.
* sysdeps/generic/glob.c (glob): Pass alternate file access functions
also in recursive call. Patch by Joe Orton <joe@orton.demon.co.uk>.
1999-12-22 Jakub Jelinek <jakub@redhat.com>
* sysdeps/sparc/fpu/ftestexcept.c (fetestexcept): Use proper type
for __fenv_stfsr argument.
* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Add
truncate64, ftruncate64, fstat64, lstat64, stat64 and mmap2.
Remove ugetrlimit.
* sysdeps/unix/sysv/linux/sparc/sparc32/mmap64.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
(XSTAT_IS_XSTAT64): Define.
* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Add
__libc_lseek64, __libc_pread, __libc_pread64, __libc_pwrite
and __libc_pwrite64.
Remove oldgetrlimit and oldsetrlimit.
* sysdeps/unix/sysv/linux/sparc/sparc64/fxstat64.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc64/lxstat64.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc64/xstat64.c: New file.
* sysdeps/unix/sysv/linux/fxstat64.c (__fxstat64): Pass the buf
pointer to the syscall, not address of that pointer.
* sysdeps/unix/sysv/linux/lxstat64.c (__lxstat64): Likewise.
* sysdeps/unix/sysv/linux/xstat64.c (__xstat64): Likewise.
(__syscall_stat64): Provide proper prototype.
* sysdeps/unix/sysv/linux/ftruncate64.c (ftruncate64): Share
has_no_truncate64 between truncate64 and ftruncate64.
* sysdeps/unix/sysv/linux/truncate64.c (truncate64): Likewise.
* sysdeps/unix/sysv/linux/kernel-features.h
(__ASSUME_TRUNCATE64_SYSCALL, __ASSUME_MMAP2_SYSCALL,
__ASSUME_STAT64_SYSCALL): Define on Sparc for kernels >= 2.3.35.
1999-12-22 Andreas Jaeger <aj@suse.de>
* sysdeps/unix/sysv/linux/alpha/syscalls.list: Add __libc_lseek64,
__libc_pread, __libc_pread64, __libc_pwrite and __libc_pwrite64.
1999-12-24 05:55:50 +00:00
|
|
|
#ifndef __ASSUME_TRUNCATE64_SYSCALL
|
|
|
|
/* The variable is shared between all wrappers around *truncate64 calls. */
|
2000-01-17 05:24:52 +00:00
|
|
|
int __have_no_truncate64;
|
Update.
1999-12-23 Ulrich Drepper <drepper@cygnus.com>
* locale/programs/ld-monetary.c (monetary_finish): Add cast to
prevent warning.
* locale/programs/ld-collate.c: Implement writing out multibyte
collation data.
* locale/setlocale.c (setlocale): Allow setting LC_COLLATE again.
* locale/localeinfo.h: Declare variables only for currently implemented
collate functionality. Remove FORWARD_CHAR and ELLIPSIS_CHAR.
* locale/lc-collate.c: Define variables only for currently implemented
functionality.
* locale/langinfo.h: Define symbols only for currently implemented
functionality.
* locale/categories.def: Define elements for currently implemented
functionality.
* locale/C-collate.c: Comment out definitions of arrays with symbol
name definitions etc.
(_nl_C_LC_COLLATE): Update for currently defined information.
* intl/libintl.h: Remove dcgettext macro definition.
* intl/gettextP.h: Declare _nl_msg_cat_cntr.
* locale/iso-4217.def: Add NAD. Remove a few obsolete entries.
* sysdeps/generic/glob.c (glob): Pass alternate file access functions
also in recursive call. Patch by Joe Orton <joe@orton.demon.co.uk>.
1999-12-22 Jakub Jelinek <jakub@redhat.com>
* sysdeps/sparc/fpu/ftestexcept.c (fetestexcept): Use proper type
for __fenv_stfsr argument.
* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Add
truncate64, ftruncate64, fstat64, lstat64, stat64 and mmap2.
Remove ugetrlimit.
* sysdeps/unix/sysv/linux/sparc/sparc32/mmap64.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
(XSTAT_IS_XSTAT64): Define.
* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Add
__libc_lseek64, __libc_pread, __libc_pread64, __libc_pwrite
and __libc_pwrite64.
Remove oldgetrlimit and oldsetrlimit.
* sysdeps/unix/sysv/linux/sparc/sparc64/fxstat64.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc64/lxstat64.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc64/xstat64.c: New file.
* sysdeps/unix/sysv/linux/fxstat64.c (__fxstat64): Pass the buf
pointer to the syscall, not address of that pointer.
* sysdeps/unix/sysv/linux/lxstat64.c (__lxstat64): Likewise.
* sysdeps/unix/sysv/linux/xstat64.c (__xstat64): Likewise.
(__syscall_stat64): Provide proper prototype.
* sysdeps/unix/sysv/linux/ftruncate64.c (ftruncate64): Share
has_no_truncate64 between truncate64 and ftruncate64.
* sysdeps/unix/sysv/linux/truncate64.c (truncate64): Likewise.
* sysdeps/unix/sysv/linux/kernel-features.h
(__ASSUME_TRUNCATE64_SYSCALL, __ASSUME_MMAP2_SYSCALL,
__ASSUME_STAT64_SYSCALL): Define on Sparc for kernels >= 2.3.35.
1999-12-22 Andreas Jaeger <aj@suse.de>
* sysdeps/unix/sysv/linux/alpha/syscalls.list: Add __libc_lseek64,
__libc_pread, __libc_pread64, __libc_pwrite and __libc_pwrite64.
1999-12-24 05:55:50 +00:00
|
|
|
#endif
|
1999-12-08 23:48:24 +00:00
|
|
|
|
|
|
|
/* Truncate the file FD refers to to LENGTH bytes. */
|
|
|
|
int
|
2000-05-26 20:11:43 +00:00
|
|
|
truncate64 (const char *path, off64_t length)
|
1999-12-08 23:48:24 +00:00
|
|
|
{
|
|
|
|
#ifndef __ASSUME_TRUNCATE64_SYSCALL
|
2000-01-17 05:24:52 +00:00
|
|
|
if (! __have_no_truncate64)
|
1999-12-08 23:48:24 +00:00
|
|
|
#endif
|
|
|
|
{
|
1999-12-09 01:39:16 +00:00
|
|
|
unsigned int low = length & 0xffffffff;
|
|
|
|
unsigned int high = length >> 32;
|
1999-12-19 00:04:05 +00:00
|
|
|
#ifndef __ASSUME_TRUNCATE64_SYSCALL
|
|
|
|
int saved_errno = errno;
|
|
|
|
#endif
|
2000-07-07 02:19:06 +00:00
|
|
|
int result = INLINE_SYSCALL (truncate64, 3, CHECK_STRING (path),
|
2000-07-06 23:42:33 +00:00
|
|
|
__LONG_LONG_PAIR (high, low));
|
1999-12-08 23:48:24 +00:00
|
|
|
#ifndef __ASSUME_TRUNCATE64_SYSCALL
|
|
|
|
if (result != -1 || errno != ENOSYS)
|
|
|
|
#endif
|
|
|
|
return result;
|
|
|
|
|
|
|
|
#ifndef __ASSUME_TRUNCATE64_SYSCALL
|
1999-12-19 00:04:05 +00:00
|
|
|
__set_errno (saved_errno);
|
2000-01-17 05:24:52 +00:00
|
|
|
__have_no_truncate64 = 1;
|
1999-12-08 23:48:24 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef __ASSUME_TRUNCATE64_SYSCALL
|
|
|
|
if ((off_t) length != length)
|
|
|
|
{
|
|
|
|
__set_errno (EINVAL);
|
|
|
|
return -1;
|
|
|
|
}
|
2004-06-30 07:43:11 +00:00
|
|
|
return __truncate (path, (off_t) length);
|
1999-12-08 23:48:24 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
/* Use the generic implementation. */
|
2005-12-15 21:13:14 +00:00
|
|
|
# include <misc/truncate64.c>
|
1999-12-08 23:48:24 +00:00
|
|
|
#endif
|