Rev 423 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
423 | giacomo | 1 | |
2 | /* |
||
3 | * map between user/group name and id for a given 'client' |
||
4 | */ |
||
5 | |||
6 | struct name_ent { |
||
7 | char name[20]; |
||
8 | }; |
||
9 | static inline int name_get_user(int uid, struct name_ent **namep) |
||
10 | { |
||
11 | struct name_ent *n = kmalloc(sizeof(*n),GFP_KERNEL); |
||
12 | if (n) sprintf(n->name, "%d",uid); |
||
13 | *namep = n; |
||
14 | return n ? 0 : -ENOMEM; |
||
15 | } |
||
16 | static inline int name_get_group(int uid, struct name_ent **namep) |
||
17 | { |
||
18 | struct name_ent *n = kmalloc(sizeof(*n),GFP_KERNEL); |
||
19 | if (n) sprintf(n->name, "%d",uid); |
||
20 | *namep = n; |
||
21 | return n ? 0 : -ENOMEM; |
||
22 | } |
||
23 | static inline int name_get_uid(char *name, int name_len, int *uidp) |
||
24 | { |
||
25 | *uidp = simple_strtoul(name, NULL, 0); |
||
26 | return 0; |
||
27 | } |
||
28 | |||
29 | static inline int name_get_gid(char *name, int name_len, int *gidp) |
||
30 | { |
||
31 | *gidp = simple_strtoul(name, NULL, 0); |
||
32 | return 0; |
||
33 | } |
||
34 | |||
35 | static inline void name_put(struct name_ent *ent) |
||
36 | { |
||
37 | kfree(ent); |
||
38 | } |