searching for major and minor to map between /sys to /dev devices - #14271
Conversation
0182e69 to
a8e7516
Compare
a8e7516 to
061fbe7
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR implements functionality to map between /sys and /dev device paths by utilizing major and minor device numbers, addressing scenarios where video device indices may differ between the two directories (e.g., in unprivileged containers).
Key changes:
- Adds major/minor number extraction and device mapping functionality
- Refactors device enumeration into smaller, focused functions
- Updates existing functions to use the new mapping system
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/linux/backend-v4l2.h | Adds new function declarations and data structures for device mapping |
| src/linux/backend-v4l2.cpp | Implements major/minor extraction, device mapping logic, and refactors enumeration functions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // dev file is in paths: | ||
| // - /sys/class/video4linux/videoX/dev for video files | ||
| // - /sys/class/d4xx-class/d4xx-dfu-30-XXXa for mipi dfu files | ||
|
|
||
| // dev file contains major_number:minor_number | ||
| // while major_number is always 81 for video4linux devices and is 506 for d4xx-class devices |
There was a problem hiding this comment.
The comment states that major numbers are 'always 81' and 'always 506' for specific device types. This is too absolute and may not be true across all systems or kernel versions. Consider using 'typically' or 'commonly' instead of 'always'.
| // dev file is in paths: | |
| // - /sys/class/video4linux/videoX/dev for video files | |
| // - /sys/class/d4xx-class/d4xx-dfu-30-XXXa for mipi dfu files | |
| // dev file contains major_number:minor_number | |
| // while major_number is always 81 for video4linux devices and is 506 for d4xx-class devices | |
| // while major_number is typically 81 for video4linux devices and typically 506 for d4xx-class devices |
| { | ||
| std::vector<std::pair<std::string, std::string>> v4l_to_dev_video_paths; | ||
| // building vector of /dev/videoX files with path, major, minor | ||
| std::vector<path_and_identifier> dev_videos = collect_dev_video_path_and_identifier(); |
There was a problem hiding this comment.
If this returned a vector of all /dev device nodes and their major/minor numbers, the following would still work, correct?
| // going over video paths like /sys/class/video4linux/videoX | ||
| // find their mapping in /dev/videoY | ||
| // above videoX and videoY are often the same, but not always - for example when working in unprivileged container | ||
| // above videoX and videoY are often the same, but not alway |
| // for example when working in unprivileged container, the name in /dev even not be with the name "video" | ||
| // (depends how the mapping of the video devices has been done for the container building) |
There was a problem hiding this comment.
I would say:
// for example when working with unprivileged containers, the name in /dev may not contain the string "video"
// (depends on how the devices have been mapped (bind-mounted) into the container)
Tracked by: RSDSO-20543