hdd_menu: make it work with sfdisk and fdisk

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@886 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
seife
2010-11-06 22:15:26 +00:00
parent 874b74e8d6
commit a84a7d6083

View File

@@ -219,6 +219,7 @@ static int check_and_umount(char * dev, char * path)
int CHDDFmtExec::exec(CMenuTarget* /*parent*/, const std::string& key)
{
char cmd[100];
char cmd2[100];
CHintBox * hintbox;
int res;
FILE * f;
@@ -260,7 +261,14 @@ int CHDDFmtExec::exec(CMenuTarget* /*parent*/, const std::string& key)
progress->showStatusMessageUTF("Executing fdisk");
progress->showGlobalStatus(0);
if (access("/sbin/sfdisk", X_OK) == 0) {
snprintf(cmd, sizeof(cmd), "/sbin/sfdisk -f -uM /dev/%s", key.c_str());
strcpy(cmd2, "0,\n;\n;\n;\ny\n");
} else {
snprintf(cmd, sizeof(cmd), "/sbin/fdisk /dev/%s", key.c_str());
strcpy(cmd2, "o\nn\np\n1\n\n\nw\n");
}
printf("CHDDFmtExec: executing %s\n", cmd);
f=popen(cmd, "w");
if (!f) {
@@ -271,7 +279,7 @@ int CHDDFmtExec::exec(CMenuTarget* /*parent*/, const std::string& key)
goto _remount;
}
fprintf(f, "0,\n;\n;\n;\ny\n");
fprintf(f, "%s", cmd2);
pclose(f);
//sleep(1);