-
-
Notifications
You must be signed in to change notification settings - Fork 14
linsysfs: expose SMBIOS DMI identification #519
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| PACKAGE= tests | ||
|
|
||
| TESTSDIR= ${TESTSBASE}/sys/fs/linsysfs | ||
|
|
||
| ATF_TESTS_SH+= dmi_id_test | ||
|
|
||
| .include <bsd.test.mk> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| #!/bin/sh | ||
|
|
||
| atf_test_case dmi_id cleanup | ||
| dmi_id_head() | ||
| { | ||
| atf_set "descr" "Verify Linux-compatible DMI identification files" | ||
| atf_set "require.user" "root" | ||
| } | ||
|
|
||
| dmi_id_body() | ||
| { | ||
| atf_require_prog kenv | ||
| atf_require_prog kldload | ||
| atf_require_prog kldstat | ||
| atf_require_prog mount | ||
| atf_require_prog stat | ||
| atf_require_prog umount | ||
|
|
||
| if ! kldstat -q -m linsysfs; then | ||
| atf_check -s exit:0 kldload linsysfs | ||
| touch linsysfs_loaded | ||
| fi | ||
|
|
||
| mkdir mnt | ||
| atf_check -s exit:0 mount -t linsysfs linsysfs "$(pwd)/mnt" | ||
| touch linsysfs_mounted | ||
|
|
||
| found=0 | ||
| while read -r name key; do | ||
| if value=$(kenv "${key}" 2>/dev/null); then | ||
| found=1 | ||
| atf_check -s exit:0 -o inline:"${value}\n" \ | ||
| cat "mnt/class/dmi/id/${name}" | ||
| atf_check -s exit:0 -o inline:"444\n" \ | ||
| stat -f '%Lp' "mnt/class/dmi/id/${name}" | ||
| elif [ -e "mnt/class/dmi/id/${name}" ]; then | ||
| atf_fail "${name} exists without ${key}" | ||
| fi | ||
| done <<-EOF | ||
| sys_vendor smbios.system.maker | ||
| product_name smbios.system.product | ||
| board_vendor smbios.planar.maker | ||
| board_name smbios.planar.product | ||
| bios_vendor smbios.bios.vendor | ||
| bios_version smbios.bios.version | ||
| chassis_vendor smbios.chassis.maker | ||
| EOF | ||
|
|
||
| if [ "${found}" -eq 0 ]; then | ||
| atf_skip "no SMBIOS identification values are available" | ||
| fi | ||
| } | ||
|
|
||
| dmi_id_cleanup() | ||
| { | ||
| if [ -f linsysfs_mounted ]; then | ||
| umount "$(pwd)/mnt" >/dev/null 2>&1 || true | ||
| fi | ||
| if [ -f linsysfs_loaded ]; then | ||
| kldunload linsysfs >/dev/null 2>&1 || true | ||
| fi | ||
| } | ||
|
|
||
| atf_init_test_cases() | ||
| { | ||
| atf_add_test_case dmi_id | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
issue (broader_impact): The
/sys/class/dmi/idinterface exposes only seven DMI attributes and omits standard fields such asproduct_uuid,product_serial,product_version,bios_date,board_version,board_serial,chassis_type, and their related fields. Linux applications that probe any of those standard paths receiveENOENTand can still fall back to SMBIOS scanning through/dev/mem, so the new interface does not reliably prevent the fallback described in the PR.Triggers: When a hardware-identification application requires a standard DMI attribute not included in this table.
Suggested fix: Add the supported non-sensitive standard DMI attributes to
linsysfs_dmi_fields, or explicitly limit the interface and callers to the subset that is guaranteed to be available.