Whamcloud - gitweb
Branch HEAD
[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  2008 Sun Microsystems, Inc. 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
53 #define DX_FMT_NAME_LEN 16
54
55 enum iam_fmt_t {
56         FMT_LFIX,
57         FMT_LVAR
58 };
59
60 struct iam_uapi_info {
61         __u16 iui_keysize;
62         __u16 iui_recsize;
63         __u16 iui_ptrsize;
64         __u16 iui_height;
65         char  iui_fmt_name[DX_FMT_NAME_LEN];
66 };
67
68 /*
69  * Creat an iam file, but do NOT open it.
70  * Return 0 if success, else -1.
71  */
72 int iam_creat(char *filename, enum iam_fmt_t fmt,
73               int blocksize, int keysize, int recsize, int ptrsize);
74
75 /*
76  * Open an iam file, but do NOT creat it if the file doesn't exist.
77  * Please use iam_creat for creating the file before use iam_open.
78  * Return file id (fd) if success, else -1.
79  */
80 int iam_open(char *filename, struct iam_uapi_info *ua);
81
82 /*
83  * Close file opened by iam_open. 
84  */
85 int iam_close(int fd);
86
87 /*
88  * Please use iam_open before use this function.
89  */
90 int iam_insert(int fd, struct iam_uapi_info *ua,
91                int key_need_convert, char *keybuf,
92                int rec_need_convert, char *recbuf);
93
94 /*
95  * Please use iam_open before use this function.
96  */
97 int iam_lookup(int fd, struct iam_uapi_info *ua,
98                int key_need_convert, char *key_buf,
99                int *keysize, char *save_key,
100                int rec_need_convert, char *rec_buf,
101                int *recsize, char *save_rec);
102
103 /*
104  * Please use iam_open before use this function.
105  */
106 int iam_delete(int fd, struct iam_uapi_info *ua,
107                int key_need_convert, char *keybuf,
108                int rec_need_convert, char *recbuf);
109
110 /*
111  * Please use iam_open before use this function.
112  */
113 int iam_it_start(int fd, struct iam_uapi_info *ua,
114                  int key_need_convert, char *key_buf,
115                  int *keysize, char *save_key,
116                  int rec_need_convert, char *rec_buf,
117                  int *recsize, char *save_rec);
118
119 /*
120  * Please use iam_open before use this function.
121  */
122 int iam_it_next(int fd, struct iam_uapi_info *ua,
123                 int key_need_convert, char *key_buf,
124                 int *keysize, char *save_key,
125                 int rec_need_convert, char *rec_buf,
126                 int *recsize, char *save_rec);
127
128 /*
129  * Please use iam_open before use this function.
130  */
131 int iam_it_stop(int fd, struct iam_uapi_info *ua,
132                 int key_need_convert, char *keybuf,
133                 int rec_need_convert, char *recbuf);
134
135 /*
136  * Change iam file mode.
137  */
138 int iam_polymorph(char *filename, unsigned long mode);
139
140
141 #endif