Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



link and unlink, therefore, should accept the "--" delimiter.

Another problem is that when link's 2nd operand is a directory, it creates
a link in that directory to the file named by the 1st operand, which is
not correct. SUSV2 specifies that "link a b" is performs the equivalent of
the function call link(a, b). unlink has the same problem: SUSV2 specifies
it must call unlink() (which means it shouldn't treat whiteouts specially
or try to reset immutable/append flags).

>How-To-Repeat:
N/A
>Fix:

Correct the manual pages by deleting the claims of SUSV2 conformance, or
apply these patches that implement the correct behaviour.

Index: ln/ln.c
===================================================================
RCS file: /home/ncvs/src/bin/ln/ln.c,v
retrieving revision 1.23
diff -u -r1.23 ln.c
--- ln/ln.c	2002/02/02 06:44:35	1.23
+++ ln/ln.c	2002/02/22 04:00:47
@@ -85,11 +85,14 @@
 	else
 		++p;
 	if (strcmp(p, "link") == 0) {
-		if (argc == 3) {
-			linkf = link;
-			exit(linkit(argv[1], argv[2], 0));
-		} else
+		argv++, argc--;
+		if (argc > 0 && strncmp(*argv, "--", 2) == 0)
+			argv++, argc--;
+		if (argc != 2)
 			usage();
+		if (link(argv[0], argv[1]) != 0)
+			err(1, "%s to %s", argv[0], argv[1]);
+		exit(0);
 	}
 
 	while ((ch = getopt(argc, argv, "fhinsv")) != -1)


Index: rm/rm.c
===================================================================
RCS file: /home/ncvs/src/bin/rm/rm.c,v
retrieving revision 1.36
diff -u -r1.36 rm.c
--- rm/rm.c	2002/02/14 01:59:47	1.36
+++ rm/rm.c	2002/02/22 04:07:03
@@ -95,11 +95,14 @@
 	else
 		++p;
 	if (strcmp(p, "unlink") == 0) {
-		if (argc == 2) {
-			rm_file(&argv[1]);
-			exit(eval);
-		} else 
+		argv++, argc--;
+		if (argc > 0 && strncmp(*argv, "--", 2) == 0)
+			argv++, argc--;
+		if (argc != 1)
 			usage();
+		if (unlink(*argv) != 0)
+			err(1, "%s", *argv);
+		exit(0);
 	}
 
 	Pflag = rflag = 0;


To Unsubscribe: send mail to majordomo@xxxxxxxxxxx
with "unsubscribe freebsd-standards" in the body of the message