Home | History | Annotate | Download | only in nfs
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 /*
     22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     23  * Use is subject to license terms.
     24  */
     25 
     26 #ifndef _NFSID_MAP_H
     27 #define	_NFSID_MAP_H
     28 
     29 #ifndef _KERNEL
     30 #include <stddef.h>
     31 #endif
     32 #include <sys/sysmacros.h>
     33 #include <sys/types.h>
     34 
     35 /*
     36  * NFSv4 id mapping daemon
     37  *
     38  * This daemon is used by the kernel to map strings in the form
     39  * "user@dns_domain" from an integer form or vice-versa.  The daemon
     40  * uses the system configured name services for the mapping.
     41  *
     42  * The status results determines if a mapping was successful.
     43  *
     44  * The mapping is cached in the kernel, so that expensive upcalls are
     45  * reduced to a minimum.
     46  */
     47 
     48 #ifdef	__cplusplus
     49 extern "C" {
     50 #endif
     51 
     52 /*
     53  * mapid commands
     54  */
     55 #define	NFSMAPID_STR_UID	1
     56 #define	NFSMAPID_UID_STR	2
     57 #define	NFSMAPID_STR_GID	3
     58 #define	NFSMAPID_GID_STR	4
     59 
     60 /*
     61  * We are passing in arguments in a variable length struct
     62  * similar to a dirent_t. We break apart a utf8string into
     63  * its components and allocate a struct long enough to hold
     64  * the string and a NUL terminator.  The caller must ensure the
     65  * terminator is set.
     66  */
     67 struct mapid_arg {
     68 	uint_t	cmd;
     69 	union {
     70 		uid_t		uid;
     71 		gid_t		gid;
     72 		int		len;
     73 	} u_arg;
     74 	char str[1];
     75 };
     76 typedef struct mapid_arg mapid_arg_t;
     77 
     78 /*
     79  * The actual required size of the args, rounded up to a 64 bit boundary
     80  */
     81 #define	MAPID_ARG_LEN(str_length)	\
     82 	((offsetof(mapid_arg_t, str[0]) + 1 + (str_length) + 7) & ~ 7)
     83 
     84 /*
     85  * Return status codes
     86  */
     87 #define	NFSMAPID_OK		0
     88 
     89 /*
     90  * numeric string is mapped to its literal number
     91  */
     92 #define	NFSMAPID_NUMSTR		1
     93 
     94 /*
     95  * Value cannot be mapped, badly formed string
     96  */
     97 #define	NFSMAPID_UNMAPPABLE	2
     98 
     99 /*
    100  * Caller provided invalid arguments
    101  */
    102 #define	NFSMAPID_INVALID	3
    103 
    104 /*
    105  * Internal error in daemon e.g. out of memory, can't return result
    106  */
    107 #define	NFSMAPID_INTERNAL	4
    108 
    109 /*
    110  * Incorrect domain used
    111  */
    112 #define	NFSMAPID_BADDOMAIN	5
    113 
    114 /*
    115  * Out of range uid/gid
    116  */
    117 #define	NFSMAPID_BADID		6
    118 
    119 /*
    120  * User or group cannot be found in nameservice
    121  */
    122 #define	NFSMAPID_NOTFOUND	7
    123 
    124 /*
    125  * Similar to the arguments, the result is variable length.
    126  * The returner must ensure the string terminator is set.
    127  */
    128 struct mapid_res {
    129 	uint_t	status;
    130 	union {
    131 		uid_t		uid;
    132 		gid_t		gid;
    133 		int		len;
    134 	} u_res;
    135 	char str[1];
    136 };
    137 typedef struct mapid_res mapid_res_t;
    138 
    139 /*
    140  * The actual required size of the result, rounded up to a 64 bit boundary
    141  */
    142 #define	MAPID_RES_LEN(str_length)	\
    143 	((offsetof(mapid_res_t, str[0]) + 1 + (str_length) + 7) & ~ 7)
    144 
    145 #ifdef	__cplusplus
    146 }
    147 #endif
    148 
    149 #endif /* _NFSID_MAP_H */
    150