Skip to content

Commit db1d6fc

Browse files
authored
Merge pull request #306 from salvete/main
[EROFS] Add a check for erofs
2 parents 0ec659d + a0492e7 commit db1d6fc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/snapshot/overlay.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package snapshot
1818

1919
import (
20+
"bytes"
2021
"context"
2122
"fmt"
2223
"os"
@@ -1379,10 +1380,18 @@ func (o *snapshotter) blockPath(id string) string {
13791380
return filepath.Join(o.root, "snapshots", id, "block")
13801381
}
13811382

1383+
func IsErofsSupported() bool {
1384+
fs, err := os.ReadFile("/proc/filesystems")
1385+
if err != nil || !bytes.Contains(fs, []byte("\terofs\n")) {
1386+
return false
1387+
}
1388+
return true
1389+
}
1390+
13821391
func (o *snapshotter) turboOCIFsMeta(id string) (string, string) {
13831392
// TODO: make the priority order (multi-meta exists) configurable later if needed
13841393
erofsmeta := filepath.Join(o.root, "snapshots", id, "fs", "erofs.fs.meta")
1385-
if _, err := os.Stat(erofsmeta); err == nil {
1394+
if _, err := os.Stat(erofsmeta); err == nil && IsErofsSupported() {
13861395
return erofsmeta, "erofs"
13871396
}
13881397
return filepath.Join(o.root, "snapshots", id, "fs", "ext4.fs.meta"), "ext4"

0 commit comments

Comments
 (0)