summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authormartin <martin@NetBSD.org>2022-03-15 09:58:38 +0000
committermartin <martin@NetBSD.org>2022-03-15 09:58:38 +0000
commite4576721c6be7c05d57aa4052772aabc5dc5a7ae (patch)
treede9e7785a9f9b3a2bb29ea486cd124066c08217b /usr.sbin
parentc5b8f94a7ff2cb17ec048ea0538e16b517cf4b76 (diff)
Pull up following revision(s) (requested by ozaki-r in ticket #1434):
usr.sbin/puffs/mount_9p/node.c: revision 1.30 usr.sbin/puffs/mount_9p/node.c: revision 1.31 mount_9p: fix writing to a file opened with write-only mode With the page cache, writing data to a file may demand to read contents from a storage to fill a page in the page cache first. Opening a file with write-only mode by a user lets a mount_9p process open a file with write-only mode too at a 9p server. Thus, a read request to the file from the page cache fails. So we need to open a file always with read mode (internally) even if it is opened with write-only mode by a user. Note that the change doesn't mean that mount_9p allows users to read contents from a file that is opened with write-only mode. - mount_9p: check returned type for Tread
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/puffs/mount_9p/node.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.sbin/puffs/mount_9p/node.c b/usr.sbin/puffs/mount_9p/node.c
index c51fb1e52c0..b1c5e58a00e 100644
--- a/usr.sbin/puffs/mount_9p/node.c
+++ b/usr.sbin/puffs/mount_9p/node.c
@@ -1,4 +1,4 @@
-/* $NetBSD: node.c,v 1.23 2019/06/07 05:34:34 ozaki-r Exp $ */
+/* $NetBSD: node.c,v 1.23.2.1 2022/03/15 09:58:38 martin 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.23 2019/06/07 05:34:34 ozaki-r Exp $");
+__RCSID("$NetBSD: node.c,v 1.23.2.1 2022/03/15 09:58:38 martin Exp $");
#endif /* !lint */
#include <assert.h>
@@ -185,6 +185,11 @@ puffs9p_node_readdir(struct puffs_usermount *pu, void *opc, struct dirent *dent,
p9pbuf_put_4(pb, *reslen); /* XXX */
GETRESPONSE(pb);
+ if (p9pbuf_get_type(pb) != P9PROTO_R_READ) {
+ rv = proto_handle_rerror(pu, pb);
+ goto out;
+ }
+
p9pbuf_get_4(pb, &count);
/*
@@ -271,6 +276,8 @@ puffs9p_node_open(struct puffs_usermount *pu, void *opc, int mode,
puffs_setback(pcc, PUFFS_SETBACK_INACT_N1);
if (pn->pn_va.va_type != VDIR) {
+ /* Always require read access for page cache */
+ mode |= FREAD;
if (mode & FREAD && p9n->fid_read == P9P_INVALFID) {
nfid = NEXTFID(p9p);
error = proto_cc_open(pu, p9n->fid_base, nfid,