Whamcloud - gitweb
Branch b1_4_mountconf
[fs/lustre-release.git] / lustre / obdclass / statfs_pack.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002, 2003 Cluster File Systems, Inc.
5  *   Author: Andreas Dilger <adilger@clusterfs.com>
6  *
7  *   This file is part of the Lustre file system, http://www.lustre.org
8  *   Lustre is a trademark of Cluster File Systems, Inc.
9  *
10  *   You may have signed or agreed to another license before downloading
11  *   this software.  If so, you are bound by the terms and conditions
12  *   of that agreement, and the following does not apply to you.  See the
13  *   LICENSE file included with this distribution for more information.
14  *
15  *   If you did not agree to a different license, then this copy of Lustre
16  *   is open source software; you can redistribute it and/or modify it
17  *   under the terms of version 2 of the GNU General Public License as
18  *   published by the Free Software Foundation.
19  *
20  *   In either case, Lustre is distributed in the hope that it will be
21  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
22  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  *   license text for more details.
24  *
25  * (Un)packing of OST/MDS requests
26  *
27  */
28
29 #define DEBUG_SUBSYSTEM S_CLASS
30
31 #ifndef EXPORT_SYMTAB
32 # define EXPORT_SYMTAB
33 #endif
34 #ifndef __KERNEL__
35 #include <liblustre.h>
36 #else
37 #include <linux/version.h>
38 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
39 #include <linux/statfs.h>
40 #endif
41 #endif
42
43 #include <linux/lustre_export.h>
44 #include <linux/lustre_net.h>
45 #include <linux/obd_support.h>
46 #include <linux/obd_class.h>
47
48 void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs)
49 {
50         memset(osfs, 0, sizeof(*osfs));
51         osfs->os_type = sfs->f_type;
52         osfs->os_blocks = sfs->f_blocks;
53         osfs->os_bfree = sfs->f_bfree;
54         osfs->os_bavail = sfs->f_bavail;
55         osfs->os_files = sfs->f_files;
56         osfs->os_ffree = sfs->f_ffree;
57         osfs->os_bsize = sfs->f_bsize;
58         osfs->os_namelen = sfs->f_namelen;
59 }
60
61 void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs)
62 {
63         memset(sfs, 0, sizeof(*sfs));
64         sfs->f_type = osfs->os_type;
65         sfs->f_blocks = osfs->os_blocks;
66         sfs->f_bfree = osfs->os_bfree;
67         sfs->f_bavail = osfs->os_bavail;
68         sfs->f_files = osfs->os_files;
69         sfs->f_ffree = osfs->os_ffree;
70         sfs->f_bsize = osfs->os_bsize;
71         sfs->f_namelen = osfs->os_namelen;
72 }
73
74 EXPORT_SYMBOL(statfs_pack);
75 EXPORT_SYMBOL(statfs_unpack);