1#ifdef __cplusplus
2extern "C" {
3#endif
4#include "EXTERN.h"
5#include "perl.h"
6#include "XSUB.h"
7#ifdef DF_STATFS_USE_MOUNT
8#include <sys/param.h>
9#include <sys/mount.h>
10#endif
11#ifdef DF_STATFS
12#include <sys/statfs.h>
13#endif
14#ifdef __cplusplus
15}
16#endif
17
18
19typedef struct statfs Statfs;
20
21
22MODULE = Filesys::Df	PACKAGE = Filesys::Df
23
24void
25_df(dir)
26	char *dir
27	PREINIT:
28	Statfs st;
29	PPCODE:
30	EXTEND(sp, 7);
31#ifdef DF_SOLARIS
32	if(statfs(dir, &st, 0, 0) == 0) {
33#else
34	if(statfs(dir, &st) == 0) {
35#endif
36		PUSHs(sv_2mortal(newSVnv((double)st.f_bsize)));
37		PUSHs(sv_2mortal(newSVnv((double)st.f_blocks)));
38		PUSHs(sv_2mortal(newSVnv((double)st.f_bfree)));
39#ifdef DF_SOLARIS
40		PUSHs(sv_2mortal(newSVnv((double)st.f_bfree)));
41#else
42		PUSHs(sv_2mortal(newSVnv((double)st.f_bavail)));
43#endif
44		PUSHs(sv_2mortal(newSVnv((double)st.f_files)));
45		PUSHs(sv_2mortal(newSVnv((double)st.f_ffree)));
46		/* No favail */
47		PUSHs(sv_2mortal(newSVnv((double)st.f_ffree)));
48	}
49
50	else {
51		PUSHs(sv_2mortal(newSVuv(0)));
52		PUSHs(sv_2mortal(newSVuv(0)));
53		PUSHs(sv_2mortal(newSVuv(0)));
54		PUSHs(sv_2mortal(newSVuv(0)));
55
56		PUSHs(sv_2mortal(newSVuv(0)));
57		PUSHs(sv_2mortal(newSVuv(0)));
58		PUSHs(sv_2mortal(newSVuv(0)));
59	}
60
61void
62_df_fh(fd)
63	int fd
64	PREINIT:
65	Statfs st;
66	PPCODE:
67	EXTEND(sp, 7);
68#ifdef DF_SOLARIS
69	if(fstatfs(fd, &st, 0, 0) == 0) {
70#else
71	if(fstatfs(fd, &st) == 0) {
72#endif
73		PUSHs(sv_2mortal(newSVnv((double)st.f_bsize)));
74		PUSHs(sv_2mortal(newSVnv((double)st.f_blocks)));
75		PUSHs(sv_2mortal(newSVnv((double)st.f_bfree)));
76#ifdef DF_SOLARIS
77		PUSHs(sv_2mortal(newSVnv((double)st.f_bfree)));
78#else
79		PUSHs(sv_2mortal(newSVnv((double)st.f_bavail)));
80#endif
81		PUSHs(sv_2mortal(newSVnv((double)st.f_files)));
82		PUSHs(sv_2mortal(newSVnv((double)st.f_ffree)));
83		/* No favail */
84		PUSHs(sv_2mortal(newSVnv((double)st.f_ffree)));
85	}
86
87	else {
88		PUSHs(sv_2mortal(newSVuv(0)));
89		PUSHs(sv_2mortal(newSVuv(0)));
90		PUSHs(sv_2mortal(newSVuv(0)));
91		PUSHs(sv_2mortal(newSVuv(0)));
92
93		PUSHs(sv_2mortal(newSVuv(0)));
94		PUSHs(sv_2mortal(newSVuv(0)));
95		PUSHs(sv_2mortal(newSVuv(0)));
96	}
97
98
99
100		
101