Skip to content

Commit 687e759

Browse files
committed
feature/guess-nvme: New feature to add nvme modules
The feature adds the ability to search for and add nvme devices. The nvme sysfs looks like this, where there are no modalias because these are virtual nodes: /sys/devices/virtual/nvme-subsystem/nvme-subsys0/... with the specific file `subsystype` with value `nvm`. In this case, symlinks `nvme[0-9]` can be searched for, which point to the actual block device. Signed-off-by: Alexey Gladkov <[email protected]>
1 parent bf56cf3 commit 687e759

File tree

3 files changed

+445
-0
lines changed

3 files changed

+445
-0
lines changed

features/guess-nvme/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Feature: guess-nvme
2+
3+
The feature adds the ability to search for and add NVME devices.

features/guess-nvme/guess/device

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash -eu
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
[ -e "$SYSFS_PATH$1"/subsystype ] ||
5+
exit 0
6+
7+
. guess-functions
8+
9+
subsystype=
10+
readline subsystype "$SYSFS_PATH$1"/subsystype
11+
12+
if [ "$subsystype" = "nvm" ]; then
13+
for syspath in \
14+
"$SYSFS_PATH$1"/nvme[0-9] \
15+
"$SYSFS_PATH$1"/nvme[0-9][0-9] \
16+
"$SYSFS_PATH$1"/nvme[0-9][0-9][0-9] \
17+
;
18+
do
19+
[ ! -L "$syspath" ] ||
20+
guess_device "${syspath#$SYSFS_PATH}"
21+
done
22+
fi

0 commit comments

Comments
 (0)