Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

ch-run: run oci bundles #1870

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Contributors:

* Richard Berger <[email protected]>
* Lucas Caudill <[email protected]>
* Krishna Chilleri <[email protected]>
* Rusty Davis <[email protected]>
* Hunter Easterday <[email protected]>
* Oliver Freyermuth <[email protected]>
Expand Down
6 changes: 6 additions & 0 deletions bin/ch-run.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ int main(int argc, char *argv[])
case IMG_NONE:
kchilleri marked this conversation as resolved.
Show resolved Hide resolved
FATAL("unknown image type: %s", args.c.img_ref);
break;
case OCI_BUNDLE:
if (args.c.newroot != NULL) // --mount was set
WARNING("--mount invalid with directory image, ignoring");
args.c.newroot = realpath_(cat(args.c.img_ref, "/rootfs"), false);
img_directory_verify(args.c.newroot, &args);
kchilleri marked this conversation as resolved.
Show resolved Hide resolved
break;
}

if (args.c.join) {
Expand Down
13 changes: 11 additions & 2 deletions bin/ch_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ enum img_type image_type(const char *ref, const char *storage_dir)
struct stat st;
FILE *fp;
char magic[4]; // four bytes, not a string
char *conff = cat(ref, "/config.json");
char *rootfs = cat(ref, "/rootfs");
kchilleri marked this conversation as resolved.
Show resolved Hide resolved

// If there’s a directory in storage where we would expect there to be if
// ref were an image name, assume it really is an image name.
Expand All @@ -380,8 +382,15 @@ enum img_type image_type(const char *ref, const char *storage_dir)
Zf (stat(ref, &st), "can't stat: %s", ref);

// If ref is the path to a directory, then it’s a directory.
if (S_ISDIR(st.st_mode))
return IMG_DIRECTORY;
// If ref is the path to a directory that contains rootfs directory
// and config.json file, assume it is an oci bundle
kchilleri marked this conversation as resolved.
Show resolved Hide resolved
if (S_ISDIR(st.st_mode)) {
if (path_exists(rootfs, NULL, true) && path_exists(conff, NULL, true)) {
return OCI_BUNDLE;
} else {
return IMG_DIRECTORY;
}
}

// Now we know it’s file-like enough to read. See if it has the SquashFS
// magic number.
Expand Down
1 change: 1 addition & 0 deletions bin/ch_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum img_type {
IMG_SQUASH, // SquashFS archive file (not yet mounted)
IMG_NAME, // name of image in storage
IMG_NONE, // image type is not set yet
OCI_BUNDLE, // contains rootfs img_directory and config.json file
kchilleri marked this conversation as resolved.
Show resolved Hide resolved
};

struct container {
Expand Down
Loading