Skip to content

Commit

Permalink
* Further nvme drive support *
Browse files Browse the repository at this point in the history
continuing 42d04a7

see #1115
  • Loading branch information
wdlkmpx committed Dec 25, 2017
1 parent 1b588d2 commit 3edf4a4
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 41 deletions.
9 changes: 4 additions & 5 deletions initrd-progs/0initrd/init
Expand Up @@ -855,7 +855,7 @@ $TRY_PARTS_LAST"

get_part_info() {
probedisk > /tmp/ALLDRVS
ls -1 /sys/block | grep -E '^scd|^sd|^mmc|^sr' > /tmp/ALLDRVS0
ls -1 /sys/block | grep -E '^scd|^sd|^mmc|^sr|^nvme' > /tmp/ALLDRVS0
PCPARTSALL="$(/sbin/probepart_init -k)"
HAVE_PARTS="$(echo "$PCPARTSALL" | grep '^/dev/' | cut -f 1-2 -d '|' | grep -E 'f2fs|udf|iso9660|ext2|ext3|ext4|reiserfs|msdos|vfat|minix|ntfs' | sed -e 's%/dev/%%')"
[ "$PDEBUG" ] && echo "$HAVE_PARTS" > /tmp/HAVE_PARTS
Expand Down Expand Up @@ -1323,10 +1323,9 @@ if [ "$PUPSAVE" ];then #refine pupmode
PUPSAVE_DRV="${PUPSAVE_DRV%[0-9]}"
PUPSAVE_DRV="${PUPSAVE_DRV%[0-9]}"
#remove any trailing 'p'
[ "${PUPSAVE_DRV:0:6}" = "mmcblk" ] && PUPSAVE_DRV="${PUPSAVE_DRV%p}"
# not sure about this, I don't have any nvme devices to test
#remove any trailing 'n'
[ "${PUPSAVE_DRV:0:4}" = "nvme" ] && PUPSAVE_DRV="${PUPSAVE_DRV%n}"
case $PUPSAVE_DRV in mmcblk*|nvme*) # mmcblk0p nvme0n1p
PUPSAVE_DRV="${PUPSAVE_DRV%p}" ;;
esac
fi
if probedisk ${PUPSAVE_DRV} -card-as-usbflash | grep -q '|usbflash|' ; then
echo "*** Pupsave is located in a flash storage device: $PUPSAVE_DRV" #debug
Expand Down
2 changes: 1 addition & 1 deletion initrd-progs/0initrd/init_full_install
Expand Up @@ -207,7 +207,7 @@ ensure_mounted() {

get_part_info() {
probedisk > /tmp/ALLDRVS
ls -1 /sys/block | grep -E '^scd|^sd|^mmc|^sr' > /tmp/ALLDRVS0
ls -1 /sys/block | grep -E '^scd|^sd|^mmc|^sr|^nvme' > /tmp/ALLDRVS0
PCPARTSALL="$(/sbin/probepart_init -k)"
HAVE_PARTS="$(echo "$PCPARTSALL" | grep '^/dev/' | cut -f 1-2 -d '|' | grep -E 'f2fs|udf|iso9660|ext2|ext3|ext4|reiserfs|msdos|vfat|minix|ntfs' | sed -e 's%/dev/%%')"
[ "$PDEBUG" ] && echo "$HAVE_PARTS" > /tmp/HAVE_PARTS
Expand Down
2 changes: 1 addition & 1 deletion initrd-progs/0initrd/sbin/debugsave
Expand Up @@ -20,7 +20,7 @@ dmesg > /tmp/dmesg.txt

#-----------------------------------------------------------

PARTITIONS=$(cat /proc/partitions | grep -E -o 'sd[a-z][1-9]|hd[a-z][1-9]|mmcblk[0-9]p[0-9]' | tr '\n' ' ')
PARTITIONS=$(cat /proc/partitions | grep -E -o 'sd[a-z][1-9]|hd[a-z][1-9]|mmcblk[0-9]p[0-9]|nvme[0-9]n[0-9]p[0-9]' | tr '\n' ' ')

if [ "$(echo $PARTITIONS)" = "" ] ; then
echo "Sorry, no partitions were detected"
Expand Down
11 changes: 7 additions & 4 deletions initrd-progs/0initrd/sbin/probedisk
Expand Up @@ -247,10 +247,13 @@ done
# for hotplug drives, remove it and it will disappear from /sys/block, however
# still shows up in 'mount' if hasn't been unmounted.
for ONEMNTD in $MNTDDEVS ; do
case $ONEMNTD in
hd*|sd*|sr*) MNTDDRVs="`echo -n "$ONEMNTD" | cut -b 1-3` " ;;
scd*) MNTDDRVs="`echo -n "$ONEMNTD" | cut -b 1-4` " ;;
mmc*) MNTDDRVs="`echo -n "$ONEMNTD" | cut -b 1-7` " ;;
# remove up to 3 trailing digits
MNTDDRVs="${ONEMNTD%[0-9]}"
MNTDDRVs="${MNTDDRVs%[0-9]}"
MNTDDRVs="${MNTDDRVs%[0-9]}"
# remove any trailing 'p' (mmcblk0p nvme0n1p)
case $MNTDDRVs in mmcblk*|nvme*)
MNTDDRVs="${MNTDDRVs%p}" ;;
esac
#prints to system log and to stderr...
[ "`echo "$ALLDRVS" | grep "$MNTDDRVs"`" = "" ] && logger -s "PROBEDISK ERROR: MOUNTED UNPLUGGED $ONEMNTD"
Expand Down
4 changes: 2 additions & 2 deletions initrd-progs/0initrd/sbin/probepart_init
Expand Up @@ -24,11 +24,11 @@ echo "PARTITIONS=${PARTITIONS}" > /tmp/probepart.log #101127
PARTNAMES="`echo "$PARTITIONS" | cut -f 2 -d ' '`" #120602

#101127 for comparison, log this... 110125 restore hd...
SYSBLOCKSUB="`ls -1 /sys/block/*/ | grep -E '^hd|^scd|^sd|^mmc|^sr' | tr '\n' ' '`"
SYSBLOCKSUB="`ls -1 /sys/block/*/ | grep -E '^hd|^scd|^sd|^mmc|^sr|^nvme' | tr '\n' ' '`"
echo "SYSBLOCKSUB=${SYSBLOCKSUB}" >> /tmp/probepart.log #101127

#all disk devices...
ALLDRVS="`ls -1 /sys/block | grep -E '^scd|^sd|^mmc|^sr'`"
ALLDRVS="`ls -1 /sys/block | grep -E '^scd|^sd|^mmc|^sr|^nvme'`"
[ -e /proc/ide ] && ALLDRVS="${ALLDRVS}
`ls -1 /proc/ide | grep '^hd'`" #110125 120602
echo "ALLDRVS=${ALLDRVS}" >> /tmp/probepart.log #101127 for debugging.
Expand Down
@@ -1,11 +1,15 @@
#!/bin/bash

echo '<JWM>'
while read a b c d; do
PARTITION=$d
DRIVE=${d//[0-9]/}
while read a b c d
do
PARTITION=$d
DRIVE="${d%[0-9]}"
DRIVE="${DRIVE%[0-9]}"
DRIVE="${DRIVE%[0-9]}"
DRIVE=${DRIVE%p}
case $PARTITION in
sd[a-z][0-9]*)
sd[a-z][0-9]*|nvme[0-9]n[0-9]p[0-9]*)
#[ $c -le 1 ] && continue # extd partition
[ "$(grep "$DRIVE" /root/.usb-drive-log-probedisk)" ] && MEDIA="usbdrv" || MEDIA="drive"
FILESYSTEM=$(guess_fstype /dev/$PARTITION 2>/dev/null)
Expand Down
7 changes: 4 additions & 3 deletions woof-code/rootfs-skeleton/bin/mount
Expand Up @@ -147,9 +147,10 @@ fi
if [ $RETVAL -eq 0 -a "$(pidof ROX-Filer)" != "" ];then
DEVNAME="`busybox mount | tail -n 1 | grep '^/dev/' | cut -f 1 -d ' ' | cut -f 3 -d '/'`"
if [ "$DEVNAME" != "" ];then
DRVNAME="`echo -n "$DEVNAME" | cut -c 1-3`"
#special case, SD card /dev/mmcblk0p1...
[ "$DRVNAME" = "mmc" ] && DRVNAME="`echo -n "$DEVNAME" | sed -e 's/p[0-9]$//'`"
case $DEVNAME in #mmcblk0p1, nvme0n1p1
mmcblk*|nvme*) DRVNAME="${DEVNAME%p*}" ;; #remove trailing p*
*) DRVNAME="`echo -n "$DEVNAME" | cut -c 1-3`" ;;
esac
xDRVNAME="$DRVNAME" #v404
[ -d /root/.pup_event/drive_${DEVNAME} ] && DRVNAME="$DEVNAME" #icon for each partition.
if [ -d /root/.pup_event/drive_${DRVNAME} ];then
Expand Down
7 changes: 4 additions & 3 deletions woof-code/rootfs-skeleton/bin/umount
Expand Up @@ -30,9 +30,10 @@ fi
#ROX: if there is a desktop icon (see pup_event_frontend_d), then refresh it...
if [ $RETVAL -eq 0 -a "$(pidof ROX-Filer)" != "" ];then
. /usr/local/pup_event/frontend_funcs #rox
DRVNAME="`echo -n "$DEVNAME" | cut -b 1-3`" #ex: DRVNAME=sda
#special case, SD card /dev/mmcblk0p1...
[ "$DRVNAME" = "mmc" ] && DRVNAME="`echo -n "$DEVNAME" | sed -e 's/p[0-9]$//'`"
case $DEVNAME in #mmcblk0p1, nvme0n1p1
mmcblk*|nvme*) DRVNAME="${DEVNAME%p*}" ;; #remove trailing p*
*) DRVNAME="`echo -n "$DEVNAME" | cut -c 1-3`" ;;
esac
DRV_CATEGORY="`probedisk /dev/${DRVNAME} | cut -f 2 -d '|'`"
[ -d /root/.pup_event/drive_${DEVNAME} ] && DRVNAME="$DEVNAME" #icon for each partition. ex: DRVNAME=sda1
if [ -d /root/.pup_event/drive_${DRVNAME} ];then
Expand Down
3 changes: 2 additions & 1 deletion woof-code/rootfs-skeleton/etc/rc.d/rc.sysinit
Expand Up @@ -429,6 +429,7 @@ chgrp floppy /dev/fd[0-9] 2>/dev/null
chgrp disk /dev/[hs]d[a-z]* 2>/dev/null
chgrp disk /dev/fuse
chgrp disk /dev/mmcblk* 2>/dev/null
chgrp disk /dev/nvme* 2>/dev/null
chgrp cdrom /dev/sr[0-9] 2>/dev/null
chmod 666 /dev/usb/* #rcrsn51 finally added 140618
chmod -R 1777 /dev/shm #SFR .. ditto
Expand Down Expand Up @@ -469,7 +470,7 @@ if [ ! -d /initrd ];then #full hd installation.
#we can determine ide/sata drives at this point (drivers builtin to kernel)...
#define ATADRIVES as all internal ide/pata/sata drives (not usb), except optical...
#110712 rewritten to handle kernel with usb driver built-in...
ALLDRVS0="`find /sys/block -maxdepth 1 -name 'mmc*' -o -name 'sd*' -o -name 'sr*' | xargs -l readlink 2>/dev/null | grep -v '/usb[0-9]' | rev | cut -f 1 -d '/' | rev`" #all *except* usb!
ALLDRVS0="`find /sys/block -maxdepth 1 -name 'mmc*' -o -name 'sd*' -o -name 'sr*' -o -name 'nvme*' | xargs -l readlink 2>/dev/null | grep -v '/usb[0-9]' | rev | cut -f 1 -d '/' | rev`" #all *except* usb!
ALLDRVS="`echo "$ALLDRVS0" | tr '\n' ' '`" #all *except* usb!
[ "$ALLDRVS" = " " ] && ALLDRVS=""
ATADRIVES="`echo "$ALLDRVS0" | grep -v '^sr' | tr '\n' ' '`"
Expand Down
7 changes: 4 additions & 3 deletions woof-code/rootfs-skeleton/sbin/mount.crypto_LUKS
Expand Up @@ -73,9 +73,10 @@ if [ $RETVAL -eq 0 -a "$(pidof ROX-Filer)" != "" ];then
DEVNAME=${DEVNAME##*/} # basename $DEVNAME
DEVNAME=${DEVNAME#lukspartition_} # remove lukspartition_ (ex: lukspartition_sdb1)
if [ "$DEVNAME" != "" ];then
DRVNAME="`echo -n "$DEVNAME" | cut -c 1-3`"
#special case, SD card /dev/mmcblk0p1...
[ "$DRVNAME" = "mmc" ] && DRVNAME="`echo -n "$DEVNAME" | sed -e 's/p[0-9]$//'`"
case $DEVNAME in #mmcblk0p1, nvme0n1p1
mmcblk*|nvme*) DRVNAME="${DEVNAME%p*}" ;; #remove trailing p*
*) DRVNAME="`echo -n "$DEVNAME" | cut -c 1-3`" ;;
esac
xDRVNAME="$DRVNAME" #v404
[ -d /root/.pup_event/drive_${DEVNAME} ] && DRVNAME="$DEVNAME" #icon for each partition.
if [ -d /root/.pup_event/drive_${DRVNAME} ];then
Expand Down
11 changes: 7 additions & 4 deletions woof-code/rootfs-skeleton/sbin/probedisk
Expand Up @@ -247,10 +247,13 @@ done
# for hotplug drives, remove it and it will disappear from /sys/block, however
# still shows up in 'mount' if hasn't been unmounted.
for ONEMNTD in $MNTDDEVS ; do
case $ONEMNTD in
hd*|sd*|sr*) MNTDDRVs="`echo -n "$ONEMNTD" | cut -b 1-3` " ;;
scd*) MNTDDRVs="`echo -n "$ONEMNTD" | cut -b 1-4` " ;;
mmc*) MNTDDRVs="`echo -n "$ONEMNTD" | cut -b 1-7` " ;;
# remove up to 3 trailing digits
MNTDDRVs="${ONEMNTD%[0-9]}"
MNTDDRVs="${MNTDDRVs%[0-9]}"
MNTDDRVs="${MNTDDRVs%[0-9]}"
# remove any trailing 'p' (mmcblk0p nvme0n1p)
case $MNTDDRVs in mmcblk*|nvme*)
MNTDDRVs="${MNTDDRVs%p}" ;;
esac
#prints to system log and to stderr...
[ "`echo "$ALLDRVS" | grep "$MNTDDRVs"`" = "" ] && logger -s "PROBEDISK ERROR: MOUNTED UNPLUGGED $ONEMNTD"
Expand Down
8 changes: 4 additions & 4 deletions woof-code/rootfs-skeleton/sbin/umount.crypto_LUKS
Expand Up @@ -61,10 +61,10 @@ if [ "$1" ] ; then

if [ $RETVAL -eq 0 -a "$(pidof ROX-Filer)" != "" ];then
. /usr/local/pup_event/frontend_funcs #rox
DEVNAME=${MOUNTPOINT##*/} #basename $MOUNTPOINT
DRVNAME="`echo -n "$DEVNAME" | cut -b 1-3`" #ex: DRVNAME=sda
#special case, SD card /dev/mmcblk0p1...
[ "$DRVNAME" = "mmc" ] && DRVNAME="`echo -n "$DEVNAME" | sed -e 's/p[0-9]$//'`"
case $DEVNAME in #mmcblk0p1, nvme0n1p1
mmcblk*|nvme*) DRVNAME="${DEVNAME%p*}" ;; #remove trailing p*
*) DRVNAME="`echo -n "$DEVNAME" | cut -c 1-3`" ;;
esac
DRV_CATEGORY="`probedisk /dev/${DRVNAME} | cut -f 2 -d '|'`"
[ -d /root/.pup_event/drive_${DEVNAME} ] && DRVNAME="$DEVNAME" #icon for each partition. ex: DRVNAME=sda1
if [ -d /root/.pup_event/drive_${DRVNAME} ];then
Expand Down
4 changes: 2 additions & 2 deletions woof-code/rootfs-skeleton/usr/local/bin/drive_all
Expand Up @@ -376,8 +376,8 @@ do
if [ $? -ne 0 ];then
#/tmp/pup_event_frontend_block_request is used in /sbin/pup_event_frontend_d to refresh drv...
case $xONEDRVNAME in
mmcblk*)
yONEDRV="`echo -n "$xONEDRVNAME" | cut -c 1-7`"
mmcblk*|nvme*) #mmcblk1p1 nvme0n1p1
yONEDRV=${xONEDRVNAME%p*} #remove trailing p*
;;
*)
yONEDRV="`echo -n "$xONEDRVNAME" | cut -c 1-3`"
Expand Down
8 changes: 4 additions & 4 deletions woof-code/rootfs-skeleton/usr/local/pup_event/frontend_change
Expand Up @@ -38,7 +38,7 @@ PARAMS="$@"
DRVCHANGE="$(echo -n "$PARAMS" | grep -v ' ' | grep '^cha' | cut -f 2 -d ':')"
if [ "$DRVCHANGE" ];then
#we want to completely refresh the desktop drive icons...
DRV_NAME="$(echo -n "$DRVCHANGE" | grep -o -E '^sd[a-z]|^hd[a-z]|^mmcblk[0-9]|^nvme[0-9]')" #remove any partition number.
DRV_NAME="$(echo -n "$DRVCHANGE" | grep -o -E '^sd[a-z]|^hd[a-z]|^mmcblk[0-9]|^nvme[0-9]n[0-9]')" #remove any partition number.
[ ! "$DRV_NAME" ] && exit #precaution.
if [ -e /root/.pup_event/drive_${DRV_NAME} ];then
remove_pinboard_func #needs DRV_NAME
Expand All @@ -51,7 +51,7 @@ fi
SCRN_X="`cat /tmp/pup_event_frontend_scrn_x`" #written by frontend_startup.
SCRN_Y="`cat /tmp/pup_event_frontend_scrn_y`" # "

