Skip to content

Commit

Permalink
Merge pull request #9308 from btw616:erofs-initial-support
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 571416660
  • Loading branch information
gvisor-bot committed Oct 6, 2023
2 parents 07b9077 + 2f01e3f commit f2f99b5
Show file tree
Hide file tree
Showing 19 changed files with 2,578 additions and 5 deletions.
2 changes: 1 addition & 1 deletion images/default/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get update && apt-get install -y curl gnupg2 git \
apt-transport-https ca-certificates gnupg-agent \
software-properties-common \
pkg-config libffi-dev patch diffutils libssl-dev iptables kmod \
clang crossbuild-essential-amd64
clang crossbuild-essential-amd64 erofs-utils

# Install Docker client for the website build.
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
Expand Down
34 changes: 34 additions & 0 deletions pkg/abi/linux/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,40 @@ var DirentType = abi.ValueSet{
DT_WHT: "DT_WHT",
}

// Values for fs on-disk file types.
const (
FT_UNKNOWN = 0
FT_REG_FILE = 1
FT_DIR = 2
FT_CHRDEV = 3
FT_BLKDEV = 4
FT_FIFO = 5
FT_SOCK = 6
FT_SYMLINK = 7
FT_MAX = 8
)

// Conversion from fs on-disk file type to dirent type.
var direntTypeByFileType = [FT_MAX]uint8{
FT_UNKNOWN: DT_UNKNOWN,
FT_REG_FILE: DT_REG,
FT_DIR: DT_DIR,
FT_CHRDEV: DT_CHR,
FT_BLKDEV: DT_BLK,
FT_FIFO: DT_FIFO,
FT_SOCK: DT_SOCK,
FT_SYMLINK: DT_LNK,
}

// FileTypeToDirentType converts the on-disk file type (FT_*) to the directory
// entry type (DT_*).
func FileTypeToDirentType(filetype uint8) uint8 {
if filetype >= FT_MAX {
return DT_UNKNOWN
}
return direntTypeByFileType[filetype]
}

// Values for preadv2/pwritev2.
const (
// NOTE(b/120162627): gVisor does not implement the RWF_HIPRI feature, but
Expand Down
31 changes: 31 additions & 0 deletions pkg/erofs/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("//tools:defs.bzl", "go_library", "go_test")

package(
default_applicable_licenses = ["//:license"],
licenses = ["notice"],
)

go_library(
name = "erofs",
srcs = ["erofs.go"],
marshal = True,
visibility = ["//visibility:public"],
deps = [
"//pkg/abi/linux",
"//pkg/cleanup",
"//pkg/errors/linuxerr",
"//pkg/hostarch",
"//pkg/log",
"//pkg/marshal",
"//pkg/marshal/primitive",
"//pkg/safemem",
"@org_golang_x_sys//unix:go_default_library",
],
)

go_test(
name = "erofs_test",
size = "small",
srcs = ["erofs_test.go"],
library = ":erofs",
)
Loading

0 comments on commit f2f99b5

Please sign in to comment.