Fork me on GitHub

plash parent


Usage

plash parent IMAGE_ID

Description

Prints the containers parent container.

Example

$ plash parent 89
88

Tested Behaviour

#!/bin/sh
set -eux

• basic tests

plash build -f 1 --invalidate-layer
test $(plash parent 2) = 1
test $(plash parent 1) = 0
(! $(plash parent 0))

Source Code


#define USAGE "usage: plash parent IMAGE_ID\n"

#include <libgen.h>
#include <plash.h>
#include <stdio.h>
#include <stdlib.h>

int parent_main(int argc, char *argv[]) {
  if (argc != 2) {
    fputs(USAGE, stderr);
    return EXIT_FAILURE;
  }
  char *nodepath = pl_call("nodepath", argv[1]);
  puts(basename(dirname(nodepath)));
  return EXIT_SUCCESS;
}