Skip to content

Commit

Permalink
NVMe mount/format feature
Browse files Browse the repository at this point in the history
- Remove test code
- Fix device path
  • Loading branch information
moodeaudio committed Jul 23, 2024
1 parent 8c5725f commit 4f9c41a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
7 changes: 3 additions & 4 deletions www/daemon/worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
15 changes: 4 additions & 11 deletions www/inc/music-source.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}

Expand All @@ -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 . '"');
}

0 comments on commit 4f9c41a

Please sign in to comment.