MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / doFileSystems

Function doFileSystems

tools/mcdevicetree.js:748–831  ·  view source on GitHub ↗
(state, dts)

Source from the content-addressed store, hash-verified

746}
747
748function doFileSystems(state, dts) {
749 const root = dts.nodes['/'];
750 const fstab = root.children.fstab;
751 const nodes = []
752 for (const name in fstab?.children)
753 nodes.push(fstab.children[name]);
754
755 state.hCode += `
756#define kModZephyrFSCount (${nodes.length})
757`;
758
759 if (0 === nodes.length)
760 return;
761
762 state.hCode += `
763#include <zephyr/fs/fs.h>
764
765struct modZephyrFS {
766 const char *label;
767 struct fs_mount_t *mountpoint;
768 uint8_t fsIndex;
769};
770
771extern const struct modZephyrFS *modZephyrGetFS(const char *label);
772
773`;
774
775 state.hCode += `
776#ifndef MODDEF_ZEPHYR_FILESYSTEM_DEFAULT
777 #define MODDEF_ZEPHYR_FILESYSTEM_DEFAULT "${nodes[0].label}"
778#endif
779`;
780
781 nodes.forEach(node => {
782 state.cCode += `
783FS_FSTAB_DECLARE_ENTRY(DT_NODELABEL(${node.label}));
784`;
785 });
786
787 state.cCode +=`
788static const struct modZephyrFS gFS[] = {
789`;
790
791 nodes.forEach((node, index) => {
792 state.cCode += ` {
793 .label = "${node.label}",
794 .mountpoint = &FS_FSTAB_ENTRY(DT_NODELABEL(${node.label})),
795 .fsIndex = ${index}
796 },
797`;
798 });
799
800 state.cCode += `};
801
802const struct modZephyrFS *modZephyrGetFS(const char *label)
803{
804 for (int i = 0; i < ARRAY_SIZE(gFS); i++) {
805 if (0 == c_strcmp(gFS[i].label, label))

Callers 1

runMethod · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected