Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Opening a block device in Windows

by davies (Vicar)
on Feb 14, 2013 at 09:38 UTC ( #1018706=perlquestion: print w/ replies, xml ) Need Help??
davies has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to write something to check for falsely reported sizes on USB & similar drives. Opening them in Linux is trivial, even for someone who knows as little about Linux as I do. Thanks to Mr. Muskrat's post (Win32) Hard Drive Information and AnthonyC's thread Windows drive letter mapping question(++ to all), I have got a lot of useful code. Hard coding as much as possible, I was hoping that the snippet below would work. Sadly, I get a "Permission denied" error. I am logged in as administrator, so I was not expecting permissions to be a problem. Googling has got me nowhere. Can anyone point me to any helpful docs?

use strict; use warnings; open my $fh, "<", '\\\\MYCOMPUTER\\root\\cimv2:Win32_LogicalDisk.Devic +eID="G:"' or die $!;

Regards,

John Davies

Comment on Opening a block device in Windows
Download Code
Re: Opening a block device in Windows
by Corion (Pope) on Feb 14, 2013 at 09:50 UTC

    If you really want direct access to the raw device, like /dev/sdx under unixish/linuxish systems, you can open \\.\F: (permissions provided), potentially using CreateFile() via Win32::API. Also see this MSDN article on direct drive access, espcecially if you don't have a drive letter yet.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (14)
As of 2015-07-02 22:03 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 (45 votes), past polls