Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Stat devfs and SCSI optical drives

Reply
Thread Tools

Stat devfs and SCSI optical drives

 
 
Chris Johnson
Guest
Posts: n/a
 
      04-03-2005
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

 
Reply With Quote
 
 
 
 
axel@white-eagle.invalid.uk
Guest
Posts: n/a
 
      04-03-2005
Chris Johnson <(E-Mail Removed)> wrote:
> 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


 
Reply With Quote
 
 
 
 
Joe Smith
Guest
Posts: n/a
 
      04-03-2005
Chris Johnson wrote:

> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
os.stat() distorts filenames that end with period (nt.stat()) ruck Python 10 09-07-2012 05:54 AM
Why do I have to prefix stat from <sys/stat.h> with the keyword struct? Rolf Krüger C++ 2 03-12-2008 10:38 PM
Date & Time representation in "struct stat" - <sys/stat.h> Magesh C Programming 3 10-05-2007 12:13 PM
struct stat st; stat(fileName.c_str(), &st); hu? Steven T. Hatton C++ 3 06-02-2005 01:50 PM
os.stat('<filename>')[stat.ST_INO] on Windows Patrick Useldinger Python 6 03-03-2005 09:21 AM



Advertisments