Discussion:
Rare Error 65 (ENOPKG) occurrence on open() call
(too old to reply)
Apolon
2003-09-30 01:16:51 UTC
Permalink
Does anyone know what the meaning of errno=65 (ENOPKG) is when an
open() call fails on SCO Open Server 5.0.6? That error code doesn't
appear in the open function man pages.

The error occurs very rarely (say once a month) in a process that runs
continuously closing/opening/creating/moving files around once every 2
hours. The open is performed directly after a system() call which
copies a file to another location. A system( "cp ..." ) call is being
used instead of the rename() function call because of the limitation
with not being able to rename across filesystems.

Here are the code excerpts which encounters the error 65. The open
function call is the one that fails occassionally. Most of the time
the program is running it works fine.

HIST_mv(tmpName, fullname);
if ((hdr->fd = open(fullname, O_RDWR , A_READ | U_WRITE)) == H_ERROR)
{
char lvCurrentDir[1024];
getcwd (lvCurrentDir, sizeof (lvCurrentDir) - 1);
xfatal_err("Fatal Error %d opening file %s in directory %s.",
errno, fullname, lvCurrentDir);
}


void HIST_mv(char* f1, char* f2)
{
char cmd[512];
int systemCallResult;

HDBG( Hdbg( "Copying file %s to %s.\n", f1, f2 ) );
sprintf(cmd, "cp %s %s", f1, f2);
systemCallResult = system(cmd);
HDBG( Hdbg( "system(\"%s\") returned %d.\n", cmd, systemCallResult
) );

HDBG( Hdbg( "Removing file %s.\n", f1 ) );
if ( unlink(f1) != 0 )
{
Hdbg( "unlink(%s) call failed with errno=%d.\n", f1, errno );
}
}

Thanks for any help,
Apolon.
Bela Lubkin
2003-10-01 01:03:15 UTC
Permalink
Post by Apolon
Does anyone know what the meaning of errno=65 (ENOPKG) is when an
open() call fails on SCO Open Server 5.0.6? That error code doesn't
appear in the open function man pages.
The error occurs very rarely (say once a month) in a process that runs
continuously closing/opening/creating/moving files around once every 2
hours. The open is performed directly after a system() call which
copies a file to another location. A system( "cp ..." ) call is being
used instead of the rename() function call because of the limitation
with not being able to rename across filesystems.
Here are the code excerpts which encounters the error 65. The open
function call is the one that fails occassionally. Most of the time
the program is running it works fine.
HIST_mv(tmpName, fullname);
if ((hdr->fd = open(fullname, O_RDWR , A_READ | U_WRITE)) == H_ERROR)
{
char lvCurrentDir[1024];
getcwd (lvCurrentDir, sizeof (lvCurrentDir) - 1);
xfatal_err("Fatal Error %d opening file %s in directory %s.",
errno, fullname, lvCurrentDir);
}
First, make sure that `errno' was 0 before the open() call, and that
getcwd() isn't affecting its value:

if (errno == ENOPKG) {
/* aha!? */
}
errno = 0; /* might be something weird from prior calls */
if ((hdr->fd = open(fullname, O_RDWR , A_READ | U_WRITE)) == H_ERROR)
{
int my_errno = errno; /* save errno */
char lvCurrentDir[1024];
getcwd (lvCurrentDir, sizeof (lvCurrentDir) - 1);
xfatal_err("Fatal Error %d opening file %s in directory %s.",
my_errno, fullname, lvCurrentDir); /* saved errno */

Other than that: where is the file it's trying to open? A local
filesystem, an NFS mount, something else? Are these your own files, or
are they arbitrary files you find on the filesystem? (For instance, is
this a backup program that searches for files and copies them?)

There are very few things in the kernel that return ENOPKG. Candidates
include the System V shared memory driver ("shm"), the Xenix shared data
driver ("xsd"), and the Advanced Power Management drivers ("uapm" and
"pwr"). Each of these drivers has "stubs.c" code -- code that gets
linked into the kernel when the driver is _not_ present -- that returns
ENOPKG for certain operations.

It isn't clear to me whether any of these could return ENOPKG for an
open() call. More typically it would be on calling shmsys(), any of the
xsd*() functions, and on attempting certain ioctls with the APM stuff.
But... there exists an obscure file type which is an on-disk
representation of a Xenix Shared Data memory segment. If you had one of
those and tried to open it, it _might_ return ENOPKG if "xsd" wasn't
linked into your kernel.

Or might not. I just tried it and:

$ mknod test-m m
$ cat test-m
cat: cannot open test-m: Is a name file (error 139)

EISNAM is not ENOPKG.
Post by Apolon
Bela<
Apolon
2003-10-01 05:52:47 UTC
Permalink
Post by Bela Lubkin
First, make sure that `errno' was 0 before the open() call, and that
Okay will do and repost with the results (should have seen this possibility!).
Note that it could be up to a month before the problem occurs again.
Post by Bela Lubkin
if (errno == ENOPKG) {
/* aha!? */
}
errno = 0; /* might be something weird from prior calls */
if ((hdr->fd = open(fullname, O_RDWR , A_READ | U_WRITE)) == H_ERROR)
{
int my_errno = errno; /* save errno */
char lvCurrentDir[1024];
getcwd (lvCurrentDir, sizeof (lvCurrentDir) - 1);
xfatal_err("Fatal Error %d opening file %s in directory %s.",
my_errno, fullname, lvCurrentDir); /* saved errno */
Other than that: where is the file it's trying to open? A local
filesystem, an NFS mount, something else? Are these your own files, or
are they arbitrary files you find on the filesystem? (For instance, is
this a backup program that searches for files and copies them?)
They're just straight files from the local file system - hence the wierdness.
Loading...