File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -54,18 +54,24 @@ func GetDeviceNumbers(patternStr string) (map[string]string, error) {
54
54
return nil
55
55
}
56
56
57
+ // Skip if not device
58
+ mode := info .Mode ()
59
+ if ! (mode & os .ModeDevice != 0 || mode & os .ModeCharDevice != 0 ) {
60
+ return nil
61
+ }
62
+
57
63
// Check if the deviceName matches the pattern
58
64
deviceName := filepath .Base (path )
59
65
if regex .MatchString (deviceName ) {
60
66
// Retrieve major/minor numbers
61
67
statT , ok := info .Sys ().(* syscall.Stat_t )
62
68
if ! ok {
63
- return nil // Skip files if syscall.Stat_t is not available
69
+ return nil
64
70
}
65
71
66
72
// Extract major and minor numbers
67
- major := (statT .Rdev >> 8 ) & 0xFF
68
- minor := statT .Rdev & 0xFF
73
+ major := (statT .Rdev >> 8 ) & 0xFFF
74
+ minor := ( statT .Rdev & 0xFF ) | (( statT . Rdev >> 12 ) & 0xFFF00 )
69
75
70
76
// Add to result map
71
77
result [deviceName ] = fmt .Sprintf ("%d:%d" , major , minor )
You can’t perform that action at this time.
0 commit comments