Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!romp!auschs!awdprime!farpoint.austin.ibm.com!web From: web@farpoint.austin.ibm.com (Bill Baker) Newsgroups: comp.unix.aix Subject: Re: Why remove() doesn't remove (symbolic links)? Keywords: remove(), symbolic link Message-ID: <7309@awdprime.UUCP> Date: 5 May 91 17:03:48 GMT References: <1991May03.174126.13324@lynx.CS.ORST.EDU> <1991May3.185244.1275@batcomputer.tn.cornell.edu> <1991May03.202209.432@lynx.CS.ORST.EDU> Sender: news@awdprime.UUCP Organization: IBM AWD, Austin Lines: 26 ||> In article <1991May03.202209.432@lynx.CS.ORST.EDU> ghe@physics.orst.edu writes: ||> >The remove() system call fails to remove ||> >the sybolic links. ||> | |When I try to call remove(b) ('b' is a symbolic link to a directory 'a'), |perror prints: | |remove: Not a directory | |I still don't know why. Remove is implemented in libc. It calls unlink or rmdir to remove files or directories. To determine which to do, it calls stat. And therein lies the problem. If it's a symlink to a directory, stat follows the link and the code tries to rmdir the symlink. Naturally, the rmdir system call fails with ENOTDIR. This is also a problem if the object is a dangling symbolic link. The code should use lstat, not stat. BUG! web --- -- Bill Baker Internet: web@glasnost.austin.ibm.com IBM PSP AWD net: web@farpoint.austin.ibm.com 11400 Burnet Rd. VNET: WEBAKER AT AUSVMQ Austin, TX; 78758-2502