glenn@stsim.ocs.com (glenn ford) (03/15/90)
I have LHARC working under SCO Xenix 2.3 pretty much except for one tiny problem. When it tries to link the temp file, to the "archive file" it gets a core dump. Now, originally a function called "rename" was being used to do this. I changed it to "link". Is this wrong? Pretty sure this is where the core dump is, cause if i manually mv the temp file to an archive file name (dont even have to do that) i can view, and extract from the temp file. Any help as to where to find "rename" in the SCO libraries or a suitable replacement would be GREATLY appreciated. I have had quite a few responses from people wanting copies also. If you want a copy please send me email *again* and I will send you the "ported" Xenix version. Glenn BBS: 301-972-2310 HOME: 301-972-6131 UUCP: ..uunet!ocsmd!stsim!glenn
goer@sophist.uucp (Richard Goerwitz) (03/16/90)
In article <859@stsim.ocs.com> glenn@stsim (glenn ford) writes: >I have LHARC working under SCO Xenix 2.3 pretty much except for one tiny >problem.... Any help as to where to find "rename" in the SCO libraries >or a suitable replacement would be GREATLY appreciated.... This keeps coming up, so I don't think it will be too much of an imposi- tion on the net to post something I found a while back, and which has proven useful on several occasions. Note that I am NOT the author: #!/bin/sh # shar: Shell Archiver (v1.22) # # Run the following text with /bin/sh to create: # rename.c # sed 's/^X//' << 'SHAR_EOF' > rename.c && X/* X * $Author: chip $ $Date: 89/06/29 13:02:31 $ X * $Header: rename.c,v 1.1 89/06/29 13:02:31 chip Exp $ X * $Revision: 1.1 $ X */ X X/* X * Rename system call -- Replacement for Berzerkeley 4.2 rename system X * call that is missing in Xenix. X * X * By Marc Frajola and Chris Paris. X * Directory hack by Chip Salzenberg. X */ X X#include <stdio.h> X#include <sys/types.h> X#include <sys/stat.h> X#include <signal.h> X#include <errno.h> X Xrename(src,dest) X char *src; /* Source file to rename */ X char *dest; /* Name for renamed file */ X{ X int status; /* Status returned from link system call */ X struct stat stbuf; /* Buffer for statting destination file */ X X /* Find out what the destination is: */ X status = stat(dest,&stbuf); X if (status >= 0) { X /* See if the file is a regular file; if not, return error: */ X if ((stbuf.st_mode & S_IFMT) != S_IFREG) { X return(-1); X } X } X X /* Unlink destination since it is a file: */ X unlink(dest); X X /* Find out what the source is: */ X status = stat(src,&stbuf); X if (status < 0) X return -1; X if ((stbuf.st_mode & S_IFMT) == S_IFDIR) X { X /* Directory hack for SCO Xenix */ X X static char mvdir[] = "/usr/lib/mv_dir"; X void (*oldsigcld)(); X int pid; X X oldsigcld = signal(SIGCLD, SIG_DFL); X while ((pid = fork()) == -1) X { X if (errno != EAGAIN) X return -1; X sleep(5); X } X if (pid == 0) X { X execl(mvdir, mvdir, src, dest, (char *) 0); X perror(mvdir); X exit(1); X } X if (wait(&status) != pid) X { X fprintf(stderr, "rename: wait failure\n"); X status = -1; X } X (void) signal(SIGCLD, oldsigcld); X } X else X { X /* Link source to destination file: */ X status = link(src,dest); X if (status != 0) { X return(-1); X } X status = unlink(src); X } X return((status == 0) ? 0 : (-1)); X} SHAR_EOF chmod 0644 rename.c || echo "restore of rename.c fails" exit 0 -Richard L. Goerwitz goer%sophist@uchicago.bitnet goer@sophist.uchicago.edu rutgers!oddjob!gide!sophist!goer
pat@rwing.UUCP (Pat Myrto) (03/17/90)
I have the same problem - lharc dumping core when it finishes, and tries to rename the temp file to the final archive name. I have a rename() function I got from a package of functions intended to make earlier versions of UNIX(tm) support at least some of the POSIX functions. This rename() function works fine elsewhere, so I don't think that you using link() is the problem (note that just replacing rename() calls with link() calls will still leave the temp file in place - a call to unlink() to unlink the temp file after the link() call succeeded is neccessary to accomplish the effect of renaming. I note that the final archive filename is not even created before it dumps core (I tried the option where the temp file is copied to the final archive - needed if the temp file is on a filesystem different than the one the archive is to be on), so the problem is somewhere else. As soon as I get time, I plan to see if I can find the problem using sdb, but being inexpert with that tool, this is going to take awhile. Has anyone else experienced this core dumping problem, and discovered the cause (my attempts are under UNIX(tm) instead of XENIX(tm), on the old UNIX-PC, which is roughly the same as SysV Rel 2.0). Thanks for any help... -- pat@rwing (Pat Myrto), Seattle, WA ...!uunet!pilchuck!rwing!pat ...!uw-beaver!uw-entropy!dataio!/ WISDOM: "Travelling unarmed is like boating without a life jacket"