diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-01-29 20:07:42 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-12 06:19:29 -0500 |
commit | 97fc8b1ebf6a0fe4bb9c71a8e91a822c22c09bc5 (patch) | |
tree | e6cda16664ef5abef549d21fae2de32a4d096129 /net/9p | |
parent | d5ea055f1cc0ff6d4170c7f60f3cb5eb09d927bc (diff) |
9p: Add 'u' and 'g' format specifies for kuids and kgids
This allows concentrating all of the conversion to and from kuids and
kgids into the format needed by the 9p protocol into one location.
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ron Minnich <rminnich@gmail.com>
Cc: Latchesar Ionkov <lucho@ionkov.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'net/9p')
-rw-r--r-- | net/9p/protocol.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/net/9p/protocol.c b/net/9p/protocol.c index 3d33ecf13327..c289c6cee98e 100644 --- a/net/9p/protocol.c +++ b/net/9p/protocol.c | |||
@@ -85,6 +85,8 @@ pdu_write_u(struct p9_fcall *pdu, const char __user *udata, size_t size) | |||
85 | d - int32_t | 85 | d - int32_t |
86 | q - int64_t | 86 | q - int64_t |
87 | s - string | 87 | s - string |
88 | u - numeric uid | ||
89 | g - numeric gid | ||
88 | S - stat | 90 | S - stat |
89 | Q - qid | 91 | Q - qid |
90 | D - data blob (int32_t size followed by void *, results are not freed) | 92 | D - data blob (int32_t size followed by void *, results are not freed) |
@@ -163,6 +165,26 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt, | |||
163 | (*sptr)[len] = 0; | 165 | (*sptr)[len] = 0; |
164 | } | 166 | } |
165 | break; | 167 | break; |
168 | case 'u': { | ||
169 | kuid_t *uid = va_arg(ap, kuid_t *); | ||
170 | __le32 le_val; | ||
171 | if (pdu_read(pdu, &le_val, sizeof(le_val))) { | ||
172 | errcode = -EFAULT; | ||
173 | break; | ||
174 | } | ||
175 | *uid = make_kuid(&init_user_ns, | ||
176 | le32_to_cpu(le_val)); | ||
177 | } break; | ||
178 | case 'g': { | ||
179 | kgid_t *gid = va_arg(ap, kgid_t *); | ||
180 | __le32 le_val; | ||
181 | if (pdu_read(pdu, &le_val, sizeof(le_val))) { | ||
182 | errcode = -EFAULT; | ||
183 | break; | ||
184 | } | ||
185 | *gid = make_kgid(&init_user_ns, | ||
186 | le32_to_cpu(le_val)); | ||
187 | } break; | ||
166 | case 'Q':{ | 188 | case 'Q':{ |
167 | struct p9_qid *qid = | 189 | struct p9_qid *qid = |
168 | va_arg(ap, struct p9_qid *); | 190 | va_arg(ap, struct p9_qid *); |
@@ -377,6 +399,20 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt, | |||
377 | errcode = -EFAULT; | 399 | errcode = -EFAULT; |
378 | } | 400 | } |
379 | break; | 401 | break; |
402 | case 'u': { | ||
403 | kuid_t uid = va_arg(ap, kuid_t); | ||
404 | __le32 val = cpu_to_le32( | ||
405 | from_kuid(&init_user_ns, uid)); | ||
406 | if (pdu_write(pdu, &val, sizeof(val))) | ||
407 | errcode = -EFAULT; | ||
408 | } break; | ||
409 | case 'g': { | ||
410 | kgid_t gid = va_arg(ap, kgid_t); | ||
411 | __le32 val = cpu_to_le32( | ||
412 | from_kgid(&init_user_ns, gid)); | ||
413 | if (pdu_write(pdu, &val, sizeof(val))) | ||
414 | errcode = -EFAULT; | ||
415 | } break; | ||
380 | case 'Q':{ | 416 | case 'Q':{ |
381 | const struct p9_qid *qid = | 417 | const struct p9_qid *qid = |
382 | va_arg(ap, const struct p9_qid *); | 418 | va_arg(ap, const struct p9_qid *); |