Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!sdd.hp.com!spool2.mu.edu!uunet!bria!mike From: mike@bria Newsgroups: comp.unix.xenix.misc Subject: Re: Soft links on Xenix 386 System V? Message-ID: <403@bria> Date: 27 Jan 91 23:01:00 GMT References: <270@ncmicro.lonestar.org> Reply-To: uunet!bria!mike (Michael Stefanik) Distribution: usa Organization: Briareus Corporation, Los Angeles, CA Lines: 95 In an article, Lance Franklin writes: >I have a little problem I'd like to solve. I have software that I'm >porting to run on either SCO Xenix 386 or Unix System V. My problem is >that the package likes to see the directory in which the package resides >on the root directory. There are reasons for this over which I have no >control at present, and on other Unix, we've been able to work around it >by doing a soft link on the root directory that points to the actual >directory. However, there appears to be no command on Xenix that does >soft links, and the closest approximation on SCO Unix is the link >command. [...] As long as you don't want to put this package on a different filesystem, a hard link will work under SCO XENIX as well (with one exception: using the 'cd ..' command can confuse you and the shell, because pwd will show you as being one place in the filesystem tree, when you're actually somewhere else). If you don't have an /etc/link and /etc/unlink for some reason or other, here is a little something I whipped up. I personally prefer my 'unlink' over the simpler flavor because it will allow you to remove directory links, but not let you clobber the "last" entry itself. For that, there is always clri. --[ cut here ]--------------------------------------------------------------- /* @(#)link.c */ #include main(argc,argv) int argc; char *argv[]; { if ( argc != 3 ) { fprintf(stderr,"Usage: %s from to\n",argv[0]); return(0); } if ( link(argv[1],argv[2]) == -1 ) { fprintf(stderr,"%s: cannot link %s\n",argv[0],argv[1]); return(0); } return(0); } /* @(#)unlink.c */ #include #include #include main(argc,argv) int argc; char *argv[]; { char *image, *path; struct stat buf; image = *argv; if ( argc < 2 ) { fprintf(stderr,"Usage: %s file [file ...]\n"); return(1); } while ( --argc ) { path = *++argv; if ( stat(path,&buf) == -1 ) { fprintf(stderr,"%s: cannot stat %s\n",image,path); return(1); } if ( (buf.st_mode & S_IFDIR) && (buf.st_nlink < 3) ) fprintf(stderr,"%s: will not unlink %s\n",image,path); else { if ( unlink(path) == -1 ) fprintf(stderr,"%s: cannot unlink %s\n", image, path); } } return(0); } ------------------------------------------------------------------------------ Compile these two and put them in /etc with persmissions of 500, owner root, group root (so those hapless users can't get themselves into trouble :-) -- Michael Stefanik, Systems Engineer (JOAT), Briareus Corporation UUCP: ...!uunet!bria!mike -- technoignorami (tek'no-ig'no-ram`i) a group of individuals that are constantly found to be saying things like "Well, it works on my DOS machine ..."