Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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 contemplating the Monastery: (5)
As of 2015-07-04 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls