-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: decouple verity from filesystem interfaces
We are going to support multiple underlying filesystems (squash, erofs and maybe more). As long as they are filesystem image blobs, verity data can be appended. Signed-off-by: Ramkumar Chinchani <[email protected]>
- Loading branch information
Showing
23 changed files
with
195 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package common | ||
|
||
import "os" | ||
|
||
func FileChanged(a os.FileInfo, path string) bool { | ||
b, err := os.Lstat(path) | ||
if err != nil { | ||
return true | ||
} | ||
return !os.SameFile(a, b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package erofs | ||
|
||
import ( | ||
"io" | ||
|
||
"machinerun.io/atomfs/verity" | ||
) | ||
|
||
type erofs struct { | ||
} | ||
|
||
func New() *erofs { | ||
return &erofs{} | ||
} | ||
|
||
func (fs *erofs) Make(tempdir string, rootfs string, eps *ExcludePaths, verity verity.VerityMetadata) (io.ReadCloser, string, string, error) { | ||
} | ||
|
||
// Mount a filesystem as container root, without host root privileges. | ||
func (fs *erofs) GuestMount(fsFile string, mountpoint string) error { | ||
return nil | ||
} | ||
|
||
func (fs *erofs) Mount(fsFile, mountpoint, rootHash string) error { | ||
return nil | ||
} | ||
|
||
func (fs *erofs) HostMount(fsFile string, mountpoint string, rootHash string) error { | ||
return nil | ||
} | ||
|
||
func (fs *erofs) Umount(mountpoint string) error { | ||
return nil | ||
} | ||
|
||
func (fs *erofs) VerityDataLocation() uint64 { | ||
return 0 | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package fs | ||
|
||
import ( | ||
"machinerun.io/atomfs/pkg/erofs" | ||
"machinerun.io/atomfs/pkg/squashfs" | ||
"machinerun.io/atomfs/pkg/types" | ||
) | ||
|
||
// New creates a filesystem instance. | ||
func New(fsType types.FilesystemType) types.Filesystem { | ||
switch fsType { | ||
case types.Squashfs: | ||
return squashfs.New() | ||
case types.Erofs: | ||
return erofs.New() | ||
default: | ||
return nil | ||
} | ||
} | ||
|
||
// NewFromMediaType creates a filesystem instance based on media-type. | ||
func NewFromMediaType(mediaType string) types.Filesystem { | ||
if squashfs.IsSquashfsMediaType(mediaType) { | ||
return New(types.Squashfs) | ||
} else if erofs.IsErofsMediaType(mediaType) { | ||
return New(types.Erofs) | ||
} | ||
|
||
return nil | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package squashfs | ||
|
||
import ( | ||
"io" | ||
|
||
"machinerun.io/atomfs/verity" | ||
) | ||
|
||
type squashfs struct { | ||
} | ||
|
||
func New() *squashfs { | ||
return &squashfs{} | ||
} | ||
|
||
func (fs *squashfs) Make(tempdir string, rootfs string, eps *ExcludePaths, verity verity.VerityMetadata) (io.ReadCloser, string, string, error) { | ||
} | ||
|
||
// Mount a filesystem as container root, without host root privileges. | ||
func (fs *squashfs) GuestMount(fsFile string, mountpoint string) error { | ||
return nil | ||
} | ||
|
||
func (fs *squashfs) Mount(fsFile, mountpoint, rootHash string) error { | ||
return nil | ||
} | ||
|
||
func (fs *squashfs) HostMount(fsFile string, mountpoint string, rootHash string) error { | ||
return nil | ||
} | ||
|
||
func (fs *squashfs) Umount(mountpoint string) error { | ||
return nil | ||
} | ||
|
||
func (fs *squashfs) VerityDataLocation() uint64 { | ||
return 0 | ||
} | ||
|
||
func (fs *squashfs) ExtractSingle(fsFile string, extractDir string) error { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package types | ||
|
||
import ( | ||
"io" | ||
|
||
"machinerun.io/atomfs/verity" | ||
) | ||
|
||
type Filesystem interface { | ||
// Make a filesystem image. | ||
Make(tempdir string, rootfs string, eps *ExcludePaths, verity verity.VerityMetadata) (io.ReadCloser, string, string, error) | ||
|
||
// Mount a filesystem as container root, without host root privileges. | ||
GuestMount(fsFile string, mountpoint string) error | ||
|
||
Mount(fs, mountpoint, rootHash string) error | ||
|
||
HostMount(fs string, mountpoint string, rootHash string) error | ||
|
||
Umount(mountpoint string) error | ||
|
||
VerityDataLocation() uint64 | ||
|
||
ExtractSingle(fsFile string, extractDir string) error | ||
} | ||
|
||
type FilesystemType string | ||
|
||
const ( | ||
Squashfs FilesystemType = "squashfs" | ||
Erofs FilesystemType = "erofs" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package verity | ||
|
||
type VerityMetadata bool | ||
|
||
const ( | ||
VeritySuffix = "verity" | ||
|
||
VerityMetadataPresent VerityMetadata = true | ||
VerityMetadataMissing VerityMetadata = false | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters