From 3edf4a48e116471c7907d923390c4c24ba28847e Mon Sep 17 00:00:00 2001 From: wdlkmpx Date: Mon, 25 Dec 2017 19:28:23 +0800 Subject: [PATCH] * Further nvme drive support * continuing 42d04a73af1725751cfa52c0c3868d4edd57d9ed see #1115 --- initrd-progs/0initrd/init | 9 ++++----- initrd-progs/0initrd/init_full_install | 2 +- initrd-progs/0initrd/sbin/debugsave | 2 +- initrd-progs/0initrd/sbin/probedisk | 11 +++++++---- initrd-progs/0initrd/sbin/probepart_init | 4 ++-- .../usr/local/jwm_config/menu_build_places_drives | 12 ++++++++---- woof-code/rootfs-skeleton/bin/mount | 7 ++++--- woof-code/rootfs-skeleton/bin/umount | 7 ++++--- woof-code/rootfs-skeleton/etc/rc.d/rc.sysinit | 3 ++- woof-code/rootfs-skeleton/sbin/mount.crypto_LUKS | 7 ++++--- woof-code/rootfs-skeleton/sbin/probedisk | 11 +++++++---- woof-code/rootfs-skeleton/sbin/umount.crypto_LUKS | 8 ++++---- woof-code/rootfs-skeleton/usr/local/bin/drive_all | 4 ++-- .../usr/local/pup_event/frontend_change | 8 ++++---- 14 files changed, 54 insertions(+), 41 deletions(-) diff --git a/initrd-progs/0initrd/init b/initrd-progs/0initrd/init index 34a16de1d73..ce7033a79dc 100755 --- a/initrd-progs/0initrd/init +++ b/initrd-progs/0initrd/init @@ -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 @@ -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 diff --git a/initrd-progs/0initrd/init_full_install b/initrd-progs/0initrd/init_full_install index 71a92078223..ae8ba4001b3 100755 --- a/initrd-progs/0initrd/init_full_install +++ b/initrd-progs/0initrd/init_full_install @@ -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 diff --git a/initrd-progs/0initrd/sbin/debugsave b/initrd-progs/0initrd/sbin/debugsave index a59c30feba1..6b1ee661aad 100755 --- a/initrd-progs/0initrd/sbin/debugsave +++ b/initrd-progs/0initrd/sbin/debugsave @@ -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" diff --git a/initrd-progs/0initrd/sbin/probedisk b/initrd-progs/0initrd/sbin/probedisk index 36643fa8f35..4cfdce8bc6c 100755 --- a/initrd-progs/0initrd/sbin/probedisk +++ b/initrd-progs/0initrd/sbin/probedisk @@ -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" diff --git a/initrd-progs/0initrd/sbin/probepart_init b/initrd-progs/0initrd/sbin/probepart_init index 176ed8ab3cc..42075a42429 100755 --- a/initrd-progs/0initrd/sbin/probepart_init +++ b/initrd-progs/0initrd/sbin/probepart_init @@ -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. diff --git a/woof-code/rootfs-packages/jwm_config/usr/local/jwm_config/menu_build_places_drives b/woof-code/rootfs-packages/jwm_config/usr/local/jwm_config/menu_build_places_drives index fe1c8393a80..37c20cfe1c9 100755 --- a/woof-code/rootfs-packages/jwm_config/usr/local/jwm_config/menu_build_places_drives +++ b/woof-code/rootfs-packages/jwm_config/usr/local/jwm_config/menu_build_places_drives @@ -1,11 +1,15 @@ #!/bin/bash echo '' -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) diff --git a/woof-code/rootfs-skeleton/bin/mount b/woof-code/rootfs-skeleton/bin/mount index f8abc1e85eb..5c851223abf 100755 --- a/woof-code/rootfs-skeleton/bin/mount +++ b/woof-code/rootfs-skeleton/bin/mount @@ -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 diff --git a/woof-code/rootfs-skeleton/bin/umount b/woof-code/rootfs-skeleton/bin/umount index 5a5cb202eb6..085a63ac493 100755 --- a/woof-code/rootfs-skeleton/bin/umount +++ b/woof-code/rootfs-skeleton/bin/umount @@ -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 diff --git a/woof-code/rootfs-skeleton/etc/rc.d/rc.sysinit b/woof-code/rootfs-skeleton/etc/rc.d/rc.sysinit index c9f0a2cbd36..284d310b7ab 100755 --- a/woof-code/rootfs-skeleton/etc/rc.d/rc.sysinit +++ b/woof-code/rootfs-skeleton/etc/rc.d/rc.sysinit @@ -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 @@ -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' ' '`" diff --git a/woof-code/rootfs-skeleton/sbin/mount.crypto_LUKS b/woof-code/rootfs-skeleton/sbin/mount.crypto_LUKS index 83c1a4b07fc..344f89c4e77 100755 --- a/woof-code/rootfs-skeleton/sbin/mount.crypto_LUKS +++ b/woof-code/rootfs-skeleton/sbin/mount.crypto_LUKS @@ -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 diff --git a/woof-code/rootfs-skeleton/sbin/probedisk b/woof-code/rootfs-skeleton/sbin/probedisk index 36643fa8f35..4cfdce8bc6c 100755 --- a/woof-code/rootfs-skeleton/sbin/probedisk +++ b/woof-code/rootfs-skeleton/sbin/probedisk @@ -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" diff --git a/woof-code/rootfs-skeleton/sbin/umount.crypto_LUKS b/woof-code/rootfs-skeleton/sbin/umount.crypto_LUKS index 3d949cd3c9e..2b388ea5aa9 100755 --- a/woof-code/rootfs-skeleton/sbin/umount.crypto_LUKS +++ b/woof-code/rootfs-skeleton/sbin/umount.crypto_LUKS @@ -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 diff --git a/woof-code/rootfs-skeleton/usr/local/bin/drive_all b/woof-code/rootfs-skeleton/usr/local/bin/drive_all index 8ac26ea9db6..6eae36629dd 100755 --- a/woof-code/rootfs-skeleton/usr/local/bin/drive_all +++ b/woof-code/rootfs-skeleton/usr/local/bin/drive_all @@ -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`" diff --git a/woof-code/rootfs-skeleton/usr/local/pup_event/frontend_change b/woof-code/rootfs-skeleton/usr/local/pup_event/frontend_change index f6fce64f596..41aa68ecf9e 100755 --- a/woof-code/rootfs-skeleton/usr/local/pup_event/frontend_change +++ b/woof-code/rootfs-skeleton/usr/local/pup_event/frontend_change @@ -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 @@ -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. @@ -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 @@ -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...