hdd-menu: add possibility to label devices; ...

inspired by 58023f866e


Origin commit data
------------------
Branch: ni/coolstream
Commit: ccc0222758
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-01-24 (Sun, 24 Jan 2021)

Origin message was:
------------------
- hdd-menu: add possibility to label devices; ...

inspired by 58023f866e


------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2021-01-24 23:44:22 +01:00
parent 23944aa21e
commit f5adee5337
6 changed files with 42 additions and 9 deletions

View File

@@ -1002,6 +1002,9 @@ hdd_format_failed Formatierung fehlgeschlagen! Stellen Sie sicher, dass der Date
hdd_format_on_mount_failed Formatieren bei Einhänge-Fehler
hdd_format_warn Alle Daten auf dem Datenträger werden gelöscht! Formatierung starten?
hdd_fs Dateisystem zum formatieren
hdd_label Datenträger-Bezeichnung
hdd_label_hint1 Datenträger-Bezeichnung eingeben und mit Speichern übernehmen
hdd_label_hint2 Nur bei "%s" (Aufnahme-Medium) werden die nötigen Verzeichnisse auf den Datenträger geschrieben
hdd_info_capacity Kapazität
hdd_info_firmware Firmware
hdd_info_head HDD Info
@@ -1410,6 +1413,7 @@ menu.hint_hdd_fmt Wählen Sie das Datenträgerformat aus
menu.hint_hdd_format Erstellt eine Partition auf dem Datenträger und formatiert diese
menu.hint_hdd_format_on_mount_failed Soll der Datenträger formatiert werden, wenn das Einhängen fehlschlägt?
menu.hint_hdd_info Datenträger-Informationen über Kapazität, Temperatur usw.
menu.hint_hdd_label Geben Sie die Datenträger-Bezeichnung ein
menu.hint_hdd_noise Setzen Sie Parameter für das Automatic Acoustic Management.\nNicht alle Datenträger unterstützen diese Funktion
menu.hint_hdd_power Interne HDD-Stromversorgung für die Coolstream HD1 Boxen aktivieren.
menu.hint_hdd_sleep Dieser Wert definiert, nach wieviel Minuten die Festplatte bei Inaktivität in den Sleep-Modus geschaltet wird

View File

@@ -1002,6 +1002,9 @@ hdd_format_failed Formating failed! Make sure device not in use, reboot and try
hdd_format_on_mount_failed Format device when mount failed
hdd_format_warn All data on device will be lost! Continue with formatting?
hdd_fs Filesystem used to format
hdd_label Device label
hdd_label_hint1 Enter device label and press save
hdd_label_hint2 Only with "%s" (recording medium) the necessary folders will be written to device
hdd_info_capacity Capacity
hdd_info_firmware Firmware
hdd_info_head HDD Info
@@ -1410,6 +1413,7 @@ menu.hint_hdd_fmt Select the data storage format
menu.hint_hdd_format Create HDD partition and format it
menu.hint_hdd_format_on_mount_failed Format HDD device when mount failed?
menu.hint_hdd_info Device information about capacity, temperature etc.
menu.hint_hdd_label Enter device label
menu.hint_hdd_noise Set Automatic Acoustic Management\nnot all drives support this
menu.hint_hdd_power Activate internal HDD power for Coolstream HD1 boxes
menu.hint_hdd_sleep Select time to stop hdd on inactivity

View File

