blob: 7cec574da89ad6681b4c3a846c2a37e9e059e286 [file] [log] [blame]
Matt Mower523a0592015-12-13 11:31:00 -06001/*
2 * Copyright (C) 2012 Freescale Semiconductor, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19
20#include "sys/statvfs.h"
21#include <sys/statfs.h>
22
23#define MAP(to,from) vfs->to = sfs.from
24
25int statvfs(const char *path, struct statvfs *vfs) {
26 struct statfs sfs;
27 int ret;
28 int *fsid;
29 if ((ret = statfs(path, &sfs)) != 0)
30 return ret;
31
32 MAP(f_bsize, f_bsize);
33 MAP(f_frsize, f_frsize);
34 MAP(f_blocks, f_blocks);
35 MAP(f_bfree, f_bfree);
36 MAP(f_bavail, f_bavail);
37 MAP(f_files, f_files);
38 MAP(f_ffree, f_ffree);
39 MAP(f_namemax, f_namelen);
40
41 vfs->f_favail = 0;
42 vfs->f_flag = 0;
43
44 fsid = (int *)&sfs.f_fsid;
45 vfs->f_fsid = (fsid[0] << sizeof(fsid[0])) | fsid[1];
46
47 return ret;
48}