nfs4idmap.c 15.2 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/*
 *  Mapping of UID/GIDs to name and vice versa.
 *
 *  Copyright (c) 2002, 2003 The Regents of the University of
 *  Michigan.  All rights reserved.
 *
 *  Marius Aamodt Eriksen <marius@umich.edu>
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *  3. Neither the name of the University nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
 *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 *  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <linux/module.h>
#include <linux/seq_file.h>
37
#include <linux/sched.h>
38
#include <linux/slab.h>
39
#include <linux/sunrpc/svc_xprt.h>
40
#include <net/net_namespace.h>
41
#include "idmap.h"
42
#include "nfsd.h"
43
#include "netns.h"
L
Linus Torvalds 已提交
44

J
J. Bruce Fields 已提交
45 46 47 48 49 50 51 52
/*
 * Turn off idmapping when using AUTH_SYS.
 */
static bool nfs4_disable_idmapping = true;
module_param(nfs4_disable_idmapping, bool, 0644);
MODULE_PARM_DESC(nfs4_disable_idmapping,
		"Turn off server's NFSv4 idmapping when using 'sec=sys'");

L
Linus Torvalds 已提交
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
/*
 * Cache entry
 */

/*
 * XXX we know that IDMAP_NAMESZ < PAGE_SIZE, but it's ugly to rely on
 * that.
 */

#define IDMAP_TYPE_USER  0
#define IDMAP_TYPE_GROUP 1

struct ent {
	struct cache_head h;
	int               type;		       /* User / Group */
	uid_t             id;
	char              name[IDMAP_NAMESZ];
	char              authname[IDMAP_NAMESZ];
};

/* Common entry handling */

#define ENT_HASHBITS          8
#define ENT_HASHMAX           (1 << ENT_HASHBITS)

78 79
static void
ent_init(struct cache_head *cnew, struct cache_head *citm)
L
Linus Torvalds 已提交
80
{
81 82 83
	struct ent *new = container_of(cnew, struct ent, h);
	struct ent *itm = container_of(citm, struct ent, h);

L
Linus Torvalds 已提交
84 85 86 87 88 89 90
	new->id = itm->id;
	new->type = itm->type;

	strlcpy(new->name, itm->name, sizeof(new->name));
	strlcpy(new->authname, itm->authname, sizeof(new->name));
}

91
static void
92
ent_put(struct kref *ref)
L
Linus Torvalds 已提交
93
{
94 95
	struct ent *map = container_of(ref, struct ent, h.ref);
	kfree(map);
L
Linus Torvalds 已提交
96 97
}

98 99 100 101 102 103 104 105 106 107
static struct cache_head *
ent_alloc(void)
{
	struct ent *e = kmalloc(sizeof(*e), GFP_KERNEL);
	if (e)
		return &e->h;
	else
		return NULL;
}

L
Linus Torvalds 已提交
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
/*
 * ID -> Name cache
 */

static uint32_t
idtoname_hash(struct ent *ent)
{
	uint32_t hash;

	hash = hash_str(ent->authname, ENT_HASHBITS);
	hash = hash_long(hash ^ ent->id, ENT_HASHBITS);

	/* Flip LSB for user/group */
	if (ent->type == IDMAP_TYPE_GROUP)
		hash ^= 1;

	return hash;
}

static void
idtoname_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
    int *blen)
{
 	struct ent *ent = container_of(ch, struct ent, h);
	char idstr[11];

	qword_add(bpp, blen, ent->authname);
135
	snprintf(idstr, sizeof(idstr), "%u", ent->id);
L
Linus Torvalds 已提交
136 137 138 139 140 141
	qword_add(bpp, blen, ent->type == IDMAP_TYPE_GROUP ? "group" : "user");
	qword_add(bpp, blen, idstr);

	(*bpp)[-1] = '\n';
}

142 143 144 145 146 147
static int
idtoname_upcall(struct cache_detail *cd, struct cache_head *ch)
{
	return sunrpc_cache_pipe_upcall(cd, ch, idtoname_request);
}

148 149
static int
idtoname_match(struct cache_head *ca, struct cache_head *cb)
L
Linus Torvalds 已提交
150
{
151 152 153
	struct ent *a = container_of(ca, struct ent, h);
	struct ent *b = container_of(cb, struct ent, h);

L
Linus Torvalds 已提交
154 155 156 157 158 159 160 161 162 163 164 165 166 167
	return (a->id == b->id && a->type == b->type &&
	    strcmp(a->authname, b->authname) == 0);
}

