fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
0df6fa791
master
1# NVME user space tooling for Linux 2# See: https://github.com/linux-nvme/nvme-cli 3 4set cmds list list-subsys id-ctrl id-ns id-ns-granularity id-ns-lba-format list-ns list-ctrl nvm-id-ctrl nvm-id-ns nvm-id-ns-lba-format primary-ctrl-caps list-secondary cmdset-ind-id-ns ns-descs id-nvmset id-uuid id-iocs id-domain list-endgrp create-ns delete-ns attach-ns detach-ns get-ns-id get-log telemetry-log fw-log changed-ns-list-log smart-log ana-log error-log effects-log endurance-log predictable-lat-log pred-lat-event-agg-log persistent-event-log endurance-event-agg-log lba-status-log resv-notif-log boot-part-log get-feature device-self-test self-test-log supported-log-pages fid-support-effects-log mi-cmd-support-effects-log media-unit-stat-log supported-cap-config-log set-feature set-property get-property format fw-commit fw-download admin-passthru io-passthru security-send security-recv get-lba-status capacity-mgmt resv-acquire resv-register resv-release resv-report dsm copy flush compare read write write-zeroes write-uncor verify sanitize sanitize-log reset subsystem-reset ns-rescan show-regs discover connect-all connect disconnect disconnect-all config gen-hostnqn show-hostnqn gen-dhchap-key check-dhchap-key gen-tls-key check-tls-key dir-receive dir-send virt-mgmt rpmb lockdown dim version help 5 6function __fish_print_nvme_from_nvme_cli 7# If jq is installed, we use the JSON output and parse it with jq. 8# Otherwise, we fallback to the "normal" output which doesn't make any 9# guarantees on the format. 10if command -q jq 11nvme list --output-format json| 12jq '.Devices[] | "\(.DevicePath)\t\(.ModelNumber) - \(.SerialNumber)"' --raw-output 13else 14nvme list --output-format normal| string match -r'^/dev/[^ \t]+' 15end 16end 17 18function __fish_print_nvme 19# We first try to get the list from the nvme command. If this doesn't yield 20# any results (e.g. when we are not root), we fallback to looking at file 21# names in /dev/. 22set -a list( __fish_print_nvme_from_nvme_cli ) 23 24if set -q list[ 1 ] 25printf "%s\n" $list 26else 27string match -vr --'p[0-9]+$' /dev/nvme* 28end 29end 30 31complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a list -d"List all NVMe devices and namespaces on machine" 32complete -c nvme -n"__fish_seen_subcommand_from list" -s v -l verbose -d"Increase verbosity" 33 34complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a list-subsys -d"List nvme subsystems" 35complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a id-ctrl -d"Send NVMe Identify Controller" 36complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a id-ns -d"Send NVMe Identify Namespace" 37complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a id-ns-granularity -d"Send NVMe Identify Namespace Granularity List" 38complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a id-ns-lba-format -d"Send NVMe Identify Namespace for the specified LBA Format index" 39complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a list-ns -d"Send NVMe Identify List" 40complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a list-ctrl -d"Send NVMe Identify Controller List" 41complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a nvm-id-ctrl -d"Send NVMe Identify Controller NVM Command Set" 42complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a nvm-id-ns -d"Send NVMe Identify Namespace NVM Command Set" 43complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a nvm-id-ns-lba-format -d"Send NVMe Identify Namespace NVM Command Set for the specified LBA Format index" 44complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a primary-ctrl-caps -d"Send NVMe Identify Primary Controller Capabilities" 45complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a list-secondary -d"List Secondary Controllers associated with a Primary Controller" 46complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a cmdset-ind-id-ns -d"I/O Command Set Independent Identify Namespace" 47complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a ns-descs -d"Send NVMe Namespace Descriptor List" 48complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a id-nvmset -d"Send NVMe Identify NVM Set List" 49complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a id-uuid -d"Send NVMe Identify UUID List" 50complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a id-iocs -d"Send NVMe Identify I/O Command Set" 51complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a id-domain -d"Send NVMe Identify Domain List" 52complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a list-endgrp -d"Send NVMe Identify Endurance Group List" 53complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a create-ns -d"Creates a namespace with the provided parameters" 54complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a delete-ns -d"Deletes a namespace from the controller" 55complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a attach-ns -d"Attaches a namespace to requested controller(s)" 56complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a detach-ns -d"Detaches a namespace from requested controller(s)" 57complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a get-ns-id -d"Retrieve the namespace ID of opened block device" 58complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a get-log -d"Generic NVMe get log, returns log in raw format" 59complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a telemetry-log -d"Retrieve FW Telemetry log write to file" 60complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a fw-log -d"Retrieve FW Log" 61complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a changed-ns-list-log -d"Retrieve Changed Namespace List" 62complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a smart-log -d"Retrieve SMART Log" 63complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a ana-log -d"Retrieve ANA Log" 64complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a error-log -d"Retrieve Error Log" 65complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a effects-log -d"Retrieve Command Effects Log" 66complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a endurance-log -d"Retrieve Endurance Group Log" 67complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a predictable-lat-log -d"Retrieve Predictable Latency per Nvmset Log" 68complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a pred-lat-event-agg-log -d"Retrieve Predictable Latency Event Aggregate Log" 69complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a persistent-event-log -d"Retrieve Persistent Event Log" 70complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a endurance-event-agg-log -d"Retrieve Endurance Group Event Aggregate Log" 71complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a lba-status-log -d"Retrieve LBA Status Information Log" 72complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a resv-notif-log -d"Retrieve Reservation Notification Log" 73complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a boot-part-log -d"Retrieve Boot Partition Log" 74complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a get-feature -d"Get feature and show the resulting value" 75complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a device-self-test -d"Perform the necessary tests to observe the performance" 76complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a self-test-log -d"Retrieve the SELF-TEST Log" 77complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a supported-log-pages -d"Retrieve the Supported Log pages details" 78complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a fid-support-effects-log -d"Retrieve FID Support and Effects log" 79complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a mi-cmd-support-effects-log -d"Retrieve MI Command Support and Effects log" 80complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a media-unit-stat-log -d"Retrieve the configuration and wear of media units" 81complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a supported-cap-config-log -d"Retrieve the list of Supported Capacity Configuration Descriptors" 82complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a set-feature -d"Set a feature and show the resulting value" 83complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a set-property -d"Set a property and show the resulting value" 84complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a get-property -d"Get a property and show the resulting value" 85complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a format -d"Format namespace with new block format" 86complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a fw-commit -d"Verify and commit firmware to a specific slot" 87complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a fw-download -d"Download new firmware" 88complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a admin-passthru -d"Submit an arbitrary admin command" 89complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a io-passthru -d"Submit an arbitrary IO command" 90complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a security-send -d"Submit a Security Send command" 91complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a security-recv -d"Submit a Security Receive command" 92complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a get-lba-status -d"Submit a Get LBA Status command" 93complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a capacity-mgmt -d"Submit Capacity Management Command" 94complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a resv-acquire -d"Submit a Reservation Acquire" 95complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a resv-register -d"Submit a Reservation Register" 96complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a resv-release -d"Submit a Reservation Release" 97complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a resv-report -d"Submit a Reservation Report" 98complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a dsm -d"Submit a Data Set Management command" 99complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a copy -d"Submit a Simple Copy command" 100complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a flush -d"Submit a Flush command" 101complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a compare -d"Submit a Compare command" 102complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a read -d"Submit a read command" 103complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a write -d"Submit a write command" 104complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a write-zeroes -d"Submit a write zeroes command" 105complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a write-uncor -d"Submit a write uncorrectable command" 106complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a verify -d"Submit a verify command" 107complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a sanitize -d"Submit a sanitize command" 108complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a sanitize-log -d"Retrieve sanitize log" 109complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a reset -d"Resets the controller" 110complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a subsystem-reset -d"Resets the subsystem" 111complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a ns-rescan -d"Rescans the NVME namespaces" 112complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a show-regs -d"Shows the controller registers or properties" 113complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a discover -d"Discover NVMeoF subsystems" 114complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a connect-all -d"Discover and Connect to NVMeoF subsystems" 115complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a connect -d"Connect to NVMeoF subsystem" 116complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a disconnect -d"Disconnect from NVMeoF subsystem" 117complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a disconnect-all -d"Disconnect from all connected NVMeoF subsystems" 118complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a config -d"Configuration of NVMeoF subsystems" 119complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a gen-hostnqn -d"Generate NVMeoF host NQN" 120complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a show-hostnqn -d"Show NVMeoF host NQN" 121complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a gen-dhchap-key -d"Generate NVMeoF DH-HMAC-CHAP host key" 122complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a check-dhchap-key -d"Validate NVMeoF DH-HMAC-CHAP host key" 123complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a gen-tls-key -d"Generate NVMeoF TLS PSK" 124complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a check-tls-key -d"Validate NVMeoF TLS PSK" 125complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a dir-receive -d"Submit a Directive Receive command" 126complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a dir-send -d"Submit a Directive Send command" 127complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a virt-mgmt -d"Manage Flexible Resources between Primary and Secondary Controller " 128complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a rpmb -d"Replay Protection Memory Block commands" 129complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a lockdown -d"Submit Lockdown command" 130complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a dim -d"Send Discovery Information Management command to a Discovery Controller" 131complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a version -d"Show version" 132 133complete -c nvme -f -n"not __fish_seen_subcommand_from $cmds " -a help -d"Display help" 134complete -c nvme -f -n"__fish_seen_subcommand_from help" -a" $cmds " 135 136complete -c nvme -n"__fish_seen_subcommand_from list list-subsys id-ctrl id-ns list-ns list-ctrl nvm-id-ctrl primary-ctrl-caps cmdset-ind-id-ns ns-descs id-nvmset id-iocs id-domain list-endgrp fw-log changed-ns-list-log smart-log ana-log error-log effects-log endurance-log predictable-lat-log pred-lat-event-agg-log persistent-event-log endurance-event-agg-log lba-status-log resv-notif-log boot-part-log self-test-log supported-log-pages fid-support-effects-log mi-cmd-support-effects-log get-lba-status resv-report sanitize-log show-regs discover connect list list-subsys id-ctrl id-ns list-ns list-ctrl nvm-id-ctrl primary-ctrl-caps cmdset-ind-id-ns ns-descs id-nvmset id-iocs id-domain list-endgrp fw-log changed-ns-list-log smart-log ana-log error-log effects-log endurance-log predictable-lat-log pred-lat-event-agg-log persistent-event-log endurance-event-agg-log lba-status-log resv-notif-log boot-part-log self-test-log supported-log-pages fid-support-effects-log mi-cmd-support-effects-log get-lba-status resv-report sanitize-log show-regs discover connect list list-subsys id-ctrl id-ns list-ns list-ctrl nvm-id-ctrl primary-ctrl-caps cmdset-ind-id-ns ns-descs id-nvmset id-iocs id-domain list-endgrp fw-log changed-ns-list-log smart-log ana-log error-log effects-log endurance-log predictable-lat-log pred-lat-event-agg-log persistent-event-log endurance-event-agg-log lba-status-log resv-notif-log boot-part-log self-test-log supported-log-pages fid-support-effects-log mi-cmd-support-effects-log get-lba-status resv-report sanitize-log show-regs discover connect list list-subsys id-ctrl id-ns list-ns list-ctrl nvm-id-ctrl primary-ctrl-caps cmdset-ind-id-ns ns-descs id-nvmset id-iocs id-domain list-endgrp fw-log changed-ns-list-log smart-log ana-log error-log effects-log endurance-log predictable-lat-log pred-lat-event-agg-log persistent-event-log endurance-event-agg-log lba-status-log resv-notif-log boot-part-log self-test-log supported-log-pages fid-support-effects-log mi-cmd-support-effects-log get-lba-status resv-report sanitize-log show-regs discover connect" -x -s f -l output-format -d"Output format" -a"json\t normal\t" 137 138complete -c nvme -n"__fish_seen_subcommand_from id-ctrl id-ns nvm-id-ctrl primary-ctrl-caps cmdset-ind-id-ns ns-descs id-nvmset id-iocs id-domain fw-log changed-ns-list-log smart-log ana-log error-log effects-log endurance-log predictable-lat-log pred-lat-event-agg-log persistent-event-log endurance-event-agg-log lba-status-log resv-notif-log boot-part-log self-test-log supported-log-pages fid-support-effects-log mi-cmd-support-effects-log get-lba-status resv-report sanitize-log show-regs discover" -x -s f -l output-format -d"Output format" -a"binary\t" 139complete -c nvme -s h -l help -d"Display help" 140 141complete -c nvme -f -n"__fish_seen_subcommand_from id-ctrl id-ns list-ns list-ctrl nvm-id-ctrl primary-ctrl-caps cmdset-ind-id-ns ns-descs id-nvmset id-iocs id-domain list-endgrp create-ns delete-ns attach-ns detach-ns get-ns-id get-log telemetry-log fw-log changed-ns-list-log smart-log ana-log error-log effects-log endurance-log predictable-lat-log pred-lat-event-agg-log persistent-event-log endurance-event-agg-log lba-status-log resv-notif-log boot-part-log get-feature device-self-test self-test-log supported-log-pages fid-support-effects-log set-feature set-property get-property format fw-commit fw-download security-send security-recv get-lba-status capacity-mgmt resv-acquire resv-register resv-release resv-report dsm flush sanitize sanitize-log reset subsystem-reset ns-rescan show-regs dir-receive dir-send rpmb" -d"NVME device" -a"(__fish_print_nvme)"