shithub: npe

ref: 086f757bc0f6c51c01e6300ce0370d774e6f9864
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;
}