#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef DF_STATFS_USE_MOUNT
#include <sys/param.h>
#include <sys/mount.h>
#endif
#ifdef DF_STATFS
#include <sys/statfs.h>
#endif
#ifdef __cplusplus
}
#endif
typedef struct statfs Statfs;
MODULE = Filesys::Df PACKAGE = Filesys::Df
void
_df(dir)
char *dir
PREINIT:
Statfs st;
PPCODE:
EXTEND(sp, 7);
#ifdef DF_SOLARIS
if(statfs(dir, &st, 0, 0) == 0) {
#else
if(statfs(dir, &st) == 0) {
#endif
PUSHs(sv_2mortal(newSVnv((double)st.f_bsize)));
PUSHs(sv_2mortal(newSVnv((double)st.f_blocks)));
PUSHs(sv_2mortal(newSVnv((double)st.f_bfree)));
#ifdef DF_SOLARIS
PUSHs(sv_2mortal(newSVnv((double)st.f_bfree)));
#else
PUSHs(sv_2mortal(newSVnv((double)st.f_bavail)));
#endif
PUSHs(sv_2mortal(newSVnv((double)st.f_files)));
PUSHs(sv_2mortal(newSVnv((double)st.f_ffree)));
/* No favail */
PUSHs(sv_2mortal(newSVnv((double)st.f_ffree)));
}
else {
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
}
void
_df_fh(fd)
int fd
PREINIT:
Statfs st;
PPCODE:
EXTEND(sp, 7);
#ifdef DF_SOLARIS
if(fstatfs(fd, &st, 0, 0) == 0) {
#else
if(fstatfs(fd, &st) == 0) {
#endif
PUSHs(sv_2mortal(newSVnv((double)st.f_bsize)));
PUSHs(sv_2mortal(newSVnv((double)st.f_blocks)));
PUSHs(sv_2mortal(newSVnv((double)st.f_bfree)));
#ifdef DF_SOLARIS
PUSHs(sv_2mortal(newSVnv((double)st.f_bfree)));
#else
PUSHs(sv_2mortal(newSVnv((double)st.f_bavail)));
#endif
PUSHs(sv_2mortal(newSVnv((double)st.f_files)));
PUSHs(sv_2mortal(newSVnv((double)st.f_ffree)));
/* No favail */
PUSHs(sv_2mortal(newSVnv((double)st.f_ffree)));
}
else {
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
PUSHs(sv_2mortal(newSVuv(0)));
}