Currently, only l2of_nvme() supports handling of partitions which will print the partition number at the end of an OF path. However, this feature is also useful for IDE and SCSI targets as well and mandatory for Macintosh systems.
Signed-off-by: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de> --- scripts/ofpathname | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/ofpathname b/scripts/ofpathname index c37c6bd..0e58005 100755 --- a/scripts/ofpathname +++ b/scripts/ofpathname @@ -519,6 +519,13 @@ l2of_ide() if [[ -z $link ]]; then err $ERR_NO_SYSFS_DEVINFO fi + + # partition number: N in sd*N + local devpart="${DEVICE##*[a-z]}" + if [[ $devpart = $DEVICE ]]; then + devpart='' # no partition number + fi + cd $link # get the device number @@ -584,6 +591,13 @@ l2of_vd() if [[ -z $OF_PATH ]]; then err $ERR_NO_OFPATH fi + + # No partition specified. + if [[ -z $devpart ]]; then + return + fi + + OF_PATH="${OF_PATH}:${devpart}" } # @@ -786,6 +800,12 @@ l2of_scsi() err $ERR_NOT_CONFIG fi + # partition number: N in sd*N + local devpart="${DEVICE##*[a-z]}" + if [[ $devpart = $DEVICE ]]; then + devpart='' # no partition number + fi + # follow the 'device' link local link=`get_link "device"` if [[ -z $link ]]; then @@ -944,6 +964,13 @@ l2of_scsi() OF_PATH=$OF_PATH/sd@$ID,$LUN fi fi + + # No partition specified. + if [[ -z $devpart ]]; then + return + fi + + OF_PATH="${OF_PATH}:${devpart}" } # -- 2.26.1