blob: 75cfbb68b2053b9f2ad84662451ce3e889b8acb0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * fs/nfsd/nfs4idmap.c
3 *
4 * Mapping of UID/GIDs to name and vice versa.
5 *
6 * Copyright (c) 2002, 2003 The Regents of the University of
7 * Michigan. All rights reserved.
8 *
9 * Marius Aamodt Eriksen <marius@umich.edu>
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#include <linux/config.h>
38#include <linux/module.h>
39#include <linux/init.h>
40
41#include <linux/mm.h>
42#include <linux/utsname.h>
43#include <linux/errno.h>
44#include <linux/string.h>
45#include <linux/sunrpc/clnt.h>
46#include <linux/nfs.h>
47#include <linux/nfs4.h>
48#include <linux/nfs_fs.h>
49#include <linux/nfs_page.h>
50#include <linux/smp_lock.h>
51#include <linux/sunrpc/cache.h>
52#include <linux/nfsd_idmap.h>
53#include <linux/list.h>
54#include <linux/sched.h>
55#include <linux/time.h>
56#include <linux/seq_file.h>
57#include <linux/sunrpc/svcauth.h>
58
59/*
60 * Cache entry
61 */
62
63/*
64 * XXX we know that IDMAP_NAMESZ < PAGE_SIZE, but it's ugly to rely on
65 * that.
66 */
67
68#define IDMAP_TYPE_USER 0
69#define IDMAP_TYPE_GROUP 1
70
71struct ent {
72 struct cache_head h;
73 int type; /* User / Group */
74 uid_t id;
75 char name[IDMAP_NAMESZ];
76 char authname[IDMAP_NAMESZ];
77};
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079/* Common entry handling */
80
81#define ENT_HASHBITS 8
82#define ENT_HASHMAX (1 << ENT_HASHBITS)
83#define ENT_HASHMASK (ENT_HASHMAX - 1)
84
NeilBrownf9ecc922006-03-27 01:15:06 -080085static void
86ent_init(struct cache_head *cnew, struct cache_head *citm)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087{
NeilBrownf9ecc922006-03-27 01:15:06 -080088 struct ent *new = container_of(cnew, struct ent, h);
89 struct ent *itm = container_of(citm, struct ent, h);
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 new->id = itm->id;
92 new->type = itm->type;
93
94 strlcpy(new->name, itm->name, sizeof(new->name));
95 strlcpy(new->authname, itm->authname, sizeof(new->name));
96}
97
NeilBrownfd39ca92005-06-23 22:04:03 -070098static void
Linus Torvalds1da177e2005-04-16 15:20:36 -070099ent_put(struct cache_head *ch, struct cache_detail *cd)
100{
101 if (cache_put(ch, cd)) {
102 struct ent *map = container_of(ch, struct ent, h);
103 kfree(map);
104 }
105}
106
NeilBrownf9ecc922006-03-27 01:15:06 -0800107static struct cache_head *
108ent_alloc(void)
109{
110 struct ent *e = kmalloc(sizeof(*e), GFP_KERNEL);
111 if (e)
112 return &e->h;
113 else
114 return NULL;
115}
116
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117/*
118 * ID -> Name cache
119 */
120
121static struct cache_head *idtoname_table[ENT_HASHMAX];
122
123static uint32_t
124idtoname_hash(struct ent *ent)
125{
126 uint32_t hash;
127
128 hash = hash_str(ent->authname, ENT_HASHBITS);
129 hash = hash_long(hash ^ ent->id, ENT_HASHBITS);
130
131 /* Flip LSB for user/group */
132 if (ent->type == IDMAP_TYPE_GROUP)
133 hash ^= 1;
134
135 return hash;
136}
137
138static void
139idtoname_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
140 int *blen)
141{
142 struct ent *ent = container_of(ch, struct ent, h);
143 char idstr[11];
144
145 qword_add(bpp, blen, ent->authname);
146 snprintf(idstr, sizeof(idstr), "%d", ent->id);
147 qword_add(bpp, blen, ent->type == IDMAP_TYPE_GROUP ? "group" : "user");
148 qword_add(bpp, blen, idstr);
149
150 (*bpp)[-1] = '\n';
151}
152
NeilBrownf9ecc922006-03-27 01:15:06 -0800153static int
154idtoname_match(struct cache_head *ca, struct cache_head *cb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155{
NeilBrownf9ecc922006-03-27 01:15:06 -0800156 struct ent *a = container_of(ca, struct ent, h);
157 struct ent *b = container_of(cb, struct ent, h);
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 return (a->id == b->id && a->type == b->type &&
160 strcmp(a->authname, b->authname) == 0);
161}
162
163static int
164idtoname_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h)
165{
166 struct ent *ent;
167
168 if (h == NULL) {
169 seq_puts(m, "#domain type id [name]\n");
170 return 0;
171 }
172 ent = container_of(h, struct ent, h);
173 seq_printf(m, "%s %s %d", ent->authname,
174 ent->type == IDMAP_TYPE_GROUP ? "group" : "user",
175 ent->id);
176 if (test_bit(CACHE_VALID, &h->flags))
177 seq_printf(m, " %s", ent->name);
178 seq_printf(m, "\n");
179 return 0;
180}
181
182static void
183warn_no_idmapd(struct cache_detail *detail)
184{
185 printk("nfsd: nfsv4 idmapping failing: has idmapd %s?\n",
186 detail->last_close? "died" : "not been started");
187}
188
189
190static int idtoname_parse(struct cache_detail *, char *, int);
NeilBrownf9ecc922006-03-27 01:15:06 -0800191static struct ent *idtoname_lookup(struct ent *);
192static struct ent *idtoname_update(struct ent *, struct ent *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
NeilBrownfd39ca92005-06-23 22:04:03 -0700194static struct cache_detail idtoname_cache = {
Bruce Allanf35279d2005-09-06 15:17:08 -0700195 .owner = THIS_MODULE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 .hash_size = ENT_HASHMAX,
197 .hash_table = idtoname_table,
198 .name = "nfs4.idtoname",
199 .cache_put = ent_put,
200 .cache_request = idtoname_request,
201 .cache_parse = idtoname_parse,
202 .cache_show = idtoname_show,
203 .warn_no_listener = warn_no_idmapd,
NeilBrownf9ecc922006-03-27 01:15:06 -0800204 .match = idtoname_match,
205 .init = ent_init,
206 .update = ent_init,
207 .alloc = ent_alloc,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208};
209
210int
211idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
212{
213 struct ent ent, *res;
214 char *buf1, *bp;
215 int error = -EINVAL;
216
217 if (buf[buflen - 1] != '\n')
218 return (-EINVAL);
219 buf[buflen - 1]= '\0';
220
221 buf1 = kmalloc(PAGE_SIZE, GFP_KERNEL);
222 if (buf1 == NULL)
223 return (-ENOMEM);
224
225 memset(&ent, 0, sizeof(ent));
226
227 /* Authentication name */
228 if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
229 goto out;
230 memcpy(ent.authname, buf1, sizeof(ent.authname));
231
232 /* Type */
233 if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
234 goto out;
235 ent.type = strcmp(buf1, "user") == 0 ?
236 IDMAP_TYPE_USER : IDMAP_TYPE_GROUP;
237
238 /* ID */
239 if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
240 goto out;
241 ent.id = simple_strtoul(buf1, &bp, 10);
242 if (bp == buf1)
243 goto out;
244
245 /* expiry */
246 ent.h.expiry_time = get_expiry(&buf);
247 if (ent.h.expiry_time == 0)
248 goto out;
249
NeilBrownf9ecc922006-03-27 01:15:06 -0800250 error = -ENOMEM;
251 res = idtoname_lookup(&ent);
252 if (!res)
253 goto out;
254
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 /* Name */
256 error = qword_get(&buf, buf1, PAGE_SIZE);
257 if (error == -EINVAL)
258 goto out;
259 if (error == -ENOENT)
260 set_bit(CACHE_NEGATIVE, &ent.h.flags);
261 else {
262 if (error >= IDMAP_NAMESZ) {
263 error = -EINVAL;
264 goto out;
265 }
266 memcpy(ent.name, buf1, sizeof(ent.name));
267 }
268 error = -ENOMEM;
NeilBrownf9ecc922006-03-27 01:15:06 -0800269 res = idtoname_update(&ent, res);
270 if (res == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 goto out;
272
273 ent_put(&res->h, &idtoname_cache);
274
275 error = 0;
276out:
277 kfree(buf1);
278
279 return error;
280}
281
NeilBrownf9ecc922006-03-27 01:15:06 -0800282
283static struct ent *
284idtoname_lookup(struct ent *item)
285{
286 struct cache_head *ch = sunrpc_cache_lookup(&idtoname_cache,
287 &item->h,
288 idtoname_hash(item));
289 if (ch)
290 return container_of(ch, struct ent, h);
291 else
292 return NULL;
293}
294
295static struct ent *
296idtoname_update(struct ent *new, struct ent *old)
297{
298 struct cache_head *ch = sunrpc_cache_update(&idtoname_cache,
299 &new->h, &old->h,
300 idtoname_hash(new));
301 if (ch)
302 return container_of(ch, struct ent, h);
303 else
304 return NULL;
305}
306
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307
308/*
309 * Name -> ID cache
310 */
311
312static struct cache_head *nametoid_table[ENT_HASHMAX];
313
314static inline int
315nametoid_hash(struct ent *ent)
316{
317 return hash_str(ent->name, ENT_HASHBITS);
318}
319
NeilBrownfd39ca92005-06-23 22:04:03 -0700320static void
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321nametoid_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
322 int *blen)
323{
324 struct ent *ent = container_of(ch, struct ent, h);
325
326 qword_add(bpp, blen, ent->authname);
327 qword_add(bpp, blen, ent->type == IDMAP_TYPE_GROUP ? "group" : "user");
328 qword_add(bpp, blen, ent->name);
329
330 (*bpp)[-1] = '\n';
331}
332
NeilBrownf9ecc922006-03-27 01:15:06 -0800333static int
334nametoid_match(struct cache_head *ca, struct cache_head *cb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335{
NeilBrownf9ecc922006-03-27 01:15:06 -0800336 struct ent *a = container_of(ca, struct ent, h);
337 struct ent *b = container_of(cb, struct ent, h);
338
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 return (a->type == b->type && strcmp(a->name, b->name) == 0 &&
340 strcmp(a->authname, b->authname) == 0);
341}
342
343static int
344nametoid_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h)
345{
346 struct ent *ent;
347
348 if (h == NULL) {
349 seq_puts(m, "#domain type name [id]\n");
350 return 0;
351 }
352 ent = container_of(h, struct ent, h);
353 seq_printf(m, "%s %s %s", ent->authname,
354 ent->type == IDMAP_TYPE_GROUP ? "group" : "user",
355 ent->name);
356 if (test_bit(CACHE_VALID, &h->flags))
357 seq_printf(m, " %d", ent->id);
358 seq_printf(m, "\n");
359 return 0;
360}
361
NeilBrownf9ecc922006-03-27 01:15:06 -0800362static struct ent *nametoid_lookup(struct ent *);
363static struct ent *nametoid_update(struct ent *, struct ent *);
NeilBrownfd39ca92005-06-23 22:04:03 -0700364static int nametoid_parse(struct cache_detail *, char *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
NeilBrownfd39ca92005-06-23 22:04:03 -0700366static struct cache_detail nametoid_cache = {
Bruce Allanf35279d2005-09-06 15:17:08 -0700367 .owner = THIS_MODULE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 .hash_size = ENT_HASHMAX,
369 .hash_table = nametoid_table,
370 .name = "nfs4.nametoid",
371 .cache_put = ent_put,
372 .cache_request = nametoid_request,
373 .cache_parse = nametoid_parse,
374 .cache_show = nametoid_show,
375 .warn_no_listener = warn_no_idmapd,
NeilBrownf9ecc922006-03-27 01:15:06 -0800376 .match = nametoid_match,
377 .init = ent_init,
378 .update = ent_init,
379 .alloc = ent_alloc,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380};
381
NeilBrownfd39ca92005-06-23 22:04:03 -0700382static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
384{
385 struct ent ent, *res;
386 char *buf1;
387 int error = -EINVAL;
388
389 if (buf[buflen - 1] != '\n')
390 return (-EINVAL);
391 buf[buflen - 1]= '\0';
392
393 buf1 = kmalloc(PAGE_SIZE, GFP_KERNEL);
394 if (buf1 == NULL)
395 return (-ENOMEM);
396
397 memset(&ent, 0, sizeof(ent));
398
399 /* Authentication name */
400 if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
401 goto out;
402 memcpy(ent.authname, buf1, sizeof(ent.authname));
403
404 /* Type */
405 if (qword_get(&buf, buf1, PAGE_SIZE) <= 0)
406 goto out;
407 ent.type = strcmp(buf1, "user") == 0 ?
408 IDMAP_TYPE_USER : IDMAP_TYPE_GROUP;
409
410 /* Name */
411 error = qword_get(&buf, buf1, PAGE_SIZE);
412 if (error <= 0 || error >= IDMAP_NAMESZ)
413 goto out;
414 memcpy(ent.name, buf1, sizeof(ent.name));
415
416 /* expiry */
417 ent.h.expiry_time = get_expiry(&buf);
418 if (ent.h.expiry_time == 0)
419 goto out;
420
421 /* ID */
422 error = get_int(&buf, &ent.id);
423 if (error == -EINVAL)
424 goto out;
425 if (error == -ENOENT)
426 set_bit(CACHE_NEGATIVE, &ent.h.flags);
427
428 error = -ENOMEM;
NeilBrownf9ecc922006-03-27 01:15:06 -0800429 res = nametoid_lookup(&ent);
430 if (res == NULL)
431 goto out;
432 res = nametoid_update(&ent, res);
433 if (res == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 goto out;
435
436 ent_put(&res->h, &nametoid_cache);
437 error = 0;
438out:
439 kfree(buf1);
440
441 return (error);
442}
443
NeilBrownf9ecc922006-03-27 01:15:06 -0800444
445static struct ent *
446nametoid_lookup(struct ent *item)
447{
448 struct cache_head *ch = sunrpc_cache_lookup(&nametoid_cache,
449 &item->h,
450 nametoid_hash(item));
451 if (ch)
452 return container_of(ch, struct ent, h);
453 else
454 return NULL;
455}
456
457static struct ent *
458nametoid_update(struct ent *new, struct ent *old)
459{
460 struct cache_head *ch = sunrpc_cache_update(&nametoid_cache,
461 &new->h, &old->h,
462 nametoid_hash(new));
463 if (ch)
464 return container_of(ch, struct ent, h);
465 else
466 return NULL;
467}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468
469/*
470 * Exported API
471 */
472
473void
474nfsd_idmap_init(void)
475{
476 cache_register(&idtoname_cache);
477 cache_register(&nametoid_cache);
478}
479
480void
481nfsd_idmap_shutdown(void)
482{
Bruce Allanf35279d2005-09-06 15:17:08 -0700483 if (cache_unregister(&idtoname_cache))
484 printk(KERN_ERR "nfsd: failed to unregister idtoname cache\n");
485 if (cache_unregister(&nametoid_cache))
486 printk(KERN_ERR "nfsd: failed to unregister nametoid cache\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487}
488
489/*
490 * Deferred request handling
491 */
492
493struct idmap_defer_req {
494 struct cache_req req;
495 struct cache_deferred_req deferred_req;
496 wait_queue_head_t waitq;
497 atomic_t count;
498};
499
500static inline void
501put_mdr(struct idmap_defer_req *mdr)
502{
503 if (atomic_dec_and_test(&mdr->count))
504 kfree(mdr);
505}
506
507static inline void
508get_mdr(struct idmap_defer_req *mdr)
509{
510 atomic_inc(&mdr->count);
511}
512
513static void
514idmap_revisit(struct cache_deferred_req *dreq, int toomany)
515{
516 struct idmap_defer_req *mdr =
517 container_of(dreq, struct idmap_defer_req, deferred_req);
518
519 wake_up(&mdr->waitq);
520 put_mdr(mdr);
521}
522
523static struct cache_deferred_req *
524idmap_defer(struct cache_req *req)
525{
526 struct idmap_defer_req *mdr =
527 container_of(req, struct idmap_defer_req, req);
528
529 mdr->deferred_req.revisit = idmap_revisit;
530 get_mdr(mdr);
531 return (&mdr->deferred_req);
532}
533
534static inline int
NeilBrownf9ecc922006-03-27 01:15:06 -0800535do_idmap_lookup(struct ent *(*lookup_fn)(struct ent *), struct ent *key,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 struct cache_detail *detail, struct ent **item,
537 struct idmap_defer_req *mdr)
538{
NeilBrownf9ecc922006-03-27 01:15:06 -0800539 *item = lookup_fn(key);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 if (!*item)
541 return -ENOMEM;
542 return cache_check(detail, &(*item)->h, &mdr->req);
543}
544
545static inline int
NeilBrownf9ecc922006-03-27 01:15:06 -0800546do_idmap_lookup_nowait(struct ent *(*lookup_fn)(struct ent *),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 struct ent *key, struct cache_detail *detail,
548 struct ent **item)
549{
550 int ret = -ENOMEM;
551
NeilBrownf9ecc922006-03-27 01:15:06 -0800552 *item = lookup_fn(key);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 if (!*item)
554 goto out_err;
555 ret = -ETIMEDOUT;
556 if (!test_bit(CACHE_VALID, &(*item)->h.flags)
557 || (*item)->h.expiry_time < get_seconds()
558 || detail->flush_time > (*item)->h.last_refresh)
559 goto out_put;
560 ret = -ENOENT;
561 if (test_bit(CACHE_NEGATIVE, &(*item)->h.flags))
562 goto out_put;
563 return 0;
564out_put:
565 ent_put(&(*item)->h, detail);
566out_err:
567 *item = NULL;
568 return ret;
569}
570
571static int
572idmap_lookup(struct svc_rqst *rqstp,
NeilBrownf9ecc922006-03-27 01:15:06 -0800573 struct ent *(*lookup_fn)(struct ent *), struct ent *key,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 struct cache_detail *detail, struct ent **item)
575{
576 struct idmap_defer_req *mdr;
577 int ret;
578
579 mdr = kmalloc(sizeof(*mdr), GFP_KERNEL);
580 if (!mdr)
581 return -ENOMEM;
582 memset(mdr, 0, sizeof(*mdr));
583 atomic_set(&mdr->count, 1);
584 init_waitqueue_head(&mdr->waitq);
585 mdr->req.defer = idmap_defer;
586 ret = do_idmap_lookup(lookup_fn, key, detail, item, mdr);
587 if (ret == -EAGAIN) {
588 wait_event_interruptible_timeout(mdr->waitq,
589 test_bit(CACHE_VALID, &(*item)->h.flags), 1 * HZ);
590 ret = do_idmap_lookup_nowait(lookup_fn, key, detail, item);
591 }
592 put_mdr(mdr);
593 return ret;
594}
595
596static int
597idmap_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen,
598 uid_t *id)
599{
600 struct ent *item, key = {
601 .type = type,
602 };
603 int ret;
604
605 if (namelen + 1 > sizeof(key.name))
606 return -EINVAL;
607 memcpy(key.name, name, namelen);
608 key.name[namelen] = '\0';
609 strlcpy(key.authname, rqstp->rq_client->name, sizeof(key.authname));
610 ret = idmap_lookup(rqstp, nametoid_lookup, &key, &nametoid_cache, &item);
611 if (ret == -ENOENT)
612 ret = -ESRCH; /* nfserr_badname */
613 if (ret)
614 return ret;
615 *id = item->id;
616 ent_put(&item->h, &nametoid_cache);
617 return 0;
618}
619
620static int
621idmap_id_to_name(struct svc_rqst *rqstp, int type, uid_t id, char *name)
622{
623 struct ent *item, key = {
624 .id = id,
625 .type = type,
626 };
627 int ret;
628
629 strlcpy(key.authname, rqstp->rq_client->name, sizeof(key.authname));
630 ret = idmap_lookup(rqstp, idtoname_lookup, &key, &idtoname_cache, &item);
631 if (ret == -ENOENT)
632 return sprintf(name, "%u", id);
633 if (ret)
634 return ret;
635 ret = strlen(item->name);
636 BUG_ON(ret > IDMAP_NAMESZ);
637 memcpy(name, item->name, ret);
638 ent_put(&item->h, &idtoname_cache);
639 return ret;
640}
641
642int
643nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen,
644 __u32 *id)
645{
646 return idmap_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, id);
647}
648
649int
650nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen,
651 __u32 *id)
652{
653 return idmap_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, id);
654}
655
656int
657nfsd_map_uid_to_name(struct svc_rqst *rqstp, __u32 id, char *name)
658{
659 return idmap_id_to_name(rqstp, IDMAP_TYPE_USER, id, name);
660}
661
662int
663nfsd_map_gid_to_name(struct svc_rqst *rqstp, __u32 id, char *name)
664{
665 return idmap_id_to_name(rqstp, IDMAP_TYPE_GROUP, id, name);
666}