From a84a7d608316c357576c04332ce3514423fd26ad Mon Sep 17 00:00:00 2001 From: seife Date: Sat, 6 Nov 2010 22:15:26 +0000 Subject: [PATCH] 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 --- src/gui/hdd_menu.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index ada9d8626..541b99e1d 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -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); - snprintf(cmd, sizeof(cmd), "/sbin/sfdisk -f -uM /dev/%s", key.c_str()); + 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);