Skip to content
Snippets Groups Projects
Commit 3e008d98 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

display contents as a graph. Remove init field

parent 30abc76e
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <oblibs/types.h> #include <oblibs/types.h>
#include <oblibs/string.h> #include <oblibs/string.h>
#include <oblibs/files.h> #include <oblibs/files.h>
#include <oblibs/stack.h>
#include <skalibs/sgetopt.h> #include <skalibs/sgetopt.h>
#include <skalibs/genalloc.h> #include <skalibs/genalloc.h>
...@@ -118,6 +119,10 @@ static void info_display_enabled(char const *field,char const *treename) ...@@ -118,6 +119,10 @@ static void info_display_enabled(char const *field,char const *treename)
static void info_display_init(char const *field,char const *treename) static void info_display_init(char const *field,char const *treename)
{ {
/* it not possible to write the resolve file of a tree at boot
if the filesystem is ro. So consider tree as never initiated.
ssexec_{start,stop,free,...} will deal with the live state of
the services anyway.
unsigned int init = tree_isinitialized(pinfo->base.s, treename) ; unsigned int init = tree_isinitialized(pinfo->base.s, treename) ;
if (init == -1) log_dieu(LOG_EXIT_SYS, "resolve file of tree: ", treename) ; if (init == -1) log_dieu(LOG_EXIT_SYS, "resolve file of tree: ", treename) ;
...@@ -128,6 +133,7 @@ static void info_display_init(char const *field,char const *treename) ...@@ -128,6 +133,7 @@ static void info_display_init(char const *field,char const *treename)
if (buffer_putsflush(buffer_1,"\n") == -1) if (buffer_putsflush(buffer_1,"\n") == -1)
log_dieusys(LOG_EXIT_SYS,"write to stdout") ; log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
*/
} }
static void info_display_allow(char const *field, char const *treename) static void info_display_allow(char const *field, char const *treename)
...@@ -346,14 +352,23 @@ static void info_display_contents(char const *field, char const *treename) ...@@ -346,14 +352,23 @@ static void info_display_contents(char const *field, char const *treename)
size_t padding = 1 ; size_t padding = 1 ;
graph_t graph = GRAPH_ZERO ; graph_t graph = GRAPH_ZERO ;
stralloc sa = STRALLOC_ZERO ;
unsigned int areslen = 0 ; unsigned int areslen = 0 ;
resolve_service_t ares[SS_MAX_SERVICE + 1] ; resolve_service_t ares[SS_MAX_SERVICE + 1] ;
memset(ares, 0, (SS_MAX_SERVICE + 1) * sizeof(resolve_service_t)) ;
if (NOFIELD) padding = info_display_field_name(field) ; if (NOFIELD) padding = info_display_field_name(field) ;
else { field = 0 ; padding = 0 ; } else { field = 0 ; padding = 0 ; }
graph_build_service(&graph, ares, &areslen, pinfo, STATE_FLAGS_TOPROPAGATE|STATE_FLAGS_WANTUP) ; if (!resolve_get_field_tosa_g(&sa, pinfo->base.s, treename, DATA_TREE, E_RESOLVE_TREE_CONTENTS))
log_dieu(LOG_EXIT_SYS, "get field contents of tree: ", treename) ;
if (!sa.len)
goto empty ;
service_graph_g(sa.s, sa.len, &graph, ares, &areslen, pinfo, STATE_FLAGS_TOPROPAGATE|STATE_FLAGS_WANTUP) ;
if (!areslen) if (!areslen)
goto empty ; goto empty ;
...@@ -365,21 +380,13 @@ static void info_display_contents(char const *field, char const *treename) ...@@ -365,21 +380,13 @@ static void info_display_contents(char const *field, char const *treename)
depth_t d = info_graph_init() ; depth_t d = info_graph_init() ;
if (!info_walk(&graph, 0, treename, &info_graph_display_service, 0, REVERSE, &d, padding, T_STYLE)) if (!info_walk(&graph, 0, 0, &info_graph_display_service, 0, REVERSE, &d, padding, T_STYLE))
log_dieu(LOG_EXIT_SYS,"display the graph dependencies") ; log_dieu(LOG_EXIT_SYS,"display the graph dependencies") ;
goto freed ; goto freed ;
} else { } else {
stralloc sa = STRALLOC_ZERO ;
if (!resolve_get_field_tosa_g(&sa, pinfo->base.s, treename, DATA_TREE, E_RESOLVE_TREE_CONTENTS))
log_dieu(LOG_EXIT_SYS, "get tree services list of: ", treename) ;
if (!sa.len)
goto empty ;
if (REVERSE) if (REVERSE)
if (!sastr_reverse(&sa)) if (!sastr_reverse(&sa))
log_dieu(LOG_EXIT_SYS,"reverse the dependencies list") ; log_dieu(LOG_EXIT_SYS,"reverse the dependencies list") ;
...@@ -407,6 +414,7 @@ static void info_display_contents(char const *field, char const *treename) ...@@ -407,6 +414,7 @@ static void info_display_contents(char const *field, char const *treename)
freed: freed:
graph_free_all(&graph) ; graph_free_all(&graph) ;
stralloc_free(&sa) ;
} }
static void info_display_all(char const *treename,int *what) static void info_display_all(char const *treename,int *what)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment