Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: How do i find a file major and minor number

by johngg (Abbot)
on Dec 07, 2011 at 17:55 UTC ( #942299=note: print w/ replies, xml ) Need Help??


in reply to How do i find a file major and minor number

Probably something similar to this using lstat or stat.

knoppix@Microknoppix:~$ perl -E ' > $rdev = ( stat q{/dev/zero} )[ 6 ]; > $minor = $rdev % 256; > $major = int( $rdev / 256 ); > say $rdev; > say $major; > say $minor;' 261 1 5 knoppix@Microknoppix:~$ ls -l /dev/zero crw-rw-rw- 1 root root 1, 5 Dec 7 11:39 /dev/zero knoppix@Microknoppix:~$ perl -E ' > $rdev = ( stat q{/dev/zram0} )[ 6 ]; > $minor = $rdev % 256; > $major = int( $rdev / 256 ); > say $rdev; > say $major; > say $minor;' 64512 252 0 knoppix@Microknoppix:~$ ls -l /dev/zram0 brw-rw---- 1 root disk 252, 0 Dec 7 11:39 /dev/zram0 knoppix@Microknoppix:~$

I hope this is helpful.

Cheers,

JohnGG


Comment on Re: How do i find a file major and minor number
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942299]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2014-12-25 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls