Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!dsinc!widener!iggy.GW.Vitalink.COM!pacbell.com!pacbell!well!moon!aura!sjk From: sjk@aura.nbn.com (Scott J. Kramer) Newsgroups: comp.sys.amiga.programmer Subject: Re: Checking to see if a file's a link Message-ID: Date: 22 May 91 23:07:27 GMT References: <15127@darkstar.ucsc.edu> Distribution: comp Organization: sjk at home Lines: 52 In-reply-to: davids@ucscb.ucsc.edu's message of 28 Apr 91 20:56:13 GMT In article <15127@darkstar.ucsc.edu> davids@ucscb.ucsc.edu (Dave Schreiber) writes: From: davids@ucscb.ucsc.edu (Dave Schreiber) Newsgroups: comp.sys.amiga.programmer Date: 28 Apr 91 20:56:13 GMT Sender: usenet@darkstar.ucsc.edu Organization: University of California, Santa Cruz; Open Access Computing Is there a way, under 2.0, to examine a file or directory from a program and determine whether or not it's a link? I'm trying to write a DU program that will avoid going in circles if there's a link in a directory to an ancestor of that directory. And is using `which' the only way to determine this from the shell? Here's a potentially-dangerous scenario with hard links to directories: shell> version Kickstart version 36.207. Workbench version 36.69 shell> makedir xxx shell> echo > xxx/a foo shell> echo > xxx/b baz shell> makelink zzz xxx shell> which xxx Ram Disk:xxx shell> which zzz shell> list zzz Ram Disk:xxx Directory "Ram Disk:xxx" on Wednesday 22-May-91 b 4 ----rwed Today 15:44:44 a 4 ----rwed Today 15:44:41 2 files - 4 blocks used shell> delete xxx all Ram Disk:xxx/b Deleted Ram Disk:xxx/a Deleted Ram Disk:xxx Deleted shell> which zzz Ram Disk:x H/pGDone Seems too easy to clobber a directory that has links to it. Under UNIX, you can remove a file/directory which has *symlinks* to it and at least have a pointer, even if to a non-existent object. I don't think hard links to directories are a good idea. -- Scott J. Kramer UUCP: {sun,ucbvax}!pixar!aura!sjk P.O. Box 3392 Internet: sjk@aura.nbn.com San Rafael, CA 94912