Debian Codegraph @

XS_statvfs

raw
1 #ifdef __cplusplus
2 extern "C" {
3 #endif
4 #include "EXTERN.h"
5 #include "perl.h"
6 #include "XSUB.h"
7 #include <sys/statvfs.h>
8 #ifdef __cplusplus
9 }
10 #endif
11
12 typedef struct statvfs Statvfs;
13
14
15 MODULE = Filesys::Df PACKAGE = Filesys::Df
16
17
18 void
19 _df(dir)
20 char *dir
21 PREINIT:
22 Statvfs st;
23 PPCODE:
24 EXTEND(sp, 7);
25 if(statvfs(dir, &st) == 0) {
26 /* Push values as doubles because we don't know size */
27 PUSHs(sv_2mortal(newSVnv((double)st.f_frsize)));
28 PUSHs(sv_2mortal(newSVnv((double)st.f_blocks)));
29 PUSHs(sv_2mortal(newSVnv((double)st.f_bfree)));
30 PUSHs(sv_2mortal(newSVnv((double)st.f_bavail)));
31
32 PUSHs(sv_2mortal(newSVnv((double)st.f_files)));
33 PUSHs(sv_2mortal(newSVnv((double)st.f_ffree)));
34 PUSHs(sv_2mortal(newSVnv((double)st.f_favail)));
35 }
36
37 else {
38 PUSHs(sv_2mortal(newSVuv(0)));
39 PUSHs(sv_2mortal(newSVuv(0)));
40 PUSHs(sv_2mortal(newSVuv(0)));
41 PUSHs(sv_2mortal(newSVuv(0)));
42
43 PUSHs(sv_2mortal(newSVuv(0)));
44 PUSHs(sv_2mortal(newSVuv(0)));
45 PUSHs(sv_2mortal(newSVuv(0)));
46 }
47
48 void
49 _df_fh(fd)
50 int fd;
51 PREINIT:
52 Statvfs st;
53 PPCODE:
54 EXTEND(sp, 7);
55 if(fstatvfs(fd, &st) == 0) {
56 /* Push values as doubles because we don't know size */
57 PUSHs(sv_2mortal(newSVnv((double)st.f_frsize)));
58 PUSHs(sv_2mortal(newSVnv((double)st.f_blocks)));
59 PUSHs(sv_2mortal(newSVnv((double)st.f_bfree)));
60 PUSHs(sv_2mortal(newSVnv((double)st.f_bavail)));
61
62 PUSHs(sv_2mortal(newSVnv((double)st.f_files)));
63 PUSHs(sv_2mortal(newSVnv((double)st.f_ffree)));
64 PUSHs(sv_2mortal(newSVnv((double)st.f_favail)));
65 }
66
67 else {
68 PUSHs(sv_2mortal(newSVuv(0)));
69 PUSHs(sv_2mortal(newSVuv(0)));
70 PUSHs(sv_2mortal(newSVuv(0)));
71 PUSHs(sv_2mortal(newSVuv(0)));
72
73 PUSHs(sv_2mortal(newSVuv(0)));
74 PUSHs(sv_2mortal(newSVuv(0)));
75 PUSHs(sv_2mortal(newSVuv(0)));
76 }
77