I did a bit research on it and was able to do a workaround.The issue is caused by the ID string delivered by the disk ( USB 3.5"-HDD), which contains a double-quote character, and this confuses the scripts that auto-mounts the disk and some other things.
I modified the file /etc/inc/func_exthdd.inc to remove that " from the disks name.
Here is the modified file:
- Code: Select all
/* returns shareName and mountPoint */
function exthddfunc_buildExtHddUniqueString($kernDevName, &$mountPoint, &$shareName, &$newShare)
{
global $volatileConfig;
/* obtain volume label */
exec("sudo /sbin/vol_id -l /dev/{$kernDevName}", $out, $ret);
$volName = substr(trim($out[0]), 0, 14);
if(strlen($volName) == 0)
$volName = "Volume";
/* produce internal mounting point */
$driveName = substr($kernDevName, 0, 3);
$partNum = trim(substr($kernDevName, 3));
if($partNum == '')
$partNum = '0';
exec("sudo /sbin/usb_id /block/{$driveName}", $mntDir, $ret);
if (($ret != 0) || (strlen(trim($mntDir[0])) == 0))
return FAIL_E;
$mountPoint = str_replace("\"","",EXTHDD_MOUNT_DIR . "/{$mntDir[0]}_{$partNum}");
for($i = 0; $i <= 8; $i++) {
/* Volume name - up to 14 characters */
$shareName = substr($volName, 0, 14 - $i);
/* in case of name collision, replace part of volume name */
/* with MSB bytes of device serial number */
$shareName .= substr($mntDir[0], -8 - $i, $i);
/* add 4 chars from manufacturer name, partition number and 8 LSB chars from the serial number */
$shareName .= '_' . substr($mntDir[0], 0, 4) . '_' . $partNum . '_' . substr($mntDir[0], -8, 8);
/* check if a share with the same name exists */
if(($shareEnt = sharefunc_find_share($shareName, $key)) != null) {
/* name collision on active share? - new iteration */
if($shareEnt['sharestatus'] == 'active')
continue;
/* this share was mounted in the past, reactivate it */
if($shareEnt['sharemount'] == $mountPoint) {
$newShare = false;
break;
}
/* name collision on passive share - remove the old entry */
/* and re-create a new one with the same name */
if(sharefunc_del_share($shareName) != OK_E)
return FAIL_E;
}
/* there is no name collision - create new share */
$newShare = true;
break;
}
/* we are running out of name space - too much collisions! */
if($i >= 9)
return FAIL_E;
return OK_E;
} /* end of func: exthddfunc_buildExtHddUniqueString */
function exthddfunc_mountExtHdd($kernDevName)
{
if (exthddfunc_buildExtHddUniqueString($kernDevName, $mountPoint, $shareName, $newShare) != OK_E) {
logError(__FILE__, __LINE__ , "failed to create unique name for device {$kernDevName}", LOG_WARNING);
return FAIL_E;
}
/* fix naming problems with meta-characters */
$mountPointQuoted = quotemeta($mountPoint);
/* make dir for mount point */
if (mwexec("/bin/mkdir -m 777 -p {$mountPointQuoted}") != 0) {
logError(__FILE__, __LINE__ , "failed to make directory {$mountPoint} for {$kernDevName}", LOG_WARNING);
return FAIL_E;
}
/* obtain the file system number */
$device = substr($kernDevName, 0, 3);
exec("sudo /sbin/fdisk -l /dev/{$device} | grep {$kernDevName} | tr -s \" \"", $out, $ret);
$outArr = explode(" ", $out[0]);
/* if a partition is bootable, take the partition FS number from diferent place */
if (strstr($outArr[1], '*') === FALSE)
{
$fsNum = trim($outArr[4]);
}
else
{
$fsNum = trim($outArr[5]);
}
if (strcmp('4', $fsNum) == 0 ||
strcmp('6', $fsNum) == 0 ||
strcmp('b', $fsNum) == 0 ||
strcmp('c', $fsNum) == 0 ||
strcmp('e', $fsNum) == 0 ||
strcmp('f', $fsNum) == 0)
{
$fsType = "vfat";
$fsOptions = 'umask=000';
}
else if (strcmp('7', $fsNum) == 0)
{
$fsType = "ntfs";
$fsOptions = 'umask=000';
}
else if (strcmp('83', $fsNum) == 0)
{
exec("sudo /sbin/vol_id -t /dev/{$kernDevName}", $tmp, $ret);
$fsType = $tmp[0];
$fsOptions = 'noatime';
}
else
{
logError(__FILE__, __LINE__ , "unknown filesystem {$fsNum}", LOG_WARNING);
@rmdir($mountPoint);
return FAIL_E;
}
/* try to mount this partition */
$ret = mwexec("/bin/mount -t {$fsType} -o {$fsOptions} /dev/{$kernDevName} {$mountPointQuoted}");
if ($ret != 0) {
logError(__FILE__, __LINE__ , "failed to mount {$kernDevName} at {$mountPoint}", LOG_WARNING);
@rmdir($mountPoint);
return FAIL_E;
}
/* To be on the safe side, change permissions of the newly mounted filesystem */
mwexec("/bin/chmod 777 {$mountPointQuoted}");
if ($newShare == true) {
/* create a share in volatile db */
$ret = sharefunc_add_share($shareName, 'public', SH_LOC_EXT, $mountPoint, $fsType);
} else {
/* notify samba about the changes */
$ret = sharefunc_enable_share($shareName, true);
}
if ($ret != OK_E) {
/* rollback - umount ext dev */
logError(__FILE__, __LINE__ , "failed add/enable share {$shareName}", LOG_WARNING);
mwexec("/bin/umount -f {$mountPointQuoted}");
@rmdir($mountPoint);
return FAIL_E;
}
return OK_E;
} /* end of func: exthddfunc_mountExtHdd */
function exthddfunc_unmountExtHdd($kernDevName)
{
/* read the list of all mounted filesystems */
$allMounts = file("/proc/mounts");
if (!isset($allMounts)) {
logError(__FILE__, __LINE__ , "cannot read /proc/mounts", LOG_WARNING);
return FAIL_E;
}
/* check if our deveice is mounted */
foreach($allMounts as $mount)
{
$mountParams = explode(" ", $mount);
if(substr($mountParams[0], 5, 3) == "{$kernDevName}")
{
$mountPoint = trim($mountParams[1]);
if (!isset($mountPoint))
{
logError(__FILE__, __LINE__ , "cannot locate {$mountParams[0]} in /proc/mounts", LOG_WARNING);
return FAIL_E;
}
/* suspend share */
if(($share = sharefunc_find_share_by_mount($mountPoint, $key)) != null)
{
/* disable share */
if (sharefunc_del_share($share['sharename']) != OK_E) {
logError(__FILE__, __LINE__ , "failed updating volatile db for device {$mountParams[0]}", LOG_WARNING);
}
}
/* sync write buffers */
mwexec("/bin/sync");
$mountPointQuoted = quotemeta($mountPoint);
if (mwexec("/bin/umount -f {$mountPointQuoted}") != 0)
{
logError(__FILE__, __LINE__ , "cannot unmount {$mountParams[0]} from {$mountPointQuoted}", LOG_WARNING);
return FAIL_E;
}
/* remove this entry from /etc/mtab */
$mountedPartitions = file("/etc/mtab");
foreach($mountedPartitions as $mountIndex => $currentMount)
{
$fields = explode(' ', $currentMount);
if(realpath($fields[1]) == realpath($mountPoint))
{
unset($mountedPartitions[$mountIndex]);
$mtabCont = implode("\n", $mountedPartitions);
$fd = fopen("/etc/mtab", "w");
if (!$fd)
{
logError(__FILE__, __LINE__ , "cannot open mtab file", LOG_WARNING);
}
else
{
fwrite($fd, $mtabCont);
fclose($fd);
}
break;
}
}
@rmdir($mountPoint);
}
}
return OK_E;
} /* end of func: exthddfunc_unmountExtHdd */
function exthddfunc_formatExtHdd($kernDevName)
{
$ret = mwexec("/sbin/mkdosfs /dev/$kernDevName");
if ($ret != 0)
return FAIL_E;
return OK_E;
} /* end of func: exthddfunc_formatExtHdd */
?>
I tried to attach the file to the post, but all extensions i tried got rejected, so just copy the text in the code box and save it as /etc/inc/func_exthdd.inc on your MSS2.If you use a windows pc, just ensure you save the file in unix format by use of an appropriate editor ( e.g. TotalEdit etc.) or use the DOS2UNIX tool on your MSS2 commandline to convert the file.Not sure if this will create issues when saved as DOS format, just to be on the safe side.
There are more places affected by the device ID string ( usb device listing and power management in Web UI) unfortunately, so i will have a look if i can fix these as well.
With the modified func_exthdd.inc the TOSHIBA drive got mounted automatically and i was able to run a backup from the web UI, even though the UI says there are no disk drives attached.
Please let me know, if that worked for you ok or if you need some help with this.
regard,
TWELVE
