Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dracut-functions): avoid awk in get_maj_min() #15

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

pvalena
Copy link
Collaborator

@pvalena pvalena commented Aug 9, 2024

The get_maj_min() cache lookup is commonly used
across many flows. While awk should be available,
some highly constrained environments may not have it.
A second call to grep can provide the same behaviour
without adding a dependnecy.

Lines in the cache will be of the form "/dev/sda2 8:2".
awk '{print $NF}' returns the last word of a matching line. Since
the initial matching regex is so specific a second call to grep can
easily extract the last word.

(cherry picked commit ec7efd5)

Related: RHEL-47145

(We've rebased anyway.)

@pvalena
Copy link
Collaborator Author

pvalena commented Aug 19, 2024

Reason: performance enhancement

The `get_maj_min()` cache lookup is commonly used
across many flows. While `awk` should be available,
some highly constrained environments may not have it.
A second call to `grep` can provide the same behaviour
without adding a dependnecy.

Lines in the cache will be of the form "/dev/sda2 8:2".
`awk '{print $NF}'` returns the last word of a matching line. Since
the initial matching regex is so specific a second call to grep can
easily extract the last word.

(cherry picked commit ec7efd5)

Related: RHEL-47145
@pvalena pvalena force-pushed the rhel10-get_maj_min branch from 22eae90 to 9b94bc7 Compare August 19, 2024 10:18
@pvalena
Copy link
Collaborator Author

pvalena commented Aug 19, 2024

Easyfix, LGTM.

@pvalena pvalena merged commit d18bbc3 into main Aug 19, 2024
20 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants