Skip to content

Customize VFS location via meshtasticd #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions cores/portduino/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ void portduinoAddArguments(const struct argp_child &child,
childArguments = _childArguments;
}

/**
* call from portduinoSetup() if you want to specify a custom filesystem root
*/
static const char* portduinoCustomfsRoot = nullptr;
void portduinoCustomFSDir(const char *newFsRoot) {
portduinoCustomfsRoot = newFsRoot;
}

void reboot() {
int err = execv(progArgv[0], progArgv);
printf("execv() returned %i!\n", err);
Expand Down Expand Up @@ -141,18 +149,23 @@ int main(int argc, char *argv[]) {
String fsRoot;

if (!args->fsDir) {
// create a default dir
if(portduinoCustomfsRoot) {
fsRoot = portduinoCustomfsRoot;
} else {
// create a default dir

const char *homeDir = getenv("HOME");
assert(homeDir);
const char *homeDir = getenv("HOME");
assert(homeDir);

fsRoot += homeDir + String("/.portduino");
mkdir(fsRoot.c_str(), 0700);
fsRoot += homeDir + String("/.portduino");
mkdir(fsRoot.c_str(), 0700);

const char *instanceName = "default";
fsRoot += "/" + String(instanceName);
} else
const char *instanceName = "default";
fsRoot += "/" + String(instanceName);
}
} else {
fsRoot += args->fsDir;
}

printf("Portduino is starting, VFS root at %s\n", fsRoot.c_str());

Expand Down