* 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.
This commit is contained in:
@@ -1752,13 +1752,45 @@ cygwin_setmode (int fd, int mode)
|
||||
return res;
|
||||
}
|
||||
|
||||
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);
|
||||
|
Reference in New Issue
Block a user