« Return to Thread: Fwd: Stupid Vista-64 tricks

Fwd: Stupid Vista-64 tricks

by Georg Nikodym :: Rate this Message:

Reply to Author | View in Thread

Resending from an address that's actually subscribed to the list.

Begin forwarded message:

> From: Georg Nikodym <georgn@...>
> Date: August 24, 2007 14:14:17 EDT (CA)
> To: MinGW Users List <mingw-users@...>
> Cc: cygwin-developers@...
> Subject: Stupid Vista-64 tricks
>
> This is not strictly speaking a cygwin problem.  More a question of  
> what an alien app needs to do to be useful inside a cygwin  
> environment.  So apologies in advance for the intrusion.
>
> Consider the following program:
>
> #include <stdio.h>
> #include <string.h>
> #include <errno.h>
> #include <fcntl.h>
> #include <sys/types.h>
> #include <sys/stat.h>
>
> int
> main(int argc, char **argv)
> {
>         FILE *fp;
>         int fd;
>         mode_t mode;
>
>         chmod("foo", 0666);
>         unlink("foo");
>         chmod("bar", 0666);
>         unlink("bar");
>         chmod("baz", 0666);
>         unlink("baz");
>
>         mode = umask(002);
>         mode = umask(002);
>
>         printf("mode = %o\n", mode);
>
>         fp = fopen("foo", "w");
>         if (fp == NULL) {
>                 fprintf(stderr, "%s: foo: %s (%d)\n", argv[0],
>                         strerror(errno), errno);
>                 exit(1);
>         }
>
>         fclose(fp);
>         chmod("foo", 0777);
>
>         fd = open("bar", O_CREAT|O_WRONLY);
>         if (fd < 0) {
>                 fprintf(stderr, "%s: bar: %s (%d)\n", argv[0],
>                         strerror(errno), errno);
>                 exit(2);
>         }
>
>         close(fd);
>         chmod("bar", 0777);
>
>         fd = open("baz", O_CREAT|O_RDWR, 0644);
>         if (fd < 0) {
>                 fprintf(stderr, "%s: baz: %s (%d)\n", argv[0],
>                         strerror(errno), errno);
>                 exit(2);
>         }
>
>         close(fd);
>         chmod("baz", 0777);
>
>         return 0;
> }
>
> Compiled with mingw's gcc (3.4.5) and run inside an MSYS bash, it  
> operates almost as expected (the umask() and chmod() calls don't  
> quite act the way a UNIX hand like myself would expect).
>
> However, run under a cygwin shell, I see:
>
> georgn@up /tmp
> $ ./temp; ls -l foo bar baz
> mode = 0
> ----------+ 1 georgn None 0 Aug 24 13:50 bar
> ----------+ 1 georgn None 0 Aug 24 13:50 baz
> ----------+ 1 georgn None 0 Aug 24 13:50 foo
>
> georgn@up /tmp
> $
>
> (The annoying problem being, you build an app using the mingw/gcc  
> suite and a customer uses it in a cygwin shell and has things like  
> vi complain about files being read-only.  Just a general, crappy  
> user experience.)
>
> So my questions/options are:
>
> 1) Wrap my fopen/open calls with some win32 work-around that cygwin  
> likes better.  Any thoughts on what that might look like?
> 2) Learn enough about the incompatibility to offer up a patch.  Any  
> thoughts on where to start an investigation?
>
> -g
>


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

PGP.sig (193 bytes) Download Attachment

 « Return to Thread: Fwd: Stupid Vista-64 tricks