@@ -24,6 +24,8 @@ struct flb_ne *flb_ne_config_create(struct flb_input_instance *ins,
2424 struct flb_config * config )
2525{
2626 int ret ;
27+ int root_len ;
28+ flb_sds_t tmp ;
2729 struct flb_ne * ctx ;
2830
2931 ctx = flb_calloc (1 , sizeof (struct flb_ne ));
@@ -41,6 +43,59 @@ struct flb_ne *flb_ne_config_create(struct flb_input_instance *ins,
4143 }
4244
4345 /* mount points */
46+ flb_plg_info (ins , "path.rootfs = %s" , ctx -> path_rootfs );
47+
48+ if (ctx -> path_rootfs && strcmp (ctx -> path_rootfs , "/" ) != 0 ) {
49+ root_len = strlen (ctx -> path_rootfs );
50+ if (root_len > 1 && ctx -> path_rootfs [root_len - 1 ] == '/' ) {
51+ root_len -- ;
52+ }
53+
54+ /* Compose procfs path */
55+ tmp = flb_sds_create_size (1024 );
56+ if (tmp ) {
57+ if (ctx -> path_procfs [0 ] == '/' ) {
58+ tmp = flb_sds_printf (& tmp , "%.*s%s" , root_len , ctx -> path_rootfs , ctx -> path_procfs );
59+ }
60+ else {
61+ tmp = flb_sds_printf (& tmp , "%.*s/%s" , root_len , ctx -> path_rootfs , ctx -> path_procfs );
62+ }
63+ if (tmp ) {
64+ ctx -> path_procfs = tmp ;
65+ }
66+ }
67+
68+ /* Compose sysfs path */
69+ tmp = flb_sds_create_size (1024 );
70+ if (tmp ) {
71+ if (ctx -> path_sysfs [0 ] == '/' ) {
72+ tmp = flb_sds_printf (& tmp , "%.*s%s" , root_len , ctx -> path_rootfs , ctx -> path_sysfs );
73+ }
74+ else {
75+ tmp = flb_sds_printf (& tmp , "%.*s/%s" , root_len , ctx -> path_rootfs , ctx -> path_sysfs );
76+ }
77+ if (tmp ) {
78+ ctx -> path_sysfs = tmp ;
79+ }
80+ }
81+
82+ /* Compose textfile path if any */
83+ if (ctx -> path_textfile ) {
84+ tmp = flb_sds_create_size (1024 );
85+ if (tmp ) {
86+ if (ctx -> path_textfile [0 ] == '/' ) {
87+ tmp = flb_sds_printf (& tmp , "%.*s%s" , root_len , ctx -> path_rootfs , ctx -> path_textfile );
88+ }
89+ else {
90+ tmp = flb_sds_printf (& tmp , "%.*s/%s" , root_len , ctx -> path_rootfs , ctx -> path_textfile );
91+ }
92+ if (tmp ) {
93+ ctx -> path_textfile = tmp ;
94+ }
95+ }
96+ }
97+ }
98+
4499 flb_plg_info (ins , "path.procfs = %s" , ctx -> path_procfs );
45100 flb_plg_info (ins , "path.sysfs = %s" , ctx -> path_sysfs );
46101
0 commit comments