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