mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 17:01:08 +02:00
hdd_menu: only offer filesystems with kernel support
Origin commit data
------------------
Branch: ni/coolstream
Commit: 141872565e
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2015-02-08 (Sun, 08 Feb 2015)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
committed by
Jacek Jendrzej
parent
66dd6f7155
commit
bb5fbb9954
@@ -215,9 +215,36 @@ std::string CHDDMenuHandler::getFmtType(std::string name, std::string part)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CHDDMenuHandler::check_kernel_fs()
|
||||||
|
{
|
||||||
|
char line[128]; /* /proc/filesystems lines are shorter */
|
||||||
|
kernel_fs_list.clear();
|
||||||
|
FILE *f = fopen("/proc/filesystems", "r");
|
||||||
|
if (! f) {
|
||||||
|
fprintf(stderr, "CHDDMenuHandler::%s: opening /proc/filesystems failed: %m\n", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (fgets(line, sizeof(line), f)) {
|
||||||
|
size_t l = strlen(line);
|
||||||
|
if (l > 0)
|
||||||
|
line[l - 1] = 0; /* remove \n */
|
||||||
|
char *tab = strchr(line, '\t');
|
||||||
|
if (! tab) /* should not happen in any kernel I have seen */
|
||||||
|
continue;
|
||||||
|
tab++;
|
||||||
|
kernel_fs_list.insert(string(tab));
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
void CHDDMenuHandler::check_dev_tools()
|
void CHDDMenuHandler::check_dev_tools()
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < FS_MAX; i++) {
|
for (unsigned i = 0; i < FS_MAX; i++) {
|
||||||
|
if (kernel_fs_list.find(devtools[i].fmt) == kernel_fs_list.end()) {
|
||||||
|
printf("%s: filesystem '%s' not supported by kernel\n",
|
||||||
|
__func__, devtools[i].fmt.c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!access(devtools[i].fsck.c_str(), X_OK))
|
if (!access(devtools[i].fsck.c_str(), X_OK))
|
||||||
devtools[i].fsck_supported = true;
|
devtools[i].fsck_supported = true;
|
||||||
if (!access(devtools[i].mkfs.c_str(), X_OK))
|
if (!access(devtools[i].mkfs.c_str(), X_OK))
|
||||||
@@ -682,6 +709,7 @@ int CHDDMenuHandler::doMenu()
|
|||||||
show_menu = false;
|
show_menu = false;
|
||||||
in_menu = true;
|
in_menu = true;
|
||||||
|
|
||||||
|
check_kernel_fs();
|
||||||
check_dev_tools();
|
check_dev_tools();
|
||||||
|
|
||||||
_show_menu:
|
_show_menu:
|
||||||
|
@@ -64,6 +64,7 @@ class CHDDMenuHandler : public CMenuTarget
|
|||||||
bool mounted;
|
bool mounted;
|
||||||
};
|
};
|
||||||
std::vector<hdd_s> hdd_list;
|
std::vector<hdd_s> hdd_list;
|
||||||
|
std::set<std::string> kernel_fs_list;
|
||||||
struct cmp_hdd_by_name: public binary_function <const struct hdd_s, const struct hdd_s, bool>
|
struct cmp_hdd_by_name: public binary_function <const struct hdd_s, const struct hdd_s, bool>
|
||||||
{
|
{
|
||||||
bool operator() (const struct hdd_s c1, const struct hdd_s c2)
|
bool operator() (const struct hdd_s c1, const struct hdd_s c2)
|
||||||
@@ -84,6 +85,7 @@ class CHDDMenuHandler : public CMenuTarget
|
|||||||
bool add_dev(std::string dev, std::string part);
|
bool add_dev(std::string dev, std::string part);
|
||||||
bool waitfordev(std::string dev, int maxwait);
|
bool waitfordev(std::string dev, int maxwait);
|
||||||
void check_dev_tools();
|
void check_dev_tools();
|
||||||
|
void check_kernel_fs();
|
||||||
devtool_s * get_dev_tool(std::string fmt);
|
devtool_s * get_dev_tool(std::string fmt);
|
||||||
|
|
||||||
int showDeviceMenu(std::string dev);
|
int showDeviceMenu(std::string dev);
|
||||||
|
Reference in New Issue
Block a user