Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/puffs/mount_9p Handle Rerror and return errno corre...
details: https://anonhg.NetBSD.org/src/rev/2dbc0a5aaceb
branches: trunk
changeset: 999519:2dbc0a5aaceb
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Jun 07 05:34:34 2019 +0000
description:
Handle Rerror and return errno correctly (only for 9P2000.u for now)
diffstat:
usr.sbin/puffs/mount_9p/mount_9p.8 | 6 +-
usr.sbin/puffs/mount_9p/nineproto.c | 65 +++++++++++++++++++++++++++++++-----
usr.sbin/puffs/mount_9p/ninepuffs.h | 9 +++-
usr.sbin/puffs/mount_9p/node.c | 25 ++++++++-----
usr.sbin/puffs/mount_9p/subr.c | 6 +-
5 files changed, 82 insertions(+), 29 deletions(-)
diffs (truncated from 305 to 300 lines):
diff -r fa6548fa5ba2 -r 2dbc0a5aaceb usr.sbin/puffs/mount_9p/mount_9p.8
--- a/usr.sbin/puffs/mount_9p/mount_9p.8 Fri Jun 07 05:22:28 2019 +0000
+++ b/usr.sbin/puffs/mount_9p/mount_9p.8 Fri Jun 07 05:34:34 2019 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: mount_9p.8,v 1.9 2019/05/17 08:56:12 wiz Exp $
+.\" $NetBSD: mount_9p.8,v 1.10 2019/06/07 05:34:34 ozaki-r Exp $
.\"
.\" Copyright (c) 2007 Antti Kantee. All rights reserved.
.\"
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 15, 2019
+.Dd June 7, 2019
.Dt MOUNT_9P 8
.Os
.Sh NAME
@@ -92,7 +92,7 @@
.Pp
Authentication support is missing.
.Pp
-Error code handling is missing.
+Error code handling is missing for 9P2000.
.Pp
Under construction.
.Pp
diff -r fa6548fa5ba2 -r 2dbc0a5aaceb usr.sbin/puffs/mount_9p/nineproto.c
--- a/usr.sbin/puffs/mount_9p/nineproto.c Fri Jun 07 05:22:28 2019 +0000
+++ b/usr.sbin/puffs/mount_9p/nineproto.c Fri Jun 07 05:34:34 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nineproto.c,v 1.10 2019/05/17 08:48:04 ozaki-r Exp $ */
+/* $NetBSD: nineproto.c,v 1.11 2019/06/07 05:34:34 ozaki-r Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: nineproto.c,v 1.10 2019/05/17 08:48:04 ozaki-r Exp $");
+__RCSID("$NetBSD: nineproto.c,v 1.11 2019/06/07 05:34:34 ozaki-r Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -188,6 +188,49 @@
return 0;
}
+static int
+proto_rerror(struct puffs_usermount *pu, struct puffs_framebuf *pb,
+ uint32_t *_errno)
+{
+ struct puffs9p *p9p = puffs_getspecific(pu);
+ uint16_t size;
+ int rv;
+ char *name;
+
+ /* Skip size[4] Rerror tag[2] */
+ rv = puffs_framebuf_seekset(pb,
+ sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint16_t));
+ if (rv == -1)
+ return EPROTO;
+
+ rv = p9pbuf_get_str(pb, &name, &size);
+ if (rv != 0)
+ return rv;
+ if (p9p->protover == P9PROTO_VERSION_U) {
+ rv = p9pbuf_get_4(pb, _errno);
+ } else {
+ /* TODO Convert error string to errno */
+ rv = EPROTO;
+ }
+
+ return rv;
+}
+
+int
+proto_handle_rerror(struct puffs_usermount *pu, struct puffs_framebuf *pb)
+{
+ int rv;
+ uint32_t _errno;
+
+ if (p9pbuf_get_type(pb) != P9PROTO_R_ERROR)
+ return EPROTO;
+
+ rv = proto_rerror(pu, pb, &_errno);
+ if (rv == 0)
+ rv = _errno;
+ return rv;
+}
+
int
proto_cc_dupfid(struct puffs_usermount *pu, p9pfid_t oldfid, p9pfid_t newfid)
{
@@ -206,7 +249,7 @@
p9pbuf_put_2(pb, 0);
GETRESPONSE(pb);
- rv = proto_expect_walk_nqids(pb, &qids);
+ rv = proto_expect_walk_nqids(pu, pb, &qids);
if (rv == 0 && qids != 0)
rv = EPROTO;
@@ -232,7 +275,7 @@
if (waitforit) {
if (puffs_framev_enqueue_cc(pcc, p9p->servsock, pb, 0) == 0) {
if (p9pbuf_get_type(pb) != P9PROTO_R_CLUNK)
- rv = EPROTO;
+ rv = proto_handle_rerror(pu, pb);
} else {
rv = errno;
}
@@ -269,7 +312,7 @@
p9pbuf_put_1(pb, mode);
GETRESPONSE(pb);
if (p9pbuf_get_type(pb) != P9PROTO_R_OPEN)
- rv = EPROTO;
+ rv = proto_handle_rerror(pu, pb);
out:
puffs_framebuf_destroy(pb);
@@ -349,20 +392,22 @@
}
int
-proto_expect_walk_nqids(struct puffs_framebuf *pb, uint16_t *nqids)
+proto_expect_walk_nqids(struct puffs_usermount *pu, struct puffs_framebuf *pb,
+ uint16_t *nqids)
{
if (p9pbuf_get_type(pb) != P9PROTO_R_WALK)
- return EPROTO;
+ return proto_handle_rerror(pu, pb);
return p9pbuf_get_2(pb, nqids);
}
int
-proto_expect_qid(struct puffs_framebuf *pb, uint8_t op, struct qid9p *qid)
+proto_expect_qid(struct puffs_usermount *pu, struct puffs_framebuf *pb,
+ uint8_t op, struct qid9p *qid)
{
if (p9pbuf_get_type(pb) != op)
- return EPROTO;
+ return proto_handle_rerror(pu, pb);
return proto_getqid(pb, qid);
}
@@ -374,7 +419,7 @@
int rv;
if (p9pbuf_get_type(pb) != P9PROTO_R_STAT)
- return EPROTO;
+ return proto_handle_rerror(pu, pb);
if ((rv = p9pbuf_get_2(pb, &dummy)))
return rv;
return proto_getstat(pu, pb, va, NULL, NULL);
diff -r fa6548fa5ba2 -r 2dbc0a5aaceb usr.sbin/puffs/mount_9p/ninepuffs.h
--- a/usr.sbin/puffs/mount_9p/ninepuffs.h Fri Jun 07 05:22:28 2019 +0000
+++ b/usr.sbin/puffs/mount_9p/ninepuffs.h Fri Jun 07 05:34:34 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ninepuffs.h,v 1.13 2019/05/17 08:48:04 ozaki-r Exp $ */
+/* $NetBSD: ninepuffs.h,v 1.14 2019/06/07 05:34:34 ozaki-r Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -151,10 +151,13 @@
int proto_getqid(struct puffs_framebuf *, struct qid9p *);
int proto_getstat(struct puffs_usermount *, struct puffs_framebuf *, struct vattr *,
char **, uint16_t *);
-int proto_expect_walk_nqids(struct puffs_framebuf *, uint16_t *);
+int proto_expect_walk_nqids(struct puffs_usermount *,
+ struct puffs_framebuf *, uint16_t *);
int proto_expect_stat(struct puffs_usermount *, struct puffs_framebuf *,
struct vattr *);
-int proto_expect_qid(struct puffs_framebuf *, uint8_t, struct qid9p *);
+int proto_expect_qid(struct puffs_usermount *, struct puffs_framebuf *,
+ uint8_t, struct qid9p *);
+int proto_handle_rerror(struct puffs_usermount *, struct puffs_framebuf *);
int proto_cc_dupfid(struct puffs_usermount *, p9pfid_t, p9pfid_t);
int proto_cc_clunkfid(struct puffs_usermount *, p9pfid_t, int);
diff -r fa6548fa5ba2 -r 2dbc0a5aaceb usr.sbin/puffs/mount_9p/node.c
--- a/usr.sbin/puffs/mount_9p/node.c Fri Jun 07 05:22:28 2019 +0000
+++ b/usr.sbin/puffs/mount_9p/node.c Fri Jun 07 05:34:34 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: node.c,v 1.22 2019/05/17 08:48:04 ozaki-r Exp $ */
+/* $NetBSD: node.c,v 1.23 2019/06/07 05:34:34 ozaki-r Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: node.c,v 1.22 2019/05/17 08:48:04 ozaki-r Exp $");
+__RCSID("$NetBSD: node.c,v 1.23 2019/06/07 05:34:34 ozaki-r Exp $");
#endif /* !lint */
#include <assert.h>
@@ -62,6 +62,10 @@
p9pbuf_put_4(pb, p9n->fid_base);
GETRESPONSE(pb);
+ if (p9pbuf_get_type(pb) != P9PROTO_R_STAT) {
+ rv = proto_handle_rerror(pu, pb);
+ goto out;
+ }
rv = proto_expect_stat(pu, pb, vap);
out:
@@ -101,7 +105,7 @@
p9pbuf_put_str(pb, pcn->pcn_name);
GETRESPONSE(pb);
- rv = proto_expect_walk_nqids(pb, &nqid);
+ rv = proto_expect_walk_nqids(pu, pb, &nqid);
if (rv) {
rv = ENOENT;
goto out;
@@ -234,8 +238,9 @@
proto_make_stat(pu, pb, va, NULL, pn->pn_va.va_type);
GETRESPONSE(pb);
- if (p9pbuf_get_type(pb) != P9PROTO_R_WSTAT)
- rv = EPROTO;
+ if (p9pbuf_get_type(pb) != P9PROTO_R_WSTAT) {
+ rv = proto_handle_rerror(pu, pb);
+ }
out:
RETURN(rv);
@@ -330,7 +335,7 @@
GETRESPONSE(pb);
if (p9pbuf_get_type(pb) != P9PROTO_R_READ) {
- rv = EPROTO;
+ rv = proto_handle_rerror(pu, pb);
break;
}
@@ -378,7 +383,7 @@
GETRESPONSE(pb);
if (p9pbuf_get_type(pb) != P9PROTO_R_WRITE) {
- rv = EPROTO;
+ rv = proto_handle_rerror(pu, pb);
break;
}
@@ -430,7 +435,7 @@
p9pbuf_put_str(pb, ""); /* extension[s] */
GETRESPONSE(pb);
- rv = proto_expect_qid(pb, P9PROTO_R_CREATE, &nqid);
+ rv = proto_expect_qid(pu, pb, P9PROTO_R_CREATE, &nqid);
if (rv)
goto out;
@@ -512,7 +517,7 @@
GETRESPONSE(pb);
if (p9pbuf_get_type(pb) != P9PROTO_R_REMOVE) {
- rv = EPROTO;
+ rv = proto_handle_rerror(pu, pb);
} else {
proto_cc_clunkfid(pu, p9n->fid_base, 0);
p9n->fid_base = P9P_INVALFID;
@@ -585,7 +590,7 @@
GETRESPONSE(pb);
if (p9pbuf_get_type(pb) != P9PROTO_R_WSTAT)
- rv = EPROTO;
+ rv = proto_handle_rerror(pu, pb);
out:
RETURN(rv);
diff -r fa6548fa5ba2 -r 2dbc0a5aaceb usr.sbin/puffs/mount_9p/subr.c
--- a/usr.sbin/puffs/mount_9p/subr.c Fri Jun 07 05:22:28 2019 +0000
+++ b/usr.sbin/puffs/mount_9p/subr.c Fri Jun 07 05:34:34 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr.c,v 1.6 2007/11/30 19:02:39 pooka Exp $ */
+/* $NetBSD: subr.c,v 1.7 2019/06/07 05:34:34 ozaki-r Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: subr.c,v 1.6 2007/11/30 19:02:39 pooka Exp $");
+__RCSID("$NetBSD: subr.c,v 1.7 2019/06/07 05:34:34 ozaki-r Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -139,7 +139,7 @@
GETRESPONSE(pb);
if (p9pbuf_get_type(pb) != P9PROTO_R_READ) {
Home |
Main Index |
Thread Index |
Old Index