From 2ca82a55f0c8f22f0c136e66b31354c8af9e2f2a Mon Sep 17 00:00:00 2001 From: Fabian Date: Tue, 23 Apr 2024 22:25:27 +0900 Subject: [PATCH] 9pfs: set S_IFREG for regular files (fix Invalid argument on linux 6.6+, fix #996) --- lib/9p.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/9p.js b/lib/9p.js index a0a67caa7f..cb70888e3a 100644 --- a/lib/9p.js +++ b/lib/9p.js @@ -363,6 +363,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) { var idx = this.fs.CreateNode(name, this.fids[fid].inodeid, major, minor); var inode = this.fs.GetInode(idx); inode.mode = mode; + //inode.mode = mode | S_IFCHR; // XXX: fails "Mknod - fifo" test inode.uid = this.fids[fid].uid; inode.gid = gid; marshall.Marshall(["Q"], [inode.qid], this.replybuffer, 7); @@ -415,7 +416,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) { var inode = this.fs.GetInode(idx); inode.uid = this.fids[fid].uid; inode.gid = gid; - inode.mode = mode; + inode.mode = mode | S_IFREG; marshall.Marshall(["Q", "w"], [inode.qid, this.msize - 24], this.replybuffer, 7); this.BuildReply(id, tag, 13+4); this.SendReply(bufchain); @@ -529,6 +530,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) { var inode = this.fs.GetInode(this.fids[fid].inodeid); message.Debug("[setattr]: fid=" + fid + " request mask=" + req[1] + " name=" + this.fids[fid].dbg_name); if (req[1] & P9_SETATTR_MODE) { + // XXX: check mode (S_IFREG or S_IFDIR or similar should be set) inode.mode = req[2]; } if (req[1] & P9_SETATTR_UID) {