delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/04/22/11:58:43

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <000a01c308e7$f6550360$c2020c0a@jbaker1200>
From: "Jeff Baker" <jbaker AT qnx DOT com>
To: <cygwin AT cygwin DOT com>
Subject: Re: CompactFlash Disk Geometry
Date: Tue, 22 Apr 2003 11:58:05 -0400
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3718.0

Ok so allow me to correct myself here.  The 'Cylinders' element in the
DISK_GEOMETRY structure is a LARGE_INTEGER, which isn't being printed by a
simple printf("%d").  If I print the Cylinders.LowPart element the output is
correct.  Since trying to printf a LARGE_INTEGER works on both Visual C and
a version of Watcom I have, is this a bug in Cygwin?

> The following piece of code is trimmed down but shows the basic
> functionality of getting the geometry of a disk.  When I build this code
in
> VC I can get correct values for Removeable Media (SmartMedia,
CompactFlash),
> but when I build it under Cygwin the DISK_GEOMETRY structure is only
> partially correct.  I understand that this might be a problem for a mingw
> mailing list, but I don't know where such a list might be so I'm starting
> here first.  I've only tested this code on Windows XP and Windows .Net
> Server 2003 RC2.
>
> The code outputs:
> VC:    15680 1 1 512
> Cygwin:    15680 0 1 1
>
> "\\\\.\\F:" in this case is an 8M CompactFlash card in a PCMCIA adapter,
in
> a PCI Ricoh CardBus adapter.
>
> #include "windows.h"
> #include "winioctl.h"
>
> int main(void) {
>     HANDLE hnd;
>     DISK_GEOMETRY geo;
>     DWORD rbc=0;
>
>     hnd = CreateFile("\\\\.\\f:", GENERIC_READ|GENERIC_WRITE,
> FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
>     if (hnd == INVALID_HANDLE_VALUE) {
>         return 1;
>     }
>
>     memset(&geo, 0, sizeof(DISK_GEOMETRY));
>
>     if(!DeviceIoControl(hnd, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &geo,
> sizeof(geo)+20, &rbc, NULL)) {
>         return GetLastError();
>     }
>
>     printf("%d %d %d %d\n", geo.Cylinders, geo.TracksPerCylinder,
> geo.SectorsPerTrack, geo.BytesPerSector);
>
>     CloseHandle(hnd);
>     return 0;
> }
>


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019