Stat devfs and SCSI optical drives

C

Chris Johnson

I'm working on a program that needs to stat devices and pick out
optical drives. I've run the following code on my computer and my
roommates:

opendir DEV, "/dev";
for(readdir(DEV)){
my @stats = stat "/dev/$_";
print "$_: $stats[5]\n";
}
closedir DEV;

And I found that all optical drives have a $gid ($stats[5]) of 93.

However, we both have IDE optical drives and udev, so rather than write
a program with the same configuration, I'd appreciate it if I could get
some confirmation from people with SCSI optical drives and/or devfs.

Thanks,
Chris
 
A

axel

Chris Johnson said:
I'm working on a program that needs to stat devices and pick out
optical drives. I've run the following code on my computer and my
roommates:
And I found that all optical drives have a $gid ($stats[5]) of 93.
However, we both have IDE optical drives and udev, so rather than write
a program with the same configuration, I'd appreciate it if I could get
some confirmation from people with SCSI optical drives and/or devfs.

It's not a relevent question to this newsgroup.

Also any answers that you receive will be a bit pointless unless
they concern the same OS that you are using, which you do not specify.

Axel
 
J

Joe Smith

Chris said:
And I found that all optical drives have a $gid ($stats[5]) of 93.

I expect that you will get more reliable results by using $stats[6].

my $major = $stats[6] >> 8;
my $minor = $stats[6] & 0xFF;
print "$_: $major,$minor\n";

The bits stored in $stats[6] is operating system dependent.
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top