summaryrefslogtreecommitdiffhomepage
path: root/pkg/abi
diff options
context:
space:
mode:
authorBoyuan He <heboyuan@google.com>2020-08-18 21:51:06 +0000
committerAndrei Vagin <avagin@gmail.com>2020-09-16 12:19:30 -0700
commitb53e10f391929e4ad9345a823a0cf33bcfedf413 (patch)
treeda11060ea42ce01cd3e3611e2eb5087c7e2743b1 /pkg/abi
parent947088e10a15b5236f2af3206f67f27245ef2770 (diff)
Implement FUSE_MKNOD
Fixes #3492
Diffstat (limited to 'pkg/abi')
-rw-r--r--pkg/abi/linux/fuse.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/pkg/abi/linux/fuse.go b/pkg/abi/linux/fuse.go
index a1b2a2abf..97d960096 100644
--- a/pkg/abi/linux/fuse.go
+++ b/pkg/abi/linux/fuse.go
@@ -413,3 +413,46 @@ type FUSEReleaseIn struct {
// LockOwner is the id of the lock owner if there is one.
LockOwner uint64
}
+
+// FUSEMknodMeta contains all the static fields of FUSEMknodIn,
+// which is used for FUSE_MKNOD.
+//
+// +marshal
+type FUSEMknodMeta struct {
+ // Mode of the inode to create.
+ Mode uint32
+
+ // Rdev encodes device major and minor information.
+ Rdev uint32
+
+ // Umask is the current file mode creation mask.
+ Umask uint32
+
+ _ uint32
+}
+
+// FUSEMknodIn contains all the arguments sent by the kernel
+// to the daemon, to create a new file node.
+//
+// Dynamically-sized objects cannot be marshalled.
+type FUSEMknodIn struct {
+ marshal.StubMarshallable
+
+ // MknodMeta contains mode, rdev and umash field for FUSE_MKNODS.
+ MknodMeta FUSEMknodMeta
+
+ // Name is the name of the node to create.
+ Name string
+}
+
+// MarshalUnsafe serializes r.MknodMeta and r.Name to the dst buffer.
+func (r *FUSEMknodIn) MarshalUnsafe(buf []byte) {
+ r.MknodMeta.MarshalUnsafe(buf[:r.MknodMeta.SizeBytes()])
+ copy(buf[r.MknodMeta.SizeBytes():], r.Name)
+}
+
+// SizeBytes is the size of the memory representation of FUSEMknodIn.
+// 1 extra byte for null-terminated string.
+func (r *FUSEMknodIn) SizeBytes() int {
+ return r.MknodMeta.SizeBytes() + len(r.Name) + 1
+}