Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Wed, 31 Mar 2004 16:58:49 -0500 From: Mike Brown To: pechtcha AT cs DOT nyu DOT edu Cc: cygwin AT cygwin DOT com Subject: Re: 64-bit file operations (lseek64() etc) misbehaving Message-ID: <20040331215849.GD1710@esd-mbrown.us.dg.com> References: <20040331183428 DOT GA1710 AT esd-mbrown DOT us DOT dg DOT com> <20040331201910 DOT GC1710 AT esd-mbrown DOT us DOT dg DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-PMX-Version: 4.1.1.86173 Hi, Yep that fixes me. Thanks Igor. Odd that the open() succeeds for \\.\PhysicalDrive0. _shrug_. I'll gladly use /dev/sda. -Mike On Wed, Mar 31, 2004 at 04:18:49PM -0500, Igor Pechtchanski wrote: > Mike, > > FYI, the following works just fine on my system (Win2k, Cygwin 1.5.9, 11G > harddrive): > > ------------------------------------------------------------------------------ > #include > #include > #include > #include > > #define BYTE (sizeof(unsigned char)) > #define KB (1024 * BYTE) > #define MB (1024 * KB) > #define GB (1024 * MB) > > int main(int argc, char *argv[]) { > int fd; > off_t maxblock; > if ((fd = open("/dev/sda", O_RDONLY)) < 0) { > perror("open failed"); exit(2); > } > if ((maxblock = lseek(fd, 0, SEEK_END)) == (off_t) -1) { > perror("lseek failed"); exit(3); > } > printf("%llub, %lluKb, %lluMb, %lluGb in /dev/sda\n", maxblock, > maxblock / KB, maxblock / MB, maxblock / GB); > close(fd); > return 0; > } > ------------------------------------------------------------------------------ > > If I replace "/dev/sda" by "\\\\.\\PhysicalDrive0" everywhere, however, I > get the same result you do. Food for thought. > HTH, > Igor > > On Wed, 31 Mar 2004, Mike Brown wrote: > > > Hi Igor, > > > > Yes the a.out a.exe thing is a typo. I've read the page on special > > filenames. You can use the POSIX names or you can open the Windows > > device namespace name. Either way, my problem isn't with opening and > > reading from the disk device. That works fine. My problem is with > > lseek() not being able to seek past the 4Gb boundary. > > > > Thanks. > > > > On Wed, Mar 31, 2004 at 02:14:18PM -0500, Igor Pechtchanski wrote: > > > On Wed, 31 Mar 2004, Mike Brown wrote: > > > > > > > Hi, > > > > > > > > cygwin 1.5.9-1 on Windows XP Service Pack 1. > > > > > > > > I need 64-bit versions of lseek() and friends. No prototype exists for > > > > lseek64(). I've searched the archives on the list and many claim that > > > > 64-bit support is "automatic" and lseek() resolves at compile time to > > > > lseek64(). This isn't happening for me. Is there a compile time > > > > define I need to make this happen? > > > > > > > > [snip] > > > > Here's a simple example app I'm using. I run via: a.out PhysicalDrive0 > > > > > > Michael, > > > > > > I don't know if it's related to the problem you're having, but I'm sure > > > you've read , > > > right? Try compiling a Linux version with "#define lseek64 lseek", and > > > use ./a.exe /dev/sda (note that Cygwin gcc produces a.exe, not a.out, by > > > default, so I assume the above is a typo or the result of an explicit "-o" > > > flag). > > > Igor > > > > > > > ----------------------- > > > > /* #define LINUX */ > > > > #define WIN32 > > > > > > > > [snip] > > > > #ifdef WIN32 > > > > /* automatically add the \\.\ crap in front */ > > > > sprintf(filename, "\\\\.\\%s", argv[1]); > > > > #else > > > > sprintf(filename, "%s", argv[1]); > > > > #endif > > > > [snip] > > > > #ifdef WIN32 > > > > maxblock = lseek(fd, 0, SEEK_END); > > > > #else > > > > maxblock = lseek64(fd, 0, SEEK_END); > > > > #endif > > -- > http://cs.nyu.edu/~pechtcha/ > |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu > ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com > |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. > '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! > > "I have since come to realize that being between your mentor and his route > to the bathroom is a major career booster." -- Patrick Naughton -- 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/