-
Notifications
You must be signed in to change notification settings - Fork 26
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 udev rule for EBS mappings #98
Fix udev rule for EBS mappings #98
Conversation
sources/ghostdog/src/main.rs
Outdated
Ok(String::from_utf8_lossy(device_name) | ||
.replace("/dev/", "") | ||
.trim_end() | ||
.to_string()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it feels a bit loose not to anchor this to the start of the string:
Ok(String::from_utf8_lossy(device_name) | |
.replace("/dev/", "") | |
.trim_end() | |
.to_string()) | |
Ok(String::from_utf8_lossy(device_name) | |
.trim_start_matches("/dev/") | |
.trim_end() | |
.to_string()) |
sources/ghostdog/src/main.rs
Outdated
let mut device_info: Vec<u8> = vec![0; NVME_IDENTIFY_DATA_SIZE - 1024]; | ||
let mut padding = vec![32; NVME_IDENTIFY_DATA_SIZE - device_info.len() - device_name.len()]; | ||
device_info.append(&mut device_name); | ||
device_info.append(&mut padding); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could factor this into a helper function now that it's repeated
In certain workflows, EC2 adds `/dev/` to the device name. Remove it, otherwise the symlink created by `udev` will point to the wrong path. Signed-off-by: Arnaldo Garcia Rincon <agarrcia@amazon.com>
Create the symlinks to the actual devices under `/dev/by-ebs-id` so that the names don't collide with actual devices created by the kernel. Signed-off-by: Arnaldo Garcia Rincon <agarrcia@amazon.com>
96e0872
to
8472149
Compare
(addressed nits on ghostdog) |
Issue number:
#97
Description of changes:
With this change, symlinks to the underlying EBS volumes will be created under
/dev/by-ebs-id
instead of the root of/dev
. This will help prevent collisions with actual devices created by the kernel (as described in this amazonlinux/amazon-ec2-utils#37).As part of this change,
/dev/
will be removed from the device name if it is found after querying the device identifier, so that only the device id is returned to udev.Testing done:
I ran my change in an EC2 instance, and confirmed that the devices are listed under
/dev/by-ebs-id
when the mapping is added:I confirmed that in the workflow that prepends the device ID with
/dev/
, this prefix is removed and the symlink is created under/dev/by-ebs-id/
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.