xref: /openbmc/linux/fs/nfs/nfs4idmap.h (revision e5451c8f8330e03ad3cfa16048b4daf961af434f)
1*40c64c26SAnna Schumaker /*
2*40c64c26SAnna Schumaker  * fs/nfs/nfs4idmap.h
3*40c64c26SAnna Schumaker  *
4*40c64c26SAnna Schumaker  *  UID and GID to name mapping for clients.
5*40c64c26SAnna Schumaker  *
6*40c64c26SAnna Schumaker  *  Copyright (c) 2002 The Regents of the University of Michigan.
7*40c64c26SAnna Schumaker  *  All rights reserved.
8*40c64c26SAnna Schumaker  *
9*40c64c26SAnna Schumaker  *  Marius Aamodt Eriksen <marius@umich.edu>
10*40c64c26SAnna Schumaker  *
11*40c64c26SAnna Schumaker  *  Redistribution and use in source and binary forms, with or without
12*40c64c26SAnna Schumaker  *  modification, are permitted provided that the following conditions
13*40c64c26SAnna Schumaker  *  are met:
14*40c64c26SAnna Schumaker  *
15*40c64c26SAnna Schumaker  *  1. Redistributions of source code must retain the above copyright
16*40c64c26SAnna Schumaker  *     notice, this list of conditions and the following disclaimer.
17*40c64c26SAnna Schumaker  *  2. Redistributions in binary form must reproduce the above copyright
18*40c64c26SAnna Schumaker  *     notice, this list of conditions and the following disclaimer in the
19*40c64c26SAnna Schumaker  *     documentation and/or other materials provided with the distribution.
20*40c64c26SAnna Schumaker  *  3. Neither the name of the University nor the names of its
21*40c64c26SAnna Schumaker  *     contributors may be used to endorse or promote products derived
22*40c64c26SAnna Schumaker  *     from this software without specific prior written permission.
23*40c64c26SAnna Schumaker  *
24*40c64c26SAnna Schumaker  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
25*40c64c26SAnna Schumaker  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26*40c64c26SAnna Schumaker  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27*40c64c26SAnna Schumaker  *  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28*40c64c26SAnna Schumaker  *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29*40c64c26SAnna Schumaker  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30*40c64c26SAnna Schumaker  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31*40c64c26SAnna Schumaker  *  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32*40c64c26SAnna Schumaker  *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33*40c64c26SAnna Schumaker  *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34*40c64c26SAnna Schumaker  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35*40c64c26SAnna Schumaker  */
36*40c64c26SAnna Schumaker #ifndef NFS_IDMAP_H
37*40c64c26SAnna Schumaker #define NFS_IDMAP_H
38*40c64c26SAnna Schumaker 
39*40c64c26SAnna Schumaker #include <linux/uidgid.h>
40*40c64c26SAnna Schumaker #include <uapi/linux/nfs_idmap.h>
41*40c64c26SAnna Schumaker 
42*40c64c26SAnna Schumaker 
43*40c64c26SAnna Schumaker /* Forward declaration to make this header independent of others */
44*40c64c26SAnna Schumaker struct nfs_client;
45*40c64c26SAnna Schumaker struct nfs_server;
46*40c64c26SAnna Schumaker struct nfs_fattr;
47*40c64c26SAnna Schumaker struct nfs4_string;
48*40c64c26SAnna Schumaker 
49*40c64c26SAnna Schumaker int nfs_idmap_init(void);
50*40c64c26SAnna Schumaker void nfs_idmap_quit(void);
51*40c64c26SAnna Schumaker int nfs_idmap_new(struct nfs_client *);
52*40c64c26SAnna Schumaker void nfs_idmap_delete(struct nfs_client *);
53*40c64c26SAnna Schumaker 
54*40c64c26SAnna Schumaker void nfs_fattr_init_names(struct nfs_fattr *fattr,
55*40c64c26SAnna Schumaker 		struct nfs4_string *owner_name,
56*40c64c26SAnna Schumaker 		struct nfs4_string *group_name);
57*40c64c26SAnna Schumaker void nfs_fattr_free_names(struct nfs_fattr *);
58*40c64c26SAnna Schumaker void nfs_fattr_map_and_free_names(struct nfs_server *, struct nfs_fattr *);
59*40c64c26SAnna Schumaker 
60*40c64c26SAnna Schumaker int nfs_map_name_to_uid(const struct nfs_server *, const char *, size_t, kuid_t *);
61*40c64c26SAnna Schumaker int nfs_map_group_to_gid(const struct nfs_server *, const char *, size_t, kgid_t *);
62*40c64c26SAnna Schumaker int nfs_map_uid_to_name(const struct nfs_server *, kuid_t, char *, size_t);
63*40c64c26SAnna Schumaker int nfs_map_gid_to_group(const struct nfs_server *, kgid_t, char *, size_t);
64*40c64c26SAnna Schumaker 
65*40c64c26SAnna Schumaker int nfs_map_string_to_numeric(const char *name, size_t namelen, __u32 *res);
66*40c64c26SAnna Schumaker 
67*40c64c26SAnna Schumaker extern unsigned int nfs_idmap_cache_timeout;
68*40c64c26SAnna Schumaker #endif /* NFS_IDMAP_H */
69