I was building X386 this morning, and when I interrupted 'make' it
told me it had removed a directory. I checked and it really had unlinked
it. (I got it back by booting the fixit disk and running fsck.)
I've patched the make source so that it won't do this anymore.
AUTHOR: David Dawes (dawes@physics.su.OZ.AU)
386BSD-Patchkit: patch00039
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
+ * -------------------- ----- ----------------------
+ * CURRENT PATCH LEVEL: 1 00039
+ * -------------------- ----- ----------------------
+ *
+ * 10 Aug 92 David Dawes Fixed "remove directory" bug
#include <sys/wait.h>
#include <sys/errno.h>
#include <ctype.h>
#include <sys/wait.h>
#include <sys/errno.h>
#include <ctype.h>
+#include <sys/stat.h> /* 10 Aug 92*/
#include "make.h"
extern int errno;
#include "make.h"
extern int errno;
* CompatInterrupt --
* Interrupt the creation of the current target and remove it if
* it ain't precious.
* CompatInterrupt --
* Interrupt the creation of the current target and remove it if
* it ain't precious.
+ * Don't unlink it if it is a directory XXX 10 Aug 92
+ struct stat sbuf; /* 10 Aug 92*/
if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) {
char *file = Var_Value (TARGET, curTarg);
if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) {
char *file = Var_Value (TARGET, curTarg);
- if (unlink (file) == SUCCESS) {
- printf ("*** %s removed\n", file);
+ stat (file, &sbuf);
+ if (!(sbuf.st_mode & S_IFDIR)) {
+ if (unlink (file) == SUCCESS) {
+ printf ("*** %s removed\n", file);
+ }
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
+ * -------------------- ----- ----------------------
+ * CURRENT PATCH LEVEL: 1 00039
+ * -------------------- ----- ----------------------
+ *
+ * 10 Aug 92 David Dawes Fixed "remove directory" bug
char *file = (job->node->path == (char *)NULL ?
job->node->name :
job->node->path);
char *file = (job->node->path == (char *)NULL ?
job->node->name :
job->node->path);
- if (unlink (file) == 0) {
- Error ("*** %s removed", file);
+ /* Don't unlink directories */ /* 10 Aug 92*/
+ struct stat sbuf;
+ stat (file, &sbuf);
+ if (!(sbuf.st_mode & S_IFDIR)) {
+ if (unlink (file) == 0) {
+ Error ("*** %s removed", file);
+ }
}
}
#ifdef RMT_WANTS_SIGNALS
}
}
#ifdef RMT_WANTS_SIGNALS