fstat.c 284 B

1234567891011121314151617181920
  1. #include "lib.h"
  2. #include <sys/stat.h>
  3. #include <errno.h>
  4. #include <stdlib.h>
  5. #include "sys9.h"
  6. #include "dir.h"
  7. int
  8. fstat(int fd, struct stat *buf)
  9. {
  10. Dir *d;
  11. if((d = _dirfstat(fd)) == nil){
  12. _syserrno();
  13. return -1;
  14. }
  15. _dirtostat(buf, d, &_fdinfo[fd]);
  16. free(d);
  17. return 0;
  18. }