summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2006-08-07 19:29:14 +0000
committerCorinna Vinschen <corinna@vinschen.de>2006-08-07 19:29:14 +0000
commit7636b58590621af3c341c3eb37a017e0e6598d3f (patch)
tree7105f91a629f9f9d14224b6405442cf841cf875f /winsup/cygwin/syscalls.cc
parent76ddec15abf7557374341c96f999b4965bc10d8d (diff)
downloadcygnal-7636b58590621af3c341c3eb37a017e0e6598d3f.tar.gz
cygnal-7636b58590621af3c341c3eb37a017e0e6598d3f.tar.bz2
cygnal-7636b58590621af3c341c3eb37a017e0e6598d3f.zip
* autoload.cc (NtSetInformationFile): Define.
* cygwin.din: Export posix_fadvise and posix_fallocate. * fhandler.cc (fhandler_base::fadvise): New method. (fhandler_base::ftruncate): Add allow_truncate parameter. * fhandler.h (class fhandler_base): Add fadvise method. Accomodate new parameter to ftruncate. (class fhandler_pipe): Add fadvise and ftruncate methods. (class fhandler_disk_file): Add fadvise method. Accomodate new parameter to ftruncate. * fhandler_disk_file.cc (fhandler_disk_file::fadvise): New method. (fhandler_disk_file::ftruncate): Accomodate new allow_truncate parameter. Set EOF using NtSetInformationFile on NT. * ntdll.h (struct _FILE_END_OF_FILE_INFORMATION): Define. (NtSetInformationFile): Declare. * pipe.cc (fhandler_pipe::fadvise): New method. (fhandler_pipe::ftruncate): Ditto. * syscalls.cc (posix_fadvise): New function. (posix_fallocate): Ditto. (ftruncate64): Accomodate second parameter to fhandler's ftruncate method. * include/fcntl.h: Add POSIX_FADV_* flags. Add declarations of posix_fadvise and posix_fallocate. * include/cygwin/version.h: Bump API minor number.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc34
1 files changed, 33 insertions, 1 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index a8b7aa815..c56cb58f0 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1753,12 +1753,44 @@ cygwin_setmode (int fd, int mode)
}
extern "C" int
+posix_fadvise (int fd, _off64_t offset, _off64_t len, int advice)
+{
+ int res = -1;
+ cygheap_fdget cfd (fd);
+ if (cfd >= 0)
+ res = cfd->fadvise (offset, len, advice);
+ else
+ set_errno (EBADF);
+ syscall_printf ("%d = posix_fadvice (%d, %D, %D, %d)",
+ res, fd, offset, len, advice);
+ return res;
+}
+
+extern "C" int
+posix_fallocate (int fd, _off64_t offset, _off64_t len)
+{
+ int res = -1;
+ if (offset < 0 || len == 0)
+ set_errno (EINVAL);
+ else
+ {
+ cygheap_fdget cfd (fd);
+ if (cfd >= 0)
+ res = cfd->ftruncate (offset + len, false);
+ else
+ set_errno (EBADF);
+ }
+ syscall_printf ("%d = posix_fallocate (%d, %D, %D)", res, fd, offset, len);
+ return res;
+}
+
+extern "C" int
ftruncate64 (int fd, _off64_t length)
{
int res = -1;
cygheap_fdget cfd (fd);
if (cfd >= 0)
- res = cfd->ftruncate (length);
+ res = cfd->ftruncate (length, true);
else
set_errno (EBADF);
syscall_printf ("%d = ftruncate (%d, %D)", res, fd, length);