/* * statfs() emulation for MiNT/TOS * * Written by Adrian Ashley (adrian@secret.uucp) * and placed in the public domain. */ #include #include #include #ifdef __TURBOC__ #include #else #include #endif int statfs(path, buf) char *path; struct statfs *buf; { int r; _DISKINFO free; struct stat statbuf; if (!buf || !path) { errno = EFAULT; return -1; } r = stat(path, &statbuf); if (r == -1) return -1; (void) Dfree(&free, statbuf.st_dev + 1); buf->f_type = 0; buf->f_bsize = free.b_secsiz * free.b_clsiz; buf->f_blocks = free.b_total; buf->f_bfree = buf->f_bavail = free.b_free; buf->f_files = buf->f_ffree = buf->f_fsid.val[0] = buf->f_fsid.val[1] = -1L; return 0; } #ifdef TEST #include main(int argc, char **argv) { int i = 0, r; register char *p; struct statfs stbuf; while (--argc) { p = argv[++i]; r = statfs(p, &stbuf); if (r == -1) perror(p); else printf("statfs(`%s'): %ld free bytes\n", p, (long)(stbuf.f_bfree * stbuf.f_bsize)); } return 0; } #endif