github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/sentry/fs/host/host.go (about) 1 // Copyright 2020 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package host supports file descriptors imported directly. 16 package host 17 18 import ( 19 "github.com/SagerNet/gvisor/pkg/context" 20 "github.com/SagerNet/gvisor/pkg/errors/linuxerr" 21 "github.com/SagerNet/gvisor/pkg/sentry/fs" 22 ) 23 24 // filesystem is a host filesystem. 25 // 26 // +stateify savable 27 type filesystem struct{} 28 29 func init() { 30 fs.RegisterFilesystem(&filesystem{}) 31 } 32 33 // FilesystemName is the name under which the filesystem is registered. 34 const FilesystemName = "host" 35 36 // Name is the name of the filesystem. 37 func (*filesystem) Name() string { 38 return FilesystemName 39 } 40 41 // Mount returns an error. Mounting hostfs is not allowed. 42 func (*filesystem) Mount(ctx context.Context, device string, flags fs.MountSourceFlags, data string, dataObj interface{}) (*fs.Inode, error) { 43 return nil, linuxerr.EPERM 44 } 45 46 // AllowUserMount prohibits users from using mount(2) with this file system. 47 func (*filesystem) AllowUserMount() bool { 48 return false 49 } 50 51 // AllowUserList prohibits this filesystem to be listed in /proc/filesystems. 52 func (*filesystem) AllowUserList() bool { 53 return false 54 } 55 56 // Flags returns that there is nothing special about this file system. 57 func (*filesystem) Flags() fs.FilesystemFlags { 58 return 0 59 }