Skip to content

Commit a0492e7

Browse files
author
Hongzhen Luo
committed
[EROFS] Add a check for erofs
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>
1 parent 0ec659d commit a0492e7

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)