mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add API to decode 'stat.st_rdev' into major and minor numbers.
PiperOrigin-RevId: 204936533 Change-Id: Ib060920077fc914f97c4a0548a176d1368510c7b
This commit is contained in:
@@ -25,6 +25,13 @@ func MakeDeviceID(major uint16, minor uint32) uint32 {
|
||||
return (minor & 0xff) | ((uint32(major) & 0xfff) << 8) | ((minor >> 8) << 20)
|
||||
}
|
||||
|
||||
// DecodeDeviceID decodes a device ID into major and minor device numbers.
|
||||
func DecodeDeviceID(rdev uint32) (uint16, uint32) {
|
||||
major := uint16((rdev >> 8) & 0xfff)
|
||||
minor := (rdev & 0xff) | ((rdev >> 20) << 8)
|
||||
return major, minor
|
||||
}
|
||||
|
||||
// Character device IDs.
|
||||
//
|
||||
// See Documentations/devices.txt and uapi/linux/major.h.
|
||||
|
||||
Reference in New Issue
Block a user