mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix S/R support for fuse structs.
Add S/R support which was missing for a few structs in fuse, message queue and tun packages. PiperOrigin-RevId: 605139914
This commit is contained in:
committed by
gVisor bot
parent
506c6cb364
commit
1ebf17e9d9
@@ -91,6 +91,7 @@ const (
|
||||
// FUSEHeaderIn is the header read by the daemon with each request.
|
||||
//
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type FUSEHeaderIn struct {
|
||||
// Len specifies the total length of the data, including this header.
|
||||
Len uint32
|
||||
@@ -124,6 +125,7 @@ var SizeOfFUSEHeaderIn = uint32((*FUSEHeaderIn)(nil).SizeBytes())
|
||||
// reply; if they do not, this will be explicitly documented).
|
||||
//
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type FUSEHeaderOut struct {
|
||||
// Len specifies the total length of the data, including this header.
|
||||
Len uint32
|
||||
|
||||
@@ -45,6 +45,7 @@ go_library(
|
||||
"regular_file.go",
|
||||
"request_list.go",
|
||||
"request_response.go",
|
||||
"save_restore.go",
|
||||
],
|
||||
marshal = True,
|
||||
visibility = ["//pkg/sentry:internal"],
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/usermem"
|
||||
)
|
||||
|
||||
// +stateify savable
|
||||
type directoryFD struct {
|
||||
fileDescription
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import (
|
||||
)
|
||||
|
||||
// fileDescription implements vfs.FileDescriptionImpl for fuse.
|
||||
//
|
||||
// +stateify savable
|
||||
type fileDescription struct {
|
||||
vfsfd vfs.FileDescription
|
||||
vfs.FileDescriptionDefaultImpl
|
||||
|
||||
@@ -75,7 +75,7 @@ type inode struct {
|
||||
watches vfs.Watches
|
||||
|
||||
// attrMu protects the attributes of this inode.
|
||||
attrMu sync.Mutex
|
||||
attrMu sync.Mutex `state:"nosave"`
|
||||
|
||||
// +checklocks:attrMu
|
||||
ino atomicbitops.Uint64 // Stat data, not accessed for path walking.
|
||||
|
||||
@@ -30,11 +30,12 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/usermem"
|
||||
)
|
||||
|
||||
// +stateify savable
|
||||
type regularFileFD struct {
|
||||
fileDescription
|
||||
|
||||
// offMu protects off.
|
||||
offMu sync.Mutex
|
||||
offMu sync.Mutex `state:"nosave"`
|
||||
|
||||
// off is the file offset.
|
||||
// +checklocks:offMu
|
||||
|
||||
@@ -137,7 +137,7 @@ func (conn *connection) NewRequest(creds *auth.Credentials, pid uint32, ino uint
|
||||
// +stateify savable
|
||||
type futureResponse struct {
|
||||
opcode linux.FUSEOpcode
|
||||
ch chan struct{}
|
||||
ch chan struct{} `state:"nosave"`
|
||||
hdr *linux.FUSEHeaderOut
|
||||
data []byte
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright 2024 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package fuse
|
||||
|
||||
func (fRes *futureResponse) afterLoad() {
|
||||
fRes.ch = make(chan struct{})
|
||||
}
|
||||
@@ -308,6 +308,8 @@ type View interface {
|
||||
}
|
||||
|
||||
// ReaderWriter provides a send and receive view into a queue.
|
||||
//
|
||||
// +stateify savable
|
||||
type ReaderWriter struct {
|
||||
*Queue
|
||||
|
||||
@@ -315,6 +317,8 @@ type ReaderWriter struct {
|
||||
}
|
||||
|
||||
// Reader provides a send-only view into a queue.
|
||||
//
|
||||
// +stateify savable
|
||||
type Reader struct {
|
||||
*Queue
|
||||
|
||||
@@ -322,6 +326,8 @@ type Reader struct {
|
||||
}
|
||||
|
||||
// Writer provides a receive-only view into a queue.
|
||||
//
|
||||
// +stateify savable
|
||||
type Writer struct {
|
||||
*Queue
|
||||
|
||||
|
||||
@@ -53,6 +53,8 @@ type Device struct {
|
||||
}
|
||||
|
||||
// Flags set properties of a Device
|
||||
//
|
||||
// +stateify savable
|
||||
type Flags struct {
|
||||
TUN bool
|
||||
TAP bool
|
||||
|
||||
@@ -76,6 +76,9 @@ func (r *restorer) restore(l *Loader) error {
|
||||
return fmt.Errorf("creating platform: %v", err)
|
||||
}
|
||||
|
||||
// Start the old watchdog before replacing it with a new one below.
|
||||
l.watchdog.Start()
|
||||
|
||||
// Release the kernel and replace it with a new one that will be restored into.
|
||||
if l.k != nil {
|
||||
l.k.Release()
|
||||
|
||||
Reference in New Issue
Block a user