forked from len0rd/rockbox
Switch to using statvfs for simulated fat_size(). This makes io.c build on opensolaris, and also removes special ifdefing for freebsd and OS X.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25256 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
abce1b9927
commit
181e0e0878
1 changed files with 8 additions and 14 deletions
|
|
@ -25,14 +25,8 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#ifdef __FreeBSD__
|
#ifndef WIN32
|
||||||
#include <sys/param.h>
|
#include <sys/statvfs.h>
|
||||||
#include <sys/mount.h>
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#elif !defined(WIN32)
|
|
||||||
#include <sys/vfs.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
@ -472,15 +466,15 @@ void fat_size(IF_MV2(int volume,) unsigned long* size, unsigned long* free)
|
||||||
*free = free_clusters * secperclus / 2 * (bytespersec / 512);
|
*free = free_clusters * secperclus / 2 * (bytespersec / 512);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
struct statfs fs;
|
struct statvfs vfs;
|
||||||
|
|
||||||
if (!statfs(".", &fs)) {
|
if (!statvfs(".", &vfs)) {
|
||||||
DEBUGF("statfs: bsize=%d blocks=%ld free=%ld\n",
|
DEBUGF("statvfs: frsize=%d blocks=%ld free=%ld\n",
|
||||||
(int)fs.f_bsize, fs.f_blocks, fs.f_bfree);
|
(int)vfs.f_frsize, (long)vfs.f_blocks, (long)vfs.f_bfree);
|
||||||
if (size)
|
if (size)
|
||||||
*size = fs.f_blocks * (fs.f_bsize / 1024);
|
*size = vfs.f_blocks / 2 * (vfs.f_frsize / 512);
|
||||||
if (free)
|
if (free)
|
||||||
*free = fs.f_bfree * (fs.f_bsize / 1024);
|
*free = vfs.f_bfree / 2 * (vfs.f_frsize / 512);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue