1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * This file is part of Lustre, http://www.lustre.org
7 * See also lustre_idl.h for wire formats of requests.
10 #ifndef _LUSTRE_IDMAP_H
11 #define _LUSTRE_IDMAP_H
13 #include <md_object.h>
15 #define CFS_NGROUPS_PER_BLOCK ((int)(CFS_PAGE_SIZE / sizeof(gid_t)))
17 #define CFS_GROUP_AT(gi, i) \
18 ((gi)->blocks[(i) / CFS_NGROUPS_PER_BLOCK][(i) % CFS_NGROUPS_PER_BLOCK])
21 CFS_IC_NOTHING = 0, /* convert nothing */
22 CFS_IC_ALL = 1, /* convert all items */
23 CFS_IC_MAPPED = 2, /* convert mapped uid/gid */
24 CFS_IC_UNMAPPED = 3 /* convert unmapped uid/gid */
27 #define CFS_IDMAP_NOTFOUND (-1)
29 #define CFS_IDMAP_HASHSIZE 32
31 enum lustre_idmap_idx {
39 struct lustre_idmap_table {
41 struct list_head lit_idmaps[CFS_IDMAP_N_HASHES][CFS_IDMAP_HASHSIZE];
44 extern void lustre_groups_from_list(struct group_info *ginfo, gid_t *glist);
45 extern void lustre_groups_sort(struct group_info *group_info);
46 extern int lustre_in_group_p(struct md_ucred *mu, gid_t grp);
48 extern int lustre_idmap_add(struct lustre_idmap_table *t,
49 uid_t ruid, uid_t luid,
50 gid_t rgid, gid_t lgid);
51 extern int lustre_idmap_del(struct lustre_idmap_table *t,
52 uid_t ruid, uid_t luid,
53 gid_t rgid, gid_t lgid);
54 extern int lustre_idmap_lookup_uid(struct md_ucred *mu,
55 struct lustre_idmap_table *t,
56 int reverse, uid_t uid);
57 extern int lustre_idmap_lookup_gid(struct md_ucred *mu,
58 struct lustre_idmap_table *t,
59 int reverse, gid_t gid);
60 extern struct lustre_idmap_table *lustre_idmap_init(void);
61 extern void lustre_idmap_fini(struct lustre_idmap_table *t);