mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 17:31:20 +02:00
hdd_menu.cpp: add support for sgdisk; fix sfdisk usage
Signed-off-by: Markus Volk <f_l_k@t-online.de> Signed-off-by: Thilo Graf <dbt@novatux.de> - sfdisk is used primarily - ensures detection of large hard drives - using gpt tables with sfdisk or sgdisk Note: busybox fdisk doesn't support gpt tables and no large hard disks, but fallback to old behavior should work unchanged newer util versions of fdisk can do this but with different syntax. Please test.
This commit is contained in:
@@ -998,7 +998,7 @@ int CHDDMenuHandler::formatDevice(std::string dev)
|
||||
int res;
|
||||
FILE * f;
|
||||
CProgressWindow * progress;
|
||||
std::string fdisk, sfdisk, tune2fs;
|
||||
std::string fdisk, sfdisk, sgdisk, tune2fs;
|
||||
|
||||
printf("CHDDMenuHandler::formatDevice: dev %s hdd_fs %d\n", dev.c_str(), g_settings.hdd_fs);
|
||||
|
||||
@@ -1050,16 +1050,22 @@ int CHDDMenuHandler::formatDevice(std::string dev)
|
||||
|
||||
fdisk = find_executable("fdisk");
|
||||
sfdisk = find_executable("sfdisk");
|
||||
sgdisk = find_executable("sgdisk");
|
||||
tune2fs = find_executable("tune2fs");
|
||||
if (! sfdisk.empty()) {
|
||||
snprintf(cmd, sizeof(cmd), "%s -f -uM %s", sfdisk.c_str(), devname.c_str());
|
||||
strcpy(cmd2, "0,\n;\n;\n;\ny\n");
|
||||
} else if (! fdisk.empty()) {
|
||||
std::string conf = "echo 'label: gpt\n;' | ";
|
||||
snprintf(cmd, sizeof(cmd), "%s %s -f %s", conf.c_str(), sfdisk.c_str(), devname.c_str());
|
||||
}
|
||||
else if (! sgdisk.empty()) {
|
||||
snprintf(cmd, sizeof(cmd), "%s -Z -N 0 %s", sgdisk.c_str(), devname.c_str());
|
||||
}
|
||||
else if (! fdisk.empty()) {
|
||||
snprintf(cmd, sizeof(cmd), "%s -u %s", fdisk.c_str(), devname.c_str());
|
||||
strcpy(cmd2, "o\nn\np\n1\n2048\n\nw\n");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* cannot do anything */
|
||||
fprintf(stderr, "CHDDFmtExec: neither fdisk nor sfdisk found in $PATH :-(\n");
|
||||
fprintf(stderr, "CHDDFmtExec: neither fdisk, sfdisk or sgdisk found in $PATH :-(\n");
|
||||
showError(LOCALE_HDD_FORMAT_FAILED);
|
||||
goto _remount;
|
||||
}
|
||||
@@ -1080,7 +1086,7 @@ int CHDDMenuHandler::formatDevice(std::string dev)
|
||||
|
||||
fprintf(f, "%s", cmd2);
|
||||
res = pclose(f);
|
||||
printf("CHDDMenuHandler::formatDevice: (s)fdisk res: %d\n", res);
|
||||
printf("CHDDMenuHandler::formatDevice: (s(g))(f)disk res: %d\n", res);
|
||||
if (res) {
|
||||
showError(LOCALE_HDD_FORMAT_FAILED);
|
||||
goto _remount;
|
||||
@@ -1092,6 +1098,8 @@ int CHDDMenuHandler::formatDevice(std::string dev)
|
||||
#endif
|
||||
|
||||
progress->showStatusMessageUTF(mkfscmd.c_str());
|
||||
res = umount_all(dev);
|
||||
printf("CHDDMenuHandler::formatDevice: umount res %d\n", res);
|
||||
f = popen(mkfscmd.c_str(), "r");
|
||||
if (!f) {
|
||||
showError(LOCALE_HDD_FORMAT_FAILED);
|
||||
|
Reference in New Issue
Block a user