[comp.unix.sysv386] C bug in SCO Unix/ODT 1.0?

cjackso@uswnvg.UUCP (Clay Jackson) (05/16/91)

I think I've discovered a problem with SCO's ODT Development System Version
1.0 - to wit:


#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
char filename[]="foo";
main()
{
int fd;
int mode = 00400;
int o_mode = O_WRONLY|O_CREAT|O_TRUNC;

fd = open(filename, o_mode, mode);

printf("fd=%d\no_mode=%d\nmode=%d\nerrno=%d\n",fd,o_mode,mode,errno);
}

The obove code fails, returning an error code of ENOENT, which, in the
SCO Man pages, is not a documented error for that particular flavor of
open.  However:


#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
char filename[]="foo";
main()
{
int fd;
int mode = 00400;

fd = creat(filename, mode);

printf("fd=%d\nmode=%d\nerrno=%d\n",fd,o_mode,mode,errno);
}

This code works just fine.

Any comments?

TIA!

Clay Jackson
N7QNM
US West NewVector Group

uunet!uswnvg!cjackso | clayj@cjsysv.wa.com

-- 
Clay Jackson - N7QNM
US WEST NewVector Group, Inc
clayj@cjsysv.wa.com | ...uunet!uswnvg!cjackso

sef@kithrup.COM (Sean Eric Fagan) (05/17/91)

In article <814@uswnvg.UUCP> cjackso@uswnvg.UUCP (Clay Jackson) writes:
>I think I've discovered a problem with SCO's ODT Development System Version
>1.0 - to wit:

First of all, it is not a bug in the compiler.

Second of all, I can't get it to happen for me; that is, it works just fine,
created a file called foo.

-- 
Sean Eric Fagan  | "I made the universe, but please don't blame me for it;
sef@kithrup.COM  |  I had a bellyache at the time."
-----------------+           -- The Turtle (Stephen King, _It_)
Any opinions expressed are my own, and generally unpopular with others.

scotts@qsp.COM (Scott Simpers) (05/18/91)

In article <814@uswnvg.UUCP> cjackso@uswnvg.UUCP (Clay Jackson) writes:
>I think I've discovered a problem with SCO's ODT Development System Version
>1.0 - to wit:
...
>int fd;
>int mode = 00400;
>int o_mode = O_WRONLY|O_CREAT|O_TRUNC;
>
>fd = open(filename, o_mode, mode);
...
>The obove code fails, returning an error code of ENOENT, which, in the
>SCO Man pages, is not a documented error for that particular flavor of
>open.  However:
>-- 
>Clay Jackson - N7QNM
>US WEST NewVector Group, Inc
>clayj@cjsysv.wa.com | ...uunet!uswnvg!cjackso

You say it fails.  In what way?  Does the file get created?  errno does not
get reset to 0 if a call succeeds.  Try setting errno=0 before the open()
call.  If you still get a non-zero value in the printf(), then maybe you
have a bona-fide problem.

I somehow doubt it, though.  I've been using O_CREAT in a commercial product
for nearly a year now without problems.

Scott Simpers
Quality Software Products                    voice: (213)410-0303
5711 W Slauson Avenue  Suite 240             fax: (213)410-0124
Culver City, CA  90230                       ...uunet!qsp!scotts

bryan@well.sf.ca.us (Bryan Higgins) (05/19/91)

Probably the O_WRONLY combined with mode 0400 (*read* only) is the problem.

Bryan Higgins (bryan@well.sf.ca.us)