Skip to content

Commit b0d0b08

Browse files
authored
dissect: minor additions to the systemd-dissect tool (systemd#35829)
2 parents b6507d8 + bd2fd85 commit b0d0b08

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

man/systemd-dissect.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,15 @@
514514
<xi:include href="version-info.xml" xpointer="v258"/></listitem>
515515
</varlistentry>
516516

517+
<varlistentry>
518+
<term><option>--all</option></term>
519+
520+
<listitem><para>If combined with <option>--discover</option>, also shows images that start with a
521+
dot, i.e. hidden images.</para>
522+
523+
<xi:include href="version-info.xml" xpointer="v258"/></listitem>
524+
</varlistentry>
525+
517526
<xi:include href="standard-options.xml" xpointer="image-policy-open" />
518527
<xi:include href="standard-options.xml" xpointer="no-pager" />
519528
<xi:include href="standard-options.xml" xpointer="no-legend" />

src/dissect/dissect.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static ImagePolicy *arg_image_policy = NULL;
9696
static bool arg_mtree_hash = true;
9797
static bool arg_via_service = false;
9898
static RuntimeScope arg_runtime_scope = _RUNTIME_SCOPE_INVALID;
99+
static bool arg_all = false;
99100

100101
STATIC_DESTRUCTOR_REGISTER(arg_image, freep);
101102
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
@@ -154,6 +155,7 @@ static int help(void) {
154155
" --mtree-hash=BOOL Whether to include SHA256 hash in the mtree output\n"
155156
" --user Discover user images\n"
156157
" --system Discover system images\n"
158+
" --all Show hidden images too\n"
157159
"\n%3$sCommands:%4$s\n"
158160
" -h --help Show this help\n"
159161
" --version Show package version\n"
@@ -279,6 +281,7 @@ static int parse_argv(int argc, char *argv[]) {
279281
ARG_MAKE_ARCHIVE,
280282
ARG_SYSTEM,
281283
ARG_USER,
284+
ARG_ALL,
282285
};
283286

284287
static const struct option options[] = {
@@ -314,6 +317,7 @@ static int parse_argv(int argc, char *argv[]) {
314317
{ "make-archive", no_argument, NULL, ARG_MAKE_ARCHIVE },
315318
{ "system", no_argument, NULL, ARG_SYSTEM },
316319
{ "user", no_argument, NULL, ARG_USER },
320+
{ "all", no_argument, NULL, ARG_ALL },
317321
{}
318322
};
319323

@@ -554,6 +558,10 @@ static int parse_argv(int argc, char *argv[]) {
554558
user_scope_requested = true;
555559
break;
556560

561+
case ARG_ALL:
562+
arg_all = true;
563+
break;
564+
557565
case '?':
558566
return -EINVAL;
559567

@@ -1889,18 +1897,21 @@ static int action_discover(void) {
18891897

18901898
HASHMAP_FOREACH(img, images) {
18911899

1892-
if (!IN_SET(img->type, IMAGE_RAW, IMAGE_BLOCK))
1900+
if (!arg_all && startswith(img->name, "."))
18931901
continue;
18941902

18951903
r = table_add_many(
18961904
t,
18971905
TABLE_STRING, img->name,
1906+
TABLE_SET_COLOR, startswith(img->name, ".") ? ANSI_GREY : NULL,
18981907
TABLE_STRING, image_type_to_string(img->type),
18991908
TABLE_STRING, image_class_to_string(img->class),
19001909
TABLE_BOOLEAN, img->read_only,
1910+
TABLE_SET_COLOR, !img->read_only ? ANSI_HIGHLIGHT_GREEN : ANSI_HIGHLIGHT_RED,
19011911
TABLE_PATH, img->path,
19021912
TABLE_TIMESTAMP, img->mtime != 0 ? img->mtime : img->crtime,
1903-
TABLE_SIZE, img->usage);
1913+
TABLE_SIZE, img->usage,
1914+
TABLE_SET_COLOR, img->usage <= 0 ? ANSI_HIGHLIGHT_RED : NULL);
19041915
if (r < 0)
19051916
return table_log_add_error(r);
19061917
}
@@ -2055,6 +2066,16 @@ static int run(int argc, char *argv[]) {
20552066
return r;
20562067
}
20572068

2069+
if (arg_root) {
2070+
r = path_pick_update_warn(
2071+
&arg_root,
2072+
&pick_filter_image_dir,
2073+
PICK_ARCHITECTURE|PICK_TRIES,
2074+
/* ret_result= */ NULL);
2075+
if (r < 0)
2076+
return r;
2077+
}
2078+
20582079
switch (arg_action) {
20592080
case ACTION_UMOUNT:
20602081
return action_umount(arg_path);

0 commit comments

Comments
 (0)