static int
idtoname_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h)
{
	struct ent *ent;

	if (h == NULL) {
		seq_puts(m, "#domain type id [name]\n");
		return 0;
	}
	ent = container_of(h, struct ent, h);
168
	seq_printf(m, "%s %s %u", ent->authname,
L
Linus Torvalds 已提交
169 170 171 172 173 174 175 176 177
			ent->type == IDMAP_TYPE_GROUP ? "group" : "user",
			ent->id);
	if (test_bit(CACHE_VALID, &h->flags))
		seq_printf(m, " %s", ent->name);
	seq_printf(m, "\n");
	return 0;
}

static void
178
warn_no_idmapd(struct cache_detail *detail, int has_died)
L
Linus Torvalds 已提交
179 180
{
	printk("nfsd: nfsv4 idmapping failing: has idmapd %s?\n",
181
			has_died ? "died" : "not been started");
L
Linus Torvalds 已提交
182 183 184 185
}


static int         idtoname_parse(struct cache_detail *, char *, int);
186 187 188
static struct ent *idtoname_lookup(struct cache_detail *, struct ent *);
static struct ent *idtoname_update(struct cache_detail *, struct ent *,
				   struct ent *);
L
Linus Torvalds 已提交
189

190
static struct cache_detail idtoname_cache_template = {
191
	.owner		= THIS_MODULE,
L
Linus Torvalds 已提交
192 193 194
	.hash_size	= ENT_HASHMAX,
	.name		= "nfs4.idtoname",
	.cache_put	= ent_put,
195
	.cache_upcall	= idtoname_upcall,
L
Linus Torvalds 已提交
196 197 198
	.cache_parse	= idtoname_parse,
	.cache_show	= idtoname_show,
	.warn_no_listener = warn_no_idmapd,
199 200 201 202
	.match		= idtoname_match,
	.init		= ent_init,
	.update		= ent_init,
	.alloc		= ent_alloc,
L
Linus Torvalds 已提交
203 204
};

H
Harvey Harrison 已提交
205
static int
L
Linus Torvalds 已提交
206 207 208 209
idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
{
	struct ent ent, *res;
	char *buf1, *bp;
210
	int len;
L
Linus Torvalds 已提交
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
	int error = -EINVAL;

	if (buf[buflen - 1] != '\n')
		return (-EINVAL);
	buf[buflen - 1]= '\0';

	buf1 = kmalloc(PAGE_SIZE, GFP_KERNEL);
	if (buf1 == NULL)
		return (-ENOMEM);

	memset(&ent, 0, sizeof(ent));

	/* Authentication name */
	if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
		goto out;
	memcpy(ent.authname, buf1, sizeof(ent.authname));

	/* Type */
	if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
		goto out;
	ent.type = strcmp(buf1, "user") == 0 ?
		IDMAP_TYPE_USER : IDMAP_TYPE_GROUP;

	/* ID */
	if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
		goto out;
	ent.id = simple_strtoul(buf1, &bp, 10);
	if (bp == buf1)
		goto out;

	/* expiry */
	ent.h.expiry_time = get_expiry(&buf);
	if (ent.h.expiry_time == 0)
		goto out;

246
	error = -ENOMEM;
247
	res = idtoname_lookup(cd, &ent);
248 249 250
	if (!res)
		goto out;

L
Linus Torvalds 已提交
251
	/* Name */
252 253 254
	error = -EINVAL;
	len = qword_get(&buf, buf1, PAGE_SIZE);
	if (len < 0)
L
Linus Torvalds 已提交
255
		goto out;
256
	if (len == 0)
L
Linus Torvalds 已提交
257
		set_bit(CACHE_NEGATIVE, &ent.h.flags);
258 259 260
	else if (len >= IDMAP_NAMESZ)
		goto out;
	else
L
Linus Torvalds 已提交
261 262
		memcpy(ent.name, buf1, sizeof(ent.name));
	error = -ENOMEM;
263
	res = idtoname_update(cd, &ent, res);
264
	if (res == NULL)
L
Linus Torvalds 已提交
265 266
		goto out;

267
	cache_put(&res->h, cd);
L
Linus Torvalds 已提交
268 269 270 271 272 273 274 275

	error = 0;
out:
	kfree(buf1);

	return error;
}

276 277

