shithub: npe

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