@@ -363,4 +363,121 @@ void avs_config_local_fs_path_dev_nvram_and_raw_set(
363363 property_util_node_str_replace (
364364 NULL , fs_node , "raw/option" , "vf=1,posix=1" );
365365 }
366+ }
367+
368+ void avs_config_vfs_mounttable_get (struct property_node * node , struct avs_config_vfs_mounttable * mounttable )
369+ {
370+ struct property_node * fs_node ;
371+ struct property_node * mounttable_node ;
372+ struct property_node * cur ;
373+ uint8_t pos ;
374+
375+ log_assert (node );
376+ log_assert (mounttable );
377+
378+ fs_node = property_search (NULL , node , "fs" );
379+
380+ if (!fs_node ) {
381+ log_fatal ("Cannot find 'fs' node in avs config" );
382+ }
383+
384+ // Check if "new" mounttable config is used for dev/nvram and dev/raw or
385+ // legacy config
386+ mounttable_node = property_search (NULL , fs_node , "mounttable" );
387+
388+ memset (mounttable , 0 , sizeof (* mounttable ));
389+ pos = 0 ;
390+
391+ property_util_node_log (mounttable_node );
392+
393+ if (mounttable_node ) {
394+ cur = property_search (NULL , mounttable_node , "vfs" );
395+
396+ while (cur ) {
397+ if (pos >= AVS_CONFIG_MOUNTTABLE_MAX_ENTRIES ) {
398+ log_warning ("Exceeding max number of supported mounttable entries (%d), ignoring remaining" , pos );
399+ break ;
400+
401+ }
402+
403+ if (AVS_IS_ERROR (property_node_refer (NULL , cur , "name@" , PROPERTY_TYPE_ATTR ,
404+ mounttable -> entry [pos ].name , sizeof (mounttable -> entry [pos ].name )))) {
405+ // optional
406+ }
407+
408+ if (AVS_IS_ERROR (property_node_refer (NULL , cur , "fstype@" , PROPERTY_TYPE_ATTR ,
409+ mounttable -> entry [pos ].fstype , sizeof (mounttable -> entry [pos ].fstype )))) {
410+ // default
411+ str_cpy (mounttable -> entry [pos ].fstype , sizeof (mounttable -> entry [pos ].fstype ), "fs" );
412+ }
413+
414+ if (AVS_IS_ERROR (property_node_refer (NULL , cur , "src@" , PROPERTY_TYPE_ATTR ,
415+ mounttable -> entry [pos ].src , sizeof (mounttable -> entry [pos ].src )))) {
416+ log_fatal ("Missing 'src' attribute on vfs node, name: %s" , mounttable -> entry [pos ].name );
417+ }
418+
419+ if (AVS_IS_ERROR (property_node_refer (NULL , cur , "dst@" , PROPERTY_TYPE_ATTR ,
420+ mounttable -> entry [pos ].dst , sizeof (mounttable -> entry [pos ].dst )))) {
421+ log_fatal ("Missing 'dst' attribute on vfs node, name: %s" , mounttable -> entry [pos ].name );
422+ }
423+
424+ if (AVS_IS_ERROR (property_node_refer (NULL , cur , "opt@" , PROPERTY_TYPE_ATTR ,
425+ mounttable -> entry [pos ].opt , sizeof (mounttable -> entry [pos ].opt )))) {
426+ // optional
427+ }
428+
429+ cur = property_node_traversal (cur , TRAVERSE_NEXT_SEARCH_RESULT );
430+ pos ++ ;
431+ }
432+ } else {
433+ cur = property_search (NULL , node , "nvram" );
434+
435+ if (cur ) {
436+ str_cpy (mounttable -> entry [pos ].name , sizeof (mounttable -> entry [pos ].name ), "nvram" );
437+
438+ if (AVS_IS_ERROR (property_node_refer (NULL , cur , "fstype" , PROPERTY_TYPE_STR ,
439+ mounttable -> entry [pos ].fstype , sizeof (mounttable -> entry [pos ].fstype )))) {
440+ // default
441+ str_cpy (mounttable -> entry [pos ].fstype , sizeof (mounttable -> entry [pos ].fstype ), "fs" );
442+ }
443+
444+ if (AVS_IS_ERROR (property_node_refer (NULL , cur , "device" , PROPERTY_TYPE_STR ,
445+ mounttable -> entry [pos ].src , sizeof (mounttable -> entry [pos ].src )))) {
446+ log_fatal ("Missing 'device' attribute on nvram node" );
447+ }
448+
449+ str_cpy (mounttable -> entry [pos ].dst , sizeof (mounttable -> entry [pos ].dst ), "/dev/nvram" );
450+
451+ if (AVS_IS_ERROR (property_node_refer (NULL , cur , "opt" , PROPERTY_TYPE_STR ,
452+ mounttable -> entry [pos ].opt , sizeof (mounttable -> entry [pos ].opt )))) {
453+ // optional
454+ }
455+ }
456+
457+ cur = property_search (NULL , node , "raw" );
458+
459+ if (cur ) {
460+ str_cpy (mounttable -> entry [pos ].name , sizeof (mounttable -> entry [pos ].name ), "raw" );
461+
462+ if (AVS_IS_ERROR (property_node_refer (NULL , cur , "fstype" , PROPERTY_TYPE_STR ,
463+ mounttable -> entry [pos ].fstype , sizeof (mounttable -> entry [pos ].fstype )))) {
464+ // default
465+ str_cpy (mounttable -> entry [pos ].fstype , sizeof (mounttable -> entry [pos ].fstype ), "fs" );
466+ }
467+
468+ if (AVS_IS_ERROR (property_node_refer (NULL , cur , "device" , PROPERTY_TYPE_STR ,
469+ mounttable -> entry [pos ].src , sizeof (mounttable -> entry [pos ].src )))) {
470+ log_fatal ("Missing 'device' attribute on raw node" );
471+ }
472+
473+ str_cpy (mounttable -> entry [pos ].dst , sizeof (mounttable -> entry [pos ].dst ), "/dev/raw" );
474+
475+ if (AVS_IS_ERROR (property_node_refer (NULL , cur , "opt" , PROPERTY_TYPE_STR ,
476+ mounttable -> entry [pos ].opt , sizeof (mounttable -> entry [pos ].opt )))) {
477+ // optional
478+ }
479+ }
480+ }
481+
482+ mounttable -> num_entries = pos ;
366483}
0 commit comments