/* * Conky, a system monitor, based on torsmo * * This program is licensed under BSD license, read COPYING * * $Id$ */ #include "conky.h" #include #include #include #include #include #include /* linux */ #ifdef HAVE_SYS_STATFS_H #include #endif /* freebsd && netbsd */ #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_SYS_MOUNT_H #include #endif #define MAX_FS_STATS 64 static struct fs_stat fs_stats_[MAX_FS_STATS]; struct fs_stat *fs_stats = fs_stats_; static void update_fs_stat(struct fs_stat* fs); void update_fs_stats() { unsigned i; for(i=0; ipath = strdup(s); update_fs_stat(new); return new; } static void update_fs_stat(struct fs_stat* fs) { struct statfs s; if(statfs(fs->path, &s) == 0) { fs->size = (long long) s.f_blocks * s.f_bsize; /* bfree (root) or bavail (non-roots) ? */ fs->avail = (long long) s.f_bavail* s.f_bsize; fs->free = (long long) s.f_bfree * s.f_bsize;; } else { fs->size = 0; fs->avail = 0; fs->free = 0; ERR("statfs '%s': %s", fs->path, strerror(errno)); } }