Whamcloud - gitweb
Branch b1_4
[fs/lustre-release.git] / lnet / libcfs / misc.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2005 Cluster File Systems, Inc.
5  *   Author: Nikita Danilov <nikita@clusterfs.com>
6  *
7  *   This file is part of Lustre, http://www.lustre.org.
8  *
9  *   Lustre is free software; you can redistribute it and/or
10  *   modify it under the terms of version 2 of the GNU General Public
11  *   License as published by the Free Software Foundation.
12  *
13  *   Lustre is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with Lustre; if not, write to the Free Software
20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #ifndef EXPORT_SYMTAB
24 # define EXPORT_SYMTAB
25 #endif
26
27 # define DEBUG_SUBSYSTEM S_LNET
28
29 #include <libcfs/libcfs.h>
30
31 /*
32  * On-wire format is native kdev_t format of Linux kernel 2.6
33  */
34 enum {
35         WIRE_RDEV_MINORBITS = 20,
36         WIRE_RDEV_MINORMASK = ((1U << WIRE_RDEV_MINORBITS) - 1)
37 };
38
39 cfs_wire_rdev_t cfs_wire_rdev_build(cfs_major_nr_t major, cfs_minor_nr_t minor)
40 {
41         return (major << WIRE_RDEV_MINORBITS) | minor;
42 }
43
44 cfs_major_nr_t  cfs_wire_rdev_major(cfs_wire_rdev_t rdev)
45 {
46         return rdev >> WIRE_RDEV_MINORBITS;
47 }
48
49 cfs_minor_nr_t  cfs_wire_rdev_minor(cfs_wire_rdev_t rdev)
50 {
51         return rdev & WIRE_RDEV_MINORMASK;
52 }
53