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