mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 09:21:09 +02:00
Revert "hdd_menu: fix is_mounted for device links"
- broken in case readlink do not support -f switch -> filesystem always 'mounted' This reverts commit47f2cfd410
. Origin commit data ------------------ Branch: ni/coolstream Commit:990e79aa6f
Author: [CST] Focus <focus.cst@gmail.com> Date: 2015-02-10 (Tue, 10 Feb 2015) ------------------ This commit was generated by Migit
This commit is contained in:
@@ -139,25 +139,14 @@ bool CHDDMenuHandler::is_mounted(const char *dev)
|
|||||||
else
|
else
|
||||||
snprintf(devpath, sizeof(devpath), "/dev/%s", dev);
|
snprintf(devpath, sizeof(devpath), "/dev/%s", dev);
|
||||||
|
|
||||||
|
int devpathlen = strlen(devpath);
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
string realdev = backtick("readlink -f " + string(devpath));
|
|
||||||
realdev = trim(realdev);
|
|
||||||
FILE *f = fopen("/proc/mounts", "r");
|
FILE *f = fopen("/proc/mounts", "r");
|
||||||
if(f) {
|
if(f) {
|
||||||
while (!res && fgets(buffer, sizeof(buffer), f)) {
|
while (!res && fgets(buffer, sizeof(buffer), f))
|
||||||
if (buffer[0] != '/')
|
if (!strncmp(buffer, devpath, devpathlen)
|
||||||
continue; /* only "real" devices are interesting */
|
&& (buffer[devpathlen] == ' ' || buffer[devpathlen] == '\t'))
|
||||||
char *p = strchr(buffer, ' ');
|
|
||||||
if (p)
|
|
||||||
*p = 0; /* terminate at first space, kernel-user ABI is fixed */
|
|
||||||
if (!strcmp(buffer, devpath)) /* default '/dev/sda1' mount */
|
|
||||||
res = true;
|
res = true;
|
||||||
else { /* now the case of '/dev/disk/by-label/myharddrive' mounts */
|
|
||||||
string realmount = backtick("readlink -f " + string(buffer));
|
|
||||||
if (realdev == trim(realmount))
|
|
||||||
res = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
printf("CHDDMenuHandler::is_mounted: dev [%s] is %s\n", devpath, res ? "mounted" : "not mounted");
|
printf("CHDDMenuHandler::is_mounted: dev [%s] is %s\n", devpath, res ? "mounted" : "not mounted");
|
||||||
|
Reference in New Issue
Block a user