Perform some minor fixups

This commit is contained in:
Justine Tunney 2021-03-16 22:19:51 -07:00
parent ca88ce5026
commit 4e93750afd
9 changed files with 24 additions and 50 deletions

View file

@ -19,6 +19,7 @@
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/dce.h"
#include "libc/sysv/errfuns.h"
/**
* Changes size of file.
@ -31,9 +32,11 @@
* @asyncsignalsafe
*/
int ftruncate(int fd, int64_t length) {
if (fd < 0) return einval();
if (!IsWindows()) {
return sys_ftruncate(fd, length, length);
} else {
return sys_ftruncate_nt(fd, length);
if (fd >= g_fds.n) return ebadf();
return sys_ftruncate_nt(g_fds.p[fd].handle, length);
}
}