shithub: riscv

Download patch

ref: 7b48acc5257406f5cecd8d50a050419dba933c4a
parent: d49ce9f885e73cd452d8a645429d3904e4676f8d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Feb 23 13:53:44 EST 2025

cwfs: check qid.path in Tfile tag for fs_read and truncate

We used to ignore the qid.path in the data block
tags for file contents (only checking block type).

--- a/sys/src/cmd/cwfs/9p2.c
+++ b/sys/src/cmd/cwfs/9p2.c
@@ -1075,7 +1075,7 @@
 		p1 = dnodebuf1(p, d, addr, 0, file->uid);
 		p = nil;
 		if(p1 != nil){
-			if(checktag(p1, Tfile, QPNONE)){
+			if(checktag(p1, Tfile, d->qid.path)){
 				error = Ephase;
 				putbuf(p1);
 				goto out;
@@ -1193,7 +1193,7 @@
 	Dentry *d;
 	File *file;
 	Tlock *t;
-	Off offset, addr, qpath;
+	Off offset, addr;
 	Timet tim;
 	int count, error, nwrite, o, n;
 
@@ -1270,7 +1270,6 @@
 		n = BUFSIZE - o;
 		if(n > count)
 			n = count;
-		qpath = d->qid.path;
 		p1 = dnodebuf1(p, d, addr, Tfile, file->uid);
 		p = nil;
 		if(p1 == nil) {
@@ -1277,7 +1276,7 @@
 			error = Efull;
 			goto out;
 		}
-		if(checktag(p1, Tfile, qpath)){
+		if(checktag(p1, Tfile, d->qid.path)){
 			putbuf(p1);
 			error = Ephase;
 			goto out;
--- a/sys/src/cmd/cwfs/dentry.c
+++ b/sys/src/cmd/cwfs/dentry.c
@@ -255,7 +255,7 @@
 	Iobuf *pd;
 
 	pd = dnodebuf(ts->p, ts->d, ts->lastblk, Tfile, ts->uid);
-	if (pd == nil || checktag(pd, Tfile, QPNONE)) {
+	if (pd == nil || checktag(pd, Tfile, ts->d->qid.path)) {
 		if (pd != nil)
 			putbuf(pd);
 		ts->err = Ephase;
--