home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari FTP
/
ATARI_FTP_0693.zip
/
ATARI_FTP_0693
/
Mint
/
mntlib25.zoo
/
statfs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-05
|
1KB
|
72 lines
/*
* statfs() emulation for MiNT/TOS
*
* Written by Adrian Ashley (adrian@secret.uucp)
* and placed in the public domain.
*/
#include <errno.h>
#include <stat.h>
#include <osbind.h>
#ifdef __TURBOC__
#include <sys\statfs.h>
#else
#include <sys/statfs.h>
#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 <stdio.h>
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