static struct ent *
278
idtoname_lookup(struct cache_detail *cd, struct ent *item)
279
{
280
	struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h,
281 282 283 284 285 286 287 288
						    idtoname_hash(item));
	if (ch)
		return container_of(ch, struct ent, h);
	else
		return NULL;
}

static struct ent *
289
idtoname_update(struct cache_detail *cd, struct ent *new, struct ent *old)
290
{
291
	struct cache_head *ch = sunrpc_cache_update(cd, &new->h, &old->h,
292 293 294 295 296 297 298
						    idtoname_hash(new));
	if (ch)
		return container_of(ch, struct ent, h);
	else
		return NULL;
}

L
Linus Torvalds 已提交
299 300 301 302 303 304 305 306 307 308 309 310 311

/*
 * Name -> ID cache
 */

static struct cache_head *nametoid_table[ENT_HASHMAX];

static inline int
nametoid_hash(struct ent *ent)
{
	return hash_str(ent->name, ENT_HASHBITS);
}

312
static void
L
Linus Torvalds 已提交
313 314 315 316 317 318 319 320 321 322 323 324
nametoid_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
    int *blen)
{
 	struct ent *ent = container_of(ch, struct ent, h);

	qword_add(bpp, blen, ent->authname);
	qword_add(bpp, blen, ent->type == IDMAP_TYPE_GROUP ? "group" : "user");
	qword_add(bpp, blen, ent->name);

	(*bpp)[-1] = '\n';
}

325 326 327 328 329 330
static int
nametoid_upcall(struct cache_detail *cd, struct cache_head *ch)
{
	return sunrpc_cache_pipe_upcall(cd, ch, nametoid_request);
}

331 332
static int
nametoid_match(struct cache_head *ca, struct cache_head *cb)
L
Linus Torvalds 已提交
333
{
334 335 336
	struct ent *a = container_of(ca, struct ent, h);
	struct ent *b = container_of(cb, struct ent, h);

L
Linus Torvalds 已提交
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
	return (a->type == b->type && strcmp(a->name, b->name) == 0 &&
	    strcmp(a->authname, b->authname) == 0);
}

static int
nametoid_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h)
{
	struct ent *ent;

	if (h == NULL) {
		seq_puts(m, "#domain type name [id]\n");
		return 0;
	}
	ent = container_of(h, struct ent, h);
	seq_printf(m, "%s %s %s", ent->authname,
			ent->type == IDMAP_TYPE_GROUP ? "group" : "user",
			ent->name);
	if (test_bit(CACHE_VALID, &h->flags))
355
		seq_printf(m, " %u", ent->id);
L
Linus Torvalds 已提交
356 357 358 359
	seq_printf(m, "\n");
	return 0;
}

360 361 362
static struct ent *nametoid_lookup(struct cache_detail *, struct ent *);
static struct ent *nametoid_update(struct cache_detail *, struct ent *,
				   struct ent *);
363
static int         nametoid_parse(struct cache_detail *, char *, int);
L
Linus Torvalds 已提交
364

365
static struct cache_detail nametoid_cache = {
366
	.owner		= THIS_MODULE,
L
Linus Torvalds 已提交
367 368 369 370
	.hash_size	= ENT_HASHMAX,
	.hash_table	= nametoid_table,
	.name		= "nfs4.nametoid",
	.cache_put	= ent_put,
371
	.cache_upcall	= nametoid_upcall,
L
Linus Torvalds 已提交
372 373 374
	.cache_parse	= nametoid_parse,
	.cache_show	= nametoid_show,
	.warn_no_listener = warn_no_idmapd,
375 376 377 378
	.match		= nametoid_match,
	.init		= ent_init,
	.update		= ent_init,
	.alloc		= ent_alloc,
L
Linus Torvalds 已提交
379 380
};

