Whamcloud - gitweb
LU-14487 lustre: remove references to Sun Trademark.
[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.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  */
26 /*
27  * This file is part of Lustre, http://www.lustre.org/
28  *
29  * lustre/include/lustre/libiam.h
30  *
31  * iam user level library
32  *
33  * Author: Wang Di <wangdi@clusterfs.com>
34  * Author: Nikita Danilov <nikita@clusterfs.com>
35  * Author: Fan Yong <fanyong@clusterfs.com>
36  */
37
38 /*
39  *  lustre/libiam.h
40  */
41
42 #ifndef __IAM_ULIB_H__
43 #define __IAM_ULIB_H__
44
45 /** \defgroup libiam libiam
46  *
47  * @{
48  */
49
50
51 #define DX_FMT_NAME_LEN 16
52
53 enum iam_fmt_t {
54         FMT_LFIX,
55         FMT_LVAR
56 };
57
58 struct iam_uapi_info {
59         __u16 iui_keysize;
60         __u16 iui_recsize;
61         __u16 iui_ptrsize;
62         __u16 iui_height;
63         char  iui_fmt_name[DX_FMT_NAME_LEN];
64 };
65
66 /*
67  * Creat an iam file, but do NOT open it.
68  * Return 0 if success, else -1.
69  */
70 int iam_creat(char *filename, enum iam_fmt_t fmt,
71               int blocksize, int keysize, int recsize, int ptrsize);
72
73 /*
74  * Open an iam file, but do NOT creat it if the file doesn't exist.
75  * Please use iam_creat for creating the file before use iam_open.
76  * Return file id (fd) if success, else -1.
77  */
78 int iam_open(char *filename, struct iam_uapi_info *ua);
79
80 /*
81  * Close file opened by iam_open. 
82  */
83 int iam_close(int fd);
84
85 /*
86  * Please use iam_open before use this function.
87  */
88 int iam_insert(int fd, struct iam_uapi_info *ua,
89                int key_need_convert, char *keybuf,
90                int rec_need_convert, char *recbuf);
91
92 /*
93  * Please use iam_open before use this function.
94  */
95 int iam_lookup(int fd, struct iam_uapi_info *ua,
96                int key_need_convert, char *key_buf,
97                int *keysize, char *save_key,
98                int rec_need_convert, char *rec_buf,
99                int *recsize, char *save_rec);
100
101 /*
102  * Please use iam_open before use this function.
103  */
104 int iam_delete(int fd, struct iam_uapi_info *ua,
105                int key_need_convert, char *keybuf,
106                int rec_need_convert, char *recbuf);
107
108 /*
109  * Please use iam_open before use this function.
110  */
111 int iam_it_start(int fd, struct iam_uapi_info *ua,
112                  int key_need_convert, char *key_buf,
113                  int *keysize, char *save_key,
114                  int rec_need_convert, char *rec_buf,
115                  int *recsize, char *save_rec);
116
117 /*
118  * Please use iam_open before use this function.
119  */
120 int iam_it_next(int fd, struct iam_uapi_info *ua,
121                 int key_need_convert, char *key_buf,
122                 int *keysize, char *save_key,
123                 int rec_need_convert, char *rec_buf,
124                 int *recsize, char *save_rec);
125
126 /*
127  * Please use iam_open before use this function.
128  */
129 int iam_it_stop(int fd, struct iam_uapi_info *ua,
130                 int key_need_convert, char *keybuf,
131                 int rec_need_convert, char *recbuf);
132
133 /*
134  * Change iam file mode.
135  */
136 int iam_polymorph(char *filename, unsigned long mode);
137
138 /** @} libiam */
139
140 #endif