Skip to content

Commit de480b5

Browse files
ayushr2gvisor-bot
authored andcommitted
Allow lisafs server to open on deleted files in runsc gofer.
Updates the lisafs server to provide an option for allowing opening files which have been deleted in the filesystem. This is needed for save/restore of deleted files which don't have a readable handle open for them and a readable handle needs to be opened to read the contents of the file, which needs to be saved. Updates #11903 PiperOrigin-RevId: 784249243
1 parent 728dc48 commit de480b5

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

pkg/lisafs/handlers.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,10 @@ func OpenAtHandler(c *Connection, comm Communicator, payloadLen uint32) (uint32,
527527
hostOpenFD int
528528
)
529529
if err := fd.safelyRead(func() error {
530-
if fd.node.isDeleted() || fd.IsSymlink() {
530+
if fd.node.isDeleted() && !c.server.opts.OpenOnDeleted {
531+
return unix.EINVAL
532+
}
533+
if fd.IsSymlink() {
531534
return unix.EINVAL
532535
}
533536
openFD, hostOpenFD, err = fd.impl.Open(req.Flags)

pkg/lisafs/server.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ type ServerOpts struct {
6262
// AllocateOnDeleted is set to true if it's safe to call OpenFDImpl.Allocate
6363
// for deleted files.
6464
AllocateOnDeleted bool
65+
66+
// OpenOnDeleted is set to true if it's safe to call ControlFDImpl.Open for
67+
// deleted files.
68+
OpenOnDeleted bool
6569
}
6670

6771
// Init must be called before first use of the server.

runsc/fsgofer/lisafs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ func NewLisafsServer(config Config) *LisafsServer {
107107
WalkStatSupported: true,
108108
SetAttrOnDeleted: true,
109109
AllocateOnDeleted: true,
110+
OpenOnDeleted: true,
110111
})
111112
return s
112113
}

0 commit comments

Comments
 (0)