Skip to content

searching for major and minor to map between /sys to /dev devices - #14271

Merged
remibettan merged 10 commits into
realsenseai:developmentfrom
remibettan:enabling_back_unprivileged_container_keeping_enum_fast
Sep 11, 2025
Merged

searching for major and minor to map between /sys to /dev devices#14271
remibettan merged 10 commits into
realsenseai:developmentfrom
remibettan:enabling_back_unprivileged_container_keeping_enum_fast

Conversation

@remibettan

@remibettan remibettan commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Tracked by: RSDSO-20543

@remibettan
remibettan force-pushed the enabling_back_unprivileged_container_keeping_enum_fast branch 2 times, most recently from 0182e69 to a8e7516 Compare September 4, 2025 10:53
@remibettan
remibettan force-pushed the enabling_back_unprivileged_container_keeping_enum_fast branch from a8e7516 to 061fbe7 Compare September 4, 2025 14:05
@remibettan
remibettan requested a review from Copilot September 4, 2025 14:17

This comment was marked as outdated.

@remibettan
remibettan requested a review from Copilot September 4, 2025 17:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/linux/backend-v4l2.cpp Outdated
Comment on lines +583 to +588
// 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

Copilot AI Sep 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'.

Suggested change
// 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

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/linux/backend-v4l2.cpp Outdated
Comment thread src/linux/backend-v4l2.cpp Outdated
Comment thread src/linux/backend-v4l2.cpp
Comment thread src/linux/backend-v4l2.cpp Outdated
{
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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this returned a vector of all /dev device nodes and their major/minor numbers, the following would still work, correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/linux/backend-v4l2.cpp
Comment thread src/linux/backend-v4l2.cpp
Comment thread src/linux/backend-v4l2.cpp Outdated
// 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: alway -> always

Comment thread src/linux/backend-v4l2.cpp Outdated
Comment on lines +612 to +613
// 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@Nir-Az
Nir-Az self-requested a review September 11, 2025 06:35

@Nir-Az Nir-Az left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@remibettan
remibettan merged commit 8840199 into realsenseai:development Sep 11, 2025
26 checks passed
@remibettan
remibettan deleted the enabling_back_unprivileged_container_keeping_enum_fast branch July 8, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants