Whamcloud - gitweb
b=11694
[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  *  libiam.h
5  *  iam user level library
6  *
7  *   Copyright (c) 2006 Cluster File Systems, Inc.
8  *   Author: Wang Di <wangdi@clusterfs.com>
9  *   Author: Nikita Danilov <nikita@clusterfs.com>
10  *   Author: Fan Yong <fanyong@clusterfs.com>
11  *
12  *   This file is part of the Lustre file system, http://www.lustre.org
13  *   Lustre is a trademark of Cluster File Systems, Inc.
14  *
15  *   You may have signed or agreed to another license before downloading
16  *   this software.  If so, you are bound by the terms and conditions
17  *   of that agreement, and the following does not apply to you.  See the
18  *   LICENSE file included with this distribution for more information.
19  *
20  *   If you did not agree to a different license, then this copy of Lustre
21  *   is open source software; you can redistribute it and/or modify it
22  *   under the terms of version 2 of the GNU General Public License as
23  *   published by the Free Software Foundation.
24  *
25  *   In either case, Lustre is distributed in the hope that it will be
26  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
27  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  *   license text for more details.
29  */
30
31 /*
32  *  lustre/libiam.h
33  */
34
35 #ifndef __IAM_ULIB_H__
36 #define __IAM_ULIB_H__
37
38
39 #define DX_FMT_NAME_LEN 16
40
41 enum iam_fmt_t {
42         FMT_LFIX,
43         FMT_LVAR
44 };
45
46 struct iam_uapi_info {
47         __u16 iui_keysize;
48         __u16 iui_recsize;
49         __u16 iui_ptrsize;
50         __u16 iui_height;
51         char  iui_fmt_name[DX_FMT_NAME_LEN];
52 };
53
54 /*
55  * Creat an iam file, but do NOT open it.
56  * Return 0 if success, else -1.
57  */
58 int iam_creat(char *filename, enum iam_fmt_t fmt,
59               int blocksize, int keysize, int recsize, int ptrsize);
60
61 /*
62  * Open an iam file, but do NOT creat it if the file doesn't exist.
63  * Please use iam_creat for creating the file before use iam_open.
64  * Return file id (fd) if success, else -1.
65  */
66 int iam_open(char *filename, struct iam_uapi_info *ua);
67
68 /*
69  * Close file opened by iam_open. 
70  */
71 int iam_close(int fd);
72
73 /*
74  * Please use iam_open before use this function.
75  */
76 int iam_insert(int fd, struct iam_uapi_info *ua,
77                int key_need_convert, char *keybuf,
78                int rec_need_convert, char *recbuf);
79
80 /*
81  * Please use iam_open before use this function.
82  */
83 int iam_lookup(int fd, struct iam_uapi_info *ua,
84                int key_need_convert, char *key_buf,
85                int *keysize, char *save_key,
86                int rec_need_convert, char *rec_buf,
87                int *recsize, char *save_rec);
88
89 /*
90  * Please use iam_open before use this function.
91  */
92 int iam_delete(int fd, struct iam_uapi_info *ua,
93                int key_need_convert, char *keybuf,
94                int rec_need_convert, char *recbuf);
95
96 /*
97  * Please use iam_open before use this function.
98  */
99 int iam_it_start(int fd, struct iam_uapi_info *ua,
100                  int key_need_convert, char *key_buf,
101                  int *keysize, char *save_key,
102                  int rec_need_convert, char *rec_buf,
103                  int *recsize, char *save_rec);
104
105 /*
106  * Please use iam_open before use this function.
107  */
108 int iam_it_next(int fd, struct iam_uapi_info *ua,
109                 int key_need_convert, char *key_buf,
110                 int *keysize, char *save_key,
111                 int rec_need_convert, char *rec_buf,
112                 int *recsize, char *save_rec);
113
114 /*
115  * Please use iam_open before use this function.
116  */
117 int iam_it_stop(int fd, struct iam_uapi_info *ua,
118                 int key_need_convert, char *keybuf,
119                 int rec_need_convert, char *recbuf);
120
121 /*
122  * Change iam file mode.
123  */
124 int iam_polymorph(char *filename, unsigned long mode);
125
126
127 #endif