This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
> Glen, > > Somehow open on IRIX 6.2 doesn't like the flags you're passing to it. > > Check this out. I compiled the following code on Solaris 2.5.1 and on > my machine IRIX Release 6.2 IP20. The flags I pass are identical to > oflags variable in the function ncio_create in posixio.c. > > > #include <stdio.h> > #include <sys/types.h> > #include <sys/stat.h> > #include <fcntl.h> > > > main(int argc, char* argv[]) > { > int fd; > > fd = open(argv[1],(O_RDWR|O_CREAT|O_TRUNC|O_EXCL),0666); > > close(fd); > > } > > When I run this on Solaris: > > [newniwot] ~ 32> cc t.c > [newniwot] ~ 33> a.out solaris > [newniwot] ~ 34> ls -l solaris > -rw-r--r-- 1 ethan gp 0 Sep 22 17:49 solaris > > When I run on IRIX: > > [chiquita] ~ 204> cc t.c > [chiquita] ~ 205> a.out irix > [chiquita] ~ 206> ls -l irix > ---------- 1 ethan gp 0 Sep 22 17:50 irix > > > My guess is that the flags O_TRUNC and O_EXCL are mutually exclusive options > on IRIX and shouldn't be set together. I modified posixio.c to set O_EXCL when > NC_NOCLOBBER is set and set O_TRUNC only when NC_NOCLOBBER is not set. This > fixed my problem. > > I modified line 748 of posixio.c from: > > int oflags = (O_RDWR|O_CREAT|O_TRUNC); > > to: > > int oflags = (O_RDWR|O_CREAT); > > and I modified lines 764-765 from: > > if(fIsSet(ioflags, NC_NOCLOBBER)) > fSet(oflags, O_EXCL); > > to: > > if(fIsSet(ioflags, NC_NOCLOBBER)) > fSet(oflags, O_EXCL); > else > fSet(oflags, O_TRUNC); > > > -ethan This seems very odd to me (read the man page and POSIX spec for open). Did you get my email with a patch from yesterday? The code you show above, as well as the original netcdf, has the create mode (third argument to open()) set to the number 0666, rather than using the officially santioned macros from sys/stat.h (and fnctl.h) S_IRWUSR and so on. If it still behaves incorrectly using the official macros, then I'd say there was a problem with the OS or file system which needs to be reported to the vendor. Is the file system where you are testing local to the machine or NFS? If it is local to the machine, what sort of file system is it. If it is NFS, what is the remote OS? Thanks. -glenn