shithub: npe

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