1 #include "lib.h" 2 #include <sys/types.h> 3 #include <unistd.h> 4 #include <errno.h> 5 #include "dir.h" 6 7 int ftruncate(int fd,off_t length)8ftruncate(int fd, off_t length) 9 { 10 Dir d; 11 12 if(length < 0){ 13 errno = EINVAL; 14 return -1; 15 } 16 _nulldir(&d); 17 d.length = length; 18 if(_dirfwstat(fd, &d) < 0){ 19 _syserrno(); 20 return -1; 21 } 22 return 0; 23 } 24