mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
hdd_menu: fix progress reporting for HDD formatting routine
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@876 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -220,7 +220,6 @@ int CHDDFmtExec::exec(CMenuTarget* /*parent*/, const std::string& key)
|
|||||||
FILE * f;
|
FILE * f;
|
||||||
char src[128], dst[128];
|
char src[128], dst[128];
|
||||||
CProgressWindow * progress;
|
CProgressWindow * progress;
|
||||||
bool idone;
|
|
||||||
|
|
||||||
snprintf(src, sizeof(src), "/dev/%s1", key.c_str());
|
snprintf(src, sizeof(src), "/dev/%s1", key.c_str());
|
||||||
snprintf(dst, sizeof(dst), "/media/%s1", key.c_str());
|
snprintf(dst, sizeof(dst), "/media/%s1", key.c_str());
|
||||||
@@ -295,25 +294,66 @@ int CHDDFmtExec::exec(CMenuTarget* /*parent*/, const std::string& key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
idone = false;
|
setbuf(f, NULL);
|
||||||
while(fgets(buf, 255, f) != NULL)
|
int n, t, in, pos, stage;
|
||||||
|
pos = 0;
|
||||||
|
stage = 0;
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
printf("%s", buf);
|
in = fgetc(f);
|
||||||
if(!idone && strncmp(buf, "Writing inode", 13)) {
|
if (in == EOF)
|
||||||
idone = true;
|
break;
|
||||||
buf[21] = 0;
|
|
||||||
progress->showGlobalStatus(20);
|
buf[pos] = (char)in;
|
||||||
progress->showStatusMessageUTF(buf);
|
pos++;
|
||||||
}
|
buf[pos] = 0;
|
||||||
else if(strncmp(buf, "Creating", 8)) {
|
if (in == '\b' || in == '\n')
|
||||||
progress->showGlobalStatus(40);
|
pos = 0; /* start a new line */
|
||||||
progress->showStatusMessageUTF(buf);
|
//printf("%s", buf);
|
||||||
}
|
switch (stage) {
|
||||||
else if(strncmp(buf, "Writing superblocks", 19)) {
|
case 0:
|
||||||
progress->showGlobalStatus(60);
|
if (strcmp(buf, "Writing inode tables:") == 0) {
|
||||||
progress->showStatusMessageUTF(buf);
|
stage++;
|
||||||
|
progress->showGlobalStatus(20);
|
||||||
|
progress->showStatusMessageUTF(buf);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (in == '\b' && sscanf(buf, "%d/%d\b", &n, &t) == 2) {
|
||||||
|
int percent = 100 * n / t;
|
||||||
|
progress->showLocalStatus(percent);
|
||||||
|
progress->showGlobalStatus(20 + percent / 5);
|
||||||
|
}
|
||||||
|
if (strstr(buf, "done")) {
|
||||||
|
stage++;
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (strstr(buf, "blocks):") && sscanf(buf, "Creating journal (%d blocks):", &n) == 1) {
|
||||||
|
progress->showLocalStatus(0);
|
||||||
|
progress->showGlobalStatus(60);
|
||||||
|
progress->showStatusMessageUTF(buf);
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
if (strstr(buf, "done")) {
|
||||||
|
stage++;
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (strcmp(buf, "Writing superblocks and filesystem accounting information:") == 0) {
|
||||||
|
progress->showGlobalStatus(80);
|
||||||
|
progress->showStatusMessageUTF(buf);
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// printf("unknown stage! %d \n\t", stage);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
progress->showLocalStatus(100);
|
||||||
pclose(f);
|
pclose(f);
|
||||||
progress->showGlobalStatus(100);
|
progress->showGlobalStatus(100);
|
||||||
sleep(2);
|
sleep(2);
|
||||||
|
Reference in New Issue
Block a user