Skip to content

Commit

Permalink
[EROFS] Add a check for erofs
Browse files Browse the repository at this point in the history
Add an additional check to verify whether the host machine
truly supports the EROFS file system, and only mount it as
the EROFS file system if it is supported.

Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
  • Loading branch information
salvete committed Oct 8, 2024
1 parent 21384b9 commit 209f328
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/snapshot/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package snapshot

import (
"bytes"
"context"
"fmt"
"os"
Expand Down Expand Up @@ -1379,10 +1380,18 @@ func (o *snapshotter) blockPath(id string) string {
return filepath.Join(o.root, "snapshots", id, "block")
}

func IsErofsSupported() bool {
fs, err := os.ReadFile("/proc/filesystems")
if err != nil || !bytes.Contains(fs, []byte("\terofs\n")) {
return false
}
return true
}

func (o *snapshotter) turboOCIFsMeta(id string) (string, string) {
// TODO: make the priority order (multi-meta exists) configurable later if needed
erofsmeta := filepath.Join(o.root, "snapshots", id, "fs", "erofs.fs.meta")
if _, err := os.Stat(erofsmeta); err == nil {
if _, err := os.Stat(erofsmeta); err == nil && IsErofsSupported() {
return erofsmeta, "erofs"
}
return filepath.Join(o.root, "snapshots", id, "fs", "ext4.fs.meta"), "ext4"
Expand Down

0 comments on commit 209f328

Please sign in to comment.