Module Name:    othersrc
Committed By:   agc
Date:           Mon Nov 26 16:00:54 UTC 2012

Modified Files:
        othersrc/external/bsd/mat/dist: frontends.c mat.c mat.h

Log Message:
+ unmap the mmap'ed memory in the all cases.

+ be consistent with the type of integer when printing

+ add an error count field to the main structure

+ check error count in the frontends

ride previous shlib major bump

with thanks to marc balmer for keeping me honest


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 othersrc/external/bsd/mat/dist/frontends.c \
    othersrc/external/bsd/mat/dist/mat.h
cvs rdiff -u -r1.7 -r1.8 othersrc/external/bsd/mat/dist/mat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/mat/dist/frontends.c
diff -u othersrc/external/bsd/mat/dist/frontends.c:1.6 othersrc/external/bsd/mat/dist/frontends.c:1.7
--- othersrc/external/bsd/mat/dist/frontends.c:1.6	Mon Nov 26 05:49:05 2012
+++ othersrc/external/bsd/mat/dist/frontends.c	Mon Nov 26 16:00:54 2012
@@ -287,7 +287,7 @@ mat_tar(int argc, char **argv)
 	if (dir != NULL && chdir(cwd) < 0) {
 		(void) fprintf(stderr, "can't chdir back to '%s'\n", cwd);
 	}
-	return ok;
+	return ok && mat.errorc == 0;
 }
 
 #ifndef MAT_ARGC_MAX
@@ -439,7 +439,7 @@ mat_pax(int argc, char **argv)
 	if (dir != NULL && chdir(cwd) < 0) {
 		(void) fprintf(stderr, "can't chdir back to '%s'\n", cwd);
 	}
-	return ok;
+	return ok && mat.errorc == 0;
 }
 
 /* varargs version of pax */
Index: othersrc/external/bsd/mat/dist/mat.h
diff -u othersrc/external/bsd/mat/dist/mat.h:1.6 othersrc/external/bsd/mat/dist/mat.h:1.7
--- othersrc/external/bsd/mat/dist/mat.h:1.6	Sun Nov 25 20:20:36 2012
+++ othersrc/external/bsd/mat/dist/mat.h	Mon Nov 26 16:00:54 2012
@@ -108,6 +108,7 @@ typedef struct mat_t {
 	char		 from[MAT_PATH_MAX];	/* path to change from */
 	char		 to[MAT_PATH_MAX];	/* path to change to */
 	void		*re;		/* pointer to compiled regexp */
+	unsigned	 errorc;	/* # of errors */
 } mat_t;
 
 int mat_init(mat_t */*mat*/, const char */*f*/, const char */*mode*/);

Index: othersrc/external/bsd/mat/dist/mat.c
diff -u othersrc/external/bsd/mat/dist/mat.c:1.7 othersrc/external/bsd/mat/dist/mat.c:1.8
--- othersrc/external/bsd/mat/dist/mat.c:1.7	Mon Nov 26 05:49:05 2012
+++ othersrc/external/bsd/mat/dist/mat.c	Mon Nov 26 16:00:54 2012
@@ -185,23 +185,28 @@ static int
 memwrite(FILE *fp, uint64_t off, const void *p, size_t size)
 {
 	char	*mapped;
+	int	 ok;
 
+	ok = 1;
 	mapped = mmap(NULL, size, PROT_WRITE, MAP_SHARED, fileno(fp), (off_t)off);
 	if (mapped == MAP_FAILED) {
 		if (write(fileno(fp), p, size) != (ssize_t)size) {
-			fprintf(stderr, "short write %zu chars\n", size);
-			return 0;
+			ok = 0;
 		}
 	} else {
-		lseek(fileno(fp), (off_t)(off + size - 1), SEEK_SET);
-		if (write(fileno(fp), "", 1) != 1) {
-			fprintf(stderr, "short write %" PRIu64 " chars\n", size);
-			return 0;
+		if (lseek(fileno(fp), (off_t)(off + size - 1), SEEK_SET) < 0) {
+			ok = 0;
+		} else if (write(fileno(fp), "", 1) != 1) {
+			ok = 0;
+		} else {
+			memcpy(mapped, p, size);
 		}
-		memcpy(mapped, p, size);
 		munmap(mapped, size);
 	}
-	return 1;
+	if (!ok) {
+		fprintf(stderr, "memwrite: short write %zu chars\n", size);
+	}
+	return ok;
 }
 
 /* write to mat archive */
@@ -212,6 +217,7 @@ archive_write(mat_t *mat, const void *p,
 		mat->off += size;
 		return 1;
 	}
+	mat->errorc += 1;
 	return 0;
 }
 

Reply via email to