| delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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: | <41472B3F.8030800@agilent.com> |
| Date: | Tue, 14 Sep 2004 10:32:47 -0700 |
| From: | Earl Chew <earl_chew AT agilent DOT com> |
| User-Agent: | Mozilla Thunderbird 0.5 (Windows/20040207) |
| MIME-Version: | 1.0 |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: BUG: Bad call to GetFileSze in ext2fsprogs lib/ext2fs/getsize.c |
| References: | <414532D7 DOT 8050506 AT agilent DOT com> |
| In-Reply-To: | <414532D7.8050506@agilent.com> |
| X-OriginalArrivalTime: | 14 Sep 2004 17:32:48.0447 (UTC) FILETIME=[DA6FD4F0:01C49A80] |
Earl Chew wrote:
> The call to GetFileSize() doesn't match the Microsoft documentation,
> and invariably mis-sizes the disk image as zero.
A couple of comments regarding your recent changes:
a. GetFileSize() returns the bits 32-63 of the file size in
the 2nd parameter. I think code like this is more better:
DWORD high_filesize;
filesize = GetFileSize(dev, &high_filesize);
if (filesize != INVALID_FILE_SIZE || GetLastError() != NO_ERROR)
*retblocks (((unsigned long long) high_filesize << 32)
+ filesize) / blocksize;
b. Use of CreateFile() causes problems because win32 doesn't know
about the cygwin mount points. Code like this is more flexible:
fd = open(file, O_RDONLY | O_BINARY);
if (fd == -1)
return EBADF;
dev = (HANDLE) get_osfhandle(fd);
...
close(fd);
c. Similarly, code in unix_io.c needs to force binary mode to
avoid getting incorrect results when cygwin decides the image
is text!
open_flags = (flags & IO_FLAG_RW) ? O_RDWR : O_RDONLY;
#ifdef O_BINARY
open_flags |= O_BINARY;
#endif
Earl
--
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |