bin/92149
Eugene Grosbein
eugen at kuzbass.ru
Sun Jan 22 22:10:12 PST 2006
The following reply was made to PR bin/92149; it has been noted by GNATS.
From: Eugene Grosbein <eugen at kuzbass.ru>
To: bug-followup at freebsd.org
Cc:
Subject: Re: bin/92149
Date: Mon, 23 Jan 2006 13:08:07 +0700
Hi!
Sorry, I've sent wrong (buggy) version of patch, here is right one.
--- ln.c.orig Sun Jan 22 20:05:44 2006
+++ ln.c Mon Jan 23 12:47:00 2006
@@ -198,9 +198,17 @@
/*
* If the file exists, then unlink it forcibly if -f was specified
* and interactively if -i was specified.
+ *
+ * For the directory, remove it when dealing with symbolic link only.
*/
if (fflag && exists) {
- if (unlink(source)) {
+ if (S_ISDIR(sb.st_mode)) {
+ if (sflag && rmdir(source)) {
+ warn("%s", source);
+ return (1);
+ }
+ }
+ else if (unlink(source)) {
warn("%s", source);
return (1);
}
@@ -216,7 +224,13 @@
return (1);
}
- if (unlink(source)) {
+ if (S_ISDIR(sb.st_mode)) {
+ if (sflag && rmdir(source)) {
+ warn("%s", source);
+ return (1);
+ }
+ }
+ else if (unlink(source)) {
warn("%s", source);
return (1);
}
--- ln.1.orig Sun Jan 22 20:18:12 2006
+++ ln.1 Mon Jan 23 12:44:28 2006
@@ -69,8 +69,12 @@
The options are as follows:
.Bl -tag -width flag
.It Fl f
-If the target file already exists,
-then unlink it so that the link may occur.
+If the target file or (empty) directory already exists,
+then remove it so that the link may occur.
+Note that no attempt to remove the directory is performed
+when running without the
+.Fl s
+option.
(The
.Fl f
option overrides any previous
More information about the freebsd-bugs
mailing list