1 /* $NetBSD: linux_statfs.h,v 1.3 2008/04/28 20:23:44 martin Exp $ */
4 * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe
9 * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _LINUX_STATFS_H
34 #define _LINUX_STATFS_H
36 static void bsd_to_linux_statfs(const struct statvfs
*,
37 struct linux_statfs
*);
40 * Convert NetBSD statvfs structure to Linux statfs structure.
41 * Linux doesn't have f_flag, and we can't set f_frsize due
42 * to glibc statvfs() bug (see below).
45 bsd_to_linux_statfs(const struct statvfs
*bsp
, struct linux_statfs
*lsp
)
49 for (i
= 0; i
< linux_fstypes_cnt
; i
++) {
50 if (strcmp(bsp
->f_fstypename
, linux_fstypes
[i
].bsd
) == 0) {
51 lsp
->l_ftype
= linux_fstypes
[i
].linux
;
56 if (i
== linux_fstypes_cnt
) {
57 lsp
->l_ftype
= LINUX_DEFAULT_SUPER_MAGIC
;
61 * The sizes are expressed in number of blocks. The block
62 * size used for the size is f_frsize for POSIX-compliant
63 * statvfs. Linux statfs uses f_bsize as the block size
64 * (f_frsize used to not be available in Linux struct statfs).
65 * However, glibc 2.3.3 statvfs() wrapper fails to adjust the block
66 * counts for different f_frsize if f_frsize is provided by the kernel.
67 * POSIX conforming apps thus get wrong size if f_frsize
68 * is different to f_bsize. Thus, we just pretend we don't
72 lsp
->l_fbsize
= bsp
->f_frsize
;
73 lsp
->l_ffrsize
= 0; /* compat */
74 lsp
->l_fblocks
= bsp
->f_blocks
;
75 lsp
->l_fbfree
= bsp
->f_bfree
;
76 lsp
->l_fbavail
= bsp
->f_bavail
;
77 lsp
->l_ffiles
= bsp
->f_files
;
78 lsp
->l_fffree
= bsp
->f_ffree
;
79 /* Linux sets the fsid to 0..., we don't */
80 lsp
->l_ffsid
.val
[0] = bsp
->f_fsidx
.__fsid_val
[0];
81 lsp
->l_ffsid
.val
[1] = bsp
->f_fsidx
.__fsid_val
[1];
82 lsp
->l_fnamelen
= bsp
->f_namemax
;
83 (void)memset(lsp
->l_fspare
, 0, sizeof(lsp
->l_fspare
));
86 #endif /* !_LINUX_STATFS_H */