Why remove() doesn't remove (symbolic links)?

Bill Baker web at farpoint.austin.ibm.com
Mon May 6 03:03:48 AEST 1991


||> In article <1991May03.202209.432 at lynx.CS.ORST.EDU> ghe at 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 at glasnost.austin.ibm.com
IBM PSP                AWD net: web at farpoint.austin.ibm.com
11400 Burnet Rd.       VNET: WEBAKER AT AUSVMQ
Austin, TX; 78758-2502



More information about the Comp.unix.aix mailing list