From 4f9c41a48963747dc4fca891b64158016ffce83f Mon Sep 17 00:00:00 2001 From: Tim Curtis Date: Tue, 23 Jul 2024 17:38:26 -0400 Subject: [PATCH] NVMe mount/format feature - Remove test code - Fix device path --- www/daemon/worker.php | 7 +++---- www/inc/music-source.php | 15 ++++----------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/www/daemon/worker.php b/www/daemon/worker.php index c2491f2c..c23b877c 100755 --- a/www/daemon/worker.php +++ b/www/daemon/worker.php @@ -2248,10 +2248,9 @@ function runQueuedJob() { $status = $parts[1]; // Could be existing label or status (Unformatted, Not ext4, Not labeled) $newLabel = $parts[2]; sendFECmd('nvme_formatting_drive'); - // TEST: - workerLog('queueargs: (' . $_SESSION['w_queueargs'] . ')'); - sleep(6); - //PROD:nvmeFormatDrive($device, $newLabel); + workerLog('worker: Formatting: ' . $device . ', label: ' . $newLabel); + nvmeFormatDrive($device, $newLabel); + workerLog('worker: Format complete'); break; case 'fs_mountmon': sysCmd('killall -s 9 mountmon.php'); diff --git a/www/inc/music-source.php b/www/inc/music-source.php index 5eaa7eb2..27aa8394 100644 --- a/www/inc/music-source.php +++ b/www/inc/music-source.php @@ -374,14 +374,14 @@ function nvmeListDrives() { // Check for /dev/nvme0n1 and similar if (str_contains($device, 'nvme') && strlen($device) > 5) { // Check for ext4 format - $format = getDriveFormat($device); + $format = getDriveFormat('/dev/' . $device); if (empty($format)) { $status = LIB_NVME_UNFORMATTED; } else if ($format != 'ext4') { $status = LIB_NVME_NOT_EXT4; } else { // Get drive label - $label = getDrivelabel($device); + $label = getDrivelabel('/dev/' . $device); if (empty($label)) { $status = LIB_NVME_NO_LABEL; } else { @@ -393,11 +393,6 @@ function nvmeListDrives() { } } - // TEST: - $drives['/dev/nvme0n1'] = 'Some volume label'; - $drives['/dev/nvme1n1'] = 'Unformatted'; - $drives['/dev/nvme2n1'] = 'Not ext4'; - $drives['/dev/nvme3n1'] = 'No label'; return $drives; } @@ -412,8 +407,6 @@ function getDriveLabel($device) { } function nvmeFormatDrive($device, $label) { - // TEST: - workerLog('nvmeFormatDrive(): ' . $device . '|' . $label); - //sysCmd('mkfs -t ext4 ' . $device); - //sysCmd('e2label ' . $device . ' ' . $label); // Need quotes around the label? + sysCmd('mkfs -t ext4 ' . $device); + sysCmd('e2label ' . $device . ' "' . $label . '"'); }