@@ -53,6 +53,7 @@
#include <gui/widget/msgbox.h>
#include <gui/widget/hintbox.h>
#include <gui/widget/progresswindow.h>
#include <gui/widget/keyboard_input.h>
#include <system/helpers.h>
#include <system/settings.h>
@@ -65,6 +66,8 @@
#define MDEV_MOUNT "/lib/mdev/fs/mdev-mount"
#define MOUNT_BASE "/media/"
#define MKFS_LABEL_DEFAULT "records"
#define HDD_NOISE_OPTION_COUNT 4
const CMenuOptionChooser::keyval HDD_NOISE_OPTIONS[HDD_NOISE_OPTION_COUNT] =
{
@@ -87,13 +90,13 @@ const CMenuOptionChooser::keyval HDD_SLEEP_OPTIONS[HDD_SLEEP_OPTION_COUNT] =
};
devtool_s CHDDMenuHandler::devtools[] = {
{ "ext4", "fsck.ext4", "-C 1 -f -y", "mkfs.ext4", "-m 0", false, false },
{ "ext3", "fsck.ext3", "-C 1 -f -y", "mkfs.ext3", "-m 0", false, false },
{ "ext2", "fsck.ext2", "-C 1 -f -y", "mkfs.ext2", "-m 0", false, false },
{ "f2fs", "fsck.f2fs", "", "mkfs.f2fs", "-f", false, false },
{ "vfat", "fsck.vfat", "-a", "mkfs.vfat", "", false, false },
{ "exfat", "fsck.exfat", "", "mkfs.exfat", "", false, false },
{ "xfs", "xfs_repair", "", "mkfs.xfs", "-f", false, false },
{ "ext4", "fsck.ext4", "-C 1 -f -y", "mkfs.ext4", "-m 0", "-L", false, false },
{ "ext3", "fsck.ext3", "-C 1 -f -y", "mkfs.ext3", "-m 0", "-L", false, false },
{ "ext2", "fsck.ext2", "-C 1 -f -y", "mkfs.ext2", "-m 0", "-L", false, false },
{ "f2fs", "fsck.f2fs", "", "mkfs.f2fs", "-f", "-l", false, false },
{ "vfat", "fsck.vfat", "-a", "mkfs.vfat", "", "-n", false, false },
{ "exfat", "fsck.exfat", "", "mkfs.exfat", "", "-n", false, false },
{ "xfs", "xfs_repair", "", "mkfs.xfs", "-f", "-L", false, false },
};
#define FS_MAX (sizeof(CHDDMenuHandler::devtools)/sizeof(devtool_s))
@@ -108,6 +111,7 @@ CHDDMenuHandler::CHDDMenuHandler()
show_menu = false;
in_menu = false;
lock_refresh = false;
mkfs_label = MKFS_LABEL_DEFAULT;
}
CHDDMenuHandler::~CHDDMenuHandler()
@@ -649,6 +653,13 @@ int CHDDMenuHandler::showDeviceMenu(std::string dev)
mc->setHint("", LOCALE_MENU_HINT_HDD_FMT);
hddmenu->addItem(mc);
char hint2[1024];
snprintf(hint2, sizeof(hint2)-1, g_Locale->getText(LOCALE_HDD_LABEL_HINT2), MKFS_LABEL_DEFAULT);
CKeyboardInput choseLabel((std::string) g_Locale->getText(LOCALE_HDD_LABEL), &mkfs_label, 0, NULL, NULL, (std::string) g_Locale->getText(LOCALE_HDD_LABEL_HINT1), (std::string) hint2);
mf = new CMenuForwarder(LOCALE_HDD_LABEL, true, mkfs_label, &choseLabel);
mf->setHint("", LOCALE_MENU_HINT_HDD_LABEL);
hddmenu->addItem(mf);
std::string key = "f" + dev;
mf = new CMenuForwarder(LOCALE_HDD_FORMAT, true, "", this, key.c_str());
mf->setHint("", LOCALE_MENU_HINT_HDD_FORMAT);
@@ -1065,7 +1076,10 @@ int CHDDMenuHandler::formatDevice(std::string dev)
std::string devpart = dev + part;
std::string partname = devname + part;
std::string mkfscmd = devtool->mkfs + " " + devtool->mkfs_options + " " + partname;
std::string mkfscmd = devtool->mkfs + " " + devtool->mkfs_options + " ";
if (!devtool->mkfs_labelswitch.empty() && !mkfs_label.empty())
mkfscmd += devtool->mkfs_labelswitch + " \"" + mkfs_label + "\" ";
mkfscmd += partname;
printf("mkfs cmd: [%s]\n", mkfscmd.c_str());
res = ShowMsg(LOCALE_HDD_FORMAT, g_Locale->getText(LOCALE_HDD_FORMAT_WARN), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo );
@@ -1249,7 +1263,8 @@ _remount:
if (!res) {
res = mount_dev(devpart);
if(res) {
if (res && mkfs_label == MKFS_LABEL_DEFAULT)
{
std::string dst = MOUNT_BASE + devpart;
snprintf(cmd, sizeof(cmd), "%s/movies", dst.c_str());
safe_mkdir(cmd);

View File

@@ -34,6 +34,7 @@ struct devtool_s {
std::string fsck_options;
std::string mkfs;
std::string mkfs_options;
std::string mkfs_labelswitch;
bool fsck_supported;
bool mkfs_supported;
};
@@ -48,6 +49,7 @@ class CHDDMenuHandler : public CMenuTarget
{
private:
int width;
std::string mkfs_label;
std::string mount;
std::string umount;
bool show_menu;

View File

@@ -1029,6 +1029,9 @@ typedef enum
LOCALE_HDD_FORMAT_ON_MOUNT_FAILED,
LOCALE_HDD_FORMAT_WARN,
LOCALE_HDD_FS,
LOCALE_HDD_LABEL,
LOCALE_HDD_LABEL_HINT1,
LOCALE_HDD_LABEL_HINT2,
LOCALE_HDD_INFO_CAPACITY,
LOCALE_HDD_INFO_FIRMWARE,
LOCALE_HDD_INFO_HEAD,
@@ -1437,6 +1440,7 @@ typedef enum
LOCALE_MENU_HINT_HDD_FORMAT,
LOCALE_MENU_HINT_HDD_FORMAT_ON_MOUNT_FAILED,
LOCALE_MENU_HINT_HDD_INFO,
LOCALE_MENU_HINT_HDD_LABEL,
LOCALE_MENU_HINT_HDD_NOISE,
LOCALE_MENU_HINT_HDD_POWER,
LOCALE_MENU_HINT_HDD_SLEEP,

View File

@@ -1029,6 +1029,9 @@ const char * locale_real_names[] =
"hdd_format_on_mount_failed",
"hdd_format_warn",
"hdd_fs",
"hdd_label",
"hdd_label_hint1",
"hdd_label_hint2",
"hdd_info_capacity",
"hdd_info_firmware",
"hdd_info_head",
@@ -1437,6 +1440,7 @@ const char * locale_real_names[] =
"menu.hint_hdd_format",
"menu.hint_hdd_format_on_mount_failed",
"menu.hint_hdd_info",
"menu.hint_hdd_label",
"menu.hint_hdd_noise",
"menu.hint_hdd_power",
"menu.hint_hdd_sleep",