Apollo/Kronos: Display backup options for 'var' and 'root1'...

...only if are mounted.

- Using /proc/mounts to find correct mountpoint for backup


Origin commit data
------------------
Branch: ni/coolstream
Commit: 885f13f6b0
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2015-09-22 (Tue, 22 Sep 2015)



------------------
This commit was generated by Migit
This commit is contained in:
Michael Liebmann
2015-09-22 13:39:47 +02:00
parent 1cac7299e4
commit 26e82ad0cf
3 changed files with 49 additions and 13 deletions

View File

@@ -898,3 +898,21 @@ std::string to_string(unsigned long long i)
return s.str();
}
std::string getJFFS2MountPoint(int mtdPos)
{
FILE* fd = fopen("/proc/mounts", "r");
if (!fd) return "";
int iBlock;
char lineRead[1024], sMount[512], sFs[512];
memset(lineRead, '\0', sizeof(lineRead));
while (fgets(lineRead, sizeof(lineRead)-1, fd)) {
sscanf(lineRead, "/dev/mtdblock%d %512s %512s", &iBlock, sMount, sFs);
if ((iBlock == mtdPos) && (strstr(sMount, "/") != NULL) && (strstr(sFs, "jffs2") != NULL)) {
fclose(fd);
return sMount;
}
memset(lineRead, '\0', sizeof(lineRead));
}
fclose(fd);
return "";
}