DRV_NAMES="$(echo -n "$PARAMS" | tr ' ' '\n' | cut -f 2 -d ':' | grep -E '^[hs]d[a-z]$|^mmcblk[0-9]$|^nvme[0-9]$|^sr|^fd' | sort -V -u)" #dump partitions. 130614
DRV_NAMES="$(echo -n "$PARAMS" | tr ' ' '\n' | cut -f 2 -d ':' | grep -E '^[hs]d[a-z]$|^mmcblk[0-9]$|^nvme[0-9]n[0-9]$|^sr|^fd' | sort -V -u)" #dump partitions. 130614
ALL_DEVSS="$(echo -n "$PARAMS" | tr ' ' '\n' | cut -f 2 -d ':' | sort -V -u)" #130614

for DRV_NAME in $DRV_NAMES #precaution, uevents might have more than one drive mixed in.
Expand Down Expand Up @@ -89,7 +89,7 @@ do
[ -e /sys/block/$DRV_NAME ] && ACTION='add'
fi
;;
sd*|mmc*)
sd*|mmc*|nvme*)
if [ -e /sys/block/$DRV_NAME ];then
ACTION='add'
else
Expand All @@ -111,7 +111,7 @@ do

ALL_CNT=`echo -n "$ALL_DEVS" | wc -w` #=1 then no partitions.
if [ $ALL_CNT -eq 1 ];then #precaution
[ "$(echo -n "$ALL_DEVS" | grep -v -E '^[hs]d[a-z]$|^mmcblk[0-9]$|^nvme[0-9]$|^sr|^fd')" != "" ] && ALL_CNT=99 #any non-0 number.
[ "$(echo -n "$ALL_DEVS" | grep -v -E '^[hs]d[a-z]$|^mmcblk[0-9]$|^nvme[0-9]n[0-9]$|^sr|^fd')" != "" ] && ALL_CNT=99 #any non-0 number.
fi

#code extracted from /sbin/probepart...
Expand Down

0 comments on commit 3edf4a4

Please sign in to comment.