Whamcloud - gitweb
ORNL-2 Enable OBD_CONNECT_ATTRFID supporting on lustre-2.x
[fs/lustre-release.git] / lustre / include / lustre / libiam.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/include/lustre/libiam.h
37  *
38  * iam user level library
39  *
40  * Author: Wang Di <wangdi@clusterfs.com>
41  * Author: Nikita Danilov <nikita@clusterfs.com>
42  * Author: Fan Yong <fanyong@clusterfs.com>
43  */
44
45 /*
46  *  lustre/libiam.h
47  */
48
49 #ifndef __IAM_ULIB_H__
50 #define __IAM_ULIB_H__
51
52 /** \defgroup libiam libiam
53  *
54  * @{
55  */
56
57
58 #define DX_FMT_NAME_LEN 16
59
60 enum iam_fmt_t {
61         FMT_LFIX,
62         FMT_LVAR
63 };
64
65 struct iam_uapi_info {
66         __u16 iui_keysize;
67         __u16 iui_recsize;
68         __u16 iui_ptrsize;
69         __u16 iui_height;
70         char  iui_fmt_name[DX_FMT_NAME_LEN];
71 };
72
73 /*
74  * Creat an iam file, but do NOT open it.
75  * Return 0 if success, else -1.
76  */
77 int iam_creat(char *filename, enum iam_fmt_t fmt,
78               int blocksize, int keysize, int recsize, int ptrsize);
79
80 /*
81  * Open an iam file, but do NOT creat it if the file doesn't exist.
82  * Please use iam_creat for creating the file before use iam_open.
83  * Return file id (fd) if success, else -1.
84  */
85 int iam_open(char *filename, struct iam_uapi_info *ua);
86
87 /*
88  * Close file opened by iam_open. 
89  */
90 int iam_close(int fd);
91
92 /*
93  * Please use iam_open before use this function.
94  */
95 int iam_insert(int fd, struct iam_uapi_info *ua,
96                int key_need_convert, char *keybuf,
97                int rec_need_convert, char *recbuf);
98
99 /*
100  * Please use iam_open before use this function.
101  */
102 int iam_lookup(int fd, struct iam_uapi_info *ua,
103                int key_need_convert, char *key_buf,
104                int *keysize, char *save_key,
105                int rec_need_convert, char *rec_buf,
106                int *recsize, char *save_rec);
107
108 /*
109  * Please use iam_open before use this function.
110  */
111 int iam_delete(int fd, struct iam_uapi_info *ua,
112                int key_need_convert, char *keybuf,
113                int rec_need_convert, char *recbuf);
114
115 /*
116  * Please use iam_open before use this function.
117  */
118 int iam_it_start(int fd, struct iam_uapi_info *ua,
119                  int key_need_convert, char *key_buf,
120                  int *keysize, char *save_key,
121                  int rec_need_convert, char *rec_buf,
122                  int *recsize, char *save_rec);
123
124 /*
125  * Please use iam_open before use this function.
126  */
127 int iam_it_next(int fd, struct iam_uapi_info *ua,
128                 int key_need_convert, char *key_buf,
129                 int *keysize, char *save_key,
130                 int rec_need_convert, char *rec_buf,
131                 int *recsize, char *save_rec);
132
133 /*
134  * Please use iam_open before use this function.
135  */
136 int iam_it_stop(int fd, struct iam_uapi_info *ua,
137                 int key_need_convert, char *keybuf,
138                 int rec_need_convert, char *recbuf);
139
140 /*
141  * Change iam file mode.
142  */
143 int iam_polymorph(char *filename, unsigned long mode);
144
145 /** @} libiam */
146
147 #endif