381
static int
L
Linus Torvalds 已提交
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
{
	struct ent ent, *res;
	char *buf1;
	int error = -EINVAL;

	if (buf[buflen - 1] != '\n')
		return (-EINVAL);
	buf[buflen - 1]= '\0';

	buf1 = kmalloc(PAGE_SIZE, GFP_KERNEL);
	if (buf1 == NULL)
		return (-ENOMEM);

	memset(&ent, 0, sizeof(ent));

	/* Authentication name */
	if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
		goto out;
	memcpy(ent.authname, buf1, sizeof(ent.authname));

	/* Type */
	if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
		goto out;
	ent.type = strcmp(buf1, "user") == 0 ?
		IDMAP_TYPE_USER : IDMAP_TYPE_GROUP;

	/* Name */
	error = qword_get(&buf, buf1, PAGE_SIZE);
	if (error <= 0 || error >= IDMAP_NAMESZ)
		goto out;
	memcpy(ent.name, buf1, sizeof(ent.name));

	/* expiry */
	ent.h.expiry_time = get_expiry(&buf);
	if (ent.h.expiry_time == 0)
		goto out;

	/* ID */
	error = get_int(&buf, &ent.id);
	if (error == -EINVAL)
		goto out;
	if (error == -ENOENT)
		set_bit(CACHE_NEGATIVE, &ent.h.flags);

	error = -ENOMEM;
428
	res = nametoid_lookup(cd, &ent);
429 430
	if (res == NULL)
		goto out;
431
	res = nametoid_update(cd, &ent, res);
432
	if (res == NULL)
L
Linus Torvalds 已提交
433 434
		goto out;

435
	cache_put(&res->h, cd);
L
Linus Torvalds 已提交
436 437 438 439 440 441 442
	error = 0;
out:
	kfree(buf1);

	return (error);
}

443 444

static struct ent *
445
nametoid_lookup(struct cache_detail *cd, struct ent *item)
446
{
447
	struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h,
448 449 450 451 452 453 454 455
						    nametoid_hash(item));
	if (ch)
		return container_of(ch, struct ent, h);
	else
		return NULL;
}

static struct ent *
456
nametoid_update(struct cache_detail *cd, struct ent *new, struct ent *old)
457
{
458
	struct cache_head *ch = sunrpc_cache_update(cd, &new->h, &old->h,
459 460 461 462 463 464
						    nametoid_hash(new));
	if (ch)
		return container_of(ch, struct ent, h);
	else
		return NULL;
}
L
Linus Torvalds 已提交
465 466 467 468 469

/*
 * Exported API
 */

470
int
471
nfsd_idmap_init(struct net *net)
L
Linus Torvalds 已提交
472
{
473
	int rv;
474
	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
475

476 477 478 479
	nn->idtoname_cache = cache_create_net(&idtoname_cache_template, net);
	if (IS_ERR(nn->idtoname_cache))
		return PTR_ERR(nn->idtoname_cache);
	rv = cache_register_net(nn->idtoname_cache, net);
480
	if (rv)
481
		goto destroy_idtoname_cache;
482
	rv = cache_register_net(&nametoid_cache, net);
483
	if (rv)
484 485 486 487 488 489 490
		goto unregister_idtoname_cache;
	return 0;

unregister_idtoname_cache:
	cache_unregister_net(nn->idtoname_cache, net);
destroy_idtoname_cache:
	cache_destroy_net(nn->idtoname_cache, net);
491
	return rv;
L
Linus Torvalds 已提交
492 493 494
}

void
495
nfsd_idmap_shutdown(struct net *net)
L
Linus Torvalds 已提交
496
{
497 498 499
	struct nfsd_net *nn = net_generic(net, nfsd_net_id);

	cache_unregister_net(nn->idtoname_cache, net);
500
	cache_unregister_net(&nametoid_cache, net);
501
	cache_destroy_net(nn->idtoname_cache, net);
L
Linus Torvalds 已提交
502 503 504 505
}

static int
idmap_lookup(struct svc_rqst *rqstp,
506 507
		struct ent *(*lookup_fn)(struct cache_detail *, struct ent *),
		struct ent *key, struct cache_detail *detail, struct ent **item)
L
Linus Torvalds 已提交
508 509 510
{
	int ret;

511
	*item = lookup_fn(detail, key);
512
	if (!*item)
L
Linus Torvalds 已提交
513
		return -ENOMEM;
514 515 516 517 518
 retry:
	ret = cache_check(detail, &(*item)->h, &rqstp->rq_chandle);

	if (ret == -ETIMEDOUT) {
		struct ent *prev_item = *item;
519
		*item = lookup_fn(detail, key);
520 521 522
		if (*item != prev_item)
			goto retry;
		cache_put(&(*item)->h, detail);
L
Linus Torvalds 已提交
523 524 525 526
	}
	return ret;
}

527 528 529 530 531 532 533 534 535
static char *
rqst_authname(struct svc_rqst *rqstp)
{
	struct auth_domain *clp;

	clp = rqstp->rq_gssclient ? rqstp->rq_gssclient : rqstp->rq_client;
	return clp->name;
}

536
static __be32
L
Linus Torvalds 已提交
537 538 539 540 541 542 543 544 545
idmap_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen,
		uid_t *id)
{
	struct ent *item, key = {
		.type = type,
	};
	int ret;

	if (namelen + 1 > sizeof(key.name))
546
		return nfserr_badowner;
L
Linus Torvalds 已提交
547 548
	memcpy(key.name, name, namelen);
	key.name[namelen] = '\0';
549
	strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
L
Linus Torvalds 已提交
550 551
	ret = idmap_lookup(rqstp, nametoid_lookup, &key, &nametoid_cache, &item);
	if (ret == -ENOENT)
552
		return nfserr_badowner;
L
Linus Torvalds 已提交
553
	if (ret)
554
		return nfserrno(ret);
L
Linus Torvalds 已提交
555
	*id = item->id;
556
	cache_put(&item->h, &nametoid_cache);
L
Linus Torvalds 已提交
557 558 559 560 561 562 563 564 565 566 567
	return 0;
}

static int
idmap_id_to_name(struct svc_rqst *rqstp, int type, uid_t id, char *name)
{
	struct ent *item, key = {
		.id = id,
		.type = type,
	};
	int ret;
568
	struct nfsd_net *nn = net_generic(rqstp->rq_xprt->xpt_net, nfsd_net_id);
L
Linus Torvalds 已提交
569

570
	strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
571
	ret = idmap_lookup(rqstp, idtoname_lookup, &key, nn->idtoname_cache, &item);
L
Linus Torvalds 已提交
572 573 574 575 576 577 578
	if (ret == -ENOENT)
		return sprintf(name, "%u", id);
	if (ret)
		return ret;
	ret = strlen(item->name);
	BUG_ON(ret > IDMAP_NAMESZ);
	memcpy(name, item->name, ret);
579
	cache_put(&item->h, nn->idtoname_cache);
L
Linus Torvalds 已提交
580 581 582
	return ret;
}

J
J. Bruce Fields 已提交
583 584 585 586 587 588 589 590 591 592 593 594
static bool
numeric_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, uid_t *id)
{
	int ret;
	char buf[11];

	if (namelen + 1 > sizeof(buf))
		/* too long to represent a 32-bit id: */
		return false;
	/* Just to make sure it's null-terminated: */
	memcpy(buf, name, namelen);
	buf[namelen] = '\0';
595
	ret = kstrtouint(name, 10, id);
J
J. Bruce Fields 已提交
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
	return ret == 0;
}

static __be32
do_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, uid_t *id)
{
	if (nfs4_disable_idmapping && rqstp->rq_flavor < RPC_AUTH_GSS)
		if (numeric_name_to_id(rqstp, type, name, namelen, id))
			return 0;
		/*
		 * otherwise, fall through and try idmapping, for
		 * backwards compatibility with clients sending names:
		 */
	return idmap_name_to_id(rqstp, type, name, namelen, id);
}

static int
do_id_to_name(struct svc_rqst *rqstp, int type, uid_t id, char *name)
{
	if (nfs4_disable_idmapping && rqstp->rq_flavor < RPC_AUTH_GSS)
		return sprintf(name, "%u", id);
	return idmap_id_to_name(rqstp, type, id, name);
}

620
__be32
L
Linus Torvalds 已提交
621 622 623
nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen,
		__u32 *id)
{
J
J. Bruce Fields 已提交
624
	return do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, id);
L
Linus Torvalds 已提交
625 626
}

627
__be32
L
Linus Torvalds 已提交
628 629 630
nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen,
		__u32 *id)
{
J
J. Bruce Fields 已提交
631
	return do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, id);
L
Linus Torvalds 已提交
632 633 634 635 636
}

int
nfsd_map_uid_to_name(struct svc_rqst *rqstp, __u32 id, char *name)
{
J
J. Bruce Fields 已提交
637
	return do_id_to_name(rqstp, IDMAP_TYPE_USER, id, name);
L
Linus Torvalds 已提交
638 639 640 641 642
}

int
nfsd_map_gid_to_name(struct svc_rqst *rqstp, __u32 id, char *name)
{
J
J. Bruce Fields 已提交
643
	return do_id_to_name(rqstp, IDMAP_TYPE_GROUP, id, name);
L
Linus Torvalds 已提交
644
}