File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -77,8 +77,10 @@ rm -rf $RPM_BUILD_ROOT
7777%changelog
7878* Thu Jan 18 2024 Keith Gable <gablk@amazon.com> - 2.2.0-1
7979- Corrected issue where an ec2-metadata error was written to stdout
80+ - Change ec2nvme-nsid to use Bash string manipulation to improve
81+ performance and reliability
8082
81- * Mon Jun 5 2023 Guillaume Delacour <delacoug@amazon.com> - 2.2.0-1
83+ * Mon Jun 5 2023 Guillaume Delacour <delacoug@amazon.com> - 2.2.0-1
8284- Add `--quiet` option to `ec2-metadata --help` output
8385- Add `-R`/`--region` option to `ec2-metadata` to discover the EC2 instance's region
8486
Original file line number Diff line number Diff line change 66# for the specific language governing permissions and limitations under
77# the License.
88
9- # Expected input if partition's kernel name like nvme0n1p2
10- if [ $# -eq 0 ] ; then
9+ # Expected input is partition's kernel name like nvme0n1p2 or nvme0n1, output would be 1
10+
11+ if [[ $# -ne 1 ]]; then
1112 exit 1
1213else
13- # extract ns id from partition's kernel name and export it
14- NSID=$( echo -n " $@ " | cut -f 3 -d ' n' | cut -f 1 -d ' p' )
14+ kernel_name=$1
15+
16+ # Remove nvme prefix (also deals with any /dev that might accidentally get passed in)
17+ prefix_removed=${kernel_name#* nvme* n}
18+
19+ # Remove partition suffix
20+ NSID=${prefix_removed% p* }
21+
1522 echo " _NS_ID=${NSID} "
1623fi
You can’t perform that action at this time.
0 commit comments