shithub: npe

ref: 176ccb9606a671c69cfcf1bdfb04a90c06cf5cce
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;
}