Date: Sun, 31 Aug 2008 20:50:04 GMT From: Ed Schouten <ed@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 148937 for review Message-ID: <200808312050.m7VKo4D5013121@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=148937 Change 148937 by ed@ed_dull on 2008/08/31 20:49:21 IFC (so I can test `make universe'). Affected files ... .. //depot/projects/mpsafetty/ObsoleteFiles.inc#9 integrate .. //depot/projects/mpsafetty/bin/Makefile#2 integrate .. //depot/projects/mpsafetty/bin/pkill/Makefile#1 branch .. //depot/projects/mpsafetty/bin/pkill/pkill.1#1 branch .. //depot/projects/mpsafetty/bin/pkill/pkill.c#1 branch .. //depot/projects/mpsafetty/bin/sh/sh.1#2 integrate .. //depot/projects/mpsafetty/etc/sendmail/freebsd.submit.mc#2 integrate .. //depot/projects/mpsafetty/gnu/usr.bin/binutils/libbfd/Makefile.amd64#2 integrate .. //depot/projects/mpsafetty/lib/libarchive/Makefile#3 integrate .. //depot/projects/mpsafetty/lib/libarchive/archive.h#2 integrate .. //depot/projects/mpsafetty/lib/libarchive/archive_write_set_format.c#2 integrate .. //depot/projects/mpsafetty/lib/libarchive/archive_write_set_format_by_name.c#2 integrate .. //depot/projects/mpsafetty/lib/libarchive/archive_write_set_format_mtree.c#1 branch .. //depot/projects/mpsafetty/lib/libarchive/archive_write_set_format_shar.c#2 integrate .. //depot/projects/mpsafetty/lib/libarchive/test/main.c#2 integrate .. //depot/projects/mpsafetty/rescue/rescue/Makefile#2 integrate .. //depot/projects/mpsafetty/sbin/gpt/Makefile#2 delete .. //depot/projects/mpsafetty/sbin/gpt/add.c#2 delete .. //depot/projects/mpsafetty/sbin/gpt/boot.c#2 delete .. //depot/projects/mpsafetty/sbin/gpt/create.c#2 delete .. //depot/projects/mpsafetty/sbin/gpt/destroy.c#2 delete .. //depot/projects/mpsafetty/sbin/gpt/gpt.8#2 delete .. //depot/projects/mpsafetty/sbin/gpt/gpt.c#2 delete .. //depot/projects/mpsafetty/sbin/gpt/gpt.h#2 delete .. //depot/projects/mpsafetty/sbin/gpt/label.c#2 delete .. //depot/projects/mpsafetty/sbin/gpt/map.c#2 delete .. //depot/projects/mpsafetty/sbin/gpt/map.h#2 delete .. //depot/projects/mpsafetty/sbin/gpt/migrate.c#2 delete .. //depot/projects/mpsafetty/sbin/gpt/recover.c#2 delete .. //depot/projects/mpsafetty/sbin/gpt/remove.c#2 delete .. //depot/projects/mpsafetty/sbin/gpt/show.c#2 delete .. //depot/projects/mpsafetty/sbin/mount/mount.c#2 integrate .. //depot/projects/mpsafetty/share/man/man4/witness.4#2 integrate .. //depot/projects/mpsafetty/share/man/man9/vfs_busy.9#2 integrate .. //depot/projects/mpsafetty/share/man/man9/vfs_unbusy.9#2 integrate .. //depot/projects/mpsafetty/sys/arm/at91/if_ate.c#2 integrate .. //depot/projects/mpsafetty/sys/boot/sparc64/loader/main.c#4 integrate .. //depot/projects/mpsafetty/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/syscons/syscons.c#6 integrate .. //depot/projects/mpsafetty/sys/dev/usb/ehci_pci.c#4 integrate .. //depot/projects/mpsafetty/sys/dev/usb/ohci_pci.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/usb/ufoma.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/usb/uhci_pci.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/usb/uipaq.c#4 integrate .. //depot/projects/mpsafetty/sys/dev/usb/umodem.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/usb/uplcom.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/usb/uvscom.c#2 integrate .. //depot/projects/mpsafetty/sys/geom/journal/g_journal.c#2 integrate .. //depot/projects/mpsafetty/sys/gnu/fs/ext2fs/ext2_vfsops.c#2 integrate .. //depot/projects/mpsafetty/sys/kern/subr_witness.c#5 integrate .. //depot/projects/mpsafetty/sys/kern/vfs_lookup.c#2 integrate .. //depot/projects/mpsafetty/sys/kern/vfs_mount.c#7 integrate .. //depot/projects/mpsafetty/sys/kern/vfs_subr.c#7 integrate .. //depot/projects/mpsafetty/sys/kern/vfs_syscalls.c#3 integrate .. //depot/projects/mpsafetty/sys/modules/usb/Makefile#2 integrate .. //depot/projects/mpsafetty/sys/netinet/if_ether.c#4 integrate .. //depot/projects/mpsafetty/sys/netinet/libalias/alias_db.c#2 integrate .. //depot/projects/mpsafetty/sys/netinet6/udp6_usrreq.c#4 integrate .. //depot/projects/mpsafetty/sys/nfsclient/nfs_vfsops.c#6 integrate .. //depot/projects/mpsafetty/sys/powerpc/aim/clock.c#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/aim/machdep.c#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/aim/vm_machdep.c#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/include/cpufunc.h#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/powerpc/db_interface.c#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/powerpc/pmap_dispatch.c#2 integrate .. //depot/projects/mpsafetty/sys/sys/mount.h#2 integrate .. //depot/projects/mpsafetty/sys/ufs/ffs/ffs_softdep.c#3 integrate .. //depot/projects/mpsafetty/sys/ufs/ufs/ufs_vfsops.c#2 integrate .. //depot/projects/mpsafetty/tools/regression/atm/README#2 integrate .. //depot/projects/mpsafetty/usr.bin/Makefile#2 integrate .. //depot/projects/mpsafetty/usr.bin/pkill/Makefile#2 delete .. //depot/projects/mpsafetty/usr.bin/pkill/pkill.1#2 delete .. //depot/projects/mpsafetty/usr.bin/pkill/pkill.c#2 delete Differences ... ==== //depot/projects/mpsafetty/ObsoleteFiles.inc#9 (text+ko) ==== @@ -1,5 +1,5 @@ # -# $FreeBSD: src/ObsoleteFiles.inc,v 1.156 2008/08/24 10:01:22 ed Exp $ +# $FreeBSD: src/ObsoleteFiles.inc,v 1.157 2008/08/31 08:33:41 antoine Exp $ # # This file lists old files (OLD_FILES), libraries (OLD_LIBS) and # directories (OLD_DIRS) which should get removed at an update. Recently @@ -16,6 +16,24 @@ # 20080823: removal of unneeded pt_chown, to implement grantpt(3) OLD_FILES+=usr/libexec/pt_chown +# 20080822: ntp 4.2.4p5 import +OLD_FILES+=usr/share/doc/ntp/driver23.html +OLD_FILES+=usr/share/doc/ntp/driver24.html +# 20080821: several man pages moved from man4.i386 to man4 +.if ${TARGET_ARCH} == "i386" +OLD_FILES+=usr/share/man/man4/i386/acpi_aiboost.4.gz +OLD_FILES+=usr/share/man/man4/i386/acpi_asus.4.gz +OLD_FILES+=usr/share/man/man4/i386/acpi_fujitsu.4.gz +OLD_FILES+=usr/share/man/man4/i386/acpi_ibm.4.gz +OLD_FILES+=usr/share/man/man4/i386/acpi_panasonic.4.gz +OLD_FILES+=usr/share/man/man4/i386/acpi_sony.4.gz +OLD_FILES+=usr/share/man/man4/i386/acpi_toshiba.4.gz +OLD_FILES+=usr/share/man/man4/i386/ichwd.4.gz +OLD_FILES+=usr/share/man/man4/i386/if_ndis.4.gz +OLD_FILES+=usr/share/man/man4/i386/io.4.gz +OLD_FILES+=usr/share/man/man4/i386/linux.4.gz +OLD_FILES+=usr/share/man/man4/i386/ndis.4.gz +.endif # 20080820: MPSAFE TTY layer integrated OLD_FILES+=usr/include/sys/linedisc.h OLD_FILES+=usr/share/man/man3/posix_openpt.3.gz ==== //depot/projects/mpsafetty/bin/Makefile#2 (text+ko) ==== @@ -1,5 +1,5 @@ # From: @(#)Makefile 8.1 (Berkeley) 5/31/93 -# $FreeBSD: src/bin/Makefile,v 1.27 2008/03/13 17:38:06 obrien Exp $ +# $FreeBSD: src/bin/Makefile,v 1.28 2008/08/31 14:27:59 yar Exp $ .include <bsd.own.mk> @@ -25,6 +25,7 @@ mkdir \ mv \ pax \ + pkill \ ps \ pwd \ ${_rcp} \ ==== //depot/projects/mpsafetty/bin/sh/sh.1#2 (text+ko) ==== @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 -.\" $FreeBSD: src/bin/sh/sh.1,v 1.126 2007/12/05 12:29:26 ru Exp $ +.\" $FreeBSD: src/bin/sh/sh.1,v 1.127 2008/08/30 22:35:21 ed Exp $ .\" .Dd October 7, 2006 .Dt SH 1 @@ -2118,7 +2118,7 @@ For aliases the alias expansion is printed; for commands and tracked aliases the complete pathname of the command is printed. -.It Ic ulimit Oo Fl HSabcdflmnstuv Oc Op Ar limit +.It Ic ulimit Oo Fl HSabcdflmnpstuv Oc Op Ar limit Set or display resource limits (see .Xr getrlimit 2 ) . If @@ -2172,6 +2172,8 @@ The maximal resident set size of a process, in kilobytes. .It Fl n Ar nofiles The maximal number of descriptors that could be opened by a process. +.It Fl p Ar pseudoterminals +The maximal number of pseudo-terminals for this user ID. .It Fl s Ar stacksize The maximal size of the stack segment, in kilobytes. .It Fl t Ar time ==== //depot/projects/mpsafetty/etc/sendmail/freebsd.submit.mc#2 (text+ko) ==== @@ -13,10 +13,9 @@ # This is the FreeBSD configuration for a set-group-ID sm-msp sendmail # that acts as a initial mail submission program. # -# divert(0)dnl -VERSIONID(`$FreeBSD: src/etc/sendmail/freebsd.submit.mc,v 1.6 2007/11/05 00:18:06 gshapiro Exp $') +VERSIONID(`$FreeBSD: src/etc/sendmail/freebsd.submit.mc,v 1.7 2008/08/31 18:21:15 gshapiro Exp $') define(`confCF_VERSION', `Submit')dnl define(`__OSTYPE__',`')dnl dirty hack to keep proto.m4 from complaining define(`_USE_DECNET_SYNTAX_', `1')dnl support DECnet ==== //depot/projects/mpsafetty/gnu/usr.bin/binutils/libbfd/Makefile.amd64#2 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/gnu/usr.bin/binutils/libbfd/Makefile.amd64,v 1.4 2004/07/08 17:05:32 obrien Exp $ +# $FreeBSD: src/gnu/usr.bin/binutils/libbfd/Makefile.amd64,v 1.5 2008/08/31 09:17:27 rpaulo Exp $ .include "${.CURDIR}/Makefile.i386" @@ -8,11 +8,13 @@ DEFAULT_VECTOR= bfd_elf64_x86_64_vec SRCS+= elf64-amd64-fbsd.c \ + efi-app-ia32.c \ elf64.c \ elf64-gen.c \ elf64-target.h -VECS= bfd_elf64_x86_64_vec \ +VECS= ${DEFAULT_VECTOR} \ + bfd_efi_app_ia32_vec \ ${I386_VECS} CLEANFILES+= elf64-amd64-fbsd.c ==== //depot/projects/mpsafetty/lib/libarchive/Makefile#3 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/lib/libarchive/Makefile,v 1.87 2008/08/24 05:54:28 kientzle Exp $ +# $FreeBSD: src/lib/libarchive/Makefile,v 1.88 2008/08/31 07:21:46 kientzle Exp $ LIB= archive DPADD= ${LIBBZ2} ${LIBZ} @@ -65,6 +65,7 @@ archive_write_set_format_by_name.c \ archive_write_set_format_cpio.c \ archive_write_set_format_cpio_newc.c \ + archive_write_set_format_mtree.c \ archive_write_set_format_pax.c \ archive_write_set_format_shar.c \ archive_write_set_format_ustar.c \ ==== //depot/projects/mpsafetty/lib/libarchive/archive.h#2 (text+ko) ==== @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libarchive/archive.h,v 1.18 2008/07/05 01:50:40 kientzle Exp $ + * $FreeBSD: src/lib/libarchive/archive.h,v 1.19 2008/08/31 07:21:46 kientzle Exp $ */ #ifndef ARCHIVE_H_INCLUDED @@ -465,6 +465,7 @@ __LA_DECL int archive_write_set_format_ar_svr4(struct archive *); __LA_DECL int archive_write_set_format_cpio(struct archive *); __LA_DECL int archive_write_set_format_cpio_newc(struct archive *); +__LA_DECL int archive_write_set_format_mtree(struct archive *); /* TODO: int archive_write_set_format_old_tar(struct archive *); */ __LA_DECL int archive_write_set_format_pax(struct archive *); __LA_DECL int archive_write_set_format_pax_restricted(struct archive *); ==== //depot/projects/mpsafetty/lib/libarchive/archive_write_set_format.c#2 (text+ko) ==== @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format.c,v 1.5 2007/06/22 05:47:00 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format.c,v 1.6 2008/08/31 07:21:46 kientzle Exp $"); #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -44,6 +44,7 @@ { ARCHIVE_FORMAT_CPIO, archive_write_set_format_cpio }, { ARCHIVE_FORMAT_CPIO_SVR4_NOCRC, archive_write_set_format_cpio_newc }, { ARCHIVE_FORMAT_CPIO_POSIX, archive_write_set_format_cpio }, + { ARCHIVE_FORMAT_MTREE, archive_write_set_format_mtree }, { ARCHIVE_FORMAT_SHAR, archive_write_set_format_shar }, { ARCHIVE_FORMAT_SHAR_BASE, archive_write_set_format_shar }, { ARCHIVE_FORMAT_SHAR_DUMP, archive_write_set_format_shar_dump }, ==== //depot/projects/mpsafetty/lib/libarchive/archive_write_set_format_by_name.c#2 (text+ko) ==== @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_by_name.c,v 1.7 2007/06/22 05:47:00 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_by_name.c,v 1.8 2008/08/31 07:21:46 kientzle Exp $"); #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -49,6 +49,7 @@ { "argnu", archive_write_set_format_ar_svr4 }, { "arsvr4", archive_write_set_format_ar_svr4 }, { "cpio", archive_write_set_format_cpio }, + { "mtree", archive_write_set_format_mtree }, { "newc", archive_write_set_format_cpio_newc }, { "odc", archive_write_set_format_cpio }, { "pax", archive_write_set_format_pax }, ==== //depot/projects/mpsafetty/lib/libarchive/archive_write_set_format_shar.c#2 (text+ko) ==== @@ -1,5 +1,6 @@ /*- * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2008 Joerg Sonnenberger * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,12 +25,11 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_shar.c,v 1.19 2008/03/15 11:04:45 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_shar.c,v 1.20 2008/08/31 07:10:40 kientzle Exp $"); #ifdef HAVE_ERRNO_H #include <errno.h> #endif -#include <stdarg.h> #include <stdio.h> #ifdef HAVE_STDLIB_H #include <stdlib.h> @@ -49,13 +49,14 @@ struct archive_entry *entry; int has_data; char *last_dir; - char outbuff[1024]; - size_t outbytes; + + /* Line buffer for uuencoded dump format */ + char outbuff[45]; size_t outpos; - int uuavail; - char uubuffer[3]; + int wrote_header; struct archive_string work; + struct archive_string quoted_name; }; static int archive_write_shar_finish(struct archive_write *); @@ -67,23 +68,33 @@ static ssize_t archive_write_shar_data_uuencode(struct archive_write *, const void * buff, size_t); static int archive_write_shar_finish_entry(struct archive_write *); -static int shar_printf(struct archive_write *, const char *fmt, ...); -static void uuencode_group(struct shar *); -static int -shar_printf(struct archive_write *a, const char *fmt, ...) +/* + * Copy the given string to the buffer, quoting all shell meta characters + * found. + */ +static void +shar_quote(struct archive_string *buf, const char *str, int in_shell) { - struct shar *shar; - va_list ap; - int ret; + static const char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~"; + size_t len; - shar = (struct shar *)a->format_data; - va_start(ap, fmt); - archive_string_empty(&(shar->work)); - archive_string_vsprintf(&(shar->work), fmt, ap); - ret = ((a->compressor.write)(a, shar->work.s, strlen(shar->work.s))); - va_end(ap); - return (ret); + while (*str != '\0') { + if ((len = strcspn(str, meta)) != 0) { + archive_strncat(buf, str, len); + str += len; + } else if (*str == '\n') { + if (in_shell) + archive_strcat(buf, "\"\n\""); + else + archive_strcat(buf, "\\n"); + ++str; + } else { + archive_strappend_char(buf, '\\'); + archive_strappend_char(buf, *str); + ++str; + } + } } /* @@ -105,6 +116,8 @@ return (ARCHIVE_FATAL); } memset(shar, 0, sizeof(*shar)); + archive_string_init(&shar->work); + archive_string_init(&shar->quoted_name); a->format_data = shar; a->pad_uncompressed = 0; @@ -146,16 +159,11 @@ const char *name; char *p, *pp; struct shar *shar; - int ret; shar = (struct shar *)a->format_data; if (!shar->wrote_header) { - ret = shar_printf(a, "#!/bin/sh\n"); - if (ret != ARCHIVE_OK) - return (ret); - ret = shar_printf(a, "# This is a shell archive\n"); - if (ret != ARCHIVE_OK) - return (ret); + archive_strcat(&shar->work, "#!/bin/sh\n"); + archive_strcat(&shar->work, "# This is a shell archive\n"); shar->wrote_header = 1; } @@ -192,10 +200,11 @@ } } + archive_string_empty(&shar->quoted_name); + shar_quote(&shar->quoted_name, name, 1); + /* Stock preparation for all file types. */ - ret = shar_printf(a, "echo x %s\n", name); - if (ret != ARCHIVE_OK) - return (ret); + archive_string_sprintf(&shar->work, "echo x %s\n", shar->quoted_name.s); if (archive_entry_filetype(entry) != AE_IFDIR) { /* Try to create the dir. */ @@ -210,12 +219,10 @@ /* Don't try to "mkdir ." */ free(p); } else if (shar->last_dir == NULL) { - ret = shar_printf(a, - "mkdir -p %s > /dev/null 2>&1\n", p); - if (ret != ARCHIVE_OK) { - free(p); - return (ret); - } + archive_strcat(&shar->work, "mkdir -p "); + shar_quote(&shar->work, p, 1); + archive_strcat(&shar->work, + " > /dev/null 2>&1\n"); shar->last_dir = p; } else if (strcmp(p, shar->last_dir) == 0) { /* We've already created this exact dir. */ @@ -225,13 +232,10 @@ /* We've already created a subdir. */ free(p); } else { - ret = shar_printf(a, - "mkdir -p %s > /dev/null 2>&1\n", p); - if (ret != ARCHIVE_OK) { - free(p); - return (ret); - } - free(shar->last_dir); + archive_strcat(&shar->work, "mkdir -p "); + shar_quote(&shar->work, p, 1); + archive_strcat(&shar->work, + " > /dev/null 2>&1\n"); shar->last_dir = p; } } else { @@ -242,51 +246,47 @@ /* Handle file-type specific issues. */ shar->has_data = 0; if ((linkname = archive_entry_hardlink(entry)) != NULL) { - ret = shar_printf(a, "ln -f %s %s\n", linkname, name); - if (ret != ARCHIVE_OK) - return (ret); + archive_strcat(&shar->work, "ln -f "); + shar_quote(&shar->work, linkname, 1); + archive_string_sprintf(&shar->work, " %s\n", + shar->quoted_name.s); } else if ((linkname = archive_entry_symlink(entry)) != NULL) { - ret = shar_printf(a, "ln -fs %s %s\n", linkname, name); - if (ret != ARCHIVE_OK) - return (ret); + archive_strcat(&shar->work, "ln -fs "); + shar_quote(&shar->work, linkname, 1); + archive_string_sprintf(&shar->work, " %s\n", + shar->quoted_name.s); } else { switch(archive_entry_filetype(entry)) { case AE_IFREG: if (archive_entry_size(entry) == 0) { /* More portable than "touch." */ - ret = shar_printf(a, "test -e \"%s\" || :> \"%s\"\n", name, name); - if (ret != ARCHIVE_OK) - return (ret); + archive_string_sprintf(&shar->work, + "test -e \"%s\" || :> \"%s\"\n", + shar->quoted_name.s, shar->quoted_name.s); } else { if (shar->dump) { - ret = shar_printf(a, - "uudecode -o %s << 'SHAR_END'\n", - name); - if (ret != ARCHIVE_OK) - return (ret); - ret = shar_printf(a, "begin %o %s\n", - archive_entry_mode(entry) & 0777, - name); - if (ret != ARCHIVE_OK) - return (ret); + archive_string_sprintf(&shar->work, + "uudecode -p > %s << 'SHAR_END'\n", + shar->quoted_name.s); + archive_string_sprintf(&shar->work, + "begin %o ", + archive_entry_mode(entry) & 0777); + shar_quote(&shar->work, name, 0); + archive_strcat(&shar->work, "\n"); } else { - ret = shar_printf(a, + archive_string_sprintf(&shar->work, "sed 's/^X//' > %s << 'SHAR_END'\n", - name); - if (ret != ARCHIVE_OK) - return (ret); + shar->quoted_name.s); } shar->has_data = 1; shar->end_of_line = 1; shar->outpos = 0; - shar->outbytes = 0; } break; case AE_IFDIR: - ret = shar_printf(a, "mkdir -p %s > /dev/null 2>&1\n", - name); - if (ret != ARCHIVE_OK) - return (ret); + archive_string_sprintf(&shar->work, + "mkdir -p %s > /dev/null 2>&1\n", + shar->quoted_name.s); /* Record that we just created this directory. */ if (shar->last_dir != NULL) free(shar->last_dir); @@ -302,23 +302,20 @@ */ break; case AE_IFIFO: - ret = shar_printf(a, "mkfifo %s\n", name); - if (ret != ARCHIVE_OK) - return (ret); + archive_string_sprintf(&shar->work, + "mkfifo %s\n", shar->quoted_name.s); break; case AE_IFCHR: - ret = shar_printf(a, "mknod %s c %d %d\n", name, + archive_string_sprintf(&shar->work, + "mknod %s c %d %d\n", shar->quoted_name.s, archive_entry_rdevmajor(entry), archive_entry_rdevminor(entry)); - if (ret != ARCHIVE_OK) - return (ret); break; case AE_IFBLK: - ret = shar_printf(a, "mknod %s b %d %d\n", name, + archive_string_sprintf(&shar->work, + "mknod %s b %d %d\n", shar->quoted_name.s, archive_entry_rdevmajor(entry), archive_entry_rdevminor(entry)); - if (ret != ARCHIVE_OK) - return (ret); break; default: return (ARCHIVE_WARN); @@ -328,69 +325,119 @@ return (ARCHIVE_OK); } -/* XXX TODO: This could be more efficient XXX */ static ssize_t archive_write_shar_data_sed(struct archive_write *a, const void *buff, size_t n) { + static const size_t ensured = 65533; struct shar *shar; const char *src; + char *buf, *buf_end; int ret; size_t written = n; shar = (struct shar *)a->format_data; - if (!shar->has_data) + if (!shar->has_data || n == 0) return (0); src = (const char *)buff; - ret = ARCHIVE_OK; - shar->outpos = 0; - while (n-- > 0) { - if (shar->end_of_line) { - shar->outbuff[shar->outpos++] = 'X'; - shar->end_of_line = 0; + + /* + * ensure is the number of bytes in buffer before expanding the + * current character. Each operation writes the current character + * and optionally the start-of-new-line marker. This can happen + * twice before entering the loop, so make sure three additional + * bytes can be written. + */ + if (archive_string_ensure(&shar->work, ensured + 3) == NULL) + __archive_errx(1, "Out of memory"); + + if (shar->work.length > ensured) { + ret = (*a->compressor.write)(a, shar->work.s, + shar->work.length); + if (ret != ARCHIVE_OK) + return (ARCHIVE_FATAL); + archive_string_empty(&shar->work); + } + buf = shar->work.s + shar->work.length; + buf_end = shar->work.s + ensured; + + if (shar->end_of_line) { + *buf++ = 'X'; + shar->end_of_line = 0; + } + + while (n-- != 0) { + if ((*buf++ = *src++) == '\n') { + if (n == 0) + shar->end_of_line = 1; + else + *buf++ = 'X'; } - if (*src == '\n') - shar->end_of_line = 1; - shar->outbuff[shar->outpos++] = *src++; - if (shar->outpos > sizeof(shar->outbuff) - 2) { - ret = (a->compressor.write)(a, shar->outbuff, - shar->outpos); + if (buf >= buf_end) { + shar->work.length = buf - shar->work.s; + ret = (*a->compressor.write)(a, shar->work.s, + shar->work.length); if (ret != ARCHIVE_OK) - return (ret); - shar->outpos = 0; + return (ARCHIVE_FATAL); + archive_string_empty(&shar->work); + buf = shar->work.s; } } - if (shar->outpos > 0) - ret = (a->compressor.write)(a, shar->outbuff, shar->outpos); - if (ret != ARCHIVE_OK) - return (ret); + shar->work.length = buf - shar->work.s; + return (written); } #define UUENC(c) (((c)!=0) ? ((c) & 077) + ' ': '`') -/* XXX This could be a lot more efficient. XXX */ +static void +uuencode_group(const char _in[3], char out[4]) +{ + const unsigned char *in = (const unsigned char *)_in; + int t; + + t = (in[0] << 16) | (in[1] << 8) | in[2]; + out[0] = UUENC( 0x3f & (t >> 18) ); + out[1] = UUENC( 0x3f & (t >> 12) ); + out[2] = UUENC( 0x3f & (t >> 6) ); + out[3] = UUENC( 0x3f & t ); +} + static void -uuencode_group(struct shar *shar) +uuencode_line(struct shar *shar, const char *inbuf, size_t len) { - int t; + char tmp_buf[3], *buf; + size_t alloc_len; + + /* len <= 45 -> expanded to 60 + len byte + new line */ + alloc_len = shar->work.length + 62; + if (archive_string_ensure(&shar->work, alloc_len) == NULL) + __archive_errx(1, "Out of memory"); - t = 0; - if (shar->uuavail > 0) - t = 0xff0000 & (shar->uubuffer[0] << 16); - if (shar->uuavail > 1) - t |= 0x00ff00 & (shar->uubuffer[1] << 8); - if (shar->uuavail > 2) - t |= 0x0000ff & (shar->uubuffer[2]); - shar->outbuff[shar->outpos++] = UUENC( 0x3f & (t>>18) ); - shar->outbuff[shar->outpos++] = UUENC( 0x3f & (t>>12) ); - shar->outbuff[shar->outpos++] = UUENC( 0x3f & (t>>6) ); - shar->outbuff[shar->outpos++] = UUENC( 0x3f & (t) ); - shar->uuavail = 0; - shar->outbytes += shar->uuavail; - shar->outbuff[shar->outpos] = 0; + buf = shar->work.s + shar->work.length; + *buf++ = UUENC(len); + while (len >= 3) { + uuencode_group(inbuf, buf); + len -= 3; + inbuf += 3; + buf += 4; + } + if (len != 0) { + tmp_buf[0] = inbuf[0]; + if (len == 1) + tmp_buf[1] = '\0'; + else + tmp_buf[1] = inbuf[1]; + tmp_buf[2] = '\0'; + uuencode_group(inbuf, buf); + buf += 4; + } + *buf++ = '\n'; + if ((buf - shar->work.s) > (ptrdiff_t)(shar->work.length + 62)) + __archive_errx(1, "Buffer overflow"); + shar->work.length = buf - shar->work.s; } static ssize_t @@ -406,21 +453,39 @@ if (!shar->has_data) return (ARCHIVE_OK); src = (const char *)buff; - n = length; - while (n-- > 0) { - if (shar->uuavail == 3) - uuencode_group(shar); - if (shar->outpos >= 60) { - ret = shar_printf(a, "%c%s\n", UUENC(shar->outbytes), - shar->outbuff); - if (ret != ARCHIVE_OK) - return (ret); - shar->outpos = 0; - shar->outbytes = 0; + + if (shar->outpos != 0) { + n = 45 - shar->outpos; + if (n > length) + n = length; + memcpy(shar->outbuff + shar->outpos, src, n); + if (shar->outpos + n < 45) { + shar->outpos += n; + return length; } + uuencode_line(shar, shar->outbuff, 45); + src += n; + n = length - n; + } else { + n = length; + } - shar->uubuffer[shar->uuavail++] = *src++; - shar->outbytes++; + while (n >= 45) { + uuencode_line(shar, src, 45); + src += 45; + n -= 45; + + if (shar->work.length < 65536) + continue; + ret = (*a->compressor.write)(a, shar->work.s, + shar->work.length); + if (ret != ARCHIVE_OK) + return (ARCHIVE_FATAL); + archive_string_empty(&shar->work); + } + if (n != 0) { + memcpy(shar->outbuff, src, n); + shar->outpos = n; } return (length); } @@ -439,54 +504,43 @@ if (shar->dump) { /* Finish uuencoded data. */ if (shar->has_data) { - if (shar->uuavail > 0) - uuencode_group(shar); - if (shar->outpos > 0) { - ret = shar_printf(a, "%c%s\n", - UUENC(shar->outbytes), shar->outbuff); - if (ret != ARCHIVE_OK) - return (ret); - shar->outpos = 0; - shar->uuavail = 0; - shar->outbytes = 0; - } - ret = shar_printf(a, "%c\n", UUENC(0)); - if (ret != ARCHIVE_OK) - return (ret); - ret = shar_printf(a, "end\n", UUENC(0)); - if (ret != ARCHIVE_OK) - return (ret); - ret = shar_printf(a, "SHAR_END\n"); - if (ret != ARCHIVE_OK) - return (ret); + if (shar->outpos > 0) + uuencode_line(shar, shar->outbuff, + shar->outpos); + archive_strcat(&shar->work, "`\nend\n"); + archive_strcat(&shar->work, "SHAR_END\n"); } /* Restore file mode, owner, flags. */ /* * TODO: Don't immediately restore mode for * directories; defer that to end of script. */ - ret = shar_printf(a, "chmod %o %s\n", - archive_entry_mode(shar->entry) & 07777, - archive_entry_pathname(shar->entry)); - if (ret != ARCHIVE_OK) - return (ret); + archive_string_sprintf(&shar->work, "chmod %o ", + archive_entry_mode(shar->entry) & 07777); + shar_quote(&shar->work, archive_entry_pathname(shar->entry), 1); + archive_strcat(&shar->work, "\n"); u = archive_entry_uname(shar->entry); g = archive_entry_gname(shar->entry); if (u != NULL || g != NULL) { - ret = shar_printf(a, "chown %s%s%s %s\n", - (u != NULL) ? u : "", - (g != NULL) ? ":" : "", (g != NULL) ? g : "", - archive_entry_pathname(shar->entry)); - if (ret != ARCHIVE_OK) - return (ret); + archive_strcat(&shar->work, "chown "); + if (u != NULL) + shar_quote(&shar->work, u, 1); + if (g != NULL) { + archive_strcat(&shar->work, ":"); + shar_quote(&shar->work, g, 1); + } + shar_quote(&shar->work, + archive_entry_pathname(shar->entry), 1); + archive_strcat(&shar->work, "\n"); } if ((p = archive_entry_fflags_text(shar->entry)) != NULL) { - ret = shar_printf(a, "chflags %s %s\n", p, - archive_entry_pathname(shar->entry)); - if (ret != ARCHIVE_OK) - return (ret); + archive_string_sprintf(&shar->work, "chflags %s ", + p, archive_entry_pathname(shar->entry)); + shar_quote(&shar->work, + archive_entry_pathname(shar->entry), 1); + archive_strcat(&shar->work, "\n"); } /* TODO: restore ACLs */ @@ -494,20 +548,24 @@ } else { if (shar->has_data) { /* Finish sed-encoded data: ensure last line ends. */ - if (!shar->end_of_line) { - ret = shar_printf(a, "\n"); - if (ret != ARCHIVE_OK) - return (ret); - } - ret = shar_printf(a, "SHAR_END\n"); - if (ret != ARCHIVE_OK) - return (ret); + if (!shar->end_of_line) + archive_strappend_char(&shar->work, '\n'); + archive_strcat(&shar->work, "SHAR_END\n"); } } archive_entry_free(shar->entry); shar->entry = NULL; - return (0); + + if (shar->work.length < 65536) + return (ARCHIVE_OK); + + ret = (*a->compressor.write)(a, shar->work.s, shar->work.length); + if (ret != ARCHIVE_OK) + return (ARCHIVE_FATAL); + archive_string_empty(&shar->work); + + return (ARCHIVE_OK); } static int @@ -529,17 +587,22 @@ * shar format, then sets another format (which would invoke * shar_finish to free the format-specific data). */ - if (shar->wrote_header) { - ret = shar_printf(a, "exit\n"); - if (ret != ARCHIVE_OK) - return (ret); - /* Shar output is never padded. */ - archive_write_set_bytes_in_last_block(&a->archive, 1); - /* - * TODO: shar should also suppress padding of - * uncompressed data within gzip/bzip2 streams. - */ - } + if (shar->wrote_header == 0) + return (ARCHIVE_OK); + + archive_strcat(&shar->work, "exit\n"); + + ret = (*a->compressor.write)(a, shar->work.s, shar->work.length); + if (ret != ARCHIVE_OK) + return (ARCHIVE_FATAL); + + /* Shar output is never padded. */ + archive_write_set_bytes_in_last_block(&a->archive, 1); + /* + * TODO: shar should also suppress padding of + * uncompressed data within gzip/bzip2 streams. + */ + return (ARCHIVE_OK); } @@ -549,11 +612,13 @@ struct shar *shar; shar = (struct shar *)a->format_data; - if (shar->entry != NULL) - archive_entry_free(shar->entry); - if (shar->last_dir != NULL) - free(shar->last_dir); + if (shar == NULL) + return (ARCHIVE_OK); + + archive_entry_free(shar->entry); + free(shar->last_dir); archive_string_free(&(shar->work)); + archive_string_free(&(shar->quoted_name)); free(shar); a->format_data = NULL; return (ARCHIVE_OK); ==== //depot/projects/mpsafetty/lib/libarchive/test/main.c#2 (text+ko) ==== @@ -40,10 +40,12 @@ * The next few lines are the only differences. */ #undef PROGRAM /* Testing a library, not a program. */ +#define LIBRARY "libarchive" #define ENVBASE "LIBARCHIVE" /* Prefix for environment variables. */ #define EXTRA_DUMP(x) archive_error_string((struct archive *)(x)) #define EXTRA_VERSION archive_version() -__FBSDID("$FreeBSD: src/lib/libarchive/test/main.c,v 1.13 2008/06/15 10:35:22 kientzle Exp $"); +#define KNOWNREF "test_compat_gtar_1.tgz.uu" +__FBSDID("$FreeBSD: src/lib/libarchive/test/main.c,v 1.14 2008/08/31 07:06:02 kientzle Exp $"); /* * "list.h" is simply created by "grep DEFINE_TEST"; it has @@ -841,7 +843,53 @@ fclose(in); } +static char * +get_refdir(const char *tmpdir) +{ + char *ref, *p; + /* Get the current dir. */ + systemf("/bin/pwd > %s/refdir", tmpdir); + ref = slurpfile(NULL, "%s/refdir", tmpdir); + p = ref + strlen(ref); + while (p[-1] == '\n') { + --p; + *p = '\0'; + } + systemf("rm %s/refdir", tmpdir); + /* Look for a known file. */ + p = slurpfile(NULL, "%s/%s", ref, KNOWNREF); + if (p != NULL) { + free(p); + return (ref); + } + p = slurpfile(NULL, "%s/test/%s", ref, KNOWNREF); + if (p != NULL) { + free(p); + p = malloc(strlen(ref) + strlen("/test") + 1); + strcpy(p, ref); + strcat(p, "/test"); + free(ref); + return (p); + } + p = slurpfile(NULL, "%s/%s/test/%s", ref, LIBRARY, KNOWNREF); + if (p != NULL) { + free(p); + p = malloc(strlen(ref) + 1 + strlen(LIBRARY) + strlen("/test") + 1); + strcpy(p, ref); + strcat(p, "/"); + strcat(p, LIBRARY); + strcat(p, "/test"); + free(ref); + return (p); + } + printf("Unable to locate known reference file %s\n", KNOWNREF); + printf(" Checked directory %s\n", ref); + printf(" Checked directory %s/test\n", ref); + printf(" Checked directory %s/%s/test\n", ref, LIBRARY); + exit(1); +} + int main(int argc, char **argv) { >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808312050.m7VKo4D5013121>