| 1 | /* | 
|---|
| 2 | Unix SMB/CIFS implementation. | 
|---|
| 3 | VFS API's statvfs abstraction | 
|---|
| 4 | Copyright (C) Alexander Bokovoy                      2005 | 
|---|
| 5 | Copyright (C) Steve French                           2005 | 
|---|
| 6 |  | 
|---|
| 7 | This program is free software; you can redistribute it and/or modify | 
|---|
| 8 | it under the terms of the GNU General Public License as published by | 
|---|
| 9 | the Free Software Foundation; either version 2 of the License, or | 
|---|
| 10 | (at your option) any later version. | 
|---|
| 11 |  | 
|---|
| 12 | This program is distributed in the hope that it will be useful, | 
|---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 15 | GNU General Public License for more details. | 
|---|
| 16 |  | 
|---|
| 17 | You should have received a copy of the GNU General Public License | 
|---|
| 18 | along with this program; if not, write to the Free Software | 
|---|
| 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 
|---|
| 20 | */ | 
|---|
| 21 |  | 
|---|
| 22 | #include "includes.h" | 
|---|
| 23 |  | 
|---|
| 24 | #if defined(LINUX) && defined(HAVE_FSID_INT) | 
|---|
| 25 | static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf) | 
|---|
| 26 | { | 
|---|
| 27 | struct statvfs statvfs_buf; | 
|---|
| 28 | int result; | 
|---|
| 29 |  | 
|---|
| 30 | result = statvfs(path, &statvfs_buf); | 
|---|
| 31 |  | 
|---|
| 32 | if (!result) { | 
|---|
| 33 | statbuf->OptimalTransferSize = statvfs_buf.f_frsize; | 
|---|
| 34 | statbuf->BlockSize = statvfs_buf.f_bsize; | 
|---|
| 35 | statbuf->TotalBlocks = statvfs_buf.f_blocks; | 
|---|
| 36 | statbuf->BlocksAvail = statvfs_buf.f_bfree; | 
|---|
| 37 | statbuf->UserBlocksAvail = statvfs_buf.f_bavail; | 
|---|
| 38 | statbuf->TotalFileNodes = statvfs_buf.f_files; | 
|---|
| 39 | statbuf->FreeFileNodes = statvfs_buf.f_ffree; | 
|---|
| 40 | statbuf->FsIdentifier = statvfs_buf.f_fsid; | 
|---|
| 41 | } | 
|---|
| 42 | return result; | 
|---|
| 43 | } | 
|---|
| 44 | #endif | 
|---|
| 45 |  | 
|---|
| 46 | /* | 
|---|
| 47 | sys_statvfs() is an abstraction layer over system-dependent statvfs()/statfs() | 
|---|
| 48 | for particular POSIX systems. Due to controversy of what is considered more important | 
|---|
| 49 | between LSB and FreeBSD/POSIX.1 (IEEE Std 1003.1-2001) we need to abstract the interface | 
|---|
| 50 | so that particular OS would use its preffered interface. | 
|---|
| 51 | */ | 
|---|
| 52 | int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf) | 
|---|
| 53 | { | 
|---|
| 54 | #if defined(LINUX) && defined(HAVE_FSID_INT) | 
|---|
| 55 | return linux_statvfs(path, statbuf); | 
|---|
| 56 | #else | 
|---|
| 57 | /* BB change this to return invalid level */ | 
|---|
| 58 | #ifdef EOPNOTSUPP | 
|---|
| 59 | return EOPNOTSUPP; | 
|---|
| 60 | #else | 
|---|
| 61 | return -1; | 
|---|
| 62 | #endif /* EOPNOTSUPP */ | 
|---|
| 63 | #endif /* LINUX */ | 
|---|
| 64 |  | 
|---|
| 65 | } | 
|---|