shithub: npe

ref: 090b7a5e6744afa35aa1a8ca66071748c228a776
dir: /libnpe/ftruncate.c/

View raw version
#include <npe.h>
#include <errno.h>

int
ftruncate(int fd, off_t length)
{
	Dir d;

	if(length < 0){
		errno = EINVAL;
		return -1;
	}
	nulldir(&d);
	d.length = length;
	if(dirfwstat(fd, &d) < 0){
		errno = ENOENT;
		return -1;
	}
	return 0;
}