Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Apr 2002 11:36:27 -0700 (PDT)
From:      Brian Feldman <green@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 10146 for review
Message-ID:  <200204221836.g3MIaRK11376@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=10146

Change 10146 by green@green_laptop_2 on 2002/04/22 11:35:57

	Back out badness.

Affected files ...

... //depot/projects/trustedbsd/mac/usr.sbin/extattrctl/extattrctl.c#11 edit

Differences ...

==== //depot/projects/trustedbsd/mac/usr.sbin/extattrctl/extattrctl.c#11 (text+ko) ====

@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002 Robert N. M. Watson
+ * Copyright (c) 1999-2001 Robert N. M. Watson
  * All rights reserved.
  *
  * This software was developed by Robert Watson for the TrustedBSD Project.
@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/usr.sbin/extattrctl/extattrctl.c,v 1.19 2002/04/19 01:42:55 rwatson Exp $
+ * $FreeBSD: src/usr.sbin/extattrctl/extattrctl.c,v 1.17 2001/12/31 18:21:24 rwatson Exp $
  */
 /*
  * Developed by the TrustedBSD Project.
@@ -84,26 +84,26 @@
 	return (buf.f_files);
 }
 
-static const char zero_buf[8192];
-
 int
 initattr(int argc, char *argv[])
 {
 	struct ufs_extattr_fileheader	uef;
 	char	*fs_path = NULL;
-	int	ch, chunksize, i, error, flags;
-	ssize_t	wlen;
-	size_t	easize;
+	char	*zero_buf = NULL;
+	long	loop, num_inodes;
+	int	ch, i, error, chunksize, overwrite = 0, flags;
 
-	flags = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
 	optind = 0;
 	while ((ch = getopt(argc, argv, "fp:r:w:")) != -1)
 		switch (ch) {
 		case 'f':
-			flags &= ~O_EXCL;
+			overwrite = 1;
 			break;
 		case 'p':
-			fs_path = optarg;
+			if ((fs_path = strdup(optarg)) == NULL) {
+				perror("strdup");
+				return(-1);
+			}
 			break;
 		case '?':
 		default:
@@ -116,6 +116,11 @@
 	if (argc != 2)
 		usage();
 
+	if (overwrite)
+		flags = O_CREAT | O_WRONLY;
+	else
+		flags = O_CREAT | O_EXCL | O_WRONLY;
+
 	error = 0;
 	if ((i = open(argv[1], flags, 0600)) != -1) {
 		FILE *fp;
@@ -161,26 +166,6 @@
 		perror(argv[1]);
 		return (-1);
 	}
-	uef.uef_magic = UFS_EXTATTR_MAGIC;
-	uef.uef_version = UFS_EXTATTR_VERSION;
-	uef.uef_size = atoi(argv[0]);
-	if (write(i, &uef, sizeof(uef)) == -1)
-		error = -1;
-	else if (fs_path != NULL) {
-		easize = (sizeof uef + uef.uef_size) *
-		    num_inodes_by_path(fs_path);
-		while (easize > 0) {
-			if (easize > sizeof zero_buf)
-				wlen = write(i, zero_buf, sizeof zero_buf);
-			else
-				wlen = write(i, zero_buf, easize);
-			if (wlen == -1) {
-				error = -1;
-				break;
-			}
-			easize -= wlen;
-		}
-	}
 	if (error == -1) {
 		perror(argv[1]);
 		unlink(argv[1]);

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204221836.g3MIaRK11376>