Usage
plash rm IMAGE_ID
Description
Deletes the given image atomically. Running containers based on that image
have an undefined behaviour.
Tested Behaviour
#!/bin/sh
set -xeu
• plash nodepath subcommand does not know deleted containers
newcont=$(plash build -f 1 --invalidate-layer)
plash nodepath $newcont
plash rm $newcont
(! plash nodepath $newcont)
• Specifying an unknown container errors
(! plash rm 9999999)
• Can be used together with the "b" subcommand
plash b rm -f 1 --run 'touch /plash-rm-test-file'
Source Code
#define USAGE "usage: plash rm IMAGE_ID\n"
#include <plash.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int rm_main(int argc, char *argv[]) {
if (argc != 2) {
fputs(USAGE, stderr);
return EXIT_FAILURE;
}
char *nodepath = pl_call("nodepath", argv[1]);
char *tmp = pl_call("mkdtemp");
pl_unshare_user();
if (rename(nodepath, tmp) == -1)
pl_fatal("rename %s %s", nodepath, tmp);
execlp("rm", "rm", "-rf", tmp, NULL);
pl_fatal("execlp");
return EXIT_SUCCESS;
}