svn commit: r213469 - head/usr.bin/tar

2010-10-05 Thread Tim Kientzle
Author: kientzle
Date: Wed Oct  6 04:30:40 2010
New Revision: 213469
URL: http://svn.freebsd.org/changeset/base/213469

Log:
  Recognize both ! and ^ as markers for negated character classes.
  
  Submitted by: Mykola Dzham

Modified:
  head/usr.bin/tar/pathmatch.c

Modified: head/usr.bin/tar/pathmatch.c
==
--- head/usr.bin/tar/pathmatch.cWed Oct  6 01:23:40 2010
(r213468)
+++ head/usr.bin/tar/pathmatch.cWed Oct  6 04:30:40 2010
(r213469)
@@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$");
 
 /*
  * Check whether a character 'c' is matched by a list specification [...]:
- ** Leading '!' negates the class.
+ ** Leading '!' or '^' negates the class.
  ** - is a range of characters
  ** \ removes any special meaning for 
  *
@@ -60,7 +60,7 @@ pm_list(const char *start, const char *e
(void)flags; /* UNUSED */
 
/* If this is a negated class, return success for nomatch. */
-   if (*p == '!' && p < end) {
+   if ((*p == '!' || *p == '^') && p < end) {
match = 0;
nomatch = 1;
++p;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213643 - head/usr.bin/ar

2010-10-08 Thread Tim Kientzle
Author: kientzle
Date: Sat Oct  9 05:31:08 2010
New Revision: 213643
URL: http://svn.freebsd.org/changeset/base/213643

Log:
  Add -D (deterministic) option to ar.
  When set, it forces all timestamps and owners to zero and
  modes to 0644.  Useful for producing libraries that are
  bitwise identical across multiple build runs.
  
  Submitted by: Erik Cederstrand
  Reviewed by:  Kai Wang

Modified:
  head/usr.bin/ar/ar.1
  head/usr.bin/ar/ar.c
  head/usr.bin/ar/ar.h
  head/usr.bin/ar/write.c

Modified: head/usr.bin/ar/ar.1
==
--- head/usr.bin/ar/ar.1Sat Oct  9 02:50:23 2010(r213642)
+++ head/usr.bin/ar/ar.1Sat Oct  9 05:31:08 2010(r213643)
@@ -62,6 +62,7 @@
 .Op Fl a Ar position-after
 .Op Fl b Ar position-before
 .Op Fl c
+.Op Fl D
 .Op Fl i Ar position-before
 .Op Fl j
 .Op Fl s
@@ -179,6 +180,16 @@ from the archive specified by argument
 .Ar archive .
 The archive's symbol table, if present, is updated to reflect
 the new contents of the archive.
+.It Fl D
+When used in combination with the 
+.Fl r
+or
+.Fl q
+option, insert 0's instead of the real mtime, uid and gid values 
+and 0644 instead of file mode from the members named by arguments
+.Ar files ... .
+This ensures that checksums on the resulting archives are reproducible
+when member contents are identical.
 .It Fl f
 Synonymous with option
 .Fl T .

Modified: head/usr.bin/ar/ar.c
==
--- head/usr.bin/ar/ar.cSat Oct  9 02:50:23 2010(r213642)
+++ head/usr.bin/ar/ar.cSat Oct  9 05:31:08 2010(r213643)
@@ -154,7 +154,7 @@ main(int argc, char **argv)
}
}
 
-   while ((opt = getopt_long(argc, argv, "abCcdfijlMmopqrSsTtuVvxz",
+   while ((opt = getopt_long(argc, argv, "abCcdDfijlMmopqrSsTtuVvxz",
longopts, NULL)) != -1) {
switch(opt) {
case 'a':
@@ -173,6 +173,9 @@ main(int argc, char **argv)
case 'd':
set_mode(bsdar, opt);
break;
+   case 'D':
+   bsdar->options |= AR_D;
+   break;
case 'f':
case 'T':
bsdar->options |= AR_TR;
@@ -269,6 +272,8 @@ main(int argc, char **argv)
only_mode(bsdar, "-c", "qr");
if (bsdar->options & AR_CC)
only_mode(bsdar, "-C", "x");
+   if (bsdar->options & AR_D)
+   only_mode(bsdar, "-D", "qr");
if (bsdar->options & AR_O)
only_mode(bsdar, "-o", "x");
if (bsdar->options & AR_SS)
@@ -356,9 +361,9 @@ bsdar_usage(void)
(void)fprintf(stderr, "\tar -m [-Tjsvz] archive file ...\n");
(void)fprintf(stderr, "\tar -m [-Tabijsvz] position archive file 
...\n");
(void)fprintf(stderr, "\tar -p [-Tv] archive [file ...]\n");
-   (void)fprintf(stderr, "\tar -q [-Tcjsvz] archive file ...\n");
-   (void)fprintf(stderr, "\tar -r [-Tcjsuvz] archive file ...\n");
-   (void)fprintf(stderr, "\tar -r [-Tabcijsuvz] position archive file 
...\n");
+   (void)fprintf(stderr, "\tar -q [-TcDjsvz] archive file ...\n");
+   (void)fprintf(stderr, "\tar -r [-TcDjsuvz] archive file ...\n");
+   (void)fprintf(stderr, "\tar -r [-TabcDijsuvz] position archive file 
...\n");
(void)fprintf(stderr, "\tar -s [-jz] archive\n");
(void)fprintf(stderr, "\tar -t [-Tv] archive [file ...]\n");
(void)fprintf(stderr, "\tar -x [-CTouv] archive [file ...]\n");

Modified: head/usr.bin/ar/ar.h
==
--- head/usr.bin/ar/ar.hSat Oct  9 02:50:23 2010(r213642)
+++ head/usr.bin/ar/ar.hSat Oct  9 05:31:08 2010(r213643)
@@ -43,6 +43,7 @@
 #define AR_U   0x0200  /* only extract or update newer members.*/
 #define AR_V   0x0400  /* verbose mode */
 #define AR_Z   0x0800  /* gzip compression */
+#define AR_D   0x1000  /* insert dummy mode, mtime, uid and gid */
 
 #define DEF_BLKSZ 10240/* default block size */
 

Modified: head/usr.bin/ar/write.c
==
--- head/usr.bin/ar/write.c Sat Oct  9 02:50:23 2010(r213642)
+++ head/usr.bin/ar/write.c Sat Oct  9 05:31:08 2010(r213643)
@@ -163,11 +163,24 @@ create_obj_from_file(struct bsdar *bsdar
if (mtime != 0 && bsdar->options & AR_U && sb.st_mtime <= mtime)
goto giveup;
 
-   obj->uid = sb.st_uid;
-   obj->gid = sb.st_gid;
-   obj->md = sb.st_mode;
+   /*
+* When option '-D' is specified, mtime and UID / GID from the file
+* will be replaced with 0, and file mode with 644. This ensures that 
+* checksums will match for two archi

Re: svn commit: r214596 - head/bin/rm

2010-10-31 Thread Tim Kientzle

On Oct 31, 2010, at 9:06 AM, Pawel Jakub Dawidek wrote:

> On Sun, Oct 31, 2010 at 09:21:28AM +, Ulrich Spoerlein wrote:
>> Author: uqs
>> Date: Sun Oct 31 09:21:27 2010
>> New Revision: 214596
>> URL: http://svn.freebsd.org/changeset/base/214596
>> 
>> Log:
>>  Elaborate some more on the non-security implications of using -P
> [...]
>> +.Pp
>> +N.B.: The
>> +.Fl P
>> +flag is not considered a security feature
>> +.Pq see Sx BUGS .
> 
> I'm sorry for jumping so late into the subject, but if it is not a
> security feature than what other purpose has left?
> 
> Really guys, this option is useless.

I completely agree.

> There is no reliable way to verify if the blocks are really overwritten.
> Period.

Not from userspace, no.  I think the only reasonable approach
is to add a new syscall (unlink_with_overwrite(2)?) and chase the
implications down through the filesystem, GEOM, and driver
interfaces.

Tim

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r228750 - head/usr.bin/cpio/test

2011-12-21 Thread Tim Kientzle
On Dec 20, 2011, at 2:27 PM, Martin Matuska wrote:
> On 20.12.2011 21:56, John Baldwin wrote:
>> On Tuesday, December 20, 2011 3:37:17 pm Martin Matuska wrote:
>>> Author: mm
>>> Date: Tue Dec 20 20:37:17 2011
>>> New Revision: 228750
>>> URL: http://svn.freebsd.org/changeset/base/228750
>>> 
>>> Log:
>>>  Sync bsdcpio with vendor branch release/2.8:
>>> 
>>>  Revision 3770:
>>>  Merge r3768 from trunk: Fix typo in dev/ino verification for cpio formats.
>>> 
>>>  Obtained from: http://code.google.com/p/libarchive
>>>  MFC after: 2 weeks
>> If libarchive is now maintained externally rather than in the tree, is it 
>> time 
>> for bsdtar, bsdcpio, and libarchive to move to contrib and for vendor 
>> imports 
>> to be managed as they are for other contrib bits?
>> 
> I agree, this is the right thing to do. I am going to start making
> appropriate bits under vendor/.

Thanks for tackling this, Martin.

It's long overdue.

Tim

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214822 - head/lib/libarchive

2010-11-04 Thread Tim Kientzle
Author: kientzle
Date: Fri Nov  5 05:11:54 2010
New Revision: 214822
URL: http://svn.freebsd.org/changeset/base/214822

Log:
  Clarify the naming:  Methods that free an object should
  be called "free".  Retain the old "finish" names to preserve
  source compatibility for now.

Modified:
  head/lib/libarchive/archive.h
  head/lib/libarchive/archive_private.h
  head/lib/libarchive/archive_read.3
  head/lib/libarchive/archive_read.c
  head/lib/libarchive/archive_read_disk.3
  head/lib/libarchive/archive_read_disk.c
  head/lib/libarchive/archive_read_extract.c
  head/lib/libarchive/archive_virtual.c
  head/lib/libarchive/archive_write.3
  head/lib/libarchive/archive_write.c
  head/lib/libarchive/archive_write_disk.3
  head/lib/libarchive/archive_write_disk.c
  head/lib/libarchive/libarchive.3

Modified: head/lib/libarchive/archive.h
==
--- head/lib/libarchive/archive.h   Fri Nov  5 02:45:13 2010
(r214821)
+++ head/lib/libarchive/archive.h   Fri Nov  5 05:11:54 2010
(r214822)
@@ -482,11 +482,10 @@ __LA_DECL voidarchive_read_extract_set
 /* Close the file and release most resources. */
 __LA_DECL int   archive_read_close(struct archive *);
 /* Release all resources and destroy the object. */
-/* Note that archive_read_finish will call archive_read_close for you. */
-#if ARCHIVE_VERSION_NUMBER < 200
-/* Erroneously declared to return void in libarchive 1.x */
-__LA_DECL void  archive_read_finish(struct archive *);
-#else
+/* Note that archive_read_free will call archive_read_close for you. */
+__LA_DECL int   archive_read_free(struct archive *);
+#if ARCHIVE_VERSION_NUMBER < 400
+/* Synonym for archive_read_free() for backwards compatibility. */
 __LA_DECL int   archive_read_finish(struct archive *);
 #endif
 
@@ -503,7 +502,7 @@ __LA_DECL intarchive_read_finish(stru
  *  - archive_write_header to write the header
  *  - archive_write_data to write the entry data
  *   5) archive_write_close to close the output
- *   6) archive_write_finish to cleanup the writer and release resources
+ *   6) archive_write_free to cleanup the writer and release resources
  */
 __LA_DECL struct archive   *archive_write_new(void);
 __LA_DECL int   archive_write_set_bytes_per_block(struct archive *,
@@ -584,13 +583,12 @@ __LA_DECL __LA_SSIZE_T archive_write_da
 #endif
 __LA_DECL int   archive_write_finish_entry(struct archive *);
 __LA_DECL int   archive_write_close(struct archive *);
-#if ARCHIVE_VERSION_NUMBER < 200
-/* Return value was incorrect in libarchive 1.x. */
-__LA_DECL void  archive_write_finish(struct archive *);
-#else
-/* Libarchive 2.x and later returns an error if this fails. */
-/* It can fail if the archive wasn't already closed, in which case
- * archive_write_finish() will implicitly call archive_write_close(). */
+
+/* This can fail if the archive wasn't already closed, in which case
+ * archive_write_free() will implicitly call archive_write_close(). */
+__LA_DECL int   archive_write_free(struct archive *);
+#if ARCHIVE_VERSION_NUMBER < 400
+/* Synonym for archive_write_free() for backwards compatibility. */
 __LA_DECL int   archive_write_finish(struct archive *);
 #endif
 
@@ -619,7 +617,7 @@ __LA_DECL int   archive_write_set_options
  *  - construct an appropriate struct archive_entry structure
  *  - archive_write_header to create the file/dir/etc on disk
  *  - archive_write_data to write the entry data
- *   4) archive_write_finish to cleanup the writer and release resources
+ *   4) archive_write_free to cleanup the writer and release resources
  *
  * In particular, you can use this in conjunction with archive_read()
  * to pull entries out of an archive and create them on disk.

Modified: head/lib/libarchive/archive_private.h
==
--- head/lib/libarchive/archive_private.h   Fri Nov  5 02:45:13 2010
(r214821)
+++ head/lib/libarchive/archive_private.h   Fri Nov  5 05:11:54 2010
(r214822)
@@ -58,7 +58,7 @@
 
 struct archive_vtable {
int (*archive_close)(struct archive *);
-   int (*archive_finish)(struct archive *);
+   int (*archive_free)(struct archive *);
int (*archive_write_header)(struct archive *,
struct archive_entry *);
int (*archive_write_finish_entry)(struct archive *);

Modified: head/lib/libarchive/archive_read.3
==
--- head/lib/libarchive/archive_read.3  Fri Nov  5 02:45:13 2010
(r214821)
+++ head/lib/libarchive/archive_read.3  Fri Nov  5 05:11:54 2010
(r214822)
@@ -69,7 +69,7 @@
 .Nm archive_read_extract2 ,
 .Nm archive_read_extract_set_progress_callback ,
 .Nm archive_read_close ,

svn commit: r214905 - in head/lib/libarchive: . test

2010-11-06 Thread Tim Kientzle
Author: kientzle
Date: Sun Nov  7 03:40:37 2010
New Revision: 214905
URL: http://svn.freebsd.org/changeset/base/214905

Log:
  If the Zip reader doesn't see a PK signature block
  because there's inter-entry garbage, just scan forward
  to find the next one.  This allows us to handle a lot
  of Zip archives that have been modified in-place.
  
  Thanks to: Gleb Kurtsou for sending me a sample archive

Added:
  head/lib/libarchive/test/test_compat_zip_2.zip.uu   (contents, props changed)
Modified:
  head/lib/libarchive/archive_read_support_format_zip.c
  head/lib/libarchive/test/test_compat_zip.c

Modified: head/lib/libarchive/archive_read_support_format_zip.c
==
--- head/lib/libarchive/archive_read_support_format_zip.c   Sun Nov  7 
03:26:22 2010(r214904)
+++ head/lib/libarchive/archive_read_support_format_zip.c   Sun Nov  7 
03:40:37 2010(r214905)
@@ -128,6 +128,7 @@ static int  archive_read_format_zip_read_
 static int archive_read_format_zip_read_data_skip(struct archive_read *a);
 static int archive_read_format_zip_read_header(struct archive_read *,
struct archive_entry *);
+static int search_next_signature(struct archive_read *);
 static int zip_read_data_deflate(struct archive_read *a, const void **buff,
size_t *size, off_t *offset);
 static int zip_read_data_none(struct archive_read *a, const void **buff,
@@ -317,10 +318,17 @@ archive_read_format_zip_read_header(stru
signature = (const char *)h;
}
 
+   /* If we don't see a PK signature here, scan forward. */
if (signature[0] != 'P' || signature[1] != 'K') {
-   archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-   "Bad ZIP file");
-   return (ARCHIVE_FATAL);
+   r = search_next_signature(a);
+   if (r != ARCHIVE_OK) {
+   archive_set_error(&a->archive, 
ARCHIVE_ERRNO_FILE_FORMAT,
+   "Bad ZIP file");
+   return (ARCHIVE_FATAL);
+   }
+   if ((h = __archive_read_ahead(a, 4, NULL)) == NULL)
+   return (ARCHIVE_FATAL);
+   signature = (const char *)h;
}
 
/*
@@ -375,6 +383,42 @@ archive_read_format_zip_read_header(stru
 }
 
 static int
+search_next_signature(struct archive_read *a)
+{
+   const void *h;
+   const char *p, *q;
+   size_t skip;
+   ssize_t bytes;
+   int64_t skipped = 0;
+
+   for (;;) {
+   h = __archive_read_ahead(a, 4, &bytes);
+   if (h == NULL)
+   return (ARCHIVE_FATAL);
+   p = h;
+   q = p + bytes;
+
+   while (p + 4 <= q) {
+   if (p[0] == 'P' && p[1] == 'K') {
+   if ((p[2] == '\001' && p[3] == '\002')
+   || (p[2] == '\003' && p[3] == '\004')
+   || (p[2] == '\005' && p[3] == '\006')
+   || (p[2] == '\007' && p[3] == '\010')
+   || (p[2] == '0' && p[3] == '0')) {
+   skip = p - (const char *)h;
+   __archive_read_consume(a, skip);
+   return (ARCHIVE_OK);
+   }
+   }
+   ++p;
+   }
+   skip = p - (const char *)h;
+   __archive_read_consume(a, skip);
+   skipped += skip;
+   }
+}
+
+static int
 zip_read_file_header(struct archive_read *a, struct archive_entry *entry,
 struct zip *zip)
 {
@@ -888,6 +932,9 @@ process_extra(const void* extra, struct 
if (datasize >= 4)
zip->gid = archive_le16dec(p + offset + 2);
break;
+   case 0x7875:
+   /* Info-Zip Unix Extra Field (type 3) "ux". */
+   break;
default:
break;
}

Modified: head/lib/libarchive/test/test_compat_zip.c
==
--- head/lib/libarchive/test/test_compat_zip.c  Sun Nov  7 03:26:22 2010
(r214904)
+++ head/lib/libarchive/test/test_compat_zip.c  Sun Nov  7 03:40:37 2010
(r214905)
@@ -71,10 +71,43 @@ finish:
 #endif
 }
 
+/*
+ * Verify that we skip junk between entries.  The compat_zip_2.zip file
+ * has several bytes of junk between 'file1' and 'file2'.  Such
+ * junk is routinely introduced by some Zip writers when they manipulate
+ * existing zip archives.
+ */
+static void
+test_compat_zip_2(void)
+{
+   char name[] = "test_compat_zip_2.zip";
+   struct archive_entry *ae;
+   struct archiv

Re: svn commit: r214905 - in head/lib/libarchive: . test

2010-11-07 Thread Tim Kientzle
On Nov 6, 2010, at 9:09 PM, Anonymous wrote:
> Tim Kientzle  writes:
> 
>> Author: kientzle
>> Date: Sun Nov  7 03:40:37 2010
>> New Revision: 214905
>> URL: http://svn.freebsd.org/changeset/base/214905
>> 
>> Log:
>>  If the Zip reader doesn't see a PK signature block
>>  because there's inter-entry garbage, just scan forward
>>  to find the next one.  This allows us to handle a lot
>>  of Zip archives that have been modified in-place.
> 
> It's unrelated but can you also look at archives produces by Mojo Setup?
> 
>  http://icculus.org/mojosetup/examples/
> 
> $ /usr/bin/unzip duke3d-mojosetup-linux-x86.bin
> Archive:  duke3d-mojosetup-linux-x86.bin
> unzip: Unrecognized archive format
> zsh: exit 1
> 
> $ LOCALBASE/bin/unzip duke3d-mojosetup-linux-x86.bin
> Archive:  duke3d-mojosetup-linux-x86.bin
> warning [duke3d-mojosetup-linux-x86.bin]:  157716 extra bytes at beginning or 
> within zipfile
>  (attempting to process anyway)
>   creating: data/
>  inflating: data/duke3d_readme.txt

Libarchive currently doesn't support self-extracting Zip archives
(the "157716 extra bytes" that Info-Zip mentions).  There's
a hack in libarchive's Zip reader that mostly supports one
particular common type of self-extracting Zip archive, but
it's not very easy to generalize.

There are a couple of possible options for addressing
this, but I won't have time to work on any of those any
time soon.

Tim

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215227 - in stable/8/usr.bin/tar: . test

2010-11-12 Thread Tim Kientzle
Author: kientzle
Date: Sat Nov 13 05:43:58 2010
New Revision: 215227
URL: http://svn.freebsd.org/changeset/base/215227

Log:
  MFC some Makefile tweaks.

Modified:
  stable/8/usr.bin/tar/Makefile
  stable/8/usr.bin/tar/test/Makefile
Directory Properties:
  stable/8/usr.bin/tar/   (props changed)

Modified: stable/8/usr.bin/tar/Makefile
==
--- stable/8/usr.bin/tar/Makefile   Sat Nov 13 03:11:27 2010
(r215226)
+++ stable/8/usr.bin/tar/Makefile   Sat Nov 13 05:43:58 2010
(r215227)
@@ -4,7 +4,6 @@
 PROG=  bsdtar
 BSDTAR_VERSION_STRING=2.7.0
 SRCS=  bsdtar.c cmdline.c getdate.c matching.c read.c siginfo.c subst.c tree.c 
util.c write.c
-WARNS?=5
 DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ} ${LIBLZMA}
 LDADD= -larchive -lbz2 -lz -lmd -llzma
 .if ${MK_OPENSSL} != "no"
@@ -12,7 +11,7 @@ LDADD+= -lcrypto
 .endif
 CFLAGS+=   -DBSDTAR_VERSION_STRING=\"${BSDTAR_VERSION_STRING}\"
 CFLAGS+=   -DPLATFORM_CONFIG_H=\"config_freebsd.h\"
-CFLAGS+=   -I${.CURDIR}
+CFLAGS+=   -I${.CURDIR} -I${.CURDIR}/../../lib/libarchive
 SYMLINKS=  bsdtar ${BINDIR}/tar
 MLINKS=bsdtar.1 tar.1
 DEBUG_FLAGS=-g

Modified: stable/8/usr.bin/tar/test/Makefile
==
--- stable/8/usr.bin/tar/test/Makefile  Sat Nov 13 03:11:27 2010
(r215226)
+++ stable/8/usr.bin/tar/test/Makefile  Sat Nov 13 05:43:58 2010
(r215227)
@@ -45,7 +45,6 @@ CFLAGS+= -I${TAR_SRCDIR}
 # Uncomment to link against dmalloc
 #LDADD+= -L/usr/local/lib -ldmalloc
 #CFLAGS+= -I/usr/local/include -DUSE_DMALLOC
-WARNS=6
 
 check test:bsdtar_test
./bsdtar_test -p ${.OBJDIR}/../bsdtar -r ${.CURDIR}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215228 - stable/8/usr.bin/tar

2010-11-12 Thread Tim Kientzle
===
--- stable/8/usr.bin/tar/bsdtar.h   Sat Nov 13 05:43:58 2010
(r215227)
+++ stable/8/usr.bin/tar/bsdtar.h   Sat Nov 13 05:50:49 2010
(r215228)
@@ -78,7 +78,6 @@ struct bsdtar {
 
/* Miscellaneous state information */
struct archive   *archive;
-   const char   *progname;
int   argc;
char**argv;
const char   *optarg;
@@ -134,11 +133,7 @@ enum {
OPTION_VERSION
 };
 
-
-void   bsdtar_errc(struct bsdtar *, int _eval, int _code,
-   const char *fmt, ...) __LA_DEAD;
 intbsdtar_getopt(struct bsdtar *);
-void   bsdtar_warnc(struct bsdtar *, int _code, const char *fmt, ...);
 void   cleanup_exclusions(struct bsdtar *);
 void   do_chdir(struct bsdtar *);
 intedit_pathname(struct bsdtar *, struct archive_entry *);
@@ -164,7 +159,7 @@ voidtar_mode_u(struct bsdtar *bsdtar);
 void   tar_mode_x(struct bsdtar *bsdtar);
 intunmatched_inclusions(struct bsdtar *bsdtar);
 intunmatched_inclusions_warn(struct bsdtar *bsdtar, const char *msg);
-void   usage(struct bsdtar *);
+void   usage(void);
 intyes(const char *fmt, ...);
 
 #if HAVE_REGEX_H

Modified: stable/8/usr.bin/tar/cmdline.c
==
--- stable/8/usr.bin/tar/cmdline.c  Sat Nov 13 05:43:58 2010
(r215227)
+++ stable/8/usr.bin/tar/cmdline.c  Sat Nov 13 05:50:49 2010
(r215228)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "bsdtar.h"
+#include "err.h"
 
 /*
  * Short options for tar.  Please keep this sorted.
@@ -220,7 +221,7 @@ bsdtar_getopt(struct bsdtar *bsdtar)
if (p[1] == ':') {
bsdtar->optarg = *bsdtar->argv;
if (bsdtar->optarg == NULL) {
-   bsdtar_warnc(bsdtar, 0,
+   bsdtar_warnc(0,
"Option %c requires an argument",
opt);
return ('?');
@@ -287,7 +288,7 @@ bsdtar_getopt(struct bsdtar *bsdtar)
/* Otherwise, pick up the next word. */
opt_word = *bsdtar->argv;
if (opt_word == NULL) {
-   bsdtar_warnc(bsdtar, 0,
+   bsdtar_warnc(0,
"Option -%c requires an argument",
opt);
return ('?');
@@ -338,13 +339,13 @@ bsdtar_getopt(struct bsdtar *bsdtar)
 
/* Fail if there wasn't a unique match. */
if (match == NULL) {
-   bsdtar_warnc(bsdtar, 0,
+   bsdtar_warnc(0,
"Option %s%s is not supported",
long_prefix, opt_word);
return ('?');
}
if (match2 != NULL) {
-   bsdtar_warnc(bsdtar, 0,
+   bsdtar_warnc(0,
"Ambiguous option %s%s (matches --%s and --%s)",
long_prefix, opt_word, match->name, match2->name);
return ('?');
@@ -356,7 +357,7 @@ bsdtar_getopt(struct bsdtar *bsdtar)
if (bsdtar->optarg == NULL) {
bsdtar->optarg = *bsdtar->argv;
if (bsdtar->optarg == NULL) {
-   bsdtar_warnc(bsdtar, 0,
+   bsdtar_warnc(0,
"Option %s%s requires an argument",
long_prefix, match->name);
return ('?');
@@ -367,7 +368,7 @@ bsdtar_getopt(struct bsdtar *bsdtar)
} else {
/* Argument forbidden: fail if there is one. */
if (bsdtar->optarg != NULL) {
-   bsdtar_warnc(bsdtar, 0,
+   bsdtar_warnc(0,
"Option %s%s does not allow an argument",
long_prefix, match->name);
return ('?');

Copied: stable/8/usr.bin/tar/err.c (from r203557, head/usr.bin/tar/err.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/8/usr.bin/tar/err.c  Sat Nov 13 

svn commit: r215229 - stable/8/usr.bin/tar

2010-11-12 Thread Tim Kientzle
Author: kientzle
Date: Sat Nov 13 05:52:45 2010
New Revision: 215229
URL: http://svn.freebsd.org/changeset/base/215229

Log:
  MFC: Allow -b up to 8192.  Folks working with
  modern high-speed tape drives are routinely using
  block sizes of 1MB (-b 2048), allowing up to 8192
  should allow a little room for future growth.

Modified:
  stable/8/usr.bin/tar/bsdtar.c
Directory Properties:
  stable/8/usr.bin/tar/   (props changed)

Modified: stable/8/usr.bin/tar/bsdtar.c
==
--- stable/8/usr.bin/tar/bsdtar.c   Sat Nov 13 05:50:49 2010
(r215228)
+++ stable/8/usr.bin/tar/bsdtar.c   Sat Nov 13 05:52:45 2010
(r215229)
@@ -186,9 +186,9 @@ main(int argc, char **argv)
break;
case 'b': /* SUSv2 */
t = atoi(bsdtar->optarg);
-   if (t <= 0 || t > 1024)
+   if (t <= 0 || t > 8192)
bsdtar_errc(1, 0,
-   "Argument to -b is out of range (1..1024)");
+   "Argument to -b is out of range (1..8192)");
bsdtar->bytes_per_block = 512 * t;
break;
case 'C': /* GNU tar */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215230 - stable/8/usr.bin/tar

2010-11-12 Thread Tim Kientzle
Author: kientzle
Date: Sat Nov 13 05:53:55 2010
New Revision: 215230
URL: http://svn.freebsd.org/changeset/base/215230

Log:
  MFC minor Makefile reformat.

Modified:
  stable/8/usr.bin/tar/Makefile
Directory Properties:
  stable/8/usr.bin/tar/   (props changed)

Modified: stable/8/usr.bin/tar/Makefile
==
--- stable/8/usr.bin/tar/Makefile   Sat Nov 13 05:52:45 2010
(r215229)
+++ stable/8/usr.bin/tar/Makefile   Sat Nov 13 05:53:55 2010
(r215230)
@@ -3,7 +3,17 @@
 
 PROG=  bsdtar
 BSDTAR_VERSION_STRING=2.7.0
-SRCS=  bsdtar.c cmdline.c err.c getdate.c matching.c read.c siginfo.c subst.c 
tree.c util.c write.c
+SRCS=  bsdtar.c\
+   cmdline.c   \
+   err.c   \
+   getdate.c   \
+   matching.c  \
+   read.c  \
+   siginfo.c   \
+   subst.c \
+   tree.c  \
+   util.c  \
+   write.c
 DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ} ${LIBLZMA}
 LDADD= -larchive -lbz2 -lz -lmd -llzma
 .if ${MK_OPENSSL} != "no"
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215231 - stable/8/usr.bin/tar

2010-11-12 Thread Tim Kientzle
Author: kientzle
Date: Sat Nov 13 05:55:56 2010
New Revision: 215231
URL: http://svn.freebsd.org/changeset/base/215231

Log:
  MFC: reverse an ill-advised experiment trying
  to emulate a "root user" on Windows.

Modified:
  stable/8/usr.bin/tar/bsdtar.c
  stable/8/usr.bin/tar/bsdtar_platform.h
Directory Properties:
  stable/8/usr.bin/tar/   (props changed)

Modified: stable/8/usr.bin/tar/bsdtar.c
==
--- stable/8/usr.bin/tar/bsdtar.c   Sat Nov 13 05:53:55 2010
(r215230)
+++ stable/8/usr.bin/tar/bsdtar.c   Sat Nov 13 05:55:56 2010
(r215231)
@@ -159,8 +159,10 @@ main(int argc, char **argv)
/* Default: Perform basic security checks. */
bsdtar->extract_flags |= SECURITY;
 
-   /* Defaults for root user: */
-   if (bsdtar_is_privileged(bsdtar)) {
+#ifndef _WIN32
+   /* On POSIX systems, assume --same-owner and -p when run by
+* the root user.  This doesn't make any sense on Windows. */
+   if (bsdtar->user_uid == 0) {
/* --same-owner */
bsdtar->extract_flags |= ARCHIVE_EXTRACT_OWNER;
/* -p */
@@ -169,6 +171,7 @@ main(int argc, char **argv)
bsdtar->extract_flags |= ARCHIVE_EXTRACT_XATTR;
bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
}
+#endif
 
bsdtar->argv = argv;
bsdtar->argc = argc;

Modified: stable/8/usr.bin/tar/bsdtar_platform.h
==
--- stable/8/usr.bin/tar/bsdtar_platform.h  Sat Nov 13 05:53:55 2010
(r215230)
+++ stable/8/usr.bin/tar/bsdtar_platform.h  Sat Nov 13 05:55:56 2010
(r215231)
@@ -164,12 +164,8 @@
 #define__LA_DEAD
 #endif
 
-#if defined(__CYGWIN__)
-#include "bsdtar_cygwin.h"
-#elif defined(_WIN32) /* && !__CYGWIN__ */
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include "bsdtar_windows.h"
-#else
-#define bsdtar_is_privileged(bsdtar)   (bsdtar->user_uid == 0)
 #endif
 
 #endif /* !BSDTAR_PLATFORM_H_INCLUDED */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215232 - stable/8/usr.bin/tar

2010-11-12 Thread Tim Kientzle
Author: kientzle
Date: Sat Nov 13 06:00:27 2010
New Revision: 215232
URL: http://svn.freebsd.org/changeset/base/215232

Log:
  MFC r203568:  Refactor and simplify the SIGINFO/SIGUSR1
  handling.  Switch to a custom function to format 64-bit
  ints to avoid the headache of trying to guess printf
  modifiers on different platforms.

Deleted:
  stable/8/usr.bin/tar/siginfo.c
Modified:
  stable/8/usr.bin/tar/Makefile
  stable/8/usr.bin/tar/bsdtar.c
  stable/8/usr.bin/tar/bsdtar.h
  stable/8/usr.bin/tar/read.c
  stable/8/usr.bin/tar/util.c
  stable/8/usr.bin/tar/write.c
Directory Properties:
  stable/8/usr.bin/tar/   (props changed)

Modified: stable/8/usr.bin/tar/Makefile
==
--- stable/8/usr.bin/tar/Makefile   Sat Nov 13 05:55:56 2010
(r215231)
+++ stable/8/usr.bin/tar/Makefile   Sat Nov 13 06:00:27 2010
(r215232)
@@ -9,7 +9,6 @@ SRCS=   bsdtar.c\
getdate.c   \
matching.c  \
read.c  \
-   siginfo.c   \
subst.c \
tree.c  \
util.c  \

Modified: stable/8/usr.bin/tar/bsdtar.c
==
--- stable/8/usr.bin/tar/bsdtar.c   Sat Nov 13 05:55:56 2010
(r215231)
+++ stable/8/usr.bin/tar/bsdtar.c   Sat Nov 13 06:00:27 2010
(r215232)
@@ -47,6 +47,9 @@ __FBSDID("$FreeBSD$");
 #ifdef HAVE_PATHS_H
 #include 
 #endif
+#ifdef HAVE_SIGNAL_H
+#include 
+#endif
 #include 
 #ifdef HAVE_STDLIB_H
 #include 
@@ -82,7 +85,32 @@ __FBSDID("$FreeBSD$");
 #define_PATH_DEFTAPE "/dev/tape"
 #endif
 
-/* External function to parse a date/time string (from getdate.y) */
+#if defined(HAVE_SIGACTION) && (defined(SIGINFO) || defined(SIGUSR1))
+static volatile int siginfo_occurred;
+
+static void
+siginfo_handler(int sig)
+{
+   (void)sig; /* UNUSED */
+   siginfo_occurred = 1;
+}
+
+int
+need_report(void)
+{
+   int r = siginfo_occurred;
+   siginfo_occurred = 0;
+   return (r);
+}
+#else
+int
+need_report(void)
+{
+   return (0);
+}
+#endif
+
+/* External function to parse a date/time string */
 time_t get_date(time_t, const char *);
 
 static void long_help(void);
@@ -114,11 +142,23 @@ main(int argc, char **argv)
memset(bsdtar, 0, sizeof(*bsdtar));
bsdtar->fd = -1; /* Mark as "unused" */
option_o = 0;
-#if defined(_WIN32) && !defined(__CYGWIN__)
-   /* Make sure open() function will be used with a binary mode. */
-   /* on cygwin, we need something similar, but instead link against */
-   /* a special startup object, binmode.o */
-   _set_fmode(_O_BINARY);
+
+#if defined(HAVE_SIGACTION) && (defined(SIGINFO) || defined(SIGUSR1))
+   { /* Catch SIGINFO and SIGUSR1, if they exist. */
+   struct sigaction sa;
+   sa.sa_handler = siginfo_handler;
+   sigemptyset(&sa.sa_mask);
+   sa.sa_flags = 0;
+#ifdef SIGINFO
+   if (sigaction(SIGINFO, &sa, NULL))
+   bsdtar_errc(1, errno, "sigaction(SIGINFO) failed");
+#endif
+#ifdef SIGUSR1
+   /* ... and treat SIGUSR1 the same way as SIGINFO. */
+   if (sigaction(SIGUSR1, &sa, NULL))
+   bsdtar_errc(1, errno, "sigaction(SIGUSR1) failed");
+#endif
+   }
 #endif
 
/* Need bsdtar_progname before calling bsdtar_warnc. */

Modified: stable/8/usr.bin/tar/bsdtar.h
==
--- stable/8/usr.bin/tar/bsdtar.h   Sat Nov 13 05:55:56 2010
(r215231)
+++ stable/8/usr.bin/tar/bsdtar.h   Sat Nov 13 06:00:27 2010
(r215232)
@@ -142,16 +142,13 @@ int   exclude_from_file(struct bsdtar *, c
 intexcluded(struct bsdtar *, const char *pathname);
 intinclude(struct bsdtar *, const char *pattern);
 intinclude_from_file(struct bsdtar *, const char *pathname);
+intneed_report(void);
 intpathcmp(const char *a, const char *b);
 intprocess_lines(struct bsdtar *bsdtar, const char *pathname,
int (*process)(struct bsdtar *, const char *));
 void   safe_fprintf(FILE *, const char *fmt, ...);
 void   set_chdir(struct bsdtar *, const char *newdir);
-void   siginfo_init(struct bsdtar *);
-void   siginfo_setinfo(struct bsdtar *, const char * oper,
-   const char * path, int64_t size);
-void   siginfo_printinfo(struct bsdtar *, off_t progress);
-void   siginfo_done(struct bsdtar *);
+const char *tar_i64toa(int64_t);
 void   tar_mode_c(struct bsdtar *bsdtar);
 void   tar_mode_r(struct bsdtar *bsdtar);
 void   tar_mode_t(struct bsdtar *bsdtar);

Modified: stable/8/usr.bin/tar/read.c
==
--- stable/8/usr.bin/tar/read.c Sat Nov 13 05:55:56 2010(r215231)
+++ stable/8/usr.bin/tar/read.c Sat Nov 13 06:00:27 2010(r2152

svn commit: r215233 - stable/8/lib/libarchive

2010-11-12 Thread Tim Kientzle
Author: kientzle
Date: Sat Nov 13 06:07:39 2010
New Revision: 215233
URL: http://svn.freebsd.org/changeset/base/215233

Log:
  MFC archive_file_count() utility function.

Modified:
  stable/8/lib/libarchive/Makefile
  stable/8/lib/libarchive/archive.h
  stable/8/lib/libarchive/archive_private.h
  stable/8/lib/libarchive/archive_read.c
  stable/8/lib/libarchive/archive_util.3
  stable/8/lib/libarchive/archive_util.c
  stable/8/lib/libarchive/archive_virtual.c
Directory Properties:
  stable/8/lib/libarchive/   (props changed)

Modified: stable/8/lib/libarchive/Makefile
==
--- stable/8/lib/libarchive/MakefileSat Nov 13 06:00:27 2010
(r215232)
+++ stable/8/lib/libarchive/MakefileSat Nov 13 06:07:39 2010
(r215233)
@@ -227,6 +227,7 @@ MLINKS+=archive_util.3 archive_compress
 MLINKS+=   archive_util.3 archive_compression_name.3
 MLINKS+=   archive_util.3 archive_errno.3
 MLINKS+=   archive_util.3 archive_error_string.3
+MLINKS+=   archive_util.3 archive_file_count.3
 MLINKS+=   archive_util.3 archive_format.3
 MLINKS+=   archive_util.3 archive_format_name.3
 MLINKS+=   archive_util.3 archive_set_error.3

Modified: stable/8/lib/libarchive/archive.h
==
--- stable/8/lib/libarchive/archive.h   Sat Nov 13 06:00:27 2010
(r215232)
+++ stable/8/lib/libarchive/archive.h   Sat Nov 13 06:07:39 2010
(r215233)
@@ -704,6 +704,7 @@ __LA_DECL void   archive_set_error(struc
const char *fmt, ...);
 __LA_DECL void  archive_copy_error(struct archive *dest,
struct archive *src);
+__LA_DECL int   archive_file_count(struct archive *);
 
 #ifdef __cplusplus
 }

Modified: stable/8/lib/libarchive/archive_private.h
==
--- stable/8/lib/libarchive/archive_private.h   Sat Nov 13 06:00:27 2010
(r215232)
+++ stable/8/lib/libarchive/archive_private.h   Sat Nov 13 06:07:39 2010
(r215233)
@@ -25,6 +25,10 @@
  * $FreeBSD$
  */
 
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
 #ifndef ARCHIVE_PRIVATE_H_INCLUDED
 #defineARCHIVE_PRIVATE_H_INCLUDED
 
@@ -87,9 +91,11 @@ struct archive {
const char *compression_name;
 
/* Position in UNCOMPRESSED data stream. */
-   off_t file_position;
+   int64_t   file_position;
/* Position in COMPRESSED data stream. */
-   off_t raw_position;
+   int64_t   raw_position;
+   /* Number of file entries processed. */
+   int   file_count;
 
int   archive_error_number;
const char   *error;
@@ -107,4 +113,12 @@ int__archive_parse_options(const char *
 
 #defineerr_combine(a,b)((a) < (b) ? (a) : (b))
 
+#if defined(__BORLANDC__) || (defined(_MSC_VER) &&  _MSC_VER <= 1300)
+# define   ARCHIVE_LITERAL_LL(x)   x##i64
+# define   ARCHIVE_LITERAL_ULL(x)  x##ui64
+#else
+# define   ARCHIVE_LITERAL_LL(x)   x##ll
+# define   ARCHIVE_LITERAL_ULL(x)  x##ull
+#endif
+
 #endif

Modified: stable/8/lib/libarchive/archive_read.c
==
--- stable/8/lib/libarchive/archive_read.c  Sat Nov 13 06:00:27 2010
(r215232)
+++ stable/8/lib/libarchive/archive_read.c  Sat Nov 13 06:07:39 2010
(r215233)
@@ -386,6 +386,7 @@ archive_read_next_header2(struct archive
ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
"archive_read_next_header");
 
+   ++_a->file_count;
archive_entry_clear(entry);
archive_clear_error(&a->archive);
 

Modified: stable/8/lib/libarchive/archive_util.3
==
--- stable/8/lib/libarchive/archive_util.3  Sat Nov 13 06:00:27 2010
(r215232)
+++ stable/8/lib/libarchive/archive_util.3  Sat Nov 13 06:07:39 2010
(r215233)
@@ -34,6 +34,7 @@
 .Nm archive_copy_error ,
 .Nm archive_errno ,
 .Nm archive_error_string ,
+.Nm archive_file_count ,
 .Nm archive_format ,
 .Nm archive_format_name ,
 .Nm archive_set_error
@@ -53,6 +54,8 @@
 .Ft const char *
 .Fn archive_error_string "struct archive *"
 .Ft int
+.Fn archive_file_count "struct archive *"
+.Ft int
 .Fn archive_format "struct archive *"
 .Ft const char *
 .Fn archive_format_name "struct archive *"
@@ -92,6 +95,12 @@ obtained from passing the result of
 .Fn archive_errno
 to
 .Xr strerror 3 .
+.It Fn archive_file_count
+Returns a count of the number of files processed by this archive object.
+The count is incremented by calls to
+.Xr archive_write_header
+or
+.Xr archive_read_next_header .
 .It Fn archive_format
 Returns a numeric code in

svn commit: r216258 - in head/lib/libarchive: . test

2010-12-07 Thread Tim Kientzle
Author: kientzle
Date: Tue Dec  7 16:48:01 2010
New Revision: 216258
URL: http://svn.freebsd.org/changeset/base/216258

Log:
  Don't write data into an empty "file."
  
  In particular, this check avoids a warning when
  extracting directory entries from certain GNU tar
  archives that store directory contents.
  
  MFC after: 3 days

Modified:
  head/lib/libarchive/archive_read_extract.c
  head/lib/libarchive/test/Makefile
  head/lib/libarchive/test/test_acl_freebsd.c

Modified: head/lib/libarchive/archive_read_extract.c
==
--- head/lib/libarchive/archive_read_extract.c  Tue Dec  7 16:30:52 2010
(r216257)
+++ head/lib/libarchive/archive_read_extract.c  Tue Dec  7 16:48:01 2010
(r216258)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "archive.h"
+#include "archive_entry.h"
 #include "archive_private.h"
 #include "archive_read_private.h"
 #include "archive_write_disk_private.h"
@@ -107,7 +108,7 @@ archive_read_extract2(struct archive *_a
if (r != ARCHIVE_OK)
/* If _write_header failed, copy the error. */
archive_copy_error(&a->archive, ad);
-   else
+   else if (archive_entry_size(entry) > 0)
/* Otherwise, pour data into the entry. */
r = copy_data(_a, ad);
r2 = archive_write_finish_entry(ad);

Modified: head/lib/libarchive/test/Makefile
==
--- head/lib/libarchive/test/Makefile   Tue Dec  7 16:30:52 2010
(r216257)
+++ head/lib/libarchive/test/Makefile   Tue Dec  7 16:48:01 2010
(r216258)
@@ -2,10 +2,6 @@
 
 # Where to find the libarchive sources
 LA_SRCDIR=${.CURDIR}/..
-.PATH: ${LA_SRCDIR}
-
-# Get a list of all libarchive source files
-LA_SRCS!=make -f ${LA_SRCDIR}/Makefile -V SRCS
 
 TESTS= \
test_acl_basic.c\
@@ -113,8 +109,8 @@ TESTS= \
test_write_open_memory.c
 
 
-# Build the test program using all libarchive sources + the test sources.
-SRCS= ${LA_SRCS}   \
+# Build the test program.
+SRCS= \
${TESTS}\
list.h  \
main.c  \
@@ -125,14 +121,11 @@ NO_MAN=yes
 PROG=libarchive_test
 INTERNALPROG=yes  # Don't install this; it's just for testing
 DPADD=${LIBBZ2} ${LIBZ} ${LIBMD} ${LIBCRYPTO} ${LIBBSDXML}
-CFLAGS+= -DPLATFORM_CONFIG_H=\"config_freebsd.h\"
-LDADD= -lz -lbz2 -lmd -lcrypto -lbsdxml
+LDADD= -L ${.OBJDIR}/.. -larchive
+LDADD+= -lz -lbz2 -llzma -lmd -lcrypto -lbsdxml
 CFLAGS+= -g
 CFLAGS+= -I${LA_SRCDIR} -I.
-
-# Uncomment to build and test lzma and xz support via liblzma
-#CFLAGS+= -I/usr/local/include -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1
-#LDADD+= -L/usr/local/lib -llzma
+CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1
 
 # Uncomment to link against dmalloc
 #LDADD+= -L/usr/local/lib -ldmalloc

Modified: head/lib/libarchive/test/test_acl_freebsd.c
==
--- head/lib/libarchive/test/test_acl_freebsd.c Tue Dec  7 16:30:52 2010
(r216257)
+++ head/lib/libarchive/test/test_acl_freebsd.c Tue Dec  7 16:48:01 2010
(r216258)
@@ -220,6 +220,11 @@ DEFINE_TEST(test_acl_freebsd)
skipping("ACL tests require that ACL support be enabled on the 
filesystem");
return;
}
+   if (n != 0 && errno == EINVAL) {
+   close(fd);
+   skipping("POSIX.1e ACL tests require that POSIX.1e ACL support 
be enabled on the filesystem");
+   return;
+   }
failure("acl_set_fd(): errno = %d (%s)",
errno, strerror(errno));
assertEqualInt(0, n);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196638 - head/lib/libc/posix1e

2009-08-28 Thread Tim Kientzle
Author: kientzle
Date: Sat Aug 29 03:17:24 2009
New Revision: 196638
URL: http://svn.freebsd.org/changeset/base/196638

Log:
  Style: Remove trailing whitespace.

Modified:
  head/lib/libc/posix1e/acl_support.c

Modified: head/lib/libc/posix1e/acl_support.c
==
--- head/lib/libc/posix1e/acl_support.c Sat Aug 29 02:17:40 2009
(r196637)
+++ head/lib/libc/posix1e/acl_support.c Sat Aug 29 03:17:24 2009
(r196638)
@@ -80,7 +80,7 @@ _acl_differs(const acl_t a, const acl_t 
 
return (0);
 }
-   
+
 /*
  * _posix1e_acl_entry_compare -- compare two acl_entry structures to
  * determine the order they should appear in.  Used by _posix1e_acl_sort to
@@ -164,7 +164,7 @@ _posix1e_acl(acl_t acl, acl_type_t type)
  * from code in sys/kern/kern_acl.c, and if changes are made in one, they
  * should be made in the other also.  This copy of acl_check is made
  * available * in userland for the benefit of processes wanting to check ACLs
- * for validity before submitting them to the kernel, or for performing 
+ * for validity before submitting them to the kernel, or for performing
  * in userland file system checking.  Needless to say, the kernel makes
  * the real checks on calls to get/setacl.
  *
@@ -203,7 +203,7 @@ _posix1e_acl_check(acl_t acl)
stage = ACL_USER;
count_user_obj++;
break;
-   
+
case ACL_USER:
/* printf("_posix1e_acl_check: %d: ACL_USER\n", i); */
if (stage > ACL_USER)
@@ -213,8 +213,8 @@ _posix1e_acl_check(acl_t acl)
return (EINVAL);
highest_uid = entry->ae_id;
count_user++;
-   break;  
-   
+   break;
+
case ACL_GROUP_OBJ:
/* printf("_posix1e_acl_check: %d: ACL_GROUP_OBJ\n",
i); */
@@ -223,7 +223,7 @@ _posix1e_acl_check(acl_t acl)
stage = ACL_GROUP;
count_group_obj++;
break;
-   
+
case ACL_GROUP:
/* printf("_posix1e_acl_check: %d: ACL_GROUP\n", i); */
if (stage > ACL_GROUP)
@@ -234,7 +234,7 @@ _posix1e_acl_check(acl_t acl)
highest_gid = entry->ae_id;
count_group++;
break;
-   
+
case ACL_MASK:
/* printf("_posix1e_acl_check: %d: ACL_MASK\n", i); */
if (stage > ACL_MASK)
@@ -242,7 +242,7 @@ _posix1e_acl_check(acl_t acl)
stage = ACL_MASK;
count_mask++;
break;
-   
+
case ACL_OTHER:
/* printf("_posix1e_acl_check: %d: ACL_OTHER\n", i); */
if (stage > ACL_OTHER)
@@ -250,7 +250,7 @@ _posix1e_acl_check(acl_t acl)
stage = ACL_OTHER;
count_other++;
break;
-   
+
default:
/* printf("_posix1e_acl_check: %d: INVALID\n", i); */
return (EINVAL);
@@ -260,7 +260,7 @@ _posix1e_acl_check(acl_t acl)
 
if (count_user_obj != 1)
return (EINVAL);
-   
+
if (count_group_obj != 1)
return (EINVAL);
 
@@ -312,7 +312,7 @@ _posix1e_acl_id_to_name(acl_tag_t tag, u
g = NULL;
else
g = getgrgid(id);
-   if (g == NULL) 
+   if (g == NULL)
i = snprintf(buf, buf_len, "%d", id);
else
i = snprintf(buf, buf_len, "%s", g->gr_name);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196961 - in head/lib/libarchive: . test

2009-09-07 Thread Tim Kientzle
Author: kientzle
Date: Tue Sep  8 04:52:12 2009
New Revision: 196961
URL: http://svn.freebsd.org/changeset/base/196961

Log:
  Update tests to match r195873, which corrected how hardlinked files
  on iso9660 images were returned.  While I'm poking around, update
  some comments around this area to try to clarify what's going on and
  what still remains to be improved.

Modified:
  head/lib/libarchive/archive_read_support_format_iso9660.c
  head/lib/libarchive/test/test_read_format_isojoliet_bz2.c
  head/lib/libarchive/test/test_read_format_isorr_bz2.c

Modified: head/lib/libarchive/archive_read_support_format_iso9660.c
==
--- head/lib/libarchive/archive_read_support_format_iso9660.c   Tue Sep  8 
04:08:14 2009(r196960)
+++ head/lib/libarchive/archive_read_support_format_iso9660.c   Tue Sep  8 
04:52:12 2009(r196961)
@@ -571,9 +571,13 @@ archive_read_format_iso9660_read_header(
if (file->symlink.s != NULL)
archive_entry_copy_symlink(entry, file->symlink.s);
 
-   /* If this entry points to the same data as the previous
-* entry, convert this into a hardlink to that entry.
-* But don't bother for zero-length files. */
+   /* Note: If the input isn't seekable, we can't rewind to
+* return the same body again, so if the next entry refers to
+* the same data, we have to return it as a hardlink to the
+* original entry. */
+   /* TODO: We have enough information here to compute an
+* accurate value for nlinks.  We should do so and ignore
+* nlinks from the RR extensions. */
if (file->offset == iso9660->previous_offset
&& file->size == iso9660->previous_size
&& file->size > 0) {
@@ -586,8 +590,21 @@ archive_read_format_iso9660_read_header(
return (ARCHIVE_OK);
}
 
-   /* If the offset is before our current position, we can't
-* seek backwards to extract it, so issue a warning. */
+   /* Except for the hardlink case above, if the offset of the
+* next entry is before our current position, we can't seek
+* backwards to extract it, so issue a warning.  Note that
+* this can only happen if this entry was added to the heap
+* after we passed this offset, that is, only if the directory
+* mentioning this entry is later than the body of the entry.
+* Such layouts are very unusual; most ISO9660 writers lay out
+* and record all directory information first, then store
+* all file bodies. */
+   /* TODO: Someday, libarchive's I/O core will support optional
+* seeking.  When that day comes, this code should attempt to
+* seek and only return the error if the seek fails.  That
+* will give us support for whacky ISO images that require
+* seeking while retaining the ability to read almost all ISO
+* images in a streaming fashion. */
if (file->offset < iso9660->current_position) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Ignoring out-of-order file @%x (%s) %jd < %jd",
@@ -628,7 +645,7 @@ archive_read_format_iso9660_read_header(
struct file_info *child;
 
/* N.B.: these special directory identifiers
-* are 8 bit "values" even on a 
+* are 8 bit "values" even on a
 * Joliet CD with UCS-2 (16bit) encoding.
 */
 

Modified: head/lib/libarchive/test/test_read_format_isojoliet_bz2.c
==
--- head/lib/libarchive/test/test_read_format_isojoliet_bz2.c   Tue Sep  8 
04:08:14 2009(r196960)
+++ head/lib/libarchive/test/test_read_format_isojoliet_bz2.c   Tue Sep  8 
04:52:12 2009(r196961)
@@ -107,14 +107,12 @@ joliettest(int withrr)
assertEqualInt(2, archive_entry_gid(ae));
}
 
-   /* A hardlink to the regular file. */
+   /* A regular file with two names ("hardlink" gets returned
+* first, so it's not marked as a hardlink). */
assertEqualInt(0, archive_read_next_header(a, &ae));
assertEqualString("hardlink", archive_entry_pathname(ae));
assert(S_ISREG(archive_entry_stat(ae)->st_mode));
-   if (withrr) {
-   assertEqualString("long-joliet-file-name.textfile",
-   archive_entry_hardlink(ae));
-   }
+   assert(archive_entry_hardlink(ae) == NULL);
assertEqualInt(6, archive_entry_size(ae));
assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
assertEqualInt(6, (int)size);
@@ -123,20 +121,27 @@ joliettest(int withrr)
if (withrr) {
assertEqualInt(86401, archive_entry_mtime(ae));

svn commit: r196962 - in head/lib/libarchive: . test

2009-09-07 Thread Tim Kientzle
Author: kientzle
Date: Tue Sep  8 05:02:41 2009
New Revision: 196962
URL: http://svn.freebsd.org/changeset/base/196962

Log:
  Fiz /usr/bin/unzip: A bug deep in libarchive's read-ahead logic
  (incorrect handling of zero-length reads before the copy buffer is
  allocated) is masked by the iso9660 taster.  Tar and cpio both enable
  that taster so were protected from the bug; unzip is susceptible.
  
  This both fixes the bug and updates the test harness to exercise
  this case.
  
  Submitted by: Ed Schouten diagnosed the bug and drafted a patch
  MFC after: 7 days

Modified:
  head/lib/libarchive/archive_read.c
  head/lib/libarchive/test/test_compat_zip.c

Modified: head/lib/libarchive/archive_read.c
==
--- head/lib/libarchive/archive_read.c  Tue Sep  8 04:52:12 2009
(r196961)
+++ head/lib/libarchive/archive_read.c  Tue Sep  8 05:02:41 2009
(r196962)
@@ -928,9 +928,12 @@ __archive_read_filter_ahead(struct archi
for (;;) {
 
/*
-* If we can satisfy from the copy buffer, we're done.
+* If we can satisfy from the copy buffer (and the
+* copy buffer isn't empty), we're done.  In particular,
+* note that min == 0 is a perfectly well-defined
+* request.
 */
-   if (filter->avail >= min) {
+   if (filter->avail >= min && filter->avail > 0) {
if (avail != NULL)
*avail = filter->avail;
return (filter->next);

Modified: head/lib/libarchive/test/test_compat_zip.c
==
--- head/lib/libarchive/test/test_compat_zip.c  Tue Sep  8 04:52:12 2009
(r196961)
+++ head/lib/libarchive/test/test_compat_zip.c  Tue Sep  8 05:02:41 2009
(r196962)
@@ -36,7 +36,7 @@ test_compat_zip_1(void)
 
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
-   assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+   assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
extract_reference_file(name);
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 
10240));
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r196981 - head/usr.bin/unzip

2009-09-09 Thread Tim Kientzle

Andrey Chernov wrote:

On Tue, Sep 08, 2009 at 03:55:13PM +, Roman Divacky wrote:

+* Detect whether this is a text file.  ...  but libarchive
+* does not read the central directory, so we have to
+* guess ...
+*/
+   if (a_opt && n == 0) {
+   for (p = buffer; p < end; ++p) {
+   if (!isascii((unsigned char)*p)) {
+   text = 0;
+   break;
+   }
+   }
+   }
+


If I understand the purpose of this code right, better use
isalnum()+ispunct()+ispace()
combination to count non-ASCII people too.
Also setlocale() call must be added to the main() for that.


Personally, I would rather see unzip just ignore the -a
option entirely, but I suppose that's probably infeasible.

Since this is only to support -a (which does end-of-line
conversions), I would suggest using a rather different
set of heuristics that examines end-of-line sequences
and control characters only:
  * Any byte value <31 that's not CR or LF: not text
  * LF not preceded by CR: not text
  * CR not followed by LF: not text (or at least, not DOS text)
  * Otherwise, it is text.

At a minimum, this dodges the locale issue.

Someday, I'll get around to filling in the seek support
that libarchive needs for reading central directories,
then unzip can look at the "text file" bit (which
is no more reliable than anything described above) and
this code can just go away.

Tim
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r196981 - head/usr.bin/unzip

2009-09-09 Thread Tim Kientzle

Andrey Chernov wrote:

On Wed, Sep 09, 2009 at 08:16:09AM -0700, Tim Kientzle wrote:

Since this is only to support -a (which does end-of-line
conversions), I would suggest using a rather different
set of heuristics that examines end-of-line sequences
and control characters only:
   * Any byte value <31 that's not CR or LF: not text


More carefully - <32, TAB and ^Z (MSDOS EOT) must be 
allowed too and perhaps ^L.


Yes, but be careful.  Remember that -a processing
is destructive; it's better to err on the side of
marking something binary.

Tim

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r197266 - in stable/8/lib/libarchive: . test

2009-09-16 Thread Tim Kientzle
Author: kientzle
Date: Thu Sep 17 06:31:59 2009
New Revision: 197266
URL: http://svn.freebsd.org/changeset/base/197266

Log:
  MFC r196962: Fix /usr/bin/unzip: A bug deep in libarchive's read-ahead logic
  (incorrect handling of zero-length reads before the copy buffer is
  allocated) is masked by the iso9660 taster.  Tar and cpio both enable
  that taster so were protected from the bug; unzip is susceptible.
  
  This both fixes the bug and updates the test harness to exercise
  this case.
  
  Submitted by: Ed Schouten diagnosed the bug and drafted a patch
  Approved by:  re (kib)

Modified:
  stable/8/lib/libarchive/   (props changed)
  stable/8/lib/libarchive/archive_read.c
  stable/8/lib/libarchive/test/test_compat_zip.c

Modified: stable/8/lib/libarchive/archive_read.c
==
--- stable/8/lib/libarchive/archive_read.c  Thu Sep 17 05:30:55 2009
(r197265)
+++ stable/8/lib/libarchive/archive_read.c  Thu Sep 17 06:31:59 2009
(r197266)
@@ -928,9 +928,12 @@ __archive_read_filter_ahead(struct archi
for (;;) {
 
/*
-* If we can satisfy from the copy buffer, we're done.
+* If we can satisfy from the copy buffer (and the
+* copy buffer isn't empty), we're done.  In particular,
+* note that min == 0 is a perfectly well-defined
+* request.
 */
-   if (filter->avail >= min) {
+   if (filter->avail >= min && filter->avail > 0) {
if (avail != NULL)
*avail = filter->avail;
return (filter->next);

Modified: stable/8/lib/libarchive/test/test_compat_zip.c
==
--- stable/8/lib/libarchive/test/test_compat_zip.c  Thu Sep 17 05:30:55 
2009(r197265)
+++ stable/8/lib/libarchive/test/test_compat_zip.c  Thu Sep 17 06:31:59 
2009(r197266)
@@ -36,7 +36,7 @@ test_compat_zip_1(void)
 
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
-   assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+   assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
extract_reference_file(name);
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 
10240));
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r198768 - head/sbin/mknod

2009-11-01 Thread Tim Kientzle

Kostik Belousov wrote:

On Sun, Nov 01, 2009 at 06:25:11PM +, Christian Brueffer wrote:

Author: brueffer
Date: Sun Nov  1 18:25:11 2009
New Revision: 198768
URL: http://svn.freebsd.org/changeset/base/198768

Log:
  Refine r198714, it's not as easy as just leaving the major number zero.
  
  Submitted by:	ed

  MFC after:1 week



Moreover, you cannot create special node that would become a node used to
access device driver in the freebsd.

The only use that is left for mknod c|b is to create special nodes on
the filesystems exported by NFS for other un*xes.


I wonder if mknod c|b should print a warning?

Tim
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r225525 - head/lib/libarchive

2011-09-12 Thread Tim Kientzle
Author: kientzle
Date: Tue Sep 13 05:52:34 2011
New Revision: 225525
URL: http://svn.freebsd.org/changeset/base/225525

Log:
  Fix cpio on ARM.
  
  PR:   bin/160430
  Submitted by: Ian Lepore
  Approved by:  re (Kostik Belousov)
  MFC after:7 days

Modified:
  head/lib/libarchive/archive_read_support_format_cpio.c
  head/lib/libarchive/archive_write_set_format_cpio.c

Modified: head/lib/libarchive/archive_read_support_format_cpio.c
==
--- head/lib/libarchive/archive_read_support_format_cpio.c  Tue Sep 13 
02:46:22 2011(r225524)
+++ head/lib/libarchive/archive_read_support_format_cpio.c  Tue Sep 13 
05:52:34 2011(r225525)
@@ -54,7 +54,7 @@ struct cpio_bin_header {
unsigned char   c_mtime[4];
unsigned char   c_namesize[2];
unsigned char   c_filesize[4];
-};
+} __packed;
 
 struct cpio_odc_header {
charc_magic[6];
@@ -68,7 +68,7 @@ struct cpio_odc_header {
charc_mtime[11];
charc_namesize[6];
charc_filesize[11];
-};
+} __packed;
 
 struct cpio_newc_header {
charc_magic[6];
@@ -85,7 +85,7 @@ struct cpio_newc_header {
charc_rdevminor[8];
charc_namesize[8];
charc_crc[8];
-};
+} __packed;
 
 struct links_entry {
 struct links_entry  *next;

Modified: head/lib/libarchive/archive_write_set_format_cpio.c
==
--- head/lib/libarchive/archive_write_set_format_cpio.c Tue Sep 13 02:46:22 
2011(r225524)
+++ head/lib/libarchive/archive_write_set_format_cpio.c Tue Sep 13 05:52:34 
2011(r225525)
@@ -74,7 +74,7 @@ struct cpio_header {
charc_mtime[11];
charc_namesize[6];
charc_filesize[11];
-};
+} __packed;
 
 /*
  * Set output format to 'cpio' format.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r226635 - head/usr.bin/tar

2011-10-22 Thread Tim Kientzle
Author: kientzle
Date: Sat Oct 22 16:52:04 2011
New Revision: 226635
URL: http://svn.freebsd.org/changeset/base/226635

Log:
  Bring in the --gid --gname --uid and --uname implementation
  from libarchive.googlecode.com.
  
  MFC after:3 days

Modified:
  head/usr.bin/tar/bsdtar.c
  head/usr.bin/tar/bsdtar.h
  head/usr.bin/tar/cmdline.c
  head/usr.bin/tar/read.c
  head/usr.bin/tar/write.c

Modified: head/usr.bin/tar/bsdtar.c
==
--- head/usr.bin/tar/bsdtar.c   Sat Oct 22 16:03:45 2011(r226634)
+++ head/usr.bin/tar/bsdtar.c   Sat Oct 22 16:52:04 2011(r226635)
@@ -147,6 +147,8 @@ main(int argc, char **argv)
_bsdtar = bsdtar = &bsdtar_storage;
memset(bsdtar, 0, sizeof(*bsdtar));
bsdtar->fd = -1; /* Mark as "unused" */
+   bsdtar->gid = -1;
+   bsdtar->uid = -1;
option_o = 0;
 
 #if defined(HAVE_SIGACTION) && (defined(SIGINFO) || defined(SIGUSR1))
@@ -262,14 +264,21 @@ main(int argc, char **argv)
case OPTION_FORMAT: /* GNU tar, others */
bsdtar->create_format = bsdtar->optarg;
break;
-   case OPTION_OPTIONS:
-   bsdtar->option_options = bsdtar->optarg;
-   break;
case 'f': /* SUSv2 */
bsdtar->filename = bsdtar->optarg;
if (strcmp(bsdtar->filename, "-") == 0)
bsdtar->filename = NULL;
break;
+   case OPTION_GID: /* cpio */
+   t = atoi(bsdtar->optarg);
+   if (t < 0)
+   lafe_errc(1, 0,
+   "Argument to --gid must be positive");
+   bsdtar->gid = t;
+   break;
+   case OPTION_GNAME: /* cpio */
+   bsdtar->gname = bsdtar->optarg;
+   break;
case 'H': /* BSD convention */
bsdtar->symlink_mode = 'H';
break;
@@ -397,7 +406,8 @@ main(int argc, char **argv)
bsdtar->option_null++;
break;
case OPTION_NUMERIC_OWNER: /* GNU tar */
-   bsdtar->option_numeric_owner++;
+   bsdtar->uname = "";
+   bsdtar->gname = "";
break;
case 'O': /* GNU tar */
bsdtar->option_stdout = 1;
@@ -408,6 +418,9 @@ main(int argc, char **argv)
case OPTION_ONE_FILE_SYSTEM: /* GNU tar */
bsdtar->option_dont_traverse_mounts = 1;
break;
+   case OPTION_OPTIONS:
+   bsdtar->option_options = bsdtar->optarg;
+   break;
 #if 0
/*
 * The common BSD -P option is not necessary, since
@@ -473,6 +486,16 @@ main(int argc, char **argv)
case 'u': /* SUSv2 */
set_mode(bsdtar, opt);
break;
+   case OPTION_UID: /* cpio */
+   t = atoi(bsdtar->optarg);
+   if (t < 0)
+   lafe_errc(1, 0,
+   "Argument to --uid must be positive");
+   bsdtar->uid = t;
+   break;
+   case OPTION_UNAME: /* cpio */
+   bsdtar->uname = bsdtar->optarg;
+   break;
case 'v': /* SUSv2 */
bsdtar->verbose++;
break;

Modified: head/usr.bin/tar/bsdtar.h
==
--- head/usr.bin/tar/bsdtar.h   Sat Oct 22 16:03:45 2011(r226634)
+++ head/usr.bin/tar/bsdtar.h   Sat Oct 22 16:52:04 2011(r226635)
@@ -54,6 +54,10 @@ struct bsdtar {
int   verbose;   /* -v */
int   extract_flags; /* Flags for extract operation */
int   strip_components; /* Remove this many leading dirs */
+   int   gid;  /* --gid */
+   const char   *gname; /* --gname */
+   int   uid;  /* --uid */
+   const char   *uname; /* --uname */
char  mode; /* Program mode: 'c', 't', 'r', 'u', 'x' */
char  symlink_mode; /* H or L, per BSD conventions */
char  create_compression; /* j, y, or z */
@@ -68,7 +72,6 @@ struct bsdtar {
char  option_no_owner; /* -o */
char  option_no_subdirs; /* -n */
char  option_null; /* --null */
-   char  option_numeric_owner; /* --numeric-owner */
char  option_stdout; /* -O */
char

svn commit: r226636 - head/usr.bin/tar

2011-10-22 Thread Tim Kientzle
Author: kientzle
Date: Sat Oct 22 16:53:29 2011
New Revision: 226636
URL: http://svn.freebsd.org/changeset/base/226636

Log:
  Typo from previous commit. Urgh.

Modified:
  head/usr.bin/tar/read.c

Modified: head/usr.bin/tar/read.c
==
--- head/usr.bin/tar/read.c Sat Oct 22 16:52:04 2011(r226635)
+++ head/usr.bin/tar/read.c Sat Oct 22 16:53:29 2011(r226636)
@@ -219,7 +219,7 @@ read_archive(struct bsdtar *bsdtar, char
}
if (bsdtar->uname)
archive_entry_set_uname(entry, bsdtar->uname);
-   if (bsdtar->gname >= 0)
+   if (bsdtar->gname)
archive_entry_set_gname(entry, bsdtar->gname);
 
/*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r226638 - head/lib/libarchive

2011-10-22 Thread Tim Kientzle
Author: kientzle
Date: Sat Oct 22 17:56:24 2011
New Revision: 226638
URL: http://svn.freebsd.org/changeset/base/226638

Log:
  Correct the spelling of getgrgid and getpwuid in the man page.
  
  MFC after:3 days

Modified:
  head/lib/libarchive/archive_read_disk.3

Modified: head/lib/libarchive/archive_read_disk.3
==
--- head/lib/libarchive/archive_read_disk.3 Sat Oct 22 17:51:45 2011
(r226637)
+++ head/lib/libarchive/archive_read_disk.3 Sat Oct 22 17:56:24 2011
(r226638)
@@ -133,16 +133,16 @@ object is destroyed or when new lookup f
 This convenience function installs a standard set of user
 and group name lookup functions.
 These functions use
-.Xr getpwid 3
+.Xr getpwuid 3
 and
-.Xr getgrid 3
+.Xr getgrgid 3
 to convert ids to names, defaulting to NULL if the names cannot
 be looked up.
 These functions also implement a simple memory cache to reduce
 the number of calls to
-.Xr getpwid 3
+.Xr getpwuid 3
 and
-.Xr getgrid 3 .
+.Xr getgrgid 3 .
 .It Fn archive_read_disk_entry_from_file
 Populates a
 .Tn struct archive_entry
@@ -281,9 +281,9 @@ library was written by
 The
 .Dq standard
 user name and group name lookup functions are not the defaults because
-.Xr getgrid 3
+.Xr getgrgid 3
 and
-.Xr getpwid 3
+.Xr getpwuid 3
 are sometimes too large for particular applications.
 The current design allows the application author to use a more
 compact implementation when appropriate.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r226643 - head/lib/libarchive

2011-10-22 Thread Tim Kientzle
Author: kientzle
Date: Sat Oct 22 22:22:46 2011
New Revision: 226643
URL: http://svn.freebsd.org/changeset/base/226643

Log:
  Fix Buildworld WITHOUT_OPENSSL.
  
  PR:   kern/160922
  MFC after:3 days

Modified:
  head/lib/libarchive/archive_hash.h
  head/lib/libarchive/config_freebsd.h

Modified: head/lib/libarchive/archive_hash.h
==
--- head/lib/libarchive/archive_hash.h  Sat Oct 22 22:00:35 2011
(r226642)
+++ head/lib/libarchive/archive_hash.h  Sat Oct 22 22:22:46 2011
(r226643)
@@ -79,6 +79,13 @@ typedef MD5_CTX archive_md5_ctx;
 #  define archive_md5_init(ctx)MD5Init(ctx)
 #  define archive_md5_final(ctx, buf)  MD5Final(buf, ctx)
 #  define archive_md5_update(ctx, buf, n)  MD5Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_MD5_LIBMD)
+#  include 
+#  define ARCHIVE_HAS_MD5
+typedef MD5_CTX archive_md5_ctx;
+#  define archive_md5_init(ctx)MD5Init(ctx)
+#  define archive_md5_final(ctx, buf)  MD5Final(buf, ctx)
+#  define archive_md5_update(ctx, buf, n)  MD5Update(ctx, buf, n)
 #elif defined(ARCHIVE_HASH_MD5_LIBSYSTEM)
 #  include 
 #  define ARCHIVE_HAS_MD5
@@ -125,6 +132,13 @@ typedef SHA1_CTX archive_sha1_ctx;
 #  define archive_sha1_init(ctx)   SHA1Init(ctx)
 #  define archive_sha1_final(ctx, buf) SHA1Final(buf, ctx)
 #  define archive_sha1_update(ctx, buf, n) SHA1Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA1_LIBMD)
+#  include 
+#  define ARCHIVE_HAS_SHA1
+typedef SHA1_CTX archive_sha1_ctx;
+#  define archive_sha1_init(ctx)   SHA1_Init(ctx)
+#  define archive_sha1_final(ctx, buf) SHA1_Final(buf, ctx)
+#  define archive_sha1_update(ctx, buf, n) SHA1_Update(ctx, buf, n)
 #elif defined(ARCHIVE_HASH_SHA1_LIBSYSTEM)
 #  include 
 #  define ARCHIVE_HAS_SHA1
@@ -169,6 +183,13 @@ typedef SHA2_CTX archive_sha256_ctx;
 #  define archive_sha256_init(ctx) SHA256Init(ctx)
 #  define archive_sha256_final(ctx, buf)   SHA256Final(buf, ctx)
 #  define archive_sha256_update(ctx, buf, n)   SHA256Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA256_LIBMD)
+#  include 
+#  define ARCHIVE_HAS_SHA256
+typedef SHA256_CTX archive_sha256_ctx;
+#  define archive_sha256_init(ctx) SHA256_Init(ctx)
+#  define archive_sha256_final(ctx, buf)   SHA256_Final(buf, ctx)
+#  define archive_sha256_update(ctx, buf, n)   SHA256_Update(ctx, buf, n)
 #elif defined(ARCHIVE_HASH_SHA256_LIBSYSTEM)
 #  include 
 #  define ARCHIVE_HAS_SHA256
@@ -257,6 +278,13 @@ typedef SHA2_CTX archive_sha512_ctx;
 #  define archive_sha512_init(ctx) SHA512Init(ctx)
 #  define archive_sha512_final(ctx, buf)   SHA512Final(buf, ctx)
 #  define archive_sha512_update(ctx, buf, n)   SHA512Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA512_LIBMD)
+#  include 
+#  define ARCHIVE_HAS_SHA512
+typedef SHA512_CTX archive_sha512_ctx;
+#  define archive_sha512_init(ctx) SHA512_Init(ctx)
+#  define archive_sha512_final(ctx, buf)   SHA512_Final(buf, ctx)
+#  define archive_sha512_update(ctx, buf, n)   SHA512_Update(ctx, buf, n)
 #elif defined(ARCHIVE_HASH_SHA512_LIBSYSTEM)
 #  include 
 #  define ARCHIVE_HAS_SHA512

Modified: head/lib/libarchive/config_freebsd.h
==
--- head/lib/libarchive/config_freebsd.hSat Oct 22 22:00:35 2011
(r226642)
+++ head/lib/libarchive/config_freebsd.hSat Oct 22 22:22:46 2011
(r226643)
@@ -176,8 +176,8 @@
 #defineARCHIVE_HASH_SHA384_OPENSSL 1
 #defineARCHIVE_HASH_SHA512_OPENSSL 1
 #else
-#defineARCHIVE_HASH_MD5_LIBC 1
-#defineARCHIVE_HASH_SHA1_LIBC 1
-#defineARCHIVE_HASH_SHA256_LIBC 1
-#defineARCHIVE_HASH_SHA512_LIBC 1
+#defineARCHIVE_HASH_MD5_LIBMD 1
+#defineARCHIVE_HASH_SHA1_LIBMD 1
+#defineARCHIVE_HASH_SHA256_LIBMD 1
+#defineARCHIVE_HASH_SHA512_LIBMD 1
 #endif
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r223541 - head/usr.bin/tar

2011-06-25 Thread Tim Kientzle
Author: kientzle
Date: Sat Jun 25 16:27:49 2011
New Revision: 223541
URL: http://svn.freebsd.org/changeset/base/223541

Log:
  If there is a read error reading Y/N confirmation from the keyboard,
  exit immediately with an error.
  
  If there is an error opening or reading a file to put into the archive,
  set the return value for a deferred error exit.
  
  PR:   bin/154407

Modified:
  head/usr.bin/tar/util.c
  head/usr.bin/tar/write.c

Modified: head/usr.bin/tar/util.c
==
--- head/usr.bin/tar/util.c Sat Jun 25 16:13:56 2011(r223540)
+++ head/usr.bin/tar/util.c Sat Jun 25 16:27:49 2011(r223541)
@@ -226,7 +226,11 @@ yes(const char *fmt, ...)
fflush(stderr);
 
l = read(2, buff, sizeof(buff) - 1);
-   if (l <= 0)
+   if (l < 0) {
+ fprintf(stderr, "Keyboard read failed\n");
+ exit(1);
+   }
+   if (l == 0)
return (0);
buff[l] = 0;
 

Modified: head/usr.bin/tar/write.c
==
--- head/usr.bin/tar/write.cSat Jun 25 16:13:56 2011(r223540)
+++ head/usr.bin/tar/write.cSat Jun 25 16:27:49 2011(r223541)
@@ -919,6 +919,7 @@ write_entry_backend(struct bsdtar *bsdta
const char *pathname = archive_entry_sourcepath(entry);
fd = open(pathname, O_RDONLY | O_BINARY);
if (fd == -1) {
+   bsdtar->return_value = 1;
if (!bsdtar->verbose)
bsdtar_warnc(errno,
"%s: could not open file", pathname);
@@ -1020,6 +1021,12 @@ write_file_data(struct bsdtar *bsdtar, s
progress += bytes_written;
bytes_read = read(fd, bsdtar->buff, FILEDATABUFLEN);
}
+   if (bytes_read < 0) {
+   bsdtar_warnc(errno,
+"%s: Read error",
+archive_entry_pathname(entry));
+   bsdtar->return_value = 1;
+   }
return 0;
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r223573 - head/usr.bin/tar

2011-06-26 Thread Tim Kientzle
Author: kientzle
Date: Sun Jun 26 17:54:11 2011
New Revision: 223573
URL: http://svn.freebsd.org/changeset/base/223573

Log:
  The --newer-than test should descend into old
  directories to look for new files.
  
  PR:   bin/150890
  Submitted by: Tobias Herre
  MFC after:3 weeks

Modified:
  head/usr.bin/tar/write.c

Modified: head/usr.bin/tar/write.c
==
--- head/usr.bin/tar/write.cSun Jun 26 17:30:46 2011(r223572)
+++ head/usr.bin/tar/write.cSun Jun 26 17:54:11 2011(r223573)
@@ -752,6 +752,9 @@ write_hierarchy(struct bsdtar *bsdtar, s
break;
}
 
+   if (bsdtar->option_no_subdirs)
+   descend = 0;
+
/*
 * Are we about to cross to a new filesystem?
 */
@@ -764,7 +767,6 @@ write_hierarchy(struct bsdtar *bsdtar, s
} else if (descend == 0) {
/* We're not descending, so no need to check. */
} else if (bsdtar->option_dont_traverse_mounts) {
-   /* User has asked us not to cross mount points. */
descend = 0;
} else {
/* We're prepared to cross a mount point. */
@@ -791,8 +793,15 @@ write_hierarchy(struct bsdtar *bsdtar, s
 * In -u mode, check that the file is newer than what's
 * already in the archive; in all modes, obey --newerXXX flags.
 */
-   if (!new_enough(bsdtar, name, st))
+   if (!new_enough(bsdtar, name, st)) {
+   if (!descend)
+   continue;
+   if (bsdtar->option_interactive &&
+   !yes("add '%s'", name))
+   continue;
+   tree_descend(tree);
continue;
+   }
 
archive_entry_free(entry);
entry = archive_entry_new();
@@ -868,8 +877,7 @@ write_hierarchy(struct bsdtar *bsdtar, s
!yes("add '%s'", name))
continue;
 
-   /* Note: if user vetoes, we won't descend. */
-   if (descend && !bsdtar->option_no_subdirs)
+   if (descend)
tree_descend(tree);
 
/*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r190162 - head/usr.bin/ar

2009-03-20 Thread Tim Kientzle
Author: kientzle
Date: Fri Mar 20 17:11:45 2009
New Revision: 190162
URL: http://svn.freebsd.org/changeset/base/190162

Log:
  Act like ranlib if our name ends in ranlib.  In particular,
  this works with some recent cross-building changes by Warner
  that install ranlib as, e.g., "arm-freebsd7.1-ranlib".
  
  Submitted by: John Hein

Modified:
  head/usr.bin/ar/ar.c

Modified: head/usr.bin/ar/ar.c
==
--- head/usr.bin/ar/ar.cFri Mar 20 17:10:50 2009(r190161)
+++ head/usr.bin/ar/ar.cFri Mar 20 17:11:45 2009(r190162)
@@ -108,8 +108,11 @@ main(int argc, char **argv)
if ((bsdar->progname = getprogname()) == NULL)
bsdar->progname = "ar";
 
-   if (strcmp(bsdar->progname, "ranlib") == 0 ||
-   strcmp(bsdar->progname, "bsdranlib") == 0) {
+   /* Act like ranlib if our name ends in "ranlib"; this
+* accomodates arm-freebsd7.1-ranlib, bsdranlib, etc. */
+   len = strlen(bsdar->progname);
+   if (len >= strlen("ranlib") &&
+   strcmp(bsdar->progname + len - strlen("ranlib"), "ranlib") == 0) {
while ((opt = getopt_long(argc, argv, "tV", longopts,
NULL)) != -1) {
switch(opt) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r189828 - in head: include sys/sys

2009-03-20 Thread Tim Kientzle
... we'd have to mod apps to do things like remove use of 
gnu-long-opts in to switch away from things like gtar and the savings is 
unclear.  But I can ask...


FYI:  bsdtar already supports the most popular GNU tar
long options.  There should be extremely few ports
that actually require GNU tar.

Tim
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r190098 - in head/sys/sparc64: fhc sparc64

2009-03-22 Thread Tim Kientzle

Julian Elischer wrote:

Christoph Mallon wrote:

Andriy Gapon schrieb:

 >> compliants about style (9)
 > agreement and disagreement.

basically almost every single committer who comes into the group
usually starts up by objecting to one part or another of the style
guide. ... The style guide IS open to change but not by any individual
contributer.  Most of the things in there are there for a reason that
is non obvious.   Sometimes they are arbitrary.


The most important style question when contributing
to *any* existing project is "does it match?"
Consistency contributes far more to readability
than any other style issue, especially on very
large bodies of code.

Tim
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r190516 - stable/7/bin/pax

2009-03-28 Thread Tim Kientzle
Author: kientzle
Date: Sun Mar 29 01:00:48 2009
New Revision: 190516
URL: http://svn.freebsd.org/changeset/base/190516

Log:
  MFC r187976:  Restore timestamps on symlinks
 Before this fix, pax would stop the restore sequence for
 symlinks after setting the owner.  As a result, mode
 and timestamp were not restored.  This patch corrects the
 problem by simply removing the short-circuit for symlinks
 and using lchown()/lchmod()/lutimes() always for restoring
 metadata.
  
  PR:   bin/91316
  Submitted by: Jaakko Heinonen
  Reviewed by:  Joerg Sonnenberger
  Approved by:re (Ken Smith)

Modified:
  stable/7/bin/pax/   (props changed)
  stable/7/bin/pax/file_subs.c

Modified: stable/7/bin/pax/file_subs.c
==
--- stable/7/bin/pax/file_subs.cSat Mar 28 23:24:34 2009
(r190515)
+++ stable/7/bin/pax/file_subs.cSun Mar 29 01:00:48 2009
(r190516)
@@ -425,19 +425,11 @@ node_creat(ARCHD *arcn)
 * we were able to create the node. set uid/gid, modes and times
 */
if (pids)
-   res = ((arcn->type == PAX_SLK) ?
-   set_lids(arcn->name, arcn->sb.st_uid, arcn->sb.st_gid) :
-   set_ids(arcn->name, arcn->sb.st_uid, arcn->sb.st_gid));
+   res = set_ids(arcn->name, arcn->sb.st_uid, arcn->sb.st_gid);
else
res = 0;
 
/*
-* symlinks are done now.
-*/
-   if (arcn->type == PAX_SLK)
-   return(0);
-
-   /*
 * IMPORTANT SECURITY NOTE:
 * if not preserving mode or we cannot set uid/gid, then PROHIBIT any
 * set uid/gid bits
@@ -632,7 +624,7 @@ chk_path( char *name, uid_t st_uid, gid_
  * used by -t to reset access times).
  * When ign is zero, only those times the user has asked for are set, the
  * other ones are left alone. We do not assume the un-documented feature
- * of many utimes() implementations that consider a 0 time value as a do
+ * of many lutimes() implementations that consider a 0 time value as a do
  * not set request.
  */
 
@@ -661,7 +653,7 @@ set_ftime(char *fnm, time_t mtime, time_
/*
 * set the times
 */
-   if (utimes(fnm, tv) < 0)
+   if (lutimes(fnm, tv) < 0)
syswarn(1, errno, "Access/modification time set failed on: %s",
fnm);
return;
@@ -677,30 +669,6 @@ set_ftime(char *fnm, time_t mtime, time_
 int
 set_ids(char *fnm, uid_t uid, gid_t gid)
 {
-   if (chown(fnm, uid, gid) < 0) {
-   /*
-* ignore EPERM unless in verbose mode or being run by root.
-* if running as pax, POSIX requires a warning.
-*/
-   if (strcmp(NM_PAX, argv0) == 0 || errno != EPERM || vflag ||
-   geteuid() == 0)
-   syswarn(1, errno, "Unable to set file uid/gid of %s",
-   fnm);
-   return(-1);
-   }
-   return(0);
-}
-
-/*
- * set_lids()
- * set the uid and gid of a file system node
- * Return:
- * 0 when set, -1 on failure
- */
-
-int
-set_lids(char *fnm, uid_t uid, gid_t gid)
-{
if (lchown(fnm, uid, gid) < 0) {
/*
 * ignore EPERM unless in verbose mode or being run by root.
@@ -724,7 +692,7 @@ void
 set_pmode(char *fnm, mode_t mode)
 {
mode &= ABITS;
-   if (chmod(fnm, mode) < 0)
+   if (lchmod(fnm, mode) < 0)
syswarn(1, errno, "Could not set permissions on %s", fnm);
return;
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r190517 - stable/7/usr.bin/tar

2009-03-28 Thread Tim Kientzle
Author: kientzle
Date: Sun Mar 29 01:04:13 2009
New Revision: 190517
URL: http://svn.freebsd.org/changeset/base/190517

Log:
  Merge r188343 from -CURRENT:   Unbreak writing shar archives.
 When copying file data to the archive, don't write more
 than was read.  This seems to have only affected the shar
 writer, since other formats proactively truncate output
 to the originally-advertised size.
  
  PR:   bin/131244
  Approved by:  re (Ken Smith)

Modified:
  stable/7/usr.bin/tar/   (props changed)
  stable/7/usr.bin/tar/write.c

Modified: stable/7/usr.bin/tar/write.c
==
--- stable/7/usr.bin/tar/write.cSun Mar 29 01:00:48 2009
(r190516)
+++ stable/7/usr.bin/tar/write.cSun Mar 29 01:04:13 2009
(r190517)
@@ -966,7 +966,7 @@ write_file_data(struct bsdtar *bsdtar, s
siginfo_printinfo(bsdtar, progress);
 
bytes_written = archive_write_data(a, bsdtar->buff,
-   FILEDATABUFLEN);
+   bytes_read);
if (bytes_written < 0) {
/* Write failed; this is bad */
bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(a));
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r190699 - head/lib/libarchive

2009-04-04 Thread Tim Kientzle
Author: kientzle
Date: Sat Apr  4 20:08:08 2009
New Revision: 190699
URL: http://svn.freebsd.org/changeset/base/190699

Log:
  Temporary hack to unbreak user/group lookups;
  use a larger buffer for getpwuid_r/getgrgid_r.
  This needs to be dynamically sized.

Modified:
  head/lib/libarchive/archive_read_disk_set_standard_lookup.c

Modified: head/lib/libarchive/archive_read_disk_set_standard_lookup.c
==
--- head/lib/libarchive/archive_read_disk_set_standard_lookup.c Sat Apr  4 
19:06:52 2009(r190698)
+++ head/lib/libarchive/archive_read_disk_set_standard_lookup.c Sat Apr  4 
20:08:08 2009(r190699)
@@ -182,7 +182,7 @@ lookup_uname(void *data, uid_t uid)
 static const char *
 lookup_uname_helper(struct archive *a, id_t id)
 {
-   char buffer[64];
+   char buffer[512];
struct passwd   pwent, *result;
int r;
 
@@ -210,7 +210,7 @@ lookup_gname(void *data, gid_t gid)
 static const char *
 lookup_gname_helper(struct archive *a, id_t id)
 {
-   char buffer[64];
+   char buffer[512];
struct groupgrent, *result;
int r;
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r190950 - head/share/man/man4

2009-04-11 Thread Tim Kientzle
Author: kientzle
Date: Sat Apr 11 22:39:38 2009
New Revision: 190950
URL: http://svn.freebsd.org/changeset/base/190950

Log:
  Any tar program should work here; the explicit
  reference to bsdtar is misleading.

Modified:
  head/share/man/man4/textdump.4

Modified: head/share/man/man4/textdump.4
==
--- head/share/man/man4/textdump.4  Sat Apr 11 22:34:08 2009
(r190949)
+++ head/share/man/man4/textdump.4  Sat Apr 11 22:39:38 2009
(r190950)
@@ -98,7 +98,7 @@ sysctl.
 .El
 .Pp
 Kernel textdumps may be extracted using
-.Xr bsdtar 1 .
+.Xr tar 1 .
 .Sh CONFIGURATION
 The
 .Nm
@@ -153,7 +153,7 @@ These scripts may also be configured usi
 .Xr ddb 8
 utility.
 .Sh SEE ALSO
-.Xr bsdtar 1 ,
+.Xr tar 1 ,
 .Xr ddb 4 ,
 .Xr tar 5 ,
 .Xr ddb 8 ,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r190955 - head/lib/libarchive

2009-04-11 Thread Tim Kientzle
Author: kientzle
Date: Sun Apr 12 04:45:40 2009
New Revision: 190955
URL: http://svn.freebsd.org/changeset/base/190955

Log:
  Merge r881 from libarchive.googlecode.com:  The "empty" format
  should not be recognized if there is a read error.

Modified:
  head/lib/libarchive/archive_read_support_format_empty.c

Modified: head/lib/libarchive/archive_read_support_format_empty.c
==
--- head/lib/libarchive/archive_read_support_format_empty.c Sun Apr 12 
03:45:03 2009(r190954)
+++ head/lib/libarchive/archive_read_support_format_empty.c Sun Apr 12 
04:45:40 2009(r190955)
@@ -60,9 +60,10 @@ static int
 archive_read_format_empty_bid(struct archive_read *a)
 {
const void *h;
+   ssize_t avail;
 
-   h = __archive_read_ahead(a, 1, NULL);
-   if (h != NULL)
+   h = __archive_read_ahead(a, 1, &avail);
+   if (avail != 0)
return (-1);
return (1);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r190956 - head/lib/libarchive

2009-04-11 Thread Tim Kientzle
Author: kientzle
Date: Sun Apr 12 04:59:11 2009
New Revision: 190956
URL: http://svn.freebsd.org/changeset/base/190956

Log:
  Merge from libarchive.googlecode.com:
  r751: Change __archive_strncat() to use a void * source, which reduces
  the amount of casting needed to use this with "char", "signed char"
  and "unsigned char".
  r752: Use additions instead of multiplications when growing buffer;
  faster and less chance of overflow.

Modified:
  head/lib/libarchive/archive_string.c
  head/lib/libarchive/archive_string.h

Modified: head/lib/libarchive/archive_string.c
==
--- head/lib/libarchive/archive_string.cSun Apr 12 04:45:40 2009
(r190955)
+++ head/lib/libarchive/archive_string.cSun Apr 12 04:59:11 2009
(r190956)
@@ -115,11 +115,11 @@ __archive_string_ensure(struct archive_s
as->buffer_length = 32;
else if (as->buffer_length < 8192)
/* Buffers under 8k are doubled for speed. */
-   as->buffer_length *= 2;
+   as->buffer_length += as->buffer_length;
else {
/* Buffers 8k and over grow by at least 25% each time. */
size_t old_length = as->buffer_length;
-   as->buffer_length = (as->buffer_length * 5) / 4;
+   as->buffer_length += as->buffer_length / 4;
/* Be safe: If size wraps, release buffer and return NULL. */
if (as->buffer_length < old_length) {
free(as->s);
@@ -142,10 +142,12 @@ __archive_string_ensure(struct archive_s
 }
 
 struct archive_string *
-__archive_strncat(struct archive_string *as, const char *p, size_t n)
+__archive_strncat(struct archive_string *as, const void *_p, size_t n)
 {
size_t s;
-   const char *pp;
+   const char *p, *pp;
+
+   p = (const char *)_p;
 
/* Like strlen(p), except won't examine positions beyond p[n]. */
s = 0;

Modified: head/lib/libarchive/archive_string.h
==
--- head/lib/libarchive/archive_string.hSun Apr 12 04:45:40 2009
(r190955)
+++ head/lib/libarchive/archive_string.hSun Apr 12 04:59:11 2009
(r190956)
@@ -99,8 +99,12 @@ __archive_string_ensure(struct archive_s
 #definearchive_string_ensure __archive_string_ensure
 
 /* Append C string, which may lack trailing \0. */
+/* The source is declared void * here because this gets used with
+ * "signed char *", "unsigned char *" and "char *" arguments.
+ * Declaring it "char *" as with some of the other functions just
+ * leads to a lot of extra casts. */
 struct archive_string *
-__archive_strncat(struct archive_string *, const char *, size_t);
+__archive_strncat(struct archive_string *, const void *, size_t);
 #definearchive_strncat  __archive_strncat
 
 /* Append a C string to an archive_string, resizing as necessary. */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r190957 - head/lib/libarchive

2009-04-11 Thread Tim Kientzle
Author: kientzle
Date: Sun Apr 12 05:04:02 2009
New Revision: 190957
URL: http://svn.freebsd.org/changeset/base/190957

Log:
  Merge from libarchive.googlecode.com r756,r761:
  Document the new archive_read_disk API.

Added:
  head/lib/libarchive/archive_read_disk.3   (contents, props changed)
Modified:
  head/lib/libarchive/Makefile

Modified: head/lib/libarchive/Makefile
==
--- head/lib/libarchive/MakefileSun Apr 12 04:59:11 2009
(r190956)
+++ head/lib/libarchive/MakefileSun Apr 12 05:04:02 2009
(r190957)
@@ -77,6 +77,7 @@ SRCS= archive_check_magic.c   \
 # Man pages to be installed.
 MAN=   archive_entry.3 \
archive_read.3  \
+   archive_read_disk.3 \
archive_util.3  \
archive_write.3 \
archive_write_disk.3\
@@ -186,6 +187,16 @@ MLINKS+=   archive_read.3 archive_read_sup
 MLINKS+=   archive_read.3 archive_read_support_format_iso9660.3
 MLINKS+=   archive_read.3 archive_read_support_format_tar.3
 MLINKS+=   archive_read.3 archive_read_support_format_zip.3
+MLINKS+=   archive_read_disk.3 archive_read_disk_entry_from_file.3
+MLINKS+=   archive_read_disk.3 archive_read_disk_gname.3
+MLINKS+=   archive_read_disk.3 archive_read_disk_new.3
+MLINKS+=   archive_read_disk.3 archive_read_disk_set_gname_lookup.3
+MLINKS+=   archive_read_disk.3 archive_read_disk_set_standard_lookup.3
+MLINKS+=   archive_read_disk.3 archive_read_disk_set_symlink_hybrid.3
+MLINKS+=   archive_read_disk.3 archive_read_disk_set_symlink_logical.3
+MLINKS+=   archive_read_disk.3 archive_read_disk_set_symlink_physical.3
+MLINKS+=   archive_read_disk.3 archive_read_disk_set_uname_lookup.3
+MLINKS+=   archive_read_disk.3 archive_read_disk_uname.3
 MLINKS+=   archive_util.3 archive_clear_error.3
 MLINKS+=   archive_util.3 archive_compression.3
 MLINKS+=   archive_util.3 archive_compression_name.3

Added: head/lib/libarchive/archive_read_disk.3
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libarchive/archive_read_disk.3 Sun Apr 12 05:04:02 2009
(r190957)
@@ -0,0 +1,308 @@
+.\" Copyright (c) 2003-2009 Tim Kientzle
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (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$
+.\"
+.Dd March 10, 2009
+.Dt archive_read_disk 3
+.Os
+.Sh NAME
+.Nm archive_read_disk_new ,
+.Nm archive_read_disk_set_symlink_logical ,
+.Nm archive_read_disk_set_symlink_physical ,
+.Nm archive_read_disk_set_symlink_hybrid ,
+.Nm archive_read_disk_entry_from_file ,
+.Nm archive_read_disk_gname ,
+.Nm archive_read_disk_uname ,
+.Nm archive_read_disk_set_uname_lookup ,
+.Nm archive_read_disk_set_gname_lookup ,
+.Nm archive_read_disk_set_standard_lookup ,
+.Nm archive_read_close ,
+.Nm archive_read_finish
+.Nd functions for reading objects from disk
+.Sh SYNOPSIS
+.In archive.h
+.Ft struct archive *
+.Fn archive_read_disk_new "void"
+.Ft int
+.Fn archive_read_disk_set_symlink_logical "struct archive *"
+.Ft int
+.Fn archive_read_disk_set_symlink_physical "struct archive *"
+.Ft int
+.Fn archive_read_disk_set_symlink_hybrid "struct archive *"
+.Ft int
+.Fn archive_read_disk_g

svn commit: r190959 - in head/lib/libarchive: . test

2009-04-11 Thread Tim Kientzle
Author: kientzle
Date: Sun Apr 12 05:33:34 2009
New Revision: 190959
URL: http://svn.freebsd.org/changeset/base/190959

Log:
  Merge from libarchive.googlecode.com:  Mostly a bunch of
  corrections to the Windows support to reconcile differences
  between Visual Studio and Cygwin.  Includes parts of
  revisions 757, 774, 787, 815, 817, 819, 820, 844, and 886.
  
  Of particular note, r886 overhauled the UTF-8/Unicode conversions to
  work correctly regardless of whether the local system uses 16-bit
  or 32-bit wchar_t.  (I assume that systems with 16-bit wchar_t
  use UTF-16 and those with 32-bit wchar_t use UCS-4.)  This revision
  also added a preference for wcrtomb() (which is thread-safe) on
  platforms that support it.

Modified:
  head/lib/libarchive/archive.h
  head/lib/libarchive/archive_check_magic.c
  head/lib/libarchive/archive_entry.c
  head/lib/libarchive/archive_entry.h
  head/lib/libarchive/archive_read_disk_set_standard_lookup.c
  head/lib/libarchive/archive_read_support_compression_program.c
  head/lib/libarchive/archive_string.c
  head/lib/libarchive/archive_write_disk.c
  head/lib/libarchive/archive_write_disk_set_standard_lookup.c
  head/lib/libarchive/archive_write_set_compression_program.c
  head/lib/libarchive/archive_write_set_format_mtree.c
  head/lib/libarchive/test/main.c
  head/lib/libarchive/test/test.h
  head/lib/libarchive/test/test_read_disk.c
  head/lib/libarchive/test/test_read_extract.c
  head/lib/libarchive/test/test_tar_large.c
  head/lib/libarchive/test/test_write_disk.c
  head/lib/libarchive/test/test_write_disk_failures.c
  head/lib/libarchive/test/test_write_disk_hardlink.c
  head/lib/libarchive/test/test_write_disk_perms.c
  head/lib/libarchive/test/test_write_disk_secure.c

Modified: head/lib/libarchive/archive.h
==
--- head/lib/libarchive/archive.h   Sun Apr 12 05:19:35 2009
(r190958)
+++ head/lib/libarchive/archive.h   Sun Apr 12 05:33:34 2009
(r190959)
@@ -46,7 +46,7 @@
 
 /* Get appropriate definitions of standard POSIX-style types. */
 /* These should match the types used in 'struct stat' */
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #define__LA_INT64_T__int64
 # if   defined(_WIN64)
 #  define  __LA_SSIZE_T__int64
@@ -68,7 +68,7 @@
  * .lib.  The default here assumes you're building a DLL.  Only
  * libarchive source should ever define __LIBARCHIVE_BUILD.
  */
-#if ((defined __WIN32__) || (defined _WIN32)) && (!defined LIBARCHIVE_STATIC)
+#if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && 
(!defined LIBARCHIVE_STATIC)
 # ifdef __LIBARCHIVE_BUILD
 #  ifdef __GNUC__
 #   define __LA_DECL   __attribute__((dllexport)) extern

Modified: head/lib/libarchive/archive_check_magic.c
==
--- head/lib/libarchive/archive_check_magic.c   Sun Apr 12 05:19:35 2009
(r190958)
+++ head/lib/libarchive/archive_check_magic.c   Sun Apr 12 05:33:34 2009
(r190959)
@@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
 #ifdef HAVE_UNISTD_H
 #include 
 #endif
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include 
 #include 
 #endif
@@ -56,7 +56,7 @@ errmsg(const char *m)
 static void
 diediedie(void)
 {
-#if defined(_WIN32) && defined(_DEBUG)
+#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
/* Cause a breakpoint exception  */
DebugBreak();
 #endif

Modified: head/lib/libarchive/archive_entry.c
==
--- head/lib/libarchive/archive_entry.c Sun Apr 12 05:19:35 2009
(r190958)
+++ head/lib/libarchive/archive_entry.c Sun Apr 12 05:33:34 2009
(r190959)
@@ -83,7 +83,7 @@ __FBSDID("$FreeBSD$");
 #elif defined makedev
 /* There's a "makedev" macro. */
 #define ae_makedev(maj, min) makedev((maj), (min))
-#elif defined mkdev || defined _WIN32 || defined __WIN32__
+#elif defined mkdev || ((defined _WIN32 || defined __WIN32__) && 
!defined(__CYGWIN__))
 /* Windows.  */
 #define ae_makedev(maj, min) mkdev((maj), (min))
 #else

Modified: head/lib/libarchive/archive_entry.h
==
--- head/lib/libarchive/archive_entry.h Sun Apr 12 05:19:35 2009
(r190958)
+++ head/lib/libarchive/archive_entry.h Sun Apr 12 05:33:34 2009
(r190959)
@@ -42,7 +42,7 @@
 
 /* Get appropriate definitions of standard POSIX-style types. */
 /* These should match the types used in 'struct stat' */
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #define__LA_INT64_T__int64
 #define__LA_UID_T  unsigned int
 #define__LA_GID_T  unsigned int
@@ -71,7 +71,7 @@
  * .lib.  The default here assumes you're building a DLL.  Only
  * libarchive source should ever define __LIBARCHIVE_BUILD.
  */
-#if ((defined __WIN32__) || (defined _WIN32)) 

svn commit: r190960 - head/lib/libarchive

2009-04-11 Thread Tim Kientzle
Author: kientzle
Date: Sun Apr 12 05:38:35 2009
New Revision: 190960
URL: http://svn.freebsd.org/changeset/base/190960

Log:
  Thanks to Christoph Mallon for pointing out the dead variable here.
  Also, rework this a little to make the logic excruciatingly clear.

Modified:
  head/lib/libarchive/archive_read_support_format_empty.c

Modified: head/lib/libarchive/archive_read_support_format_empty.c
==
--- head/lib/libarchive/archive_read_support_format_empty.c Sun Apr 12 
05:33:34 2009(r190959)
+++ head/lib/libarchive/archive_read_support_format_empty.c Sun Apr 12 
05:38:35 2009(r190960)
@@ -59,13 +59,14 @@ archive_read_support_format_empty(struct
 static int
 archive_read_format_empty_bid(struct archive_read *a)
 {
-   const void *h;
ssize_t avail;
 
-   h = __archive_read_ahead(a, 1, &avail);
-   if (avail != 0)
-   return (-1);
-   return (1);
+   (void)__archive_read_ahead(a, 1, &avail);
+   /* Bid 1 if we successfully read exactly zero bytes. */
+   if (avail == 0)
+   return (1);
+   /* Otherwise, we don't bid on this. */
+   return (-1);
 }
 
 static int
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r190961 - in head/lib/libarchive: . test

2009-04-11 Thread Tim Kientzle
Author: kientzle
Date: Sun Apr 12 05:47:23 2009
New Revision: 190961
URL: http://svn.freebsd.org/changeset/base/190961

Log:
  Merge from libarchive.googlecode.com r791, r879, r884, r948: Various
  fixes to read_support_compression_program.  In particular, failure of
  the external program is detected a lot earlier, which gives much more
  reasonable error handling.

Modified:
  head/lib/libarchive/archive_read_support_compression_program.c
  head/lib/libarchive/test/test_read_compress_program.c

Modified: head/lib/libarchive/archive_read_support_compression_program.c
==
--- head/lib/libarchive/archive_read_support_compression_program.c  Sun Apr 
12 05:38:35 2009(r190960)
+++ head/lib/libarchive/archive_read_support_compression_program.c  Sun Apr 
12 05:47:23 2009(r190961)
@@ -38,6 +38,9 @@ __FBSDID("$FreeBSD$");
 #ifdef HAVE_LIMITS_H
 #  include 
 #endif
+#ifdef HAVE_SIGNAL_H
+#  include 
+#endif
 #ifdef HAVE_STDLIB_H
 #  include 
 #endif
@@ -119,6 +122,8 @@ static int  program_bidder_free(struct ar
 struct program_filter {
char*description;
pid_tchild;
+   int  exit_status;
+   int  waitpid_return;
int  child_stdin, child_stdout;
 
char*out_buf;
@@ -211,6 +216,73 @@ program_bidder_bid(struct archive_read_f
 }
 
 /*
+ * Shut down the child, return ARCHIVE_OK if it exited normally.
+ *
+ * Note that the return value is sticky; if we're called again,
+ * we won't reap the child again, but we will return the same status
+ * (including error message if the child came to a bad end).
+ */
+static int
+child_stop(struct archive_read_filter *self, struct program_filter *state)
+{
+   /* Close our side of the I/O with the child. */
+   if (state->child_stdin != -1) {
+   close(state->child_stdin);
+   state->child_stdin = -1;
+   }
+   if (state->child_stdout != -1) {
+   close(state->child_stdout);
+   state->child_stdout = -1;
+   }
+
+   if (state->child != 0) {
+   /* Reap the child. */
+   do {
+   state->waitpid_return
+   = waitpid(state->child, &state->exit_status, 0);
+   } while (state->waitpid_return == -1 && errno == EINTR);
+   state->child = 0;
+   }
+
+   if (state->waitpid_return < 0) {
+   /* waitpid() failed?  This is ugly. */
+   archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC,
+   "Child process exited badly");
+   return (ARCHIVE_WARN);
+   }
+
+   if (WIFSIGNALED(state->exit_status)) {
+#ifdef SIGPIPE
+   /* If the child died because we stopped reading before
+* it was done, that's okay.  Some archive formats
+* have padding at the end that we routinely ignore. */
+   /* The alternative to this would be to add a step
+* before close(child_stdout) above to read from the
+* child until the child has no more to write. */
+   if (WTERMSIG(state->exit_status) == SIGPIPE)
+   return (ARCHIVE_OK);
+#endif
+   archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC,
+   "Child process exited with signal %d",
+   WTERMSIG(state->exit_status));
+   return (ARCHIVE_WARN);
+   }
+
+   if (WIFEXITED(state->exit_status)) {
+   if (WEXITSTATUS(state->exit_status) == 0)
+   return (ARCHIVE_OK);
+
+   archive_set_error(&self->archive->archive,
+   ARCHIVE_ERRNO_MISC,
+   "Child process exited with status %d",
+   WEXITSTATUS(state->exit_status));
+   return (ARCHIVE_WARN);
+   }
+
+   return (ARCHIVE_WARN);
+}
+
+/*
  * Use select() to decide whether the child is ready for read or write.
  */
 static ssize_t
@@ -229,11 +301,10 @@ child_read(struct archive_read_filter *s
 
if (ret > 0)
return (ret);
-   if (ret == 0 || (ret == -1 && errno == EPIPE)) {
-   close(state->child_stdout);
-   state->child_stdout = -1;
-   return (0);
-   }
+   if (ret == 0 || (ret == -1 && errno == EPIPE))
+   /* Child has closed its output; reap the child
+* and return the status. */
+   return (child_stop(self, state));
if (ret == -1 && errno != EAGAIN)
return (-1);
 
@@ -352,8 +423,11 @@ program_filter_read(struct archive_read_
while (state->child_stdout != -1 && total < state->out_buf_len) {
bytes = child_read(self, p, state

svn commit: r191008 - head/lib/libarchive

2009-04-13 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 13 18:56:53 2009
New Revision: 191008
URL: http://svn.freebsd.org/changeset/base/191008

Log:
  Re-enable backing up extended attributes, as the ZFS bug this
  triggered seems to have been fixed by John Baldwin's commit
  r189967.

Modified:
  head/lib/libarchive/config_freebsd.h

Modified: head/lib/libarchive/config_freebsd.h
==
--- head/lib/libarchive/config_freebsd.hMon Apr 13 18:32:26 2009
(r191007)
+++ head/lib/libarchive/config_freebsd.hMon Apr 13 18:56:53 2009
(r191008)
@@ -34,12 +34,8 @@
 #defineHAVE_ACL_SET_FD_NP 1
 #defineHAVE_ACL_SET_FILE 1
 #defineHAVE_ACL_USER 1
-#if 0
-/* XXX Temporarily disable support for reading extended attributes from
- * disk, as it seems to be badly broken on ZFS. XXX */
 #defineHAVE_EXTATTR_GET_FILE 1
 #defineHAVE_EXTATTR_LIST_FILE 1
-#endif
 #defineHAVE_EXTATTR_SET_FD 1
 #defineHAVE_EXTATTR_SET_FILE 1
 #defineHAVE_SYS_ACL_H 1
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r189967 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2009-04-13 Thread Tim Kientzle

John Baldwin wrote:

On Wednesday 18 March 2009 12:19:44 pm John Baldwin wrote:

Author: jhb
Date: Wed Mar 18 16:19:44 2009
New Revision: 189967
URL: http://svn.freebsd.org/changeset/base/189967

Log:
  The zfs_get_xattrdir() function is used to find the extended attribute
  directory for a znode.  When the directory already exists, it returns a
  referenced but unlocked vnode.  When a directory does not yet exist, it
  calls zfs_make_xattrdir() to create a new one.  zfs_make_xattrdir() returns
  the vnode both referenced and and locked and zfs_get_xattrdir() was leaking
  this vnode lock to its callers.  Fix this by dropping the vnode lock if
  zfs_make_xattrdir() successfully creates a new extended attribute
  directory.


This should fix the panics with ZFS and tar + EA.


Thanks.

One point I'm curious about.This problem was
originally triggered by calls to extattr_list_fd().
This seems to imply that any call to extattr_list_fd()
will allocate an extended attribute directory if it
doesn't already exist.

This is surprising.  It also raises questions about
both performance (tar now does extattr_list_fd()
for every file being archived) and operation
with read-only mounts.

Tim

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r191055 - head/lib/libc/string

2009-04-14 Thread Tim Kientzle

Edward Tomasz Napierala wrote:

Author: trasz
Date: Tue Apr 14 11:39:56 2009
New Revision: 191055
URL: http://svn.freebsd.org/changeset/base/191055

Log:
  There is no way for strmode(3) to append '+' if the file has ACL,
  because there is no way to figure that out based on the file mode
  itself.  Make the manual page match reality.


Yep, that '+' is why libarchive has a custom strmode()
that accepts more information than just the mode.

A related issue:  It would be really nice to be
able to find out whether a file had extended ACLs
or extended attributes based on the information
returned from stat(2).  That would allow programs
like tar to avoid a fair number of system calls.
Even just a single bit "HAS_EXTENSIONS" would help
a lot, since most files don't have any extended
ACLs or extended attributes.  It would also allow
users of strmode() (such as ls) to insert that '+'
sign themselves.

The only place I see to do this is to appropriate
some bits from st_flags.

Tim
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r191055 - head/lib/libc/string

2009-04-14 Thread Tim Kientzle

Robert Watson wrote:

On Tue, 14 Apr 2009, Tim Kientzle wrote:
A related issue:  It would be really nice to be able to find out 
whether a file had extended ACLs or extended attributes based on the 
information returned from stat(2).


Kirk, Poul-Henning, and I discussed precisely this during the initial 
UFS2 design session.  The idea was that we'd allocate a system flag that 
was essentially a "there are ACL-related extended attributes",


I was thinking a bit that indicated the existence
of *any* extended metadata, not just ACLs.
Userspace consumers can then query EAs, ACLs, etc.
if they see this bit set.

If we have bits to burn, we could assign separate
bits for specific types of extended metadata--such
as ACLs--but I think we need to start with something
pretty broad.  The variety of extended metadata is
only going to increase over time.

could be used in-kernel to avoid EA reads, and from userspace to avoid 
(or trigger) ACL reads.  I still think it would be a good idea to do 
this, although we might want to think a bit about failure modes if 
there's a crash between EA update and inode update.


You could synthesize this bit at stat() time and not
store it on disk at all.  Alternatively, you could
order inode update before EA update to get conservative
behavior:  If the bit isn't set, that would guarantee
that there was no extended metadata.  Note that this
fits well with having a single bit that indicates
"there exists some extended metadata"; clients will
have to be prepared to handle the case where the bit is
set but the particular metadata of interest to them
isn't there after all.

My primary concern here is finding ways to avoid extraneous
system calls; whether the bit is stored on disk or is
synthesized sounds like a filesystem-level optimization
that I don't personally much care about.

Tim
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r191055 - head/lib/libc/string

2009-04-15 Thread Tim Kientzle

Edward Tomasz Napierala wrote:

On 0414T1115, Tim Kientzle wrote:

  There is no way for strmode(3) to append '+' if the file has ACL,
  because there is no way to figure that out based on the file mode
  itself.  Make the manual page match reality.

Yep, that '+' is why libarchive has a custom strmode()
that accepts more information than just the mode.

A related issue:  It would be really nice to be
able to find out whether a file had extended ACLs
or extended attributes based on the information
returned from stat(2).


I know about the idea of adding a bit to the inode flags, but I never
thought about exposing it to the userland in mode_t.  Can we actually
do this without risking confusing some applications that expect only
the standard mode bits to be set?


Unfortunately, mode_t is very full and extending
it would probably cause chaos.

I was thinking of a bit in the fflags field.
That wouldn't help strmode(), of course,
but would make it easy for strmode() users
(such as ls) to add a '+' if they wanted to.

Tim

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191165 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:39:35 2009
New Revision: 191165
URL: http://svn.freebsd.org/changeset/base/191165

Log:
  Merge from libarchive.googlecode.com:  If we're
  given an empty filename, just invoke write_open_fd()
  instead of re-implementing the code to use stdout.

Modified:
  head/lib/libarchive/archive_write_open_filename.c

Modified: head/lib/libarchive/archive_write_open_filename.c
==
--- head/lib/libarchive/archive_write_open_filename.c   Fri Apr 17 00:30:56 
2009(r191164)
+++ head/lib/libarchive/archive_write_open_filename.c   Fri Apr 17 00:39:35 
2009(r191165)
@@ -71,24 +71,18 @@ archive_write_open_filename(struct archi
 {
struct write_file_data *mine;
 
-   if (filename == NULL || filename[0] == '\0') {
-   mine = (struct write_file_data *)malloc(sizeof(*mine));
-   if (mine == NULL) {
-   archive_set_error(a, ENOMEM, "No memory");
-   return (ARCHIVE_FATAL);
-   }
-   mine->filename[0] = '\0'; /* Record that we're using stdout. */
-   } else {
-   mine = (struct write_file_data *)malloc(sizeof(*mine) + 
strlen(filename));
-   if (mine == NULL) {
-   archive_set_error(a, ENOMEM, "No memory");
-   return (ARCHIVE_FATAL);
-   }
-   strcpy(mine->filename, filename);
+   if (filename == NULL || filename[0] == '\0')
+   return (archive_write_open_fd(a, 1));
+
+   mine = (struct write_file_data *)malloc(sizeof(*mine) + 
strlen(filename));
+   if (mine == NULL) {
+   archive_set_error(a, ENOMEM, "No memory");
+   return (ARCHIVE_FATAL);
}
+   strcpy(mine->filename, filename);
mine->fd = -1;
return (archive_write_open(a, mine,
-   file_open, file_write, file_close));
+   file_open, file_write, file_close));
 }
 
 static int
@@ -104,21 +98,11 @@ file_open(struct archive *a, void *clien
/*
 * Open the file.
 */
-   if (mine->filename[0] != '\0') {
-   mine->fd = open(mine->filename, flags, 0666);
-   if (mine->fd < 0) {
-   archive_set_error(a, errno, "Failed to open '%s'",
-   mine->filename);
-   return (ARCHIVE_FATAL);
-   }
-   } else {
-   /*
-* NULL filename is stdout.
-*/
-   mine->fd = 1;
-   /* By default, pad archive when writing to stdout. */
-   if (archive_write_get_bytes_in_last_block(a) < 0)
-   archive_write_set_bytes_in_last_block(a, 0);
+   mine->fd = open(mine->filename, flags, 0666);
+   if (mine->fd < 0) {
+   archive_set_error(a, errno, "Failed to open '%s'",
+   mine->filename);
+   return (ARCHIVE_FATAL);
}
 
if (fstat(mine->fd, &st) != 0) {
@@ -172,8 +156,7 @@ file_close(struct archive *a, void *clie
struct write_file_data  *mine = (struct write_file_data *)client_data;
 
(void)a; /* UNUSED */
-   if (mine->filename[0] != '\0')
-   close(mine->fd);
+   close(mine->fd);
free(mine);
return (ARCHIVE_OK);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191166 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:42:45 2009
New Revision: 191166
URL: http://svn.freebsd.org/changeset/base/191166

Log:
  Merge from libarchive.googlecode.com:  Numerous fixes to the
  write options handling, including documentation.

Modified:
  head/lib/libarchive/archive_write.3
  head/lib/libarchive/archive_write.c
  head/lib/libarchive/archive_write_set_compression_bzip2.c
  head/lib/libarchive/archive_write_set_compression_gzip.c

Modified: head/lib/libarchive/archive_write.3
==
--- head/lib/libarchive/archive_write.3 Fri Apr 17 00:39:35 2009
(r191165)
+++ head/lib/libarchive/archive_write.3 Fri Apr 17 00:42:45 2009
(r191166)
@@ -43,6 +43,9 @@
 .Nm archive_write_set_compression_gzip ,
 .Nm archive_write_set_compression_none ,
 .Nm archive_write_set_compression_program ,
+.Nm archive_write_set_compressor_options ,
+.Nm archive_write_set_format_options ,
+.Nm archive_write_set_options ,
 .Nm archive_write_open ,
 .Nm archive_write_open_fd ,
 .Nm archive_write_open_FILE ,
@@ -73,10 +76,7 @@
 .Ft int
 .Fn archive_write_set_compression_none "struct archive *"
 .Ft int
-.Fo archive_write_set_compression_program
-.Fa "struct archive *"
-.Fa "const char * cmd"
-.Fc
+.Fn archive_write_set_compression_program "struct archive *" "const char * cmd"
 .Ft int
 .Fn archive_write_set_format_cpio "struct archive *"
 .Ft int
@@ -90,6 +90,12 @@
 .Ft int
 .Fn archive_write_set_format_ustar "struct archive *"
 .Ft int
+.Fn archive_write_set_format_options "struct archive *" "const char *"
+.Ft int
+.Fn archive_write_set_compressor_options "struct archive *" "const char *"
+.Ft int
+.Fn archive_write_set_options "struct archive *" "const char *"
+.Ft int
 .Fo archive_write_open
 .Fa "struct archive *"
 .Fa "void *client_data"
@@ -210,6 +216,68 @@ Note that the compressed output is alway
 The archive will be fed into the specified compression program.
 The output of that program is blocked and written to the client
 write callbacks.
+.It Xo
+.Fn archive_write_set_compressor_options ,
+.Fn archive_write_set_format_options ,
+.Fn archive_write_set_options
+.Xc
+Specifies options that will be passed to the currently-enabled
+compressor and/or format writer.
+The argument is a comma-separated list of individual options.
+Individual options have one of the following forms:
+.Bl -tag -compact -width indent
+.It Ar option=value
+The option/value pair will be provided to every module.
+Modules that do not accept an option with this name will ignore it.
+.It Ar option
+The option will be provided to every module with a value of
+.Dq 1 .
+.It Ar !option
+The option will be provided to every module with a NULL value.
+.It Ar module:option=value , Ar module:option , Ar module:!option
+As above, but the corresponding option and value will be provided
+only to modules whose name matches
+.Ar module .
+.El
+The return value will be
+.Cm ARCHIVE_OK
+if any module accepts the option, or
+.Cm ARCHIVE_WARN
+if no module accepted the option, or
+.Cm ARCHIVE_FATAL
+if there was a fatal error while attempting to process the option.
+.Pp
+The currently supported options are:
+.Bl -tag -compact -width indent
+.It Compressor gzip
+.Bl -tag -compact -width indent
+.It Cm compression-level
+The value is interpreted as a decimal integer specifying the
+gzip compression level.
+.El
+.It Compressor xz
+.Bl -tag -compact -width indent
+.It Cm compression-level
+The value is interpreted as a decimal integer specifying the
+compression level.
+.El
+.It Format mtree
+.Bl -tag -compact -width indent
+.It Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent , Cm link 
, Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 , Cm sha384 , 
Cm sha512 , Cm size , Cm time , Cm uid , Cm uname
+Enable a particular keyword in the mtree output.
+Prefix with an exclamation mark to disable the corresponding keyword.
+The default is equivalent to
+.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname 
.
+.It Cm all
+Enables all of the above keywords.
+.It Cm use-set
+Enables generation of
+.Cm /set
+lines that specify default values for the following files and/or directories.
+.It Cm indent
+XXX needs explanation XXX
+.El
+.El
 .It Fn archive_write_open
 Freeze the settings, open the archive, and prepare for writing entries.
 This is the most generic form of this function, which accepts

Modified: head/lib/libarchive/archive_write.c
==
--- head/lib/libarchive/archive_write.c Fri Apr 17 00:39:35 2009
(r191165)
+++ head/lib/libarchive/archive_write.c Fri Apr 17 00:42:45 2009
(r191166)
@@ -132,8 +132,14 @@ archive_write_set_format_options(struct 
 {
struct archive_write *a = (struct archive_write *)_a;
char key[64], val[64];
-   int len, r;
+   int len, r, ret = ARCHIVE_OK;
 
+   __archive_check_magic(&a->archive, AR

svn commit: r191167 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:44:03 2009
New Revision: 191167
URL: http://svn.freebsd.org/changeset/base/191167

Log:
  Fix a minor memory leak.

Modified:
  head/lib/libarchive/archive_write_disk.c

Modified: head/lib/libarchive/archive_write_disk.c
==
--- head/lib/libarchive/archive_write_disk.cFri Apr 17 00:42:45 2009
(r191166)
+++ head/lib/libarchive/archive_write_disk.cFri Apr 17 00:44:03 2009
(r191167)
@@ -1278,6 +1278,8 @@ _archive_write_finish(struct archive *_a
(a->cleanup_gid)(a->lookup_gid_data);
if (a->cleanup_uid != NULL && a->lookup_uid_data != NULL)
(a->cleanup_uid)(a->lookup_uid_data);
+   if (a->entry)
+   archive_entry_free(a->entry);
archive_string_free(&a->_name_data);
archive_string_free(&a->archive.error_string);
archive_string_free(&a->path_safe);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191168 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:44:47 2009
New Revision: 191168
URL: http://svn.freebsd.org/changeset/base/191168

Log:
  Use thread-safe getgrnam_r() and getpwnam_r(); dynamically size
  the buffer used by this.

Modified:
  head/lib/libarchive/archive_write_disk_set_standard_lookup.c

Modified: head/lib/libarchive/archive_write_disk_set_standard_lookup.c
==
--- head/lib/libarchive/archive_write_disk_set_standard_lookup.cFri Apr 
17 00:44:03 2009(r191167)
+++ head/lib/libarchive/archive_write_disk_set_standard_lookup.cFri Apr 
17 00:44:47 2009(r191168)
@@ -118,12 +118,34 @@ lookup_gid(void *private_data, const cha
b->hash = h;
 #if HAVE_GRP_H
{
-   struct group*grent = getgrnam(gname);
-   if (grent != NULL)
-   gid = grent->gr_gid;
+   char _buffer[128];
+   size_t bufsize = 128;
+   char *buffer = _buffer;
+   struct groupgrent, *result;
+   int r;
+
+   for (;;) {
+   r = getgrnam_r(gname, &grent, buffer, bufsize, &result);
+   if (r == 0)
+   break;
+   if (r != ERANGE)
+   break;
+   bufsize *= 2;
+   if (buffer != _buffer)
+   free(buffer);
+   buffer = malloc(bufsize);
+   if (buffer == NULL)
+   break;
+   }
+   if (result != NULL)
+   gid = result->gr_gid;
+   if (buffer != _buffer)
+   free(buffer);
}
 #elif defined(_WIN32) && !defined(__CYGWIN__)
/* TODO: do a gname->gid lookup for Windows. */
+#else
+   #error No way to perform gid lookups on this platform
 #endif
b->id = gid;
 
@@ -155,12 +177,34 @@ lookup_uid(void *private_data, const cha
b->hash = h;
 #if HAVE_PWD_H
{
-   struct passwd   *pwent = getpwnam(uname);
-   if (pwent != NULL)
-   uid = pwent->pw_uid;
+   char _buffer[128];
+   size_t bufsize = 128;
+   char *buffer = _buffer;
+   struct passwd   pwent, *result;
+   int r;
+
+   for (;;) {
+   r = getpwnam_r(uname, &pwent, buffer, bufsize, &result);
+   if (r == 0)
+   break;
+   if (r != ERANGE)
+   break;
+   bufsize *= 2;
+   if (buffer != _buffer)
+   free(buffer);
+   buffer = malloc(bufsize);
+   if (buffer == NULL)
+   break;
+   }
+   if (result != NULL)
+   uid = result->pw_uid;
+   if (buffer != _buffer)
+   free(buffer);
}
 #elif defined(_WIN32) && !defined(__CYGWIN__)
/* TODO: do a uname->uid lookup for Windows. */
+#else
+   #error No way to look up uids on this platform
 #endif
b->id = uid;
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191169 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:45:47 2009
New Revision: 191169
URL: http://svn.freebsd.org/changeset/base/191169

Log:
  Properly clone and free the recently-added "sourcepath" field.

Modified:
  head/lib/libarchive/archive_entry.c

Modified: head/lib/libarchive/archive_entry.c
==
--- head/lib/libarchive/archive_entry.c Fri Apr 17 00:44:47 2009
(r191168)
+++ head/lib/libarchive/archive_entry.c Fri Apr 17 00:45:47 2009
(r191169)
@@ -370,6 +370,7 @@ archive_entry_clear(struct archive_entry
aes_clean(&entry->ae_gname);
aes_clean(&entry->ae_hardlink);
aes_clean(&entry->ae_pathname);
+   aes_clean(&entry->ae_sourcepath);
aes_clean(&entry->ae_symlink);
aes_clean(&entry->ae_uname);
archive_entry_acl_clear(entry);
@@ -399,6 +400,7 @@ archive_entry_clone(struct archive_entry
aes_copy(&entry2->ae_gname, &entry->ae_gname);
aes_copy(&entry2->ae_hardlink, &entry->ae_hardlink);
aes_copy(&entry2->ae_pathname, &entry->ae_pathname);
+   aes_copy(&entry2->ae_sourcepath, &entry->ae_sourcepath);
aes_copy(&entry2->ae_symlink, &entry->ae_symlink);
entry2->ae_set = entry->ae_set;
aes_copy(&entry2->ae_uname, &entry->ae_uname);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191170 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:47:16 2009
New Revision: 191170
URL: http://svn.freebsd.org/changeset/base/191170

Log:
  Accept empty options, add a new read_next_header2() which is more
  efficient for some uses.

Modified:
  head/lib/libarchive/archive_read.c

Modified: head/lib/libarchive/archive_read.c
==
--- head/lib/libarchive/archive_read.c  Fri Apr 17 00:45:47 2009
(r191169)
+++ head/lib/libarchive/archive_read.c  Fri Apr 17 00:47:16 2009
(r191170)
@@ -120,7 +120,11 @@ archive_read_set_format_options(struct a
size_t i;
int len, r;
 
+   if (s == NULL || *s == '\0')
+   return (ARCHIVE_OK);
a = (struct archive_read *)_a;
+   __archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
+   ARCHIVE_STATE_NEW, "archive_read_set_format_options");
len = 0;
for (i = 0; i < sizeof(a->formats)/sizeof(a->formats[0]); i++) {
format = &a->formats[i];
@@ -160,7 +164,11 @@ archive_read_set_filter_options(struct a
char key[64], val[64];
int len, r;
 
+   if (s == NULL || *s == '\0')
+   return (ARCHIVE_OK);
a = (struct archive_read *)_a;
+   __archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
+   ARCHIVE_STATE_NEW, "archive_read_set_filter_options");
filter = a->filter;
len = 0;
for (filter = a->filter; filter != NULL; filter = filter->upstream) {
@@ -368,18 +376,15 @@ build_stream(struct archive_read *a)
  * Read header of next entry.
  */
 int
-archive_read_next_header(struct archive *_a, struct archive_entry **entryp)
+archive_read_next_header2(struct archive *_a, struct archive_entry *entry)
 {
struct archive_read *a = (struct archive_read *)_a;
-   struct archive_entry *entry;
int slot, ret;
 
__archive_check_magic(_a, ARCHIVE_READ_MAGIC,
ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
"archive_read_next_header");
 
-   *entryp = NULL;
-   entry = a->entry;
archive_entry_clear(entry);
archive_clear_error(&a->archive);
 
@@ -437,12 +442,22 @@ archive_read_next_header(struct archive 
break;
}
 
-   *entryp = entry;
a->read_data_output_offset = 0;
a->read_data_remaining = 0;
return (ret);
 }
 
+int
+archive_read_next_header(struct archive *_a, struct archive_entry **entryp)
+{
+   int ret;
+   struct archive_read *a = (struct archive_read *)_a;
+   *entryp = NULL;
+   ret = archive_read_next_header2(_a, a->entry);
+   *entryp = a->entry;
+   return ret;
+}
+
 /*
  * Allow each registered format to bid on whether it wants to handle
  * the next entry.  Return index of winning bidder.
@@ -680,8 +695,10 @@ _archive_read_close(struct archive *_a)
 
__archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
ARCHIVE_STATE_ANY, "archive_read_close");
+   archive_clear_error(&a->archive);
a->archive.state = ARCHIVE_STATE_CLOSED;
 
+
/* Call cleanup functions registered by optional components. */
if (a->cleanup_archive_extract != NULL)
r = (a->cleanup_archive_extract)(a);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191171 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:50:00 2009
New Revision: 191171
URL: http://svn.freebsd.org/changeset/base/191171

Log:
  Don't use the open callback, which is deprecated (because it's
  never necessary).  Also, simplify just a tad by delegating
  to read_open_fd() when we know the file descriptor, instead
  of duplicating that logic.

Modified:
  head/lib/libarchive/archive_read_open_fd.c
  head/lib/libarchive/archive_read_open_file.c
  head/lib/libarchive/archive_read_open_filename.c

Modified: head/lib/libarchive/archive_read_open_fd.c
==
--- head/lib/libarchive/archive_read_open_fd.c  Fri Apr 17 00:47:16 2009
(r191170)
+++ head/lib/libarchive/archive_read_open_fd.c  Fri Apr 17 00:50:00 2009
(r191171)
@@ -52,7 +52,6 @@ struct read_fd_data {
 };
 
 static int file_close(struct archive *, void *);
-static int file_open(struct archive *, void *);
 static ssize_t file_read(struct archive *, void *, const void **buff);
 #if ARCHIVE_API_VERSION < 2
 static ssize_t file_skip(struct archive *, void *, size_t request);
@@ -63,50 +62,41 @@ static off_tfile_skip(struct archive *,
 int
 archive_read_open_fd(struct archive *a, int fd, size_t block_size)
 {
+   struct stat st;
struct read_fd_data *mine;
+   void *b;
 
-   mine = (struct read_fd_data *)malloc(sizeof(*mine));
-   if (mine == NULL) {
-   archive_set_error(a, ENOMEM, "No memory");
+   if (fstat(fd, &st) != 0) {
+   archive_set_error(a, errno, "Can't stat fd %d", fd);
return (ARCHIVE_FATAL);
}
-   mine->block_size = block_size;
-   mine->buffer = malloc(mine->block_size);
-   if (mine->buffer == NULL) {
+
+   mine = (struct read_fd_data *)malloc(sizeof(*mine));
+   b = malloc(block_size);
+   if (mine == NULL || b == NULL) {
archive_set_error(a, ENOMEM, "No memory");
free(mine);
+   free(b);
return (ARCHIVE_FATAL);
}
+   mine->block_size = block_size;
+   mine->buffer = b;
mine->fd = fd;
-   /* lseek() hardly ever works, so disable it by default.  See below. */
-   mine->can_skip = 0;
-   return (archive_read_open2(a, mine, file_open, file_read, file_skip, 
file_close));
-}
-
-static int
-file_open(struct archive *a, void *client_data)
-{
-   struct read_fd_data *mine = (struct read_fd_data *)client_data;
-   struct stat st;
-
-   if (fstat(mine->fd, &st) != 0) {
-   archive_set_error(a, errno, "Can't stat fd %d", mine->fd);
-   return (ARCHIVE_FATAL);
-   }
-
+   /*
+* Skip support is a performance optimization for anything
+* that supports lseek().  On FreeBSD, only regular files and
+* raw disk devices support lseek() and there's no portable
+* way to determine if a device is a raw disk device, so we
+* only enable this optimization for regular files.
+*/
if (S_ISREG(st.st_mode)) {
archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
-   /*
-* Enabling skip here is a performance optimization for
-* anything that supports lseek().  On FreeBSD, only
-* regular files and raw disk devices support lseek() and
-* there's no portable way to determine if a device is
-* a raw disk device, so we only enable this optimization
-* for regular files.
-*/
mine->can_skip = 1;
-   }
-   return (ARCHIVE_OK);
+   } else
+   mine->can_skip = 0;
+
+   return (archive_read_open2(a, mine,
+   NULL, file_read, file_skip, file_close));
 }
 
 static ssize_t
@@ -180,8 +170,7 @@ file_close(struct archive *a, void *clie
struct read_fd_data *mine = (struct read_fd_data *)client_data;
 
(void)a; /* UNUSED */
-   if (mine->buffer != NULL)
-   free(mine->buffer);
+   free(mine->buffer);
free(mine);
return (ARCHIVE_OK);
 }

Modified: head/lib/libarchive/archive_read_open_file.c
==
--- head/lib/libarchive/archive_read_open_file.cFri Apr 17 00:47:16 
2009(r191170)
+++ head/lib/libarchive/archive_read_open_file.cFri Apr 17 00:50:00 
2009(r191171)
@@ -55,7 +55,6 @@ struct read_FILE_data {
 };
 
 static int file_close(struct archive *, void *);
-static int file_open(struct archive *, void *);
 static ssize_t file_read(struct archive *, void *, const void **buff);
 #if ARCHIVE_API_VERSION < 2
 static ssize_t file_skip(struct archive *, void *, size_t request);
@@ -66,45 +65,36 @@ static off_tfile_skip(struct archive *,
 int
 archive_read_open_FILE(struct archive *a, FILE *f)
 {
+   struct stat st;
struct r

svn commit: r191172 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:54:35 2009
New Revision: 191172
URL: http://svn.freebsd.org/changeset/base/191172

Log:
  Merge new xz/lzma support from libarchive.googlecode.com.
  Since FreeBSD doesn't have liblzma in the base system, the
  read side will always fall back to the unxz/unlzma commands for now.
  (Which will in turn fail if those commands are not currently
  installed.)  The write side does not yet have a fallback, so
  that will just fail.

Added:
  head/lib/libarchive/archive_read_support_compression_xz.c   (contents, props 
changed)
  head/lib/libarchive/archive_write_set_compression_xz.c   (contents, props 
changed)
Modified:
  head/lib/libarchive/Makefile

Modified: head/lib/libarchive/Makefile
==
--- head/lib/libarchive/MakefileFri Apr 17 00:50:00 2009
(r191171)
+++ head/lib/libarchive/MakefileFri Apr 17 00:54:35 2009
(r191172)
@@ -39,6 +39,7 @@ SRCS= archive_check_magic.c   \
archive_read_support_compression_gzip.c \
archive_read_support_compression_none.c \
archive_read_support_compression_program.c  \
+   archive_read_support_compression_xz.c   \
archive_read_support_format_all.c   \
archive_read_support_format_ar.c\
archive_read_support_format_cpio.c  \
@@ -63,6 +64,7 @@ SRCS= archive_check_magic.c   \
archive_write_set_compression_gzip.c\
archive_write_set_compression_none.c\
archive_write_set_compression_program.c \
+   archive_write_set_compression_xz.c  \
archive_write_set_format.c  \
archive_write_set_format_ar.c   \
archive_write_set_format_by_name.c  \

Added: head/lib/libarchive/archive_read_support_compression_xz.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libarchive/archive_read_support_compression_xz.c   Fri Apr 17 
00:54:35 2009(r191172)
@@ -0,0 +1,642 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2003-2008 Tim Kientzle and Miklos Vajna
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+
+__FBSDID("$FreeBSD$");
+
+#ifdef HAVE_ERRNO_H
+#include 
+#endif
+#include 
+#ifdef HAVE_STDLIB_H
+#include 
+#endif
+#ifdef HAVE_STRING_H
+#include 
+#endif
+#ifdef HAVE_UNISTD_H
+#include 
+#endif
+#if HAVE_LZMA_H
+#include 
+#elif HAVE_LZMADEC_H
+#include 
+#endif
+
+#include "archive.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+#if HAVE_LZMA_H && HAVE_LIBLZMA
+
+struct private_data {
+   lzma_stream  stream;
+   unsigned char   *out_block;
+   size_t   out_block_size;
+   int64_t  total_out;
+   char eof; /* True = found end of compressed data. */
+};
+
+/* Combined lzma/xz filter */
+static ssize_t xz_filter_read(struct archive_read_filter *, const void **);
+static int xz_filter_close(struct archive_read_filter *);
+static int xz_lzma_bidder_init(struct archive_read_filter *);
+
+#elif HAVE_LZMADEC_H && HAVE_LIBLZMADEC
+
+struct private_data {
+   lzmadec_stream   stream;
+   unsigned char   *out_block;
+   size_t   out_block_size;
+   int64_t  total_out;
+   char eof; /* True = found end of compressed data. */
+};
+
+/* Lzma-only fi

svn commit: r191173 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:55:52 2009
New Revision: 191173
URL: http://svn.freebsd.org/changeset/base/191173

Log:
  Implement command-line fallbacks for gzip and bzip2 decompression as well.
  Not an issue for FreeBSD, since the base system has the necessary libraries.
  Since all decompressors are always available now, we can unconditionally
  enable them in archive_read_support_compression_all().

Modified:
  head/lib/libarchive/archive_read_support_compression_all.c
  head/lib/libarchive/archive_read_support_compression_bzip2.c
  head/lib/libarchive/archive_read_support_compression_gzip.c

Modified: head/lib/libarchive/archive_read_support_compression_all.c
==
--- head/lib/libarchive/archive_read_support_compression_all.c  Fri Apr 17 
00:54:35 2009(r191172)
+++ head/lib/libarchive/archive_read_support_compression_all.c  Fri Apr 17 
00:55:52 2009(r191173)
@@ -31,18 +31,24 @@ __FBSDID("$FreeBSD$");
 int
 archive_read_support_compression_all(struct archive *a)
 {
-#if HAVE_BZLIB_H
+   /* Bzip falls back to "bunzip2" command-line */
archive_read_support_compression_bzip2(a);
-#endif
/* The decompress code doesn't use an outside library. */
archive_read_support_compression_compress(a);
/* Gzip decompress falls back to "gunzip" command-line. */
archive_read_support_compression_gzip(a);
-#if HAVE_LZMADEC_H
-   /* LZMA bidding is subject to false positives because
-* the LZMA file format has a very weak signature.  It
-* may not be feasible to include LZMA detection here. */
-   /* archive_read_support_compression_lzma(a); */
-#endif
+   /* The LZMA file format has a very weak signature, so it
+* may not be feasible to keep this here, but we'll try.
+* This will come back out if there are problems. */
+   /* Lzma falls back to "unlzma" command-line program. */
+   archive_read_support_compression_lzma(a);
+   /* Xz falls back to "unxz" command-line program. */
+   archive_read_support_compression_xz(a);
+
+   /* Note: We always return ARCHIVE_OK here, even if some of the
+* above return ARCHIVE_WARN.  The intent here is to enable
+* "as much as possible."  Clients who need specific
+* compression should enable those individually so they can
+* verify the level of support. */
return (ARCHIVE_OK);
 }

Modified: head/lib/libarchive/archive_read_support_compression_bzip2.c
==
--- head/lib/libarchive/archive_read_support_compression_bzip2.cFri Apr 
17 00:54:35 2009(r191172)
+++ head/lib/libarchive/archive_read_support_compression_bzip2.cFri Apr 
17 00:55:52 2009(r191173)
@@ -86,7 +86,13 @@ archive_read_support_compression_bzip2(s
reader->init = bzip2_reader_init;
reader->options = NULL;
reader->free = bzip2_reader_free;
+#if HAVE_BZLIB_H
return (ARCHIVE_OK);
+#else
+   archive_set_error(_a, ARCHIVE_ERRNO_MISC,
+   "Using external bunzip2 program");
+   return (ARCHIVE_WARN);
+#endif
 }
 
 static int
@@ -150,10 +156,15 @@ bzip2_reader_bid(struct archive_read_fil
 static int
 bzip2_reader_init(struct archive_read_filter *self)
 {
+   int r;
 
-   archive_set_error(&self->archive->archive, -1,
-   "This version of libarchive was compiled without bzip2 support");
-   return (ARCHIVE_FATAL);
+   r = __archive_read_program(self, "bunzip2");
+   /* Note: We set the format here even if __archive_read_program()
+* above fails.  We do, after all, know what the format is
+* even if we weren't able to read it. */
+   self->code = ARCHIVE_COMPRESSION_BZIP2;
+   self->name = "bzip2";
+   return (r);
 }
 
 

Modified: head/lib/libarchive/archive_read_support_compression_gzip.c
==
--- head/lib/libarchive/archive_read_support_compression_gzip.c Fri Apr 17 
00:54:35 2009(r191172)
+++ head/lib/libarchive/archive_read_support_compression_gzip.c Fri Apr 17 
00:55:52 2009(r191173)
@@ -92,7 +92,14 @@ archive_read_support_compression_gzip(st
bidder->init = gzip_bidder_init;
bidder->options = NULL;
bidder->free = NULL; /* No data, so no cleanup necessary. */
+   /* Signal the extent of gzip support with the return value here. */
+#if HAVE_ZLIB_H
return (ARCHIVE_OK);
+#else
+   archive_set_error(_a, ARCHIVE_ERRNO_MISC,
+   "Using external gunzip program");
+   return (ARCHIVE_WARN);
+#endif
 }
 
 /*
@@ -207,9 +214,9 @@ gzip_bidder_bid(struct archive_read_filt
 #ifndef HAVE_ZLIB_H
 
 /*
- * If we don't have the library on this system, we can't actually do the
- * decompression.  We can, however, still detect compressed archives
- * and emit a usef

svn commit: r191174 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:57:11 2009
New Revision: 191174
URL: http://svn.freebsd.org/changeset/base/191174

Log:
  Minor fix: some platforms require both inttypes.h and stdint.h.

Modified:
  head/lib/libarchive/archive_platform.h

Modified: head/lib/libarchive/archive_platform.h
==
--- head/lib/libarchive/archive_platform.h  Fri Apr 17 00:55:52 2009
(r191173)
+++ head/lib/libarchive/archive_platform.h  Fri Apr 17 00:57:11 2009
(r191174)
@@ -67,7 +67,8 @@
 /* Try to get standard C99-style integer type definitions. */
 #if HAVE_INTTYPES_H
 #include 
-#elif HAVE_STDINT_H
+#endif
+#if HAVE_STDINT_H
 #include 
 #endif
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191175 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:58:44 2009
New Revision: 191175
URL: http://svn.freebsd.org/changeset/base/191175

Log:
  LZW bugfix:  when we hit end-of-file, return an invalid code.

Modified:
  head/lib/libarchive/archive_read_support_compression_compress.c

Modified: head/lib/libarchive/archive_read_support_compression_compress.c
==
--- head/lib/libarchive/archive_read_support_compression_compress.c Fri Apr 
17 00:57:11 2009(r191174)
+++ head/lib/libarchive/archive_read_support_compression_compress.c Fri Apr 
17 00:58:44 2009(r191175)
@@ -278,7 +278,7 @@ compress_filter_read(struct archive_read
*p++ = *--state->stackp;
} else {
ret = next_code(self);
-   if (ret == ARCHIVE_EOF)
+   if (ret == -1)
state->end_of_stream = ret;
else if (ret != ARCHIVE_OK)
return (ret);
@@ -424,7 +424,7 @@ getbits(struct archive_read_filter *self
= __archive_read_filter_ahead(self->upstream,
1, &ret);
if (ret == 0)
-   return (ARCHIVE_EOF);
+   return (-1);
if (ret < 0 || state->next_in == NULL)
return (ARCHIVE_FATAL);
state->avail_in = ret;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191176 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 00:59:34 2009
New Revision: 191176
URL: http://svn.freebsd.org/changeset/base/191176

Log:
  When pulling metadata from disk, lookup the user and group name at the same 
time.

Modified:
  head/lib/libarchive/archive_read_disk_entry_from_file.c

Modified: head/lib/libarchive/archive_read_disk_entry_from_file.c
==
--- head/lib/libarchive/archive_read_disk_entry_from_file.c Fri Apr 17 
00:58:44 2009(r191175)
+++ head/lib/libarchive/archive_read_disk_entry_from_file.c Fri Apr 17 
00:59:34 2009(r191176)
@@ -42,6 +42,9 @@ __FBSDID("$FreeBSD$");
 #ifdef HAVE_SYS_STAT_H
 #include 
 #endif
+#ifdef HAVE_SYS_XATTR_H
+#include 
+#endif
 #ifdef HAVE_ACL_LIBACL_H
 #include 
 #endif
@@ -84,7 +87,7 @@ archive_read_disk_entry_from_file(struct
 int fd, const struct stat *st)
 {
struct archive_read_disk *a = (struct archive_read_disk *)_a;
-   const char *path;
+   const char *path, *name;
struct stat s;
int initial_fd = fd;
int r, r1;
@@ -128,6 +131,14 @@ archive_read_disk_entry_from_file(struct
}
archive_entry_copy_stat(entry, st);
 
+   /* Lookup uname/gname */
+   name = archive_read_disk_uname(_a, archive_entry_uid(entry));
+   if (name != NULL)
+   archive_entry_copy_uname(entry, name);
+   name = archive_read_disk_gname(_a, archive_entry_gid(entry));
+   if (name != NULL)
+   archive_entry_copy_gname(entry, name);
+
 #ifdef HAVE_STRUCT_STAT_ST_FLAGS
/* On FreeBSD, we get flags for free with the stat. */
/* TODO: Does this belong in copy_stat()? */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191177 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 01:00:11 2009
New Revision: 191177
URL: http://svn.freebsd.org/changeset/base/191177

Log:
  Don't match an empty file on a read error.

Modified:
  head/lib/libarchive/archive_read_support_format_empty.c

Modified: head/lib/libarchive/archive_read_support_format_empty.c
==
--- head/lib/libarchive/archive_read_support_format_empty.c Fri Apr 17 
00:59:34 2009(r191176)
+++ head/lib/libarchive/archive_read_support_format_empty.c Fri Apr 17 
01:00:11 2009(r191177)
@@ -59,14 +59,13 @@ archive_read_support_format_empty(struct
 static int
 archive_read_format_empty_bid(struct archive_read *a)
 {
+   const void *h;
ssize_t avail;
 
-   (void)__archive_read_ahead(a, 1, &avail);
-   /* Bid 1 if we successfully read exactly zero bytes. */
-   if (avail == 0)
-   return (1);
-   /* Otherwise, we don't bid on this. */
-   return (-1);
+   h = __archive_read_ahead(a, 1, &avail);
+   if (avail != 0)
+   return (-1);
+   return (1);
 }
 
 static int
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191178 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 01:01:15 2009
New Revision: 191178
URL: http://svn.freebsd.org/changeset/base/191178

Log:
  Dynamically size the buffer we pass to getgrgid_r() and getpwuid_r().
  Keep the buffer in the cache object so we don't have to keep doing this.

Modified:
  head/lib/libarchive/archive_read_disk_set_standard_lookup.c

Modified: head/lib/libarchive/archive_read_disk_set_standard_lookup.c
==
--- head/lib/libarchive/archive_read_disk_set_standard_lookup.c Fri Apr 17 
01:00:11 2009(r191177)
+++ head/lib/libarchive/archive_read_disk_set_standard_lookup.c Fri Apr 17 
01:01:15 2009(r191178)
@@ -61,6 +61,8 @@ static const char * const NO_NAME = "(no
 
 struct name_cache {
struct archive *archive;
+   char   *buff;
+   size_t  buff_size;
int probes;
int hits;
size_t  size;
@@ -73,8 +75,8 @@ struct name_cache {
 static const char *lookup_gname(void *, gid_t);
 static const char *lookup_uname(void *, uid_t);
 static voidcleanup(void *);
-static const char *lookup_gname_helper(struct archive *, id_t gid);
-static const char *lookup_uname_helper(struct archive *, id_t uid);
+static const char *lookup_gname_helper(struct name_cache *, id_t gid);
+static const char *lookup_uname_helper(struct name_cache *, id_t uid);
 
 /*
  * Installs functions that use getpwuid()/getgrgid()---along with
@@ -128,6 +130,7 @@ cleanup(void *data)
cache->cache[i].name != NO_NAME)
free((void *)(uintptr_t)cache->cache[i].name);
}
+   free(cache->buff);
free(cache);
}
 }
@@ -137,7 +140,7 @@ cleanup(void *data)
  */
 static const char *
 lookup_name(struct name_cache *cache,
-const char * (*lookup_fn)(struct archive *, id_t), id_t id)
+const char * (*lookup_fn)(struct name_cache *, id_t), id_t id)
 {
const char *name;
int slot;
@@ -158,7 +161,7 @@ lookup_name(struct name_cache *cache,
cache->cache[slot].name = NULL;
}
 
-   name = (lookup_fn)(cache->archive, id);
+   name = (lookup_fn)(cache, id);
if (name == NULL) {
/* Cache and return the negative response. */
cache->cache[slot].name = NO_NAME;
@@ -180,23 +183,43 @@ lookup_uname(void *data, uid_t uid)
 }
 
 static const char *
-lookup_uname_helper(struct archive *a, id_t id)
+lookup_uname_helper(struct name_cache *cache, id_t id)
 {
-   char buffer[512];
struct passwd   pwent, *result;
int r;
 
-   errno = 0;
-   r = getpwuid_r((uid_t)id, &pwent, buffer, sizeof(buffer), &result);
+   if (cache->buff_size == 0) {
+   cache->buff_size = 256;
+   cache->buff = malloc(cache->buff_size);
+   }
+   if (cache->buff == NULL)
+   return (NULL);
+   for (;;) {
+   r = getpwuid_r((uid_t)id, &pwent,
+  cache->buff, cache->buff_size, &result);
+   if (r == 0)
+   break;
+   if (r != ERANGE)
+   break;
+   /* ERANGE means our buffer was too small, but POSIX
+* doesn't tell us how big the buffer should be, so
+* we just double it and try again.  Because the buffer
+* is kept around in the cache object, we shouldn't
+* have to do this very often. */
+   cache->buff_size *= 2;
+   cache->buff = realloc(cache->buff, cache->buff_size);
+   if (cache->buff == NULL)
+   break;
+   }
if (r != 0) {
-   archive_set_error(a, errno,
+   archive_set_error(cache->archive, errno,
"Can't lookup user for id %d", (int)id);
return (NULL);
}
if (result == NULL)
return (NULL);
 
-   return strdup(pwent.pw_name);
+   return strdup(result->pw_name);
 }
 
 static const char *
@@ -208,22 +231,40 @@ lookup_gname(void *data, gid_t gid)
 }
 
 static const char *
-lookup_gname_helper(struct archive *a, id_t id)
+lookup_gname_helper(struct name_cache *cache, id_t id)
 {
-   char buffer[512];
struct groupgrent, *result;
int r;
 
-   errno = 0;
-   r = getgrgid_r((gid_t)id, &grent, buffer, sizeof(buffer), &result);
+   if (cache->buff_size == 0) {
+   cache->buff_size = 256;
+   cache->buff = malloc(cache->buff_size);
+   }
+   if (cache->buff == NULL)
+   return (NULL);
+   for (;;) {
+   r = getgrgid_r((gid_t)id, &grent,
+  cache->buff, cache->buff_size, &result);
+   if (r == 0)
+   break;
+   if (r != ERANGE)
+   break;
+  

svn commit: r191179 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 01:02:12 2009
New Revision: 191179
URL: http://svn.freebsd.org/changeset/base/191179

Log:
  Document the new read options interface and the new read_header2() call.

Modified:
  head/lib/libarchive/archive_read.3

Modified: head/lib/libarchive/archive_read.3
==
--- head/lib/libarchive/archive_read.3  Fri Apr 17 01:01:15 2009
(r191178)
+++ head/lib/libarchive/archive_read.3  Fri Apr 17 01:02:12 2009
(r191179)
@@ -29,6 +29,9 @@
 .Os
 .Sh NAME
 .Nm archive_read_new ,
+.Nm archive_read_set_filter_options ,
+.Nm archive_read_set_format_options ,
+.Nm archive_read_set_options ,
 .Nm archive_read_support_compression_all ,
 .Nm archive_read_support_compression_bzip2 ,
 .Nm archive_read_support_compression_compress ,
@@ -48,6 +51,7 @@
 .Nm archive_read_open_filename ,
 .Nm archive_read_open_memory ,
 .Nm archive_read_next_header ,
+.Nm archive_read_next_header2 ,
 .Nm archive_read_data ,
 .Nm archive_read_data_block ,
 .Nm archive_read_data_skip ,
@@ -93,6 +97,12 @@
 .Ft int
 .Fn archive_read_support_format_zip "struct archive *"
 .Ft int
+.Fn archive_read_set_filter_options "struct archive *" "const char *"
+.Ft int
+.Fn archive_read_set_format_options "struct archive *" "const char *"
+.Ft int
+.Fn archive_read_set_options "struct archive *" "const char *"
+.Ft int
 .Fo archive_read_open
 .Fa "struct archive *"
 .Fa "void *client_data"
@@ -123,6 +133,8 @@
 .Fn archive_read_open_memory "struct archive *" "void *buff" "size_t size"
 .Ft int
 .Fn archive_read_next_header "struct archive *" "struct archive_entry **"
+.Ft int
+.Fn archive_read_next_header2 "struct archive *" "struct archive_entry *"
 .Ft ssize_t
 .Fn archive_read_data "struct archive *" "void *buff" "size_t len"
 .Ft int
@@ -214,6 +226,48 @@ For convenience,
 .Fn archive_read_support_format_all
 enables support for all available formats.
 Only empty archives are supported by default.
+.It Xo
+.Fn archive_read_set_filter_options ,
+.Fn archive_read_set_format_options ,
+.Fn archive_read_set_options
+.Xc
+Specifies options that will be passed to currently-registered
+filters (including decompression filters) and/or format readers.
+The argument is a comma-separated list of individual options.
+Individual options have one of the following forms:
+.Bl -tag -compact -width indent
+.It Ar option=value
+The option/value pair will be provided to every module.
+Modules that do not accept an option with this name will ignore it.
+.It Ar option
+The option will be provided to every module with a value of
+.Dq 1 .
+.It Ar !option
+The option will be provided to every module with a NULL value.
+.It Ar module:option=value , Ar module:option , Ar module:!option
+As above, but the corresponding option and value will be provided
+only to modules whose name matches
+.Ar module .
+.El
+The return value will be
+.Cm ARCHIVE_OK
+if any module accepts the option, or
+.Cm ARCHIVE_WARN
+if no module accepted the option, or
+.Cm ARCHIVE_FATAL
+if there was a fatal error while attempting to process the option.
+.Pp
+The currently supported options are:
+.Bl -tag -compact -width indent
+.It Format iso9660
+.Bl -tag -compact -width indent
+.It Cm joliet
+Support Joliet extensions.
+Defaults to enabled, use
+.Cm !joliet
+to disable.
+.El
+.El
 .It Fn archive_read_open
 The same as
 .Fn archive_read_open2 ,
@@ -266,6 +320,14 @@ memory containing the archive data.
 Read the header for the next entry and return a pointer to
 a
 .Tn struct archive_entry .
+This is a convenience wrapper around
+.Fn archive_read_next_header2
+that uses an internal
+.Tn struct archive_entry
+object.
+.It Fn archive_read_next_header2
+Read the header for the next entry and populate the provided
+.Tn struct archive_entry .
 .It Fn archive_read_data
 Read data associated with the header just read.
 Internally, this is a convenience function that calls
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191180 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 01:02:56 2009
New Revision: 191180
URL: http://svn.freebsd.org/changeset/base/191180

Log:
  Fix a memory leak:  Release the current list of /set keywords
  even when we exit on an error.

Modified:
  head/lib/libarchive/archive_read_support_format_mtree.c

Modified: head/lib/libarchive/archive_read_support_format_mtree.c
==
--- head/lib/libarchive/archive_read_support_format_mtree.c Fri Apr 17 
01:02:12 2009(r191179)
+++ head/lib/libarchive/archive_read_support_format_mtree.c Fri Apr 17 
01:02:56 2009(r191180)
@@ -404,10 +404,13 @@ read_mtree(struct archive_read *a, struc
len = readline(a, mtree, &p, 256);
if (len == 0) {
mtree->this_entry = mtree->entries;
+   free_options(global);
return (ARCHIVE_OK);
}
-   if (len < 0)
+   if (len < 0) {
+   free_options(global);
return (len);
+   }
/* Leading whitespace is never significant, ignore it. */
while (*p == ' ' || *p == '\t') {
++p;
@@ -432,13 +435,16 @@ read_mtree(struct archive_read *a, struc
} else
break;
 
-   if (r != ARCHIVE_OK)
+   if (r != ARCHIVE_OK) {
+   free_options(global);
return r;
+   }
}
 
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Can't parse line %ju", counter);
-   return ARCHIVE_FATAL;
+   free_options(global);
+   return (ARCHIVE_FATAL);
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191182 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 01:04:23 2009
New Revision: 191182
URL: http://svn.freebsd.org/changeset/base/191182

Log:
  FreeBSD has a lot of crypto functions used by the recent mtree writer updates.

Modified:
  head/lib/libarchive/config_freebsd.h

Modified: head/lib/libarchive/config_freebsd.h
==
--- head/lib/libarchive/config_freebsd.hFri Apr 17 01:03:52 2009
(r191181)
+++ head/lib/libarchive/config_freebsd.hFri Apr 17 01:04:23 2009
(r191182)
@@ -75,6 +75,7 @@
 #defineHAVE_LIMITS_H 1
 #defineHAVE_LUTIMES 1
 #defineHAVE_MALLOC 1
+#defineHAVE_MD5 1
 #defineHAVE_MD5_H 1
 #defineHAVE_MEMMOVE 1
 #defineHAVE_MEMSET 1
@@ -89,11 +90,16 @@
 #defineHAVE_POLL_H 1
 #defineHAVE_PWD_H 1
 #defineHAVE_READLINK 1
-#defineHAVE_RIPEMD_H 1
+#defineHAVE_RMD160 1
 #defineHAVE_SELECT 1
 #defineHAVE_SETENV 1
 #defineHAVE_SHA_H 1
+#defineHAVE_SHA1 1
+#defineHAVE_SHA256 1
 #defineHAVE_SHA256_H 1
+#defineHAVE_SHA384 1
+#defineHAVE_SHA512 1
+#defineHAVE_SIGNAL_H 1
 #defineHAVE_STDINT_H 1
 #defineHAVE_STDLIB_H 1
 #defineHAVE_STRCHR 1
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191181 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 01:03:52 2009
New Revision: 191181
URL: http://svn.freebsd.org/changeset/base/191181

Log:
  Ensure that the option setters return OK (option used) even
  for options that don't change the list of keywords.

Modified:
  head/lib/libarchive/archive_write_set_format_mtree.c

Modified: head/lib/libarchive/archive_write_set_format_mtree.c
==
--- head/lib/libarchive/archive_write_set_format_mtree.cFri Apr 17 
01:02:56 2009(r191180)
+++ head/lib/libarchive/archive_write_set_format_mtree.cFri Apr 17 
01:03:52 2009(r191181)
@@ -962,8 +962,10 @@ archive_write_mtree_options(struct archi
case 'd':
if (strcmp(key, "device") == 0)
keybit = F_DEV;
-   else if (strcmp(key, "dironly") == 0)
+   else if (strcmp(key, "dironly") == 0) {
mtree->dironly = (value != NULL)? 1: 0;
+   return (ARCHIVE_OK);
+   }
break;
case 'f':
if (strcmp(key, "flags") == 0)
@@ -976,8 +978,10 @@ archive_write_mtree_options(struct archi
keybit = F_GNAME;
break;
case 'i':
-   if (strcmp(key, "indent") == 0)
+   if (strcmp(key, "indent") == 0) {
mtree->indent = (value != NULL)? 1: 0;
+   return (ARCHIVE_OK);
+   }
break;
case 'l':
if (strcmp(key, "link") == 0)
@@ -1039,8 +1043,10 @@ archive_write_mtree_options(struct archi
keybit = F_UID;
else if (strcmp(key, "uname") == 0)
keybit = F_UNAME;
-   else if (strcmp(key, "use-set") == 0)
+   else if (strcmp(key, "use-set") == 0) {
mtree->set.output = (value != NULL)? 1: 0;
+   return (ARCHIVE_OK);
+   }
break;
}
if (keybit != 0) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191183 - head/lib/libarchive/test

2009-04-16 Thread Tim Kientzle
  }
+   assertEqualIntA(a, ARCHIVE_OK, r);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
extract_reference_file(name);
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 
200));
 
/* Read entries, match up names with list above. */
for (i = 0; i < 6; ++i) {
-   r = archive_read_next_header(a, &ae);
-   if (UnsupportedCompress(r, a)) {
-   skipping("Skipping GZIP compression check: "
-   "This version of libarchive was compiled "
-   "without gzip support");
-   goto finish;
-   }
failure("Could not read file %d (%s) from %s", i, n[i], name);
-   assertEqualIntA(a, ARCHIVE_OK, r);
+   assertEqualIntA(a, ARCHIVE_OK,
+   archive_read_next_header(a, &ae));
if (r != ARCHIVE_OK) {
archive_read_finish(a);
return;
@@ -79,12 +79,7 @@ verify(const char *name)
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
 
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-finish:
-#if ARCHIVE_VERSION_NUMBER < 200
-   archive_read_finish(a);
-#else
assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#endif
 }
 
 

Added: head/lib/libarchive/test/test_compat_xz.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libarchive/test/test_compat_xz.c   Fri Apr 17 01:06:31 2009
(r191183)
@@ -0,0 +1,84 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2003-2008 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+/*
+ * Verify our ability to read sample files compatibly with unxz.
+ *
+ * In particular:
+ *  * unxz will read multiple xz streams, concatenating the output
+ */
+
+/*
+ * All of the sample files have the same contents; they're just
+ * compressed in different ways.
+ */
+static void
+compat_xz(const char *name)
+{
+   const char *n[7] = { "f1", "f2", "f3", "d1/f1", "d1/f2", "d1/f3", NULL 
};
+   struct archive_entry *ae;
+   struct archive *a;
+   int i, r;
+
+   assert((a = archive_read_new()) != NULL);
+   assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+   r = archive_read_support_compression_xz(a);
+   if (r == ARCHIVE_WARN) {
+   skipping("xz reading not fully supported on this platform");
+   assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+   return;
+   }
+   assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+   extract_reference_file(name);
+   assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));
+
+   /* Read entries, match up names with list above. */
+   for (i = 0; i < 6; ++i) {
+   failure("Could not read file %d (%s) from %s", i, n[i], name);
+   assertEqualIntA(a, ARCHIVE_OK,
+   archive_read_next_header(a, &ae));
+   assertEqualString(n[i], archive_entry_pathname(ae));
+   }
+
+   /* Verify the end-of-archive. */
+   assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+   /* Verify that the format detection worked. */
+   assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_XZ);
+   a

svn commit: r191184 - head/lib/libarchive

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 01:07:37 2009
New Revision: 191184
URL: http://svn.freebsd.org/changeset/base/191184

Log:
  Publicize a handful of new functions and bump the version number
  to indicate that this is synchronized with the recent libarchive 2.7.0
  release.

Modified:
  head/lib/libarchive/archive.h

Modified: head/lib/libarchive/archive.h
==
--- head/lib/libarchive/archive.h   Fri Apr 17 01:06:31 2009
(r191183)
+++ head/lib/libarchive/archive.h   Fri Apr 17 01:07:37 2009
(r191184)
@@ -118,13 +118,13 @@ extern "C" {
  * (ARCHIVE_API_VERSION * 100 + ARCHIVE_API_FEATURE * 1000)
  * #endif
  */
-#defineARCHIVE_VERSION_NUMBER 2006901
+#defineARCHIVE_VERSION_NUMBER 2007000
 __LA_DECL int  archive_version_number(void);
 
 /*
  * Textual name/version of the library, useful for version displays.
  */
-#defineARCHIVE_VERSION_STRING "libarchive 2.6.901a"
+#defineARCHIVE_VERSION_STRING "libarchive 2.7.0"
 __LA_DECL const char * archive_version_string(void);
 
 #if ARCHIVE_VERSION_NUMBER < 300
@@ -298,6 +298,7 @@ __LA_DECL intarchive_read_support_com
 __LA_DECL int   archive_read_support_compression_bzip2(struct archive 
*);
 __LA_DECL int   archive_read_support_compression_compress(struct 
archive *);
 __LA_DECL int   archive_read_support_compression_gzip(struct archive 
*);
+__LA_DECL int   archive_read_support_compression_lzma(struct archive 
*);
 __LA_DECL int   archive_read_support_compression_none(struct archive 
*);
 __LA_DECL int   archive_read_support_compression_program(struct 
archive *,
 const char *command);
@@ -305,6 +306,8 @@ __LA_DECL intarchive_read_support_com
(struct archive *, const char *,
const void * /* match */, size_t);
 
+__LA_DECL int   archive_read_support_compression_xz(struct archive *);
+
 __LA_DECL int   archive_read_support_format_all(struct archive *);
 __LA_DECL int   archive_read_support_format_ar(struct archive *);
 __LA_DECL int   archive_read_support_format_cpio(struct archive *);
@@ -352,6 +355,10 @@ __LA_DECL int   archive_read_open_FILE(s
 __LA_DECL int   archive_read_next_header(struct archive *,
 struct archive_entry **);
 
+/* Parses and returns next entry header using the archive_entry passed in */
+__LA_DECL int   archive_read_next_header2(struct archive *,
+struct archive_entry *);
+
 /*
  * Retrieve the byte offset in UNCOMPRESSED data where last-read
  * header started.
@@ -499,9 +506,11 @@ __LA_DECL int   archive_write_set_skip_f
 __LA_DECL int   archive_write_set_compression_bzip2(struct archive *);
 __LA_DECL int   archive_write_set_compression_compress(struct archive 
*);
 __LA_DECL int   archive_write_set_compression_gzip(struct archive *);
+__LA_DECL int   archive_write_set_compression_lzma(struct archive *);
 __LA_DECL int   archive_write_set_compression_none(struct archive *);
 __LA_DECL int   archive_write_set_compression_program(struct archive *,
 const char *cmd);
+__LA_DECL int   archive_write_set_compression_xz(struct archive *);
 /* A convenience function to set the format based on the code or name. */
 __LA_DECL int   archive_write_set_format(struct archive *, int 
format_code);
 __LA_DECL int   archive_write_set_format_by_name(struct archive *,
@@ -584,10 +593,12 @@ __LA_DECL int archive_write_set_options
 
 
 /*-
+ * ARCHIVE_WRITE_DISK API
+ *
  * To create objects on disk:
  *   1) Ask archive_write_disk_new for a new archive_write_disk object.
- *   2) Set any global properties.  In particular, you should set
- *  the compression and format to use.
+ *   2) Set any global properties.  In particular, you probably
+ *  want to set the options.
  *   3) For each entry:
  *  - construct an appropriate struct archive_entry structure
  *  - archive_write_header to create the file/dir/etc on disk
@@ -601,7 +612,8 @@ __LA_DECL struct archive*archive_write_
 /* This file will not be overwritten. */
 __LA_DECL int   archive_write_disk_set_skip_file(struct archive *,
 dev_t, ino_t);
-/* Set flags to control how the next item gets created. */
+/* Set flags to control how the next item gets created.
+ * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */
 __LA_DECL int   archive_write_disk_set_options(struct archive *,
 int flags);
 /*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-un

svn commit: r191187 - in head/usr.bin/tar: . test

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 03:36:07 2009
New Revision: 191187
URL: http://svn.freebsd.org/changeset/base/191187

Log:
  Merge from libarchive.googlecode.com: Numerous Windows-specific build tweaks.

Modified:
  head/usr.bin/tar/bsdtar_platform.h
  head/usr.bin/tar/test/main.c
  head/usr.bin/tar/test/test.h
  head/usr.bin/tar/test/test_0.c
  head/usr.bin/tar/test/test_basic.c
  head/usr.bin/tar/test/test_copy.c
  head/usr.bin/tar/test/test_patterns.c
  head/usr.bin/tar/test/test_strip_components.c
  head/usr.bin/tar/test/test_symlink_dir.c
  head/usr.bin/tar/tree.c

Modified: head/usr.bin/tar/bsdtar_platform.h
==
--- head/usr.bin/tar/bsdtar_platform.h  Fri Apr 17 02:52:23 2009
(r191186)
+++ head/usr.bin/tar/bsdtar_platform.h  Fri Apr 17 03:36:07 2009
(r191187)
@@ -164,7 +164,9 @@
 #define__LA_DEAD
 #endif
 
-#ifdef _WIN32
+#if defined(__CYGWIN__)
+#include "bsdtar_cygwin.h"
+#elif defined(_WIN32) /* && !__CYGWIN__ */
 #include "bsdtar_windows.h"
 #else
 #define bsdtar_is_privileged(bsdtar)   (bsdtar->user_uid == 0)

Modified: head/usr.bin/tar/test/main.c
==
--- head/usr.bin/tar/test/main.cFri Apr 17 02:52:23 2009
(r191186)
+++ head/usr.bin/tar/test/main.cFri Apr 17 03:36:07 2009
(r191187)
@@ -56,11 +56,7 @@ __FBSDID("$FreeBSD$");
  */
 #undef DEFINE_TEST
 #defineDEFINE_TEST(name) void name(void);
-#ifdef LIST_H
-#include LIST_H
-#else
 #include "list.h"
-#endif
 
 /* Interix doesn't define these in a standard header. */
 #if __INTERIX__
@@ -754,11 +750,7 @@ slurpfile(size_t * sizep, const char *fm
 #undef DEFINE_TEST
 #defineDEFINE_TEST(n) { n, #n },
 struct { void (*func)(void); const char *name; } tests[] = {
-#ifdef LIST_H
-   #include LIST_H
-#else
#include "list.h"
-#endif
 };
 
 /*
@@ -809,7 +801,7 @@ static int test_run(int i, const char *t
/* If there were no failures, we can remove the work dir. */
if (failures == failures_before) {
if (!keep_temp_files && chdir(tmpdir) == 0) {
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
systemf("rmdir /S /Q %s", tests[i].name);
 #else
systemf("rm -rf %s", tests[i].name);
@@ -912,7 +904,7 @@ int main(int argc, char **argv)
int i, tests_run = 0, tests_failed = 0, opt;
time_t now;
char *refdir_alloc = NULL;
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
char *testprg;
 #endif
const char *opt_arg, *progname, *p;
@@ -921,8 +913,10 @@ int main(int argc, char **argv)
 
(void)argc; /* UNUSED */
 
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
/* Make sure open() function will be used with a binary mode. */
+   /* on cygwin, we need something similar, but instead link against */
+   /* a special startup object, binmode.o */
_set_fmode(_O_BINARY);
 #endif
/*
@@ -1014,7 +1008,7 @@ int main(int argc, char **argv)
if (testprog == NULL)
usage(progname);
 #endif
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
/*
 * command.com cannot accept the command used '/' with drive
 * name such as c:/xxx/command.exe when use '|' pipe handling.

Modified: head/usr.bin/tar/test/test.h
==
--- head/usr.bin/tar/test/test.hFri Apr 17 02:52:23 2009
(r191186)
+++ head/usr.bin/tar/test/test.hFri Apr 17 03:36:07 2009
(r191187)
@@ -37,7 +37,7 @@
 #elif defined(__FreeBSD__)
 /* Building as part of FreeBSD system requires a pre-built config.h. */
 #include "config_freebsd.h"
-#elif defined(_WIN32)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
 /* Win32 can't run the 'configure' script. */
 #include "config_windows.h"
 #else
@@ -45,7 +45,7 @@
 #error Oops: No config.h and no pre-built configuration in test.h.
 #endif
 
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
 #include 
 #else
 #define dirent direct
@@ -58,7 +58,7 @@
 #include 
 #include 
 #include 
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
 #include 
 #endif
 #include 
@@ -67,12 +67,16 @@
 #include 
 #endif
 
-/* No non-FreeBSD platform will have __FBSDID, so just define it here. */
 #ifdef __FreeBSD__
 #include   /* For __FBSDID */
 #else
+/* Some non-FreeBSD platforms such as newlib-derived ones like
+ * cygwin, have __FBSDID, so this definition must be guarded.
+ */
+#ifndef __FBSDID
 #define__FBSDID(a) /* null */
 #endif
+#endif
 
 /*
  * Redefine DEFINE_TEST for use in defining the test functions.

Modified: head/usr.bin/tar/test/test_0.c
==
--- head/usr.bin/tar/test/test_0.c  Fri Apr 17 02:52:23 2009
(r1911

svn commit: r191188 - head/usr.bin/tar

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 03:37:09 2009
New Revision: 191188
URL: http://svn.freebsd.org/changeset/base/191188

Log:
  Minor portability improvement in calls to ctype.h macros.

Modified:
  head/usr.bin/tar/util.c

Modified: head/usr.bin/tar/util.c
==
--- head/usr.bin/tar/util.c Fri Apr 17 03:36:07 2009(r191187)
+++ head/usr.bin/tar/util.c Fri Apr 17 03:37:09 2009(r191188)
@@ -178,7 +178,7 @@ bsdtar_expand_char(char *buff, size_t of
 {
size_t i = offset;
 
-   if (isprint(c) && c != '\\')
+   if (isprint((unsigned char)c) && c != '\\')
buff[i++] = c;
else {
buff[i++] = '\\';
@@ -254,7 +254,7 @@ yes(const char *fmt, ...)
buff[l] = 0;
 
for (p = buff; *p != '\0'; p++) {
-   if (isspace(0xff & (int)*p))
+   if (isspace((unsigned char)*p))
continue;
switch(*p) {
case 'y': case 'Y':
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191189 - head/usr.bin/tar

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 03:40:40 2009
New Revision: 191189
URL: http://svn.freebsd.org/changeset/base/191189

Log:
  Set options before opening the archive.
  Catch and report close-time errors.

Modified:
  head/usr.bin/tar/read.c

Modified: head/usr.bin/tar/read.c
==
--- head/usr.bin/tar/read.c Fri Apr 17 03:37:09 2009(r191188)
+++ head/usr.bin/tar/read.c Fri Apr 17 03:40:40 2009(r191189)
@@ -127,17 +127,13 @@ read_archive(struct bsdtar *bsdtar, char
else
archive_read_support_compression_all(a);
archive_read_support_format_all(a);
+   if (ARCHIVE_OK != archive_read_set_options(a, bsdtar->option_options))
+   bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
if (archive_read_open_file(a, bsdtar->filename,
bsdtar->bytes_per_block != 0 ? bsdtar->bytes_per_block :
DEFAULT_BYTES_PER_BLOCK))
bsdtar_errc(bsdtar, 1, 0, "Error opening archive: %s",
archive_error_string(a));
-   if (bsdtar->option_format_options != NULL) {
-   r = archive_read_set_options(a, bsdtar->option_format_options);
-   if (r != ARCHIVE_OK)
-   bsdtar_errc(bsdtar, 1, 0, "Error archive options: %s",
-   archive_error_string(a));
-   }
 
do_chdir(bsdtar);
 
@@ -298,6 +294,13 @@ read_archive(struct bsdtar *bsdtar, char
}
}
 
+
+   r = archive_read_close(a);
+   if (r != ARCHIVE_OK)
+   bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(a));
+   if (r <= ARCHIVE_WARN)
+   bsdtar->return_value = 1;
+
if (bsdtar->verbose > 2)
fprintf(stdout, "Archive Format: %s,  Compression: %s\n",
archive_format_name(a), archive_compression_name(a));
@@ -390,7 +393,7 @@ list_item_verbose(struct bsdtar *bsdtar,
 
/* Format the time using 'ls -l' conventions. */
tim = (time_t)st->st_mtime;
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
/* Windows' strftime function does not support %e format. */
if (abs(tim - now) > (365/2)*86400)
fmt = bsdtar->day_first ? "%d %b  %Y" : "%b %d  %Y";
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191190 - head/usr.bin/tar

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 03:45:15 2009
New Revision: 191190
URL: http://svn.freebsd.org/changeset/base/191190

Log:
  Merge remaining changes from libarchive.googlecode.com:
   * Add xz and lzma compression options
   * Rename --format-options to simply --options
   * Add --same-owner for GNU tar compat
   * Add -lmd and -lcrypto to fix link
   * Documentation

Modified:
  head/usr.bin/tar/Makefile
  head/usr.bin/tar/bsdtar.1
  head/usr.bin/tar/bsdtar.c
  head/usr.bin/tar/bsdtar.h
  head/usr.bin/tar/cmdline.c
  head/usr.bin/tar/write.c

Modified: head/usr.bin/tar/Makefile
==
--- head/usr.bin/tar/Makefile   Fri Apr 17 03:40:40 2009(r191189)
+++ head/usr.bin/tar/Makefile   Fri Apr 17 03:45:15 2009(r191190)
@@ -1,11 +1,11 @@
 # $FreeBSD$
 
 PROG=  bsdtar
-BSDTAR_VERSION_STRING=2.6.901a
+BSDTAR_VERSION_STRING=2.7.0
 SRCS=  bsdtar.c cmdline.c getdate.c matching.c read.c siginfo.c subst.c tree.c 
util.c write.c
 WARNS?=5
 DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ}
-LDADD= -larchive -lbz2 -lz
+LDADD= -larchive -lbz2 -lz -lmd -lcrypto
 CFLAGS+=   -DBSDTAR_VERSION_STRING=\"${BSDTAR_VERSION_STRING}\"
 CFLAGS+=   -DPLATFORM_CONFIG_H=\"config_freebsd.h\"
 CFLAGS+=   -I${.CURDIR}

Modified: head/usr.bin/tar/bsdtar.1
==
--- head/usr.bin/tar/bsdtar.1   Fri Apr 17 03:40:40 2009(r191189)
+++ head/usr.bin/tar/bsdtar.1   Fri Apr 17 03:45:15 2009(r191190)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 15, 2008
+.Dd March 25, 2009
 .Dt BSDTAR 1
 .Os
 .Sh NAME
@@ -37,12 +37,12 @@
 .Nm
 .Brq Fl c
 .Op Ar options
-.Op Ar files | directories
+.Op Ar files | Ar directories
 .Nm
 .Brq Fl r | Fl u
 .Fl f Ar archive-file
 .Op Ar options
-.Op Ar files | directories
+.Op Ar files | Ar directories
 .Nm
 .Brq Fl t | Fl x
 .Op Ar options
@@ -305,6 +305,64 @@ A synonym for
 .It Fl -one-file-system
 (c, r, and u modes)
 Do not cross mount points.
+.It Fl -options Ar options
+Select optional behaviors for particular modules.
+The argument is a text string containing comma-separated
+keywords and values.
+These are passed to the modules that handle particular
+formats to control how those formats will behave.
+Each option has one of the following forms:
+.Bl -tag -compact -width indent
+.It Ar key=value
+The key will be set to the specified value in every module that supports it.
+Modules that do not support this key will ignore it.
+.It Ar key
+The key will be enabled in every module that supports it.
+This is equivalent to
+.Ar key Ns Cm =1 .
+.It Ar !key
+The key will be disabled in every module that supports it.
+.It Ar module:key=value , Ar module:key , Ar module:!key
+As above, but the corresponding key and value will be provided
+only to modules whose name matches
+.Ar module .
+.El
+The currently supported modules and keys are:
+.Bl -tag -compact -width indent
+.It Cm iso9660:joliet
+Support Joliet extensions.
+This is enabled by default, use
+.Cm !joliet
+or
+.Cm iso9660:!joliet
+to disable.
+.It Cm gzip:compression-level
+A decimal integer from 0 to 9 specifying the gzip compression level.
+.It Cm xz:compression-level
+A decimal integer from 0 to 9 specifying the xz compression level.
+.It Cm mtree: Ns Ar keyword
+The mtree writer module allows you to specify which mtree keywords
+will be included in the output.
+Supported keywords include:
+.Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent ,
+.Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 ,
+.Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname .
+The default is equivalent to:
+.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname 
.
+.It Cm mtree:all
+Enables all of the above keywords.
+You can also use
+.Cm mtree:!all
+to disable all keywords.
+.It Cm mtree:use-set
+Enable generation of
+.Cm /set
+lines in the output.
+.It Cm mtree:indent
+XXX need explanation XXX
+.El
+If a provided option is not supported by any module, that
+is a fatal error.
 .It Fl P
 Preserve pathnames.
 By default, absolute pathnames (those that begin with a /
@@ -555,6 +613,27 @@ switches accept a variety of common date
 .Dq 5 minutes ago ,
 and
 .Dq 19:14 PST May 1 .
+.Pp
+The
+.Fl -options
+argument can be used to control various details of archive generation
+or reading.
+For example, you can generate mtree output which only contains
+.Cm type , Cm time ,
+and
+.Cm uid
+keywords:
+.Dl Nm Fl cf Pa file.tar Fl -format=mtree Fl -options='!all,type,time,uid' Pa 
dir
+or you can set the compression level used by gzip or xz compression:
+.Dl Nm Fl czf Pa file.tar Fl -options='compression-level=9' .
+For more details, see the explanation of the
+.Fn archive_read_set_options
+and
+.Fn archive_write_set_options
+API calls that are described in
+.Xr archive_read 3
+and
+.Xr archive_write 3 .
 .Sh COMPATIBILITY
 The bundled-argume

svn commit: r191192 - in head/usr.bin/cpio: . test

2009-04-16 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 04:04:57 2009
New Revision: 191192
URL: http://svn.freebsd.org/changeset/base/191192

Log:
  Merge from libarchive.googlecode.com:
   * Lots of new tests.
   * New -n / --numeric-uid-gid option
   * More sanity-checking of arguments
   * Various Windows portability improvements
   * Sync up version number to 2.7.0

Modified:
  head/usr.bin/cpio/Makefile
  head/usr.bin/cpio/bsdcpio.1
  head/usr.bin/cpio/cmdline.c
  head/usr.bin/cpio/cpio.c
  head/usr.bin/cpio/cpio.h
  head/usr.bin/cpio/cpio_platform.h
  head/usr.bin/cpio/pathmatch.c
  head/usr.bin/cpio/pathmatch.h
  head/usr.bin/cpio/test/main.c
  head/usr.bin/cpio/test/test.h
  head/usr.bin/cpio/test/test_0.c
  head/usr.bin/cpio/test/test_basic.c
  head/usr.bin/cpio/test/test_format_newc.c
  head/usr.bin/cpio/test/test_gcpio_compat.c
  head/usr.bin/cpio/test/test_option_a.c
  head/usr.bin/cpio/test/test_option_c.c
  head/usr.bin/cpio/test/test_option_d.c
  head/usr.bin/cpio/test/test_option_f.c
  head/usr.bin/cpio/test/test_option_m.c
  head/usr.bin/cpio/test/test_option_t.c
  head/usr.bin/cpio/test/test_option_u.c
  head/usr.bin/cpio/test/test_option_version.c
  head/usr.bin/cpio/test/test_option_y.c
  head/usr.bin/cpio/test/test_option_z.c
  head/usr.bin/cpio/test/test_owner_parse.c
  head/usr.bin/cpio/test/test_passthrough_dotdot.c
  head/usr.bin/cpio/test/test_passthrough_reverse.c
  head/usr.bin/cpio/test/test_pathmatch.c

Modified: head/usr.bin/cpio/Makefile
==
--- head/usr.bin/cpio/Makefile  Fri Apr 17 03:49:26 2009(r191191)
+++ head/usr.bin/cpio/Makefile  Fri Apr 17 04:04:57 2009(r191192)
@@ -3,13 +3,13 @@
 .include 
 
 PROG=  bsdcpio
-BSDCPIO_VERSION_STRING=1.1.0
+BSDCPIO_VERSION_STRING=2.7.0
 SRCS=  cpio.c cmdline.c err.c matching.c pathmatch.c
 WARNS?=6
 DPADD= ${LIBARCHIVE} ${LIBZ} ${LIBBZ2}
 CFLAGS+= -DBSDCPIO_VERSION_STRING=\"${BSDCPIO_VERSION_STRING}\"
 CFLAGS+= -DPLATFORM_CONFIG_H=\"config_freebsd.h\"
-LDADD+=-larchive -lz -lbz2
+LDADD+=-larchive -lz -lbz2 -lmd -lcrypto
 
 .if ${MK_GNU_CPIO} != "yes"
 SYMLINKS=bsdcpio ${BINDIR}/cpio

Modified: head/usr.bin/cpio/bsdcpio.1
==
--- head/usr.bin/cpio/bsdcpio.1 Fri Apr 17 03:49:26 2009(r191191)
+++ head/usr.bin/cpio/bsdcpio.1 Fri Apr 17 04:04:57 2009(r191192)
@@ -167,6 +167,15 @@ instead of copying.
 (i and p modes)
 Set file modification time on created files to match
 those in the source.
+.It Fl n
+(i mode, only with
+.Fl t )
+Display numeric uid and gid.
+By default,
+.Nm
+displays the user and group names when they are provided in the
+archive, or looks up the user and group names in the system
+password database.
 .It Fl O Ar file
 Write archive to
 .Ar file .

Modified: head/usr.bin/cpio/cmdline.c
==
--- head/usr.bin/cpio/cmdline.c Fri Apr 17 03:49:26 2009(r191191)
+++ head/usr.bin/cpio/cmdline.c Fri Apr 17 04:04:57 2009(r191192)
@@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
 /*
  * Short options for cpio.  Please keep this sorted.
  */
-static const char *short_options = "0AaBC:F:O:cdE:f:H:hijLlmopR:rtuvW:yZz";
+static const char *short_options = "0AaBC:F:O:cdE:f:H:hijLlmnopR:rtuvW:yZz";
 
 /*
  * Long options for cpio.  Please keep this sorted.
@@ -71,6 +71,7 @@ static const struct option {
{ "make-directories",   0, 'd' },
{ "no-preserve-owner",  0, OPTION_NO_PRESERVE_OWNER },
{ "null",   0, '0' },
+   { "numeric-uid-gid",0, 'n' },
{ "owner",  1, 'R' },
{ "pass-through",   0, 'p' },
{ "preserve-modification-time", 0, 'm' },

Modified: head/usr.bin/cpio/cpio.c
==
--- head/usr.bin/cpio/cpio.cFri Apr 17 03:49:26 2009(r191191)
+++ head/usr.bin/cpio/cpio.cFri Apr 17 04:04:57 2009(r191192)
@@ -32,9 +32,15 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#ifdef HAVE_SYS_MKDEV_H
+#include 
+#endif
 #ifdef HAVE_SYS_STAT_H
 #include 
 #endif
+#ifdef HAVE_SYS_TIME_H
+#include 
+#endif
 #ifdef HAVE_ERRNO_H
 #include 
 #endif
@@ -60,6 +66,12 @@ __FBSDID("$FreeBSD$");
 #ifdef HAVE_UNISTD_H
 #include 
 #endif
+#ifdef HAVE_SYS_TIME_H
+#include 
+#endif
+#ifdef HAVE_TIME_H
+#include 
+#endif
 
 #include "cpio.h"
 #include "matching.h"
@@ -94,7 +106,7 @@ static void  mode_in(struct cpio *);
 static voidmode_list(struct cpio *);
 static voidmode_out(struct cpio *);
 static voidmode_pass(struct cpio *, const char *);
-static voidrestore_time(struct cpio *, struct archive_entry *,
+static int restore_time(struct cpio *, struct archive_entry *,
const char *, int fd);
 static voidusage(void);
 static voidversi

svn commit: r191196 - head/lib/libarchive

2009-04-17 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 07:28:49 2009
New Revision: 191196
URL: http://svn.freebsd.org/changeset/base/191196

Log:
  Disabling the crypto bits should quiet tinderbox while I
  track down the library dependencies that are screwing up the /rescue build.

Modified:
  head/lib/libarchive/config_freebsd.h

Modified: head/lib/libarchive/config_freebsd.h
==
--- head/lib/libarchive/config_freebsd.hFri Apr 17 05:37:31 2009
(r191195)
+++ head/lib/libarchive/config_freebsd.hFri Apr 17 07:28:49 2009
(r191196)
@@ -75,30 +75,38 @@
 #defineHAVE_LIMITS_H 1
 #defineHAVE_LUTIMES 1
 #defineHAVE_MALLOC 1
+#if 0
 #defineHAVE_MD5 1
 #defineHAVE_MD5_H 1
+#endif
 #defineHAVE_MEMMOVE 1
 #defineHAVE_MEMSET 1
 #defineHAVE_MKDIR 1
 #defineHAVE_MKFIFO 1
 #defineHAVE_MKNOD 1
+#if 0
 #defineHAVE_OPENSSL_MD5_H 1
 #defineHAVE_OPENSSL_RIPEMD_H 1
 #defineHAVE_OPENSSL_SHA_H 1
+#endif
 #defineHAVE_PIPE 1
 #defineHAVE_POLL 1
 #defineHAVE_POLL_H 1
 #defineHAVE_PWD_H 1
 #defineHAVE_READLINK 1
+#if 0
 #defineHAVE_RMD160 1
+#endif
 #defineHAVE_SELECT 1
 #defineHAVE_SETENV 1
+#if 0
 #defineHAVE_SHA_H 1
 #defineHAVE_SHA1 1
 #defineHAVE_SHA256 1
 #defineHAVE_SHA256_H 1
 #defineHAVE_SHA384 1
 #defineHAVE_SHA512 1
+#endif
 #defineHAVE_SIGNAL_H 1
 #defineHAVE_STDINT_H 1
 #defineHAVE_STDLIB_H 1
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191227 - head/rescue/rescue

2009-04-17 Thread Tim Kientzle
Author: kientzle
Date: Fri Apr 17 22:20:44 2009
New Revision: 191227
URL: http://svn.freebsd.org/changeset/base/191227

Log:
  *** empty log message ***

Modified:
  head/rescue/rescue/Makefile

Modified: head/rescue/rescue/Makefile
==
--- head/rescue/rescue/Makefile Fri Apr 17 22:13:41 2009(r191226)
+++ head/rescue/rescue/Makefile Fri Apr 17 22:20:44 2009(r191227)
@@ -118,7 +118,7 @@ CRUNCH_PROGS_sbin= atacontrol badsect   
mount_udf mount_unionfs newfs   \
newfs_msdos nos-tun ping reboot \
restore rcorder route routed rtquery rtsol savecore \
-   spppcontrol swapon sysctl tunefs umount 
+   spppcontrol swapon sysctl tunefs umount
 
 .if ${MK_ATM} != "no"
 CRUNCH_PROGS_sbin+= atmconfig
@@ -188,7 +188,7 @@ CRUNCH_BUILDOPTS_dhclient= -DRELEASE_CRU
 
 ##
 # Programs from stock /usr/bin
-# 
+#
 CRUNCH_SRCDIRS+= usr.bin
 
 CRUNCH_PROGS_usr.bin= head mt sed tail tee
@@ -211,7 +211,7 @@ CRUNCH_ALIAS_id= groups whoami
 
 ##
 # Programs from stock /usr/sbin
-# 
+#
 CRUNCH_SRCDIRS+= usr.sbin
 
 CRUNCH_PROGS_usr.sbin= chroot
@@ -303,7 +303,7 @@ objs: $(OUTMK)
 #  Someone should replace the bin/csh and bin/sh build-tools with
 # shell scripts so we can remove this nonsense.
 build-tools:
-.for _tool in bin/csh bin/sh 
+.for _tool in bin/csh bin/sh
cd $(.CURDIR)/../../${_tool}; \
MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \
MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r191227 - head/rescue/rescue

2009-04-17 Thread Tim Kientzle

Tim Kientzle wrote:

Author: kientzle
Date: Fri Apr 17 22:20:44 2009
New Revision: 191227
URL: http://svn.freebsd.org/changeset/base/191227

Log:
  *** empty log message ***


Fat-fingered that one.  Of course, that should read:

Log:
   Style fix; strip a few trailing spaces.

Pointy hat to me for the botched commit.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191235 - head/lib/libarchive

2009-04-18 Thread Tim Kientzle
Author: kientzle
Date: Sat Apr 18 03:47:29 2009
New Revision: 191235
URL: http://svn.freebsd.org/changeset/base/191235

Log:
  Correct and update the manpage to include
  more details about some of the formats and
  to briefly describe the mtree writing capability.

Modified:
  head/lib/libarchive/libarchive-formats.5

Modified: head/lib/libarchive/libarchive-formats.5
==
--- head/lib/libarchive/libarchive-formats.5Sat Apr 18 03:10:28 2009
(r191234)
+++ head/lib/libarchive/libarchive-formats.5Sat Apr 18 03:47:29 2009
(r191235)
@@ -24,8 +24,8 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 27, 2004
-.Dt libarchive-formats 3
+.Dd April 17, 2009
+.Dt libarchive-formats 5
 .Os
 .Sh NAME
 .Nm libarchive-formats
@@ -93,8 +93,9 @@ to define custom keys by preceding them 
 When writing pax archives, libarchive uses many of the SCHILY keys
 defined by Joerg Schilling's
 .Dq star
-archiver.
-The libarchive library can read most of the SCHILY keys.
+archiver and a few LIBARCHIVE keys.
+The libarchive library can read most of the SCHILY keys
+and most of the GNU keys introduced by GNU tar.
 It silently ignores any keywords that it does not understand.
 .It Cm restricted pax
 The libarchive library can also write pax archives in which it
@@ -156,7 +157,8 @@ and
 format archives.
 A cpio archive stores each entry as a fixed-size header followed
 by a variable-length filename and variable-length data.
-Unlike tar, cpio does only minimal padding of the header or file data.
+Unlike the tar format, the cpio format does only minimal padding
+of the header or file data.
 There are a variety of cpio formats, which differ primarily in
 how they store the initial header: some store the values as
 octal or hexadecimal numbers in ASCII, others as binary values of
@@ -169,7 +171,12 @@ This format used 32-bit binary values fo
 and 16-bit binary values for the other fields.
 .It Cm odc
 The libarchive library can both read and write this
-POSIX-standard format.
+POSIX-standard format, which is officially known as the
+.Dq cpio interchange format
+or the
+.Dq octet-oriented cpio archive format
+and sometimes unofficially referred to as the
+.Dq old character format .
 This format stores the header contents as octal values in ASCII.
 It is standard, portable, and immune from byte-order confusion.
 File sizes and mtime are limited to 33 bits (8GB file size),
@@ -237,16 +244,24 @@ shardump archives less portable than pla
 Libarchive can read and extract from files containing ISO9660-compliant
 CDROM images.
 It also has partial support for Rockridge extensions.
-In many cases, this can remove the need to burn a physical CDROM.
+In many cases, this can remove the need to burn a physical CDROM
+just in order to read the files contained in an ISO9660 image.
 It also avoids security and complexity issues that come with
 virtual mounts and loopback devices.
 .Ss Zip format
-Libarchive can extract from most zip format archives.
+Libarchive can extract from most zip format archives, including
+jar archives, archives that use Zip64 extensions and many
+self-extracting zip archives.
 It currently only supports uncompressed entries and entries
 compressed with the
 .Dq deflate
 algorithm.
 Older zip compression algorithms are not supported.
+Libarchive reads Zip archives as they are being streamed,
+which allows it to read archives of arbitrary size.
+It currently does not use the central directory; this
+limits libarchive's ability to support some self-extracting
+archives and ones that have been modified in certain ways.
 .Ss Archive (library) file format
 The Unix archive format (commonly created by the
 .Xr ar 1
@@ -260,13 +275,32 @@ the GNU format derived from SVR4,
 and the BSD format, which first appeared in 4.4BSD.
 Libarchive provides read and write support for both variants.
 .Ss mtree
-Libarchive can read files in
+Libarchive can read and write files in
 .Xr mtree 5
-format. This format is not a true archive format, but rather a description
-of a file hierarchy. When requested, libarchive obtains the contents of
-the files described by the
+format.
+This format is not a true archive format, but rather a textual description
+of a file hierarchy in which each line specifies the name of a file and
+provides specific metadata about that file.
+Libarchive can read all of the keywords supported by both
+the NetBSD and FreeBSD versions of
+.Xr mtree 1 ,
+although many of the keywords cannot currently be stored in an
+.Tn archive_entry
+object.
+When reading, libarchive supports an extension that allows it
+to obtain the contents of the files described by the
 .Xr mtree 5
-format from files on disk instead.
+description from files on disk.
+When writing, libarchive supports use of the
+.Xr archive_write_set_options 3
+interface to specify which keywords should be included in the
+output.
+This includes the ability to compute hash entries such
+as
+.Cm sha

svn commit: r191239 - head/rescue/rescue

2009-04-18 Thread Tim Kientzle
Author: kientzle
Date: Sat Apr 18 06:01:55 2009
New Revision: 191239
URL: http://svn.freebsd.org/changeset/base/191239

Log:
  Libarchive is sprouting dependencies on libmd and libcrypto.
  Because crunchgen drops any repeated library (keeping only the
  first), the -lcrypto reference must be moved to after -larchive,
  not merely duplicated.
  
  I'm considering changing crunchgen's handling of duplicate
  libraries, but that's a rather more delicate issue.

Modified:
  head/rescue/rescue/Makefile

Modified: head/rescue/rescue/Makefile
==
--- head/rescue/rescue/Makefile Sat Apr 18 04:45:02 2009(r191238)
+++ head/rescue/rescue/Makefile Sat Apr 18 06:01:55 2009(r191239)
@@ -73,9 +73,6 @@ CRUNCH_PROGS_bin= cat chflags chio chmod
 ed expr getfacl hostname kenv kill ln ls mkdir mv  \
 pkill ps pwd realpath rm rmdir setfacl sh stty sync test
 CRUNCH_LIBS+= -lcrypt -ledit -lkvm -ll -lm -ltermcap -lutil
-.if ${MK_OPENSSL} != "no"
-CRUNCH_LIBS+= -lcrypto
-.endif
 
 # Additional options for specific programs
 CRUNCH_ALIAS_test= [
@@ -201,7 +198,10 @@ CRUNCH_ALIAS_bzip2= bunzip2 bzcat
 CRUNCH_LIBS+= -lbz2
 
 CRUNCH_PROGS_usr.bin+= tar
-CRUNCH_LIBS+= -larchive
+CRUNCH_LIBS+= -larchive -lmd
+.if ${MK_OPENSSL} != "no"
+CRUNCH_LIBS+= -lcrypto
+.endif
 
 CRUNCH_PROGS_usr.bin+= vi
 CRUNCH_ALIAS_vi= ex
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191240 - in head/usr.bin: cpio tar

2009-04-18 Thread Tim Kientzle
Author: kientzle
Date: Sat Apr 18 06:03:09 2009
New Revision: 191240
URL: http://svn.freebsd.org/changeset/base/191240

Log:
  Make -lcrypto usage dependent on whether or not we're building with OpenSSL.

Modified:
  head/usr.bin/cpio/Makefile
  head/usr.bin/tar/Makefile

Modified: head/usr.bin/cpio/Makefile
==
--- head/usr.bin/cpio/Makefile  Sat Apr 18 06:01:55 2009(r191239)
+++ head/usr.bin/cpio/Makefile  Sat Apr 18 06:03:09 2009(r191240)
@@ -9,7 +9,10 @@ WARNS?=6
 DPADD= ${LIBARCHIVE} ${LIBZ} ${LIBBZ2}
 CFLAGS+= -DBSDCPIO_VERSION_STRING=\"${BSDCPIO_VERSION_STRING}\"
 CFLAGS+= -DPLATFORM_CONFIG_H=\"config_freebsd.h\"
-LDADD+=-larchive -lz -lbz2 -lmd -lcrypto
+LDADD+=-larchive -lz -lbz2 -lmd
+.if ${MK_OPENSSL} != "no"
+LDADD+= -lcrypto
+.endif
 
 .if ${MK_GNU_CPIO} != "yes"
 SYMLINKS=bsdcpio ${BINDIR}/cpio

Modified: head/usr.bin/tar/Makefile
==
--- head/usr.bin/tar/Makefile   Sat Apr 18 06:01:55 2009(r191239)
+++ head/usr.bin/tar/Makefile   Sat Apr 18 06:03:09 2009(r191240)
@@ -1,11 +1,15 @@
 # $FreeBSD$
+.include 
 
 PROG=  bsdtar
 BSDTAR_VERSION_STRING=2.7.0
 SRCS=  bsdtar.c cmdline.c getdate.c matching.c read.c siginfo.c subst.c tree.c 
util.c write.c
 WARNS?=5
 DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ}
-LDADD= -larchive -lbz2 -lz -lmd -lcrypto
+LDADD= -larchive -lbz2 -lz -lmd
+.if ${MK_OPENSSL} != "no"
+LDADD+= -lcrypto
+.endif
 CFLAGS+=   -DBSDTAR_VERSION_STRING=\"${BSDTAR_VERSION_STRING}\"
 CFLAGS+=   -DPLATFORM_CONFIG_H=\"config_freebsd.h\"
 CFLAGS+=   -I${.CURDIR}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191241 - head/lib/libarchive

2009-04-18 Thread Tim Kientzle
Author: kientzle
Date: Sat Apr 18 06:06:47 2009
New Revision: 191241
URL: http://svn.freebsd.org/changeset/base/191241

Log:
  Rely on OpenSSL bits only if we're building a system with OpenSSL.
  Also, adjust the MD5 calls to rely on libmd instead of libcrypto,
  so we keep MD5 support even in the !OpenSSL case.

Modified:
  head/lib/libarchive/Makefile
  head/lib/libarchive/archive_write_set_format_mtree.c
  head/lib/libarchive/config_freebsd.h

Modified: head/lib/libarchive/Makefile
==
--- head/lib/libarchive/MakefileSat Apr 18 06:03:09 2009
(r191240)
+++ head/lib/libarchive/MakefileSat Apr 18 06:06:47 2009
(r191241)
@@ -1,4 +1,5 @@
 # $FreeBSD$
+.include 
 
 LIB=   archive
 DPADD= ${LIBBZ2} ${LIBZ}
@@ -11,6 +12,11 @@ SHLIB_MAJOR= 4
 CFLAGS+=   -DPLATFORM_CONFIG_H=\"config_freebsd.h\"
 CFLAGS+=   -I${.OBJDIR}
 
+.if ${MK_OPENSSL} != "no"
+CFLAGS+=   -DWITH_OPENSSL
+.endif
+
+
 WARNS?=6
 
 # Headers to be installed in /usr/include

Modified: head/lib/libarchive/archive_write_set_format_mtree.c
==
--- head/lib/libarchive/archive_write_set_format_mtree.cSat Apr 18 
06:03:09 2009(r191240)
+++ head/lib/libarchive/archive_write_set_format_mtree.cSat Apr 18 
06:06:47 2009(r191241)
@@ -33,13 +33,13 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#ifdef HAVE_OPENSSL_MD5_H
-#include 
-#else /* HAVE_OPENSSL_MD5_H */
 #ifdef HAVE_MD5_H
 #include 
-#endif
+#else
+#ifdef HAVE_OPENSSL_MD5_H
+#include 
 #endif /* HAVE_OPENSSL_MD5_H */
+#endif /* HAVE_MD5_H */
 #ifdef HAVE_OPENSSL_RIPEMD_H
 #include 
 #else /* HAVE_OPENSSL_RIPEMD_H */
@@ -618,7 +618,7 @@ archive_write_mtree_header(struct archiv
if ((mtree->keys & F_MD5) != 0 &&
archive_entry_filetype(entry) == AE_IFREG) {
mtree->compute_sum |= F_MD5;
-   MD5_Init(&mtree->md5ctx);
+   MD5Init(&mtree->md5ctx);
} else
mtree->compute_sum &= ~F_MD5;
 #endif
@@ -803,7 +803,7 @@ archive_write_mtree_finish_entry(struct 
if (mtree->compute_sum & F_MD5) {
unsigned char buf[16];
 
-   MD5_Final(buf, &mtree->md5ctx);
+   MD5Final(buf, &mtree->md5ctx);
archive_strcat(str, " md5digest=");
strappend_bin(str, buf, sizeof(buf));
}
@@ -901,7 +901,7 @@ archive_write_mtree_data(struct archive_
}
 #ifdef HAVE_MD5
if (mtree->compute_sum & F_MD5)
-   MD5_Update(&mtree->md5ctx, buff, n);
+   MD5Update(&mtree->md5ctx, buff, n);
 #endif
 #ifdef HAVE_RMD160
if (mtree->compute_sum & F_RMD160)

Modified: head/lib/libarchive/config_freebsd.h
==
--- head/lib/libarchive/config_freebsd.hSat Apr 18 06:03:09 2009
(r191240)
+++ head/lib/libarchive/config_freebsd.hSat Apr 18 06:06:47 2009
(r191241)
@@ -42,6 +42,14 @@
 #defineHAVE_SYS_EXTATTR_H 1
 #endif
 
+#ifdef WITH_OPENSSL
+#defineHAVE_OPENSSL_MD5_H 1
+#defineHAVE_OPENSSL_RIPEMD_H 1
+#defineHAVE_OPENSSL_SHA_H 1
+#defineHAVE_SHA384 1
+#defineHAVE_SHA512 1
+#endif
+
 #defineHAVE_BZLIB_H 1
 #defineHAVE_CHFLAGS 1
 #defineHAVE_CHOWN 1
@@ -75,38 +83,26 @@
 #defineHAVE_LIMITS_H 1
 #defineHAVE_LUTIMES 1
 #defineHAVE_MALLOC 1
-#if 0
 #defineHAVE_MD5 1
 #defineHAVE_MD5_H 1
-#endif
 #defineHAVE_MEMMOVE 1
 #defineHAVE_MEMSET 1
 #defineHAVE_MKDIR 1
 #defineHAVE_MKFIFO 1
 #defineHAVE_MKNOD 1
-#if 0
-#defineHAVE_OPENSSL_MD5_H 1
-#defineHAVE_OPENSSL_RIPEMD_H 1
-#defineHAVE_OPENSSL_SHA_H 1
-#endif
 #defineHAVE_PIPE 1
 #defineHAVE_POLL 1
 #defineHAVE_POLL_H 1
 #defineHAVE_PWD_H 1
 #defineHAVE_READLINK 1
-#if 0
+#defineHAVE_RIPEMD_H
 #defineHAVE_RMD160 1
-#endif
 #defineHAVE_SELECT 1
 #defineHAVE_SETENV 1
-#if 0
 #defineHAVE_SHA_H 1
 #defineHAVE_SHA1 1
 #defineHAVE_SHA256 1
 #defineHAVE_SHA256_H 1
-#defineHAVE_SHA384 1
-#defineHAVE_SHA512 1
-#endif
 #defineHAVE_SIGNAL_H 1
 #defineHAVE_STDINT_H 1
 #defineHAVE_STDLIB_H 1
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191262 - head/usr.bin/cpio

2009-04-18 Thread Tim Kientzle
Author: kientzle
Date: Sun Apr 19 06:59:12 2009
New Revision: 191262
URL: http://svn.freebsd.org/changeset/base/191262

Log:
  When compiled for the release crunches, be a bit
  more selective about what libarchive features we pull in:
   * No compression support
   * Only cpio and ustar writing
   * Only cpio and tar/pax readers
  This reduces a statically linked, stripped binary from 900k to 680k
  and completely eliminates the dependency on libcrypto.

Modified:
  head/usr.bin/cpio/Makefile
  head/usr.bin/cpio/cpio.c

Modified: head/usr.bin/cpio/Makefile
==
--- head/usr.bin/cpio/Makefile  Sun Apr 19 06:30:00 2009(r191261)
+++ head/usr.bin/cpio/Makefile  Sun Apr 19 06:59:12 2009(r191262)
@@ -9,6 +9,11 @@ WARNS?=6
 DPADD= ${LIBARCHIVE} ${LIBZ} ${LIBBZ2}
 CFLAGS+= -DBSDCPIO_VERSION_STRING=\"${BSDCPIO_VERSION_STRING}\"
 CFLAGS+= -DPLATFORM_CONFIG_H=\"config_freebsd.h\"
+.ifdef RELEASE_CRUNCH
+# FreeBSD's installer uses cpio in crunched binaries that are
+# statically linked, cannot use -lcrypto, and are size sensitive.
+CFLAGS+= -DSMALLER
+.endif
 LDADD+=-larchive -lz -lbz2 -lmd
 .if ${MK_OPENSSL} != "no"
 LDADD+= -lcrypto

Modified: head/usr.bin/cpio/cpio.c
==
--- head/usr.bin/cpio/cpio.cSun Apr 19 06:30:00 2009(r191261)
+++ head/usr.bin/cpio/cpio.cSun Apr 19 06:59:12 2009(r191262)
@@ -461,24 +461,37 @@ mode_out(struct cpio *cpio)
if (cpio->archive == NULL)
cpio_errc(1, 0, "Failed to allocate archive object");
switch (cpio->compress) {
-#ifdef HAVE_BZLIB_H
+#ifndef SMALLER
case 'j': case 'y':
-   archive_write_set_compression_bzip2(cpio->archive);
+   r = archive_write_set_compression_bzip2(cpio->archive);
break;
-#endif
-#ifdef HAVE_ZLIB_H
case 'z':
-   archive_write_set_compression_gzip(cpio->archive);
+   r = archive_write_set_compression_gzip(cpio->archive);
break;
-#endif
case 'Z':
-   archive_write_set_compression_compress(cpio->archive);
+   r = archive_write_set_compression_compress(cpio->archive);
break;
-   default:
-   archive_write_set_compression_none(cpio->archive);
+#endif
+   case '\0':
+   r = archive_write_set_compression_none(cpio->archive);
break;
+   default:
+   cpio_errc(1, 0, "Unrecognized compression option");
}
+   if (r != ARCHIVE_OK)
+   cpio_errc(1, 0, "Unsupported compression format");
+#ifdef SMALLER
+   if (strcmp(cpio->format, "cpio"))
+   r = archive_write_set_format_cpio(cpio->archive);
+   else if (strcmp(cpio->format, "odc"))
+   r = archive_write_set_format_cpio(cpio->archive);
+   else if (strcmp(cpio->format, "newc"))
+   r = archive_write_set_format_cpio(cpio->archive);
+   else if (strcmp(cpio->format, "ustar"))
+   r = archive_write_set_format_cpio(cpio->archive);
+#else
r = archive_write_set_format_by_name(cpio->archive, cpio->format);
+#endif
if (r != ARCHIVE_OK)
cpio_errc(1, 0, archive_error_string(cpio->archive));
archive_write_set_bytes_per_block(cpio->archive, cpio->bytes_per_block);
@@ -815,8 +828,13 @@ mode_in(struct cpio *cpio)
a = archive_read_new();
if (a == NULL)
cpio_errc(1, 0, "Couldn't allocate archive object");
+#ifdef SMALLER
+   archive_read_support_format_cpio(a);
+   archive_read_support_format_tar(a);
+#else
archive_read_support_compression_all(a);
archive_read_support_format_all(a);
+#endif
 
if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block))
cpio_errc(1, archive_errno(a),
@@ -907,8 +925,13 @@ mode_list(struct cpio *cpio)
a = archive_read_new();
if (a == NULL)
cpio_errc(1, 0, "Couldn't allocate archive object");
+#ifdef SMALLER
+   archive_read_support_format_cpio(a);
+   archive_read_support_format_tar(a);
+#else
archive_read_support_compression_all(a);
archive_read_support_format_all(a);
+#endif
 
if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block))
cpio_errc(1, archive_errno(a),
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191524 - head/lib/libarchive

2009-04-26 Thread Tim Kientzle
Author: kientzle
Date: Sun Apr 26 18:24:14 2009
New Revision: 191524
URL: http://svn.freebsd.org/changeset/base/191524

Log:
  Remove an unused variable.
  
  Thanks to:Christoph Mallon

Modified:
  head/lib/libarchive/archive_read_support_format_empty.c

Modified: head/lib/libarchive/archive_read_support_format_empty.c
==
--- head/lib/libarchive/archive_read_support_format_empty.c Sun Apr 26 
18:10:07 2009(r191523)
+++ head/lib/libarchive/archive_read_support_format_empty.c Sun Apr 26 
18:24:14 2009(r191524)
@@ -59,10 +59,9 @@ archive_read_support_format_empty(struct
 static int
 archive_read_format_empty_bid(struct archive_read *a)
 {
-   const void *h;
ssize_t avail;
 
-   h = __archive_read_ahead(a, 1, &avail);
+   (void)__archive_read_ahead(a, 1, &avail);
if (avail != 0)
return (-1);
return (1);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191525 - head/lib/libarchive

2009-04-26 Thread Tim Kientzle
Author: kientzle
Date: Sun Apr 26 18:43:49 2009
New Revision: 191525
URL: http://svn.freebsd.org/changeset/base/191525

Log:
  Exit with ARCHIVE_FATAL if the ISO image is truncated.

Modified:
  head/lib/libarchive/archive_read_support_format_iso9660.c

Modified: head/lib/libarchive/archive_read_support_format_iso9660.c
==
--- head/lib/libarchive/archive_read_support_format_iso9660.c   Sun Apr 26 
18:24:14 2009(r191524)
+++ head/lib/libarchive/archive_read_support_format_iso9660.c   Sun Apr 26 
18:43:49 2009(r191525)
@@ -683,7 +683,7 @@ archive_read_format_iso9660_read_data(st
if (bytes_read == 0)
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Truncated input file");
-   if (buff == NULL)
+   if (*buff == NULL)
return (ARCHIVE_FATAL);
if (bytes_read > iso9660->entry_bytes_remaining)
bytes_read = iso9660->entry_bytes_remaining;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191526 - head/lib/libarchive

2009-04-26 Thread Tim Kientzle
Author: kientzle
Date: Sun Apr 26 18:46:40 2009
New Revision: 191526
URL: http://svn.freebsd.org/changeset/base/191526

Log:
  Various improvements to the tar.5 manpage, including
  descriptions of the GNU tar "posix-style" sparse format,
  clarification of the Solaris tar ACL storage,
  and a few comments about Mac OS X tar's resource storage.

Modified:
  head/lib/libarchive/tar.5

Modified: head/lib/libarchive/tar.5
==
--- head/lib/libarchive/tar.5   Sun Apr 26 18:43:49 2009(r191525)
+++ head/lib/libarchive/tar.5   Sun Apr 26 18:46:40 2009(r191526)
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2003-2007 Tim Kientzle
+.\" Copyright (c) 2003-2009 Tim Kientzle
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -24,8 +24,8 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 20, 2004
-.Dt TAR 5
+.Dd April 19, 2009
+.Dt tar 5
 .Os
 .Sh NAME
 .Nm tar
@@ -71,7 +71,7 @@ necessary.
 This section describes the variant implemented by the tar command
 included in
 .At v7 ,
-which is one of the earliest widely-used versions of the tar program.
+which seems to be the earliest widely-used version of the tar program.
 .Pp
 The header record for an old-style
 .Nm
@@ -390,6 +390,11 @@ user or group information available (suc
 are temporarily unavailable).
 .It Cm SCHILY.devminor , Cm SCHILY.devmajor
 The full minor and major numbers for device nodes.
+.It Cm SCHILY.fflags
+The file flags.
+.It Cm SCHILY.realsize
+The full size of the file on disk.
+XXX explain? XXX
 .It Cm SCHILY.dev, Cm SCHILY.ino , Cm SCHILY.nlinks
 The device number, inode number, and link count for the entry.
 In particular, note that a pax interchange format archive using Joerg
@@ -560,9 +565,6 @@ plus
 When extracting, GNU tar checks that the header file name is the one it is
 expecting, that the header offset is in the correct sequence, and that
 the sum of offset and size is equal to realsize.
-FreeBSD's version of GNU tar does not handle the corner case of an
-archive's being continued in the middle of a long name or other
-extension header.
 .It "N"
 Type "N" records are no longer generated by GNU tar.
 They contained a
@@ -575,6 +577,8 @@ or
 .Dq Symlink %s to %s\en ;
 in either case, both
 filenames are escaped using K&R C syntax.
+Due to security concerns, "N" records are now generally ignored
+when reading archives.
 .It "S"
 This is a
 .Dq sparse
@@ -644,6 +648,66 @@ entry; the
 .Va realsize
 field will indicate the total size of the file.
 .El
+.Ss GNU tar pax archives
+GNU tar 1.14 (XXX check this XXX) and later will write
+pax interchange format archives when you specify the
+.Fl -posix
+flag.
+This format uses custom keywords to store sparse file information.
+There have been three iterations of this support, referred to
+as
+.Dq 0.0 ,
+.Dq 0.1 ,
+and
+.Dq 1.0 .
+.Bl -tag -width indent
+.It Cm GNU.sparse.numblocks , Cm GNU.sparse.offset , Cm GNU.sparse.numbytes , 
Cm  GNU.sparse.size
+The
+.Dq 0.0
+format used an initial
+.Cm GNU.sparse.numblocks
+attribute to indicate the number of blocks in the file, a pair of
+.Cm GNU.sparse.offset
+and
+.Cm GNU.sparse.numbytes
+to indicate the offset and size of each block,
+and a single
+.Cm GNU.sparse.size
+to indicate the full size of the file.
+This is not the same as the size in the tar header because the
+latter value does not include the size of any holes.
+This format required that the order of attributes be preserved and
+relied on readers accepting multiple appearances of the same attribute
+names, which is not officially permitted by the standards.
+.It Cm GNU.sparse.map
+The
+.Dq 0.1
+format used a single attribute that stored a comma-separated
+list of decimal numbers.
+Each pair of numbers indicated the offset and size, respectively,
+of a block of data.
+This does not work well if the archive is extracted by an archiver
+that does not recognize this extension, since many pax implementations
+simply discard unrecognized attributes.
+.It Cm GNU.sparse.major , Cm GNU.sparse.minor , Cm GNU.sparse.name , Cm 
GNU.sparse.realsize
+The
+.Dq 1.0
+format stores the sparse block map in one or more 512-byte blocks
+prepended to the file data in the entry body.
+The pax attributes indicate the existence of this map
+(via the
+.Cm GNU.sparse.major
+and
+.Cm GNU.sparse.minor
+fields)
+and the full size of the file.
+The
+.Cm GNU.sparse.name
+holds the true name of the file.
+To avoid confusion, the name stored in the regular tar header
+is a modified name so that extraction errors will be apparent
+to users.
+.El
 .Ss Solaris Tar
 XXX More Details Needed XXX
 .Pp
@@ -667,16 +731,42 @@ An additional
 .Cm A
 entry is used to store an ACL for the following regular entry.
 The body of this entry contains a seven-digit octal number
-(whose value is 0100 plus the numbe

svn commit: r191527 - in head/lib/libarchive: . test

2009-04-26 Thread Tim Kientzle
Author: kientzle
Date: Sun Apr 26 18:57:50 2009
New Revision: 191527
URL: http://svn.freebsd.org/changeset/base/191527

Log:
  Reading an mtree file is supposed to provide
  access to the file data (if the file exists on
  disk).  This was broken for the first regular
  file; fix it and add a test so it won't break again.
  
  In particular, this fixes the following idiom for creating
  a tar archive in which every file is owned by root:
  
  tar cf - --format=mtree . \
  | sed -e 's/uname=[a-z]*/uname=root/' -e 's/uid=[0-9]*/uid=0/' \
  | tar cf - @-

Modified:
  head/lib/libarchive/archive_read_support_format_mtree.c
  head/lib/libarchive/test/test_read_format_mtree.c

Modified: head/lib/libarchive/archive_read_support_format_mtree.c
==
--- head/lib/libarchive/archive_read_support_format_mtree.c Sun Apr 26 
18:46:40 2009(r191526)
+++ head/lib/libarchive/archive_read_support_format_mtree.c Sun Apr 26 
18:57:50 2009(r191527)
@@ -990,8 +990,8 @@ read_data(struct archive_read *a, const 
if (mtree->buff == NULL) {
archive_set_error(&a->archive, ENOMEM,
"Can't allocate memory");
+   return (ARCHIVE_FATAL);
}
-   return (ARCHIVE_FATAL);
}
 
*buff = mtree->buff;

Modified: head/lib/libarchive/test/test_read_format_mtree.c
==
--- head/lib/libarchive/test/test_read_format_mtree.c   Sun Apr 26 18:46:40 
2009(r191526)
+++ head/lib/libarchive/test/test_read_format_mtree.c   Sun Apr 26 18:57:50 
2009(r191527)
@@ -28,7 +28,7 @@ __FBSDID("$FreeBSD$");
 /* Single entry with a hardlink. */
 static unsigned char archive[] = {
"#mtree\n"
-   "file type=file uid=18 mode=0123\n"
+   "file type=file uid=18 mode=0123 size=3\n"
"dir type=dir\n"
" file\\040with\\040space type=file uid=18\n"
" ..\n"
@@ -49,8 +49,10 @@ static unsigned char archive[] = {
 
 DEFINE_TEST(test_read_format_mtree)
 {
+   char buff[16];
struct archive_entry *ae;
struct archive *a;
+   int fd;
 
/*
 * An access error occurred on some platform when mtree
@@ -68,12 +70,23 @@ DEFINE_TEST(test_read_format_mtree)
archive_read_support_format_all(a));
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, archive, sizeof(archive)));
+
+   /*
+* Read "file", whose data is available on disk.
+*/
+   fd = open("file", O_WRONLY | O_CREAT, 0777);
+   assert(fd >= 0);
+   assertEqualInt(3, write(fd, "hi\n", 3));
+   close(fd);
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE);
assertEqualString(archive_entry_pathname(ae), "file");
assertEqualInt(archive_entry_uid(ae), 18);
assert(S_ISREG(archive_entry_mode(ae)));
assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0123);
+   assertEqualInt(archive_entry_size(ae), 3);
+   assertEqualInt(3, archive_read_data(a, buff, 3));
+   assertEqualMem(buff, "hi\n", 3);
 
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir");
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191572 - head/lib/libarchive

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 17:42:02 2009
New Revision: 191572
URL: http://svn.freebsd.org/changeset/base/191572

Log:
  Merge r988,r1064 from libarchive.googlecode.com:
   * Split whiny skip function to create a new best-effort skip_lenient()
   * Correctly increment the top-level file position only for the top filter
   * Simulate skip by reading against the current filter, not the top filter
  
  The latter two bugs aren't currently visible because no existing
  filter delegates skip operations.

Modified:
  head/lib/libarchive/archive_read.c
  head/lib/libarchive/archive_read_private.h

Modified: head/lib/libarchive/archive_read.c
==
--- head/lib/libarchive/archive_read.c  Mon Apr 27 17:39:41 2009
(r191571)
+++ head/lib/libarchive/archive_read.c  Mon Apr 27 17:42:02 2009
(r191572)
@@ -1112,7 +1112,24 @@ __archive_read_filter_consume(struct arc
 int64_t
 __archive_read_skip(struct archive_read *a, int64_t request)
 {
-   return (__archive_read_filter_skip(a->filter, request));
+   int64_t skipped = __archive_read_skip_lenient(a, request);
+   if (skipped == request)
+   return (skipped);
+   /* We hit EOF before we satisfied the skip request. */
+   archive_set_error(&a->archive,
+   ARCHIVE_ERRNO_MISC,
+   "Truncated input file (needed %jd bytes, only %jd available)",
+   (intmax_t)request, (intmax_t)skipped);
+   return (ARCHIVE_FATAL);
+}
+
+int64_t
+__archive_read_skip_lenient(struct archive_read *a, int64_t request)
+{
+   int64_t skipped = __archive_read_filter_skip(a->filter, request);
+   if (skipped > 0)
+   a->archive.file_position += skipped;
+   return (skipped);
 }
 
 int64_t
@@ -1128,13 +1145,13 @@ __archive_read_filter_skip(struct archiv
 */
if (filter->avail > 0) {
min = minimum(request, (off_t)filter->avail);
-   bytes_skipped = __archive_read_consume(filter->archive, min);
+   bytes_skipped = __archive_read_filter_consume(filter, min);
request -= bytes_skipped;
total_bytes_skipped += bytes_skipped;
}
if (filter->client_avail > 0) {
min = minimum(request, (off_t)filter->client_avail);
-   bytes_skipped = __archive_read_consume(filter->archive, min);
+   bytes_skipped = __archive_read_filter_consume(filter, min);
request -= bytes_skipped;
total_bytes_skipped += bytes_skipped;
}
@@ -1155,7 +1172,6 @@ __archive_read_filter_skip(struct archiv
filter->fatal = 1;
return (bytes_skipped);
}
-   filter->archive->archive.file_position += bytes_skipped;
total_bytes_skipped += bytes_skipped;
request -= bytes_skipped;
filter->client_next = filter->client_buff;
@@ -1170,20 +1186,15 @@ __archive_read_filter_skip(struct archiv
while (request > 0) {
const void* dummy_buffer;
ssize_t bytes_read;
-   dummy_buffer = __archive_read_ahead(filter->archive,
+   dummy_buffer = __archive_read_filter_ahead(filter,
1, &bytes_read);
if (bytes_read < 0)
return (bytes_read);
if (bytes_read == 0) {
-   /* We hit EOF before we satisfied the skip request. */
-   archive_set_error(&filter->archive->archive,
-   ARCHIVE_ERRNO_MISC,
-   "Truncated input file (need to skip %jd bytes)",
-   (intmax_t)request);
-   return (ARCHIVE_FATAL);
+   return (total_bytes_skipped);
}
min = (size_t)(minimum(bytes_read, request));
-   bytes_read = __archive_read_consume(filter->archive, min);
+   bytes_read = __archive_read_filter_consume(filter, min);
total_bytes_skipped += bytes_read;
request -= bytes_read;
}

Modified: head/lib/libarchive/archive_read_private.h
==
--- head/lib/libarchive/archive_read_private.h  Mon Apr 27 17:39:41 2009
(r191571)
+++ head/lib/libarchive/archive_read_private.h  Mon Apr 27 17:42:02 2009
(r191572)
@@ -189,6 +189,7 @@ const void *__archive_read_filter_ahead(
 ssize_t__archive_read_consume(struct archive_read *, size_t);
 ssize_t__archive_read_filter_consume(struct archive_read_filter *, 
size_t);
 int64_t__archive_read_skip(struct archive_read *, int64_t);
+int64_t__archive_read_skip_lenient(struct archive_read *, int64_t);
 int64_t__archive_read_filter_skip(struct archive_read_filter *, 
int64_t);
 int __archive_re

svn commit: r191576 - in head/lib/libarchive: . test

2009-04-27 Thread Tim Kientzle
ive/test/test_acl_pax.c Mon Apr 27 18:27:54 2009
(r191576)
@@ -151,10 +151,10 @@ static unsigned char reference[] = {
 0,0,0,0,0,0,0,0,0,0,'1','1','3',' ','S','C','H','I','L','Y','.','a','c','l',
 '.','a','c','c','e','s','s','=','u','s','e','r',':',':','r','-','x',',','g',
 'r','o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w',
-'x',',','g','r','o','u','p',':','g','r','o','u','p','7','8',':','r','w','x',
-':','7','8',',','u','s','e','r',':','u','s','e','r','7','8',':','-','-','-',
-':','7','8',',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',
-':','7','7',10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',
+'x',',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7',
+'7',',','u','s','e','r',':','u','s','e','r','7','8',':','-','-','-',':','7',
+'8',',','g','r','o','u','p',':','g','r','o','u','p','7','8',':','r','w','x',
+':','7','8',10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',
 10,'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',
 ' ','S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -464,7 +464,7 @@ DEFINE_TEST(test_acl_pax)
 
/* Assert that the generated data matches the built-in reference data.*/
failure("Generated pax archive does not match reference; check 
'testout' and 'reference' files.");
-   assert(0 == memcmp(buff, reference, sizeof(reference)));
+   assertEqualMem(buff, reference, sizeof(reference));
failure("Generated pax archive does not match reference; check 
'testout' and 'reference' files.");
assertEqualInt((int)used, sizeof(reference));
 

Added: head/lib/libarchive/test/test_compat_solaris_tar_acl.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libarchive/test/test_compat_solaris_tar_acl.c  Mon Apr 27 
18:27:54 2009(r191576)
@@ -0,0 +1,128 @@
+/*-
+ * Copyright (c) 2003-2009 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *   

svn commit: r191578 - head/lib/libarchive

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 18:33:08 2009
New Revision: 191578
URL: http://svn.freebsd.org/changeset/base/191578

Log:
  Merge r1052,r1055 from libarchive.googlecode.com:
  Clear the error flag on entry to a few more API functions.

Modified:
  head/lib/libarchive/archive_read_open_fd.c
  head/lib/libarchive/archive_read_open_file.c
  head/lib/libarchive/archive_read_open_filename.c
  head/lib/libarchive/archive_read_support_compression_xz.c

Modified: head/lib/libarchive/archive_read_open_fd.c
==
--- head/lib/libarchive/archive_read_open_fd.c  Mon Apr 27 18:29:59 2009
(r191577)
+++ head/lib/libarchive/archive_read_open_fd.c  Mon Apr 27 18:33:08 2009
(r191578)
@@ -66,6 +66,7 @@ archive_read_open_fd(struct archive *a, 
struct read_fd_data *mine;
void *b;
 
+   archive_clear_error(a);
if (fstat(fd, &st) != 0) {
archive_set_error(a, errno, "Can't stat fd %d", fd);
return (ARCHIVE_FATAL);

Modified: head/lib/libarchive/archive_read_open_file.c
==
--- head/lib/libarchive/archive_read_open_file.cMon Apr 27 18:29:59 
2009(r191577)
+++ head/lib/libarchive/archive_read_open_file.cMon Apr 27 18:33:08 
2009(r191578)
@@ -70,6 +70,7 @@ archive_read_open_FILE(struct archive *a
size_t block_size = 128 * 1024;
void *b;
 
+   archive_clear_error(a);
mine = (struct read_FILE_data *)malloc(sizeof(*mine));
b = malloc(block_size);
if (mine == NULL || b == NULL) {

Modified: head/lib/libarchive/archive_read_open_filename.c
==
--- head/lib/libarchive/archive_read_open_filename.cMon Apr 27 18:29:59 
2009(r191577)
+++ head/lib/libarchive/archive_read_open_filename.cMon Apr 27 18:33:08 
2009(r191578)
@@ -84,6 +84,7 @@ archive_read_open_filename(struct archiv
void *b;
int fd;
 
+   archive_clear_error(a);
if (filename == NULL || filename[0] == '\0')
return (archive_read_open_fd(a, 0, block_size));
 

Modified: head/lib/libarchive/archive_read_support_compression_xz.c
==
--- head/lib/libarchive/archive_read_support_compression_xz.c   Mon Apr 27 
18:29:59 2009(r191577)
+++ head/lib/libarchive/archive_read_support_compression_xz.c   Mon Apr 27 
18:33:08 2009(r191578)
@@ -100,6 +100,7 @@ archive_read_support_compression_xz(stru
struct archive_read *a = (struct archive_read *)_a;
struct archive_read_filter_bidder *bidder = 
__archive_read_get_bidder(a);
 
+   archive_clear_error(_a);
if (bidder == NULL)
return (ARCHIVE_FATAL);
 
@@ -123,6 +124,7 @@ archive_read_support_compression_lzma(st
struct archive_read *a = (struct archive_read *)_a;
struct archive_read_filter_bidder *bidder = 
__archive_read_get_bidder(a);
 
+   archive_clear_error(_a);
if (bidder == NULL)
return (ARCHIVE_FATAL);
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191579 - head/lib/libarchive

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 18:35:03 2009
New Revision: 191579
URL: http://svn.freebsd.org/changeset/base/191579

Log:
  Merge r1021 from libarchive.googlecode.com:
  If we know it's a socket, say so.

Modified:
  head/lib/libarchive/archive_write_set_format_pax.c
  head/lib/libarchive/archive_write_set_format_ustar.c

Modified: head/lib/libarchive/archive_write_set_format_pax.c
==
--- head/lib/libarchive/archive_write_set_format_pax.c  Mon Apr 27 18:33:08 
2009(r191578)
+++ head/lib/libarchive/archive_write_set_format_pax.c  Mon Apr 27 18:35:03 
2009(r191579)
@@ -452,8 +452,14 @@ archive_write_pax_header(struct archive_
free(t);
}
break;
+   case AE_IFSOCK:
+   archive_set_error(&a->archive,
+   ARCHIVE_ERRNO_FILE_FORMAT,
+   "tar format cannot archive socket");
+   return (ARCHIVE_WARN);
default:
-   archive_set_error(&a->archive, 
ARCHIVE_ERRNO_FILE_FORMAT,
+   archive_set_error(&a->archive,
+   ARCHIVE_ERRNO_FILE_FORMAT,
"tar format cannot archive this (type=0%lo)",
(unsigned 
long)archive_entry_filetype(entry_original));
return (ARCHIVE_WARN);

Modified: head/lib/libarchive/archive_write_set_format_ustar.c
==
--- head/lib/libarchive/archive_write_set_format_ustar.cMon Apr 27 
18:33:08 2009(r191578)
+++ head/lib/libarchive/archive_write_set_format_ustar.cMon Apr 27 
18:35:03 2009(r191579)
@@ -414,8 +414,14 @@ __archive_write_format_header_ustar(stru
case AE_IFBLK: h[USTAR_typeflag_offset] = '4' ; break;
case AE_IFDIR: h[USTAR_typeflag_offset] = '5' ; break;
case AE_IFIFO: h[USTAR_typeflag_offset] = '6' ; break;
+   case AE_IFSOCK:
+   archive_set_error(&a->archive,
+   ARCHIVE_ERRNO_FILE_FORMAT,
+   "tar format cannot archive socket");
+   return (ARCHIVE_FAILED);
default:
-   archive_set_error(&a->archive, 
ARCHIVE_ERRNO_FILE_FORMAT,
+   archive_set_error(&a->archive,
+   ARCHIVE_ERRNO_FILE_FORMAT,
"tar format cannot archive this (mode=0%lo)",
(unsigned long)archive_entry_mode(entry));
ret = ARCHIVE_FAILED;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191581 - head/lib/libarchive/test

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 18:39:55 2009
New Revision: 191581
URL: http://svn.freebsd.org/changeset/base/191581

Log:
  Merge r1054,r1060 from libarchive.googlecode.com:
   * assertEqualMem() now takes void * arguments
   * Be a little smarter about what we hexdump when assertEqualMem() fails

Modified:
  head/lib/libarchive/test/main.c
  head/lib/libarchive/test/test.h

Modified: head/lib/libarchive/test/main.c
==
--- head/lib/libarchive/test/main.c Mon Apr 27 18:35:06 2009
(r191580)
+++ head/lib/libarchive/test/main.c Mon Apr 27 18:39:55 2009
(r191581)
@@ -463,13 +463,16 @@ hexdump(const char *p, const char *ref, 
 }
 
 /* assertEqualMem() displays the values of the two memory blocks. */
-/* TODO: For long blocks, hexdump the first bytes that actually differ. */
 int
 test_assert_equal_mem(const char *file, int line,
-const char *v1, const char *e1,
-const char *v2, const char *e2,
+const void *_v1, const char *e1,
+const void *_v2, const char *e2,
 size_t l, const char *ld, void *extra)
 {
+   const char *v1 = (const char *)_v1;
+   const char *v2 = (const char *)_v2;
+   size_t offset;
+
count_assertion(file, line);
if (v1 == NULL || v2 == NULL) {
if (v1 == v2) {
@@ -486,10 +489,20 @@ test_assert_equal_mem(const char *file, 
fprintf(stderr, "%s:%d: Assertion failed: memory not equal\n",
file, line);
fprintf(stderr, "  size %s = %d\n", ld, (int)l);
+   /* Dump 48 bytes (3 lines) so that the first difference is
+* in the second line. */
+   offset = 0;
+   while (l > 64 && memcmp(v1, v2, 32) == 0) {
+   /* The first two lines agree, so step forward one line. */
+   v1 += 16;
+   v2 += 16;
+   l -= 16;
+   offset += 16;
+   }
fprintf(stderr, "  Dump of %s\n", e1);
-   hexdump(v1, v2, l < 32 ? l : 32, 0);
+   hexdump(v1, v2, l < 64 ? l : 64, offset);
fprintf(stderr, "  Dump of %s\n", e2);
-   hexdump(v2, v1, l < 32 ? l : 32, 0);
+   hexdump(v2, v1, l < 64 ? l : 64, offset);
fprintf(stderr, "\n");
report_failure(extra);
return (0);

Modified: head/lib/libarchive/test/test.h
==
--- head/lib/libarchive/test/test.h Mon Apr 27 18:35:06 2009
(r191580)
+++ head/lib/libarchive/test/test.h Mon Apr 27 18:39:55 2009
(r191581)
@@ -147,7 +147,7 @@ int test_assert_equal_file(const char *,
 int test_assert_equal_int(const char *, int, int, const char *, int, const 
char *, void *);
 int test_assert_equal_string(const char *, int, const char *v1, const char *, 
const char *v2, const char *, void *);
 int test_assert_equal_wstring(const char *, int, const wchar_t *v1, const char 
*, const wchar_t *v2, const char *, void *);
-int test_assert_equal_mem(const char *, int, const char *, const char *, const 
char *, const char *, size_t, const char *, void *);
+int test_assert_equal_mem(const char *, int, const void *, const char *, const 
void *, const char *, size_t, const char *, void *);
 int test_assert_file_contents(const void *, int, const char *, ...);
 int test_assert_file_exists(const char *, ...);
 int test_assert_file_not_exists(const char *, ...);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191584 - head/lib/libarchive/test

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 18:55:22 2009
New Revision: 191584
URL: http://svn.freebsd.org/changeset/base/191584

Log:
  Merge r1032 from libarchive.googlecode.com:
  Make test_fuzz a bit more sensitive by actually reading the body
  of each entry instead of skipping it.
  While I'm here, move the "UnsupportedCompress" macro into the
  only file that still uses it.

Modified:
  head/lib/libarchive/test/test.h
  head/lib/libarchive/test/test_fuzz.c

Modified: head/lib/libarchive/test/test.h
==
--- head/lib/libarchive/test/test.h Mon Apr 27 18:46:57 2009
(r191583)
+++ head/lib/libarchive/test/test.h Mon Apr 27 18:55:22 2009
(r191584)
@@ -194,14 +194,3 @@ int read_open_memory2(struct archive *, 
   test_assert_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
 #define assertEqualStringA(a,v1,v2)   \
   test_assert_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
-
-/*
- * A compression is not supported
- * Use this define after archive_read_next_header() is called
- */
-#define UnsupportedCompress(r, a) \
-   (r != ARCHIVE_OK && \
-(strcmp(archive_error_string(a), \
-   "Unrecognized archive format") == 0 && \
- archive_compression(a) == ARCHIVE_COMPRESSION_NONE))
-

Modified: head/lib/libarchive/test/test_fuzz.c
==
--- head/lib/libarchive/test/test_fuzz.cMon Apr 27 18:46:57 2009
(r191583)
+++ head/lib/libarchive/test/test_fuzz.cMon Apr 27 18:55:22 2009
(r191584)
@@ -61,9 +61,18 @@ files[] = {
NULL
 };
 
+#define UnsupportedCompress(r, a) \
+(r != ARCHIVE_OK && \
+ (strcmp(archive_error_string(a), \
+"Unrecognized archive format") == 0 && \
+  archive_compression(a) == ARCHIVE_COMPRESSION_NONE))
+
 DEFINE_TEST(test_fuzz)
 {
const char **filep;
+   const void *blk;
+   size_t blk_size;
+   off_t blk_offset;
 
for (filep = files; *filep != NULL; ++filep) {
struct archive_entry *ae;
@@ -105,6 +114,10 @@ DEFINE_TEST(test_fuzz)
assert(0 == archive_read_finish(a));
continue;
}
+   while (0 == archive_read_data_block(a, &blk,
+   &blk_size, &blk_offset))
+   continue;
+
}
assert(0 == archive_read_close(a));
assert(0 == archive_read_finish(a));
@@ -134,7 +147,9 @@ DEFINE_TEST(test_fuzz)
 
if (0 == archive_read_open_memory(a, image, size)) {
while(0 == archive_read_next_header(a, &ae)) {
-   archive_read_data_skip(a);
+   while (0 == archive_read_data_block(a,
+   &blk, &blk_size, &blk_offset))
+   continue;
}
archive_read_close(a);
archive_read_finish(a);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191586 - head/lib/libarchive

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 19:14:43 2009
New Revision: 191586
URL: http://svn.freebsd.org/changeset/base/191586

Log:
  ino_t varies across platforms; casting (int) here avoids
  various pointless complaints.

Modified:
  head/lib/libarchive/archive_write_set_format_cpio.c

Modified: head/lib/libarchive/archive_write_set_format_cpio.c
==
--- head/lib/libarchive/archive_write_set_format_cpio.c Mon Apr 27 18:59:40 
2009(r191585)
+++ head/lib/libarchive/archive_write_set_format_cpio.c Mon Apr 27 19:14:43 
2009(r191586)
@@ -125,8 +125,9 @@ archive_write_cpio_header(struct archive
 * re-using the ones off the disk.  That way, the 18-bit c_ino
 * field only limits the number of files in the archive.
 */
-   if (archive_entry_ino(entry) > 077) {
-   archive_set_error(&a->archive, ERANGE, "large inode number 
truncated");
+   if ((int)archive_entry_ino(entry) > 077) {
+   archive_set_error(&a->archive, ERANGE,
+   "large inode number truncated");
ret = ARCHIVE_WARN;
}
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191590 - head/lib/libarchive/test

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 19:20:25 2009
New Revision: 191590
URL: http://svn.freebsd.org/changeset/base/191590

Log:
  Merge r1058 from libarchive.googlecode.com:  Require that each
  test source file has exactly one DEFINE_TEST().

Modified:
  head/lib/libarchive/test/test_pax_filename_encoding.c
  head/lib/libarchive/test/test_read_format_isojoliet_bz2.c

Modified: head/lib/libarchive/test/test_pax_filename_encoding.c
==
--- head/lib/libarchive/test/test_pax_filename_encoding.c   Mon Apr 27 
19:18:55 2009(r191589)
+++ head/lib/libarchive/test/test_pax_filename_encoding.c   Mon Apr 27 
19:20:25 2009(r191590)
@@ -40,7 +40,8 @@ __FBSDID("$FreeBSD$");
  * the right filename returned and that we get a warning only
  * if the header isn't marked as binary.
  */
-DEFINE_TEST(test_pax_filename_encoding_1)
+static void
+test_pax_filename_encoding_1(void)
 {
static const char testname[] = "test_pax_filename_encoding.tar";
/*
@@ -84,7 +85,8 @@ DEFINE_TEST(test_pax_filename_encoding_1
  * This should work; the underlying implementation should automatically
  * fall back to storing the pathname in binary.
  */
-DEFINE_TEST(test_pax_filename_encoding_2)
+static void
+test_pax_filename_encoding_2(void)
 {
char filename[] = "abc\314\214mno\374xyz";
struct archive *a;
@@ -191,7 +193,8 @@ DEFINE_TEST(test_pax_filename_encoding_2
  * read it back into "C" locale, which doesn't support the name.
  * TODO: Figure out the "right" behavior here.
  */
-DEFINE_TEST(test_pax_filename_encoding_3)
+static void
+test_pax_filename_encoding_3(void)
 {
wchar_t badname[] = L"xxxAyyyBzzz";
const char badname_utf8[] = "xxx\xE1\x88\xB4yyy\xE5\x99\xB8zzz";
@@ -325,3 +328,10 @@ DEFINE_TEST(test_pax_filename_encoding_3
assertEqualInt(0, archive_read_finish(a));
 #endif
 }
+
+DEFINE_TEST(test_pax_filename_encoding)
+{
+   test_pax_filename_encoding_1();
+   test_pax_filename_encoding_2();
+   test_pax_filename_encoding_3();
+}

Modified: head/lib/libarchive/test/test_read_format_isojoliet_bz2.c
==
--- head/lib/libarchive/test/test_read_format_isojoliet_bz2.c   Mon Apr 27 
19:18:55 2009(r191589)
+++ head/lib/libarchive/test/test_read_format_isojoliet_bz2.c   Mon Apr 27 
19:20:25 2009(r191590)
@@ -177,11 +177,7 @@ joliettest(int withrr)
 DEFINE_TEST(test_read_format_isojoliet_bz2)
 {
joliettest(0);
-}
-
 
-DEFINE_TEST(test_read_format_isojolietrr_bz2)
-{
/*  This doesn't work today; can it be made to work? */
 #if 0
joliettest(1);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191591 - head/lib/libarchive/test

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 19:23:53 2009
New Revision: 191591
URL: http://svn.freebsd.org/changeset/base/191591

Log:
  Merge r1034 from libarchive.googlecode.com:
  Put a much larger file on the reference ISO for this test.

Modified:
  head/lib/libarchive/test/test_read_format_isorr_bz2.c
  head/lib/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu

Modified: head/lib/libarchive/test/test_read_format_isorr_bz2.c
==
--- head/lib/libarchive/test/test_read_format_isorr_bz2.c   Mon Apr 27 
19:20:25 2009(r191590)
+++ head/lib/libarchive/test/test_read_format_isorr_bz2.c   Mon Apr 27 
19:23:53 2009(r191591)
@@ -26,13 +26,14 @@
 __FBSDID("$FreeBSD$");
 
 /*
-Execute the following to rebuild the data for this program:
+Execute the following command to rebuild the data for this program:
tail -n +32 test_read_format_isorr_bz2.c | /bin/sh
 
 rm -rf /tmp/iso
 mkdir /tmp/iso
 mkdir /tmp/iso/dir
 echo "hello" >/tmp/iso/file
+dd if=/dev/zero bs=1 count=12345678 >>/tmp/iso/file
 ln /tmp/iso/file /tmp/iso/hardlink
 (cd /tmp/iso; ln -s file symlink)
 TZ=utc touch -afhm -t 19700102.01 /tmp/iso /tmp/iso/file /tmp/iso/dir
@@ -95,11 +96,10 @@ DEFINE_TEST(test_read_format_isorr_bz2)
assertEqualInt(0, archive_read_next_header(a, &ae));
assertEqualString("file", archive_entry_pathname(ae));
assert(S_ISREG(archive_entry_stat(ae)->st_mode));
-   assertEqualInt(6, archive_entry_size(ae));
+   assertEqualInt(12345684, archive_entry_size(ae));
assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
-   assertEqualInt(6, (int)size);
assertEqualInt(0, offset);
-   assertEqualInt(0, memcmp(p, "hello\n", 6));
+   assertEqualMem(p, "hello\n", 6);
assertEqualInt(86401, archive_entry_mtime(ae));
assertEqualInt(86401, archive_entry_atime(ae));
assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
@@ -111,7 +111,7 @@ DEFINE_TEST(test_read_format_isorr_bz2)
assertEqualString("hardlink", archive_entry_pathname(ae));
assert(S_ISREG(archive_entry_stat(ae)->st_mode));
assertEqualString("file", archive_entry_hardlink(ae));
-   assertEqualInt(6, archive_entry_size(ae));
+   assertEqualInt(12345684, archive_entry_size(ae));
assertEqualInt(86401, archive_entry_mtime(ae));
assertEqualInt(86401, archive_entry_atime(ae));
assertEqualInt(2, archive_entry_stat(ae)->st_nlink);

Modified: head/lib/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu
==
--- head/lib/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu  Mon Apr 
27 19:20:25 2009(r191590)
+++ head/lib/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu  Mon Apr 
27 19:23:53 2009(r191591)
@@ -1,24 +1,24 @@
 $FreeBSD$
-
 begin 644 test_read_format_isorr_bz2.iso.bz2
-M0EIH.3%!629361M#:2D``,?_W?__6_Y58_GX/__?X*?OWB8AZB0`,`...@`$0"
-...@0c``qp`u:!,&J>FJ>2:CR)^I'ZB#3U/4-`!H:#(:``...@`!h9!d!ii-$,A
-M&BGFJ>34]0T!IHT&AHT:#0:``!ZC$`#0T.`!H&@&AH``!IB&C30```!H9``!
-MA(D0DTQ3T3$TVA-!IIZAA-'J:!H!H#0:#30:#30T;1*PHGAZ"/F;E""L"I6"
-M8W&#'./D%S=_T4T96&+...@94x&AL;:`Y+0C?:%=B#:8`:PP`2WF"20!EXL)6=]
-M8=A)!0Q)($C&$U#8AI(&QL2!"10P4^8D$"0,8$I-.!3R8YWZ]Q1./IDR^VYN
-MRJ&76*,$3PG?U(,=C;I20`D<&9/%5ILJIGI0(SWP3KRID6=#1MV*A>)(*B0$
-M$E:>B944(
-MO-&.8&:1K;>[K$?O7R-FWA;%5+E]WBVT9PR7J
-MNU2C2G2>5**"XH4HD`PF+(*DTT&47'A+)B";NS-UH>(]7G^\/G_343KU\17<
-M<*""-SM"%>BVIJL8SF]7L-1.-LSRP2%=KX&C56*FC&#C$XNMGL)]3X&^$V4Z
-MY`()G`%`KUR!HU8Z'"HWNE&P6MI:KZ^Q"H0L7.OV8ZJW409[QO=`&&D%=5&@RP`MO%R/J#Q
-M-KJ*6D;EH7:dk0...@8hf*ip(>*YMR$>!+A,)X+;`$94@@?U]B/=2T0CY-2=
-M*_1FPF<-...@z-_,Q>06='5:(B#3`W$8Y!:C-CE22SM9*S$00,XXJTIZ!GA(
-LGTMN:F\J-,D9>?.38*!I7T>--*b_=t44h...@``"1;7#_Q=R13A0D!M#:2D`
+M0EIH.3%!629363S[0-4``,?_W?__R_158__Z/__?8*?owb8azb2`...@`,0"
+...@0c0`sx`6uh$p:f...@32fcu-d1z@#U'J!HT>H#0`!H`T9`#U-#33(-`-3TFA#1
+MJ933TFR%#(&@`#0-'J`T``,.-#1HT&C0-``R-`9``8<:&C1H
+M-&@:`!D:`R``P1*(1$]3U,C(--``T!H:9``:``&F)?&F1;DY
+M&:fb?6...@wg9x@8AM,HTK/Q9EXPZD#E2A$D)(@;F(g^b.92glb...@`+i1!
+M1$`';Y%%P_YU^!0+8BJ(@#DC&d...@d4"1D4?Z1!$1`&Z`V[]0H($(!6L90;:>A0V<))XH7BH%"KAF8!:H8\].K:4`Y`,4,!RN:#SL[!;-"!6%0F?`H
+m2_...@*%/%<\*!XL/C2%A1AI$8/AF(#SZ;]:>$5^/NKNO<+...@_cs4xui(Q*
+M123&G=9T]QQR?"=WMV(,&60`1D0:U043)E&22GWA);Z:"9R.A@,4,IL+O=L7
+MACF:V5C!L"HB&,82/[./'>PAEG-"PA,D6T1+
+M2<\S]-*$,]X-XF%:_)1,W,=`,^+.N0""6@"85=H@<2FZ=HI-GDHK&)>/T74Y
+M+5>[4:S`Z`M87AHD`H6BE*8R%X=9AS$7&+Z?F%A.`AX!"x...@c5_?4^p".90`*]#[D(PA*&MPV7U2
+M;.]7.&/5...@c:J)S&T%=%,k...@x0[""E8G!I!/I%`KSMA<#^!%C+Y*")'1](
+MJ06:CXD^5K*:`$E`B`0$P5;&R;BF<5/Y7&(5A`?:!...@``
 `
 end
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191592 - in head/lib/libarchive: . test

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 19:30:09 2009
New Revision: 191592
URL: http://svn.freebsd.org/changeset/base/191592

Log:
  Merge r1061,r1062,r1063 from libarchive.googlecode.com:
  Fix reading big-endian binary cpio archives, and add a test.
  While I'm here, add a note about Solaris ACL extension for cpio,
  which should be relatively straightforward to support.
  
  Thanks to: Edward Napierala, who sent me a big-endian cpio archive
  from a Solaris system he's been playing with.
  Pointy hat: me

Added:
  head/lib/libarchive/test/test_read_format_cpio_bin_be.c   (contents, props 
changed)
  head/lib/libarchive/test/test_read_format_cpio_bin_be.cpio.uu   (contents, 
props changed)
Modified:
  head/lib/libarchive/archive_read_support_format_cpio.c
  head/lib/libarchive/test/Makefile

Modified: head/lib/libarchive/archive_read_support_format_cpio.c
==
--- head/lib/libarchive/archive_read_support_format_cpio.c  Mon Apr 27 
19:23:53 2009(r191591)
+++ head/lib/libarchive/archive_read_support_format_cpio.c  Mon Apr 27 
19:30:09 2009(r191592)
@@ -257,6 +257,11 @@ archive_read_format_cpio_read_header(str
cpio->entry_bytes_remaining = 0;
}
 
+   /* XXX TODO: If the full mode is 0160200, then this is a Solaris
+* ACL description for the following entry.  Read this body
+* and parse it as a Solaris-style ACL, then read the next
+* header.  XXX */
+
/* Compare name to "TRAILER!!!" to test for end-of-archive. */
if (namelength == 11 && strcmp((const char *)h, "TRAILER!!!") == 0) {
/* TODO: Store file location of start of block. */
@@ -669,7 +674,7 @@ le4(const unsigned char *p)
 static int
 be4(const unsigned char *p)
 {
-   return (p[0] + (p[1]<<8) + (p[2]<<16) + (p[3]<<24));
+   return ((p[0]<<24) + (p[1]<<16) + (p[2]<<8) + (p[3]));
 }
 
 /*

Modified: head/lib/libarchive/test/Makefile
==
--- head/lib/libarchive/test/Makefile   Mon Apr 27 19:23:53 2009
(r191591)
+++ head/lib/libarchive/test/Makefile   Mon Apr 27 19:30:09 2009
(r191592)
@@ -39,6 +39,7 @@ TESTS= \
test_read_format_ar.c   \
test_read_format_cpio_bin.c \
test_read_format_cpio_bin_Z.c   \
+   test_read_format_cpio_bin_be.c  \
test_read_format_cpio_bin_bz2.c \
test_read_format_cpio_bin_gz.c  \
test_read_format_cpio_bin_xz.c  \

Added: head/lib/libarchive/test/test_read_format_cpio_bin_be.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libarchive/test/test_read_format_cpio_bin_be.c Mon Apr 27 
19:30:09 2009    (r191592)
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_read_format_cpio_bin_be)
+{
+   struct archive_entry *ae;
+   struct archive *a;
+   const char *reference = "test_read_format_cpio_bin_be.cpio";
+
+   extract_reference_file(reference);
+   assert((a = archive_read_new()) != NULL);
+   assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+   assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+   assertEqualIntA(a, ARCHIVE_OK,
+   archive_read_open_filename(a,

svn commit: r191594 - in head/lib/libarchive: . test

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 20:09:05 2009
New Revision: 191594
URL: http://svn.freebsd.org/changeset/base/191594

Log:
  Merge r990,r1044 from libarchive.googlecode.com:
  read_support_format_raw() allows people to exploit libarchive's
  automatic decompression support by simply stubbing out the
  archive format handler.
  The raw handler is not enabled by support_format_all(), of course.
  It bids 1 on any non-empty input and always returns a single
  entry named "data" with no properties set.

Added:
  head/lib/libarchive/archive_read_support_format_raw.c   (contents, props 
changed)
  head/lib/libarchive/test/test_read_format_raw.c   (contents, props changed)
  head/lib/libarchive/test/test_read_format_raw.data.Z.uu   (contents, props 
changed)
  head/lib/libarchive/test/test_read_format_raw.data.uu   (contents, props 
changed)
Modified:
  head/lib/libarchive/Makefile
  head/lib/libarchive/archive.h
  head/lib/libarchive/test/Makefile

Modified: head/lib/libarchive/Makefile
==
--- head/lib/libarchive/MakefileMon Apr 27 19:39:18 2009
(r191593)
+++ head/lib/libarchive/MakefileMon Apr 27 20:09:05 2009
(r191594)
@@ -52,6 +52,7 @@ SRCS= archive_check_magic.c   \
archive_read_support_format_empty.c \
archive_read_support_format_iso9660.c   \
archive_read_support_format_mtree.c \
+   archive_read_support_format_raw.c   \
archive_read_support_format_tar.c   \
archive_read_support_format_zip.c   \
archive_string.c\

Modified: head/lib/libarchive/archive.h
==
--- head/lib/libarchive/archive.h   Mon Apr 27 19:39:18 2009
(r191593)
+++ head/lib/libarchive/archive.h   Mon Apr 27 20:09:05 2009
(r191594)
@@ -272,6 +272,7 @@ typedef int archive_close_callback(struc
 #defineARCHIVE_FORMAT_AR_GNU   (ARCHIVE_FORMAT_AR | 1)
 #defineARCHIVE_FORMAT_AR_BSD   (ARCHIVE_FORMAT_AR | 2)
 #defineARCHIVE_FORMAT_MTREE0x8
+#defineARCHIVE_FORMAT_RAW  0x9
 
 /*-
  * Basic outline for reading an archive:
@@ -315,6 +316,7 @@ __LA_DECL intarchive_read_support_for
 __LA_DECL int   archive_read_support_format_gnutar(struct archive *);
 __LA_DECL int   archive_read_support_format_iso9660(struct archive *);
 __LA_DECL int   archive_read_support_format_mtree(struct archive *);
+__LA_DECL int   archive_read_support_format_raw(struct archive *);
 __LA_DECL int   archive_read_support_format_tar(struct archive *);
 __LA_DECL int   archive_read_support_format_zip(struct archive *);
 

Added: head/lib/libarchive/archive_read_support_format_raw.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libarchive/archive_read_support_format_raw.c   Mon Apr 27 
20:09:05 2009(r191594)
@@ -0,0 +1,187 @@
+/*-
+ * Copyright (c) 2003-2009 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "archive_platform.h"
+__FBSDID("$FreeBSD$");
+
+#ifdef HAVE_ERRNO_H
+#include 
+#endif
+#include 
+#ifdef HAVE_STDLIB_H
+#include 
+#endif
+
+#include "archive.h"
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+stru

svn commit: r191595 - head/lib/libarchive

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 20:13:13 2009
New Revision: 191595
URL: http://svn.freebsd.org/changeset/base/191595

Log:
  Merge r991 from libarchive.googlecode.com:  Various updates
  to archive_read.3 manpage, including documentation for the
  new "raw" handler.

Modified:
  head/lib/libarchive/archive_read.3

Modified: head/lib/libarchive/archive_read.3
==
--- head/lib/libarchive/archive_read.3  Mon Apr 27 20:09:05 2009
(r191594)
+++ head/lib/libarchive/archive_read.3  Mon Apr 27 20:13:13 2009
(r191595)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 19, 2006
+.Dd April 13, 2009
 .Dt archive_read 3
 .Os
 .Sh NAME
@@ -36,12 +36,18 @@
 .Nm archive_read_support_compression_bzip2 ,
 .Nm archive_read_support_compression_compress ,
 .Nm archive_read_support_compression_gzip ,
+.Nm archive_read_support_compression_lzma ,
 .Nm archive_read_support_compression_none ,
+.Nm archive_read_support_compression_xz ,
 .Nm archive_read_support_compression_program ,
+.Nm archive_read_support_compression_program_signature ,
 .Nm archive_read_support_format_all ,
+.Nm archive_read_support_format_ar ,
 .Nm archive_read_support_format_cpio ,
 .Nm archive_read_support_format_empty ,
 .Nm archive_read_support_format_iso9660 ,
+.Nm archive_read_support_format_mtree,
+.Nm archive_read_support_format_raw,
 .Nm archive_read_support_format_tar ,
 .Nm archive_read_support_format_zip ,
 .Nm archive_read_open ,
@@ -78,21 +84,38 @@
 .Ft int
 .Fn archive_read_support_compression_gzip "struct archive *"
 .Ft int
+.Fn archive_read_support_compression_lzma "struct archive *"
+.Ft int
 .Fn archive_read_support_compression_none "struct archive *"
 .Ft int
+.Fn archive_read_support_compression_xz "struct archive *"
+.Ft int
 .Fo archive_read_support_compression_program
 .Fa "struct archive *"
 .Fa "const char *cmd"
 .Fc
 .Ft int
+.Fo archive_read_support_compression_program_signature
+.Fa "struct archive *"
+.Fa "const char *cmd"
+.Fa "const void *signature"
+.Fa "size_t signature_length"
+.Fc
+.Ft int
 .Fn archive_read_support_format_all "struct archive *"
 .Ft int
+.Fn archive_read_support_format_ar "struct archive *"
+.Ft int
 .Fn archive_read_support_format_cpio "struct archive *"
 .Ft int
 .Fn archive_read_support_format_empty "struct archive *"
 .Ft int
 .Fn archive_read_support_format_iso9660 "struct archive *"
 .Ft int
+.Fn archive_read_support_format_mtree "struct archive *"
+.Ft int
+.Fn archive_read_support_format_raw "struct archive *"
+.Ft int
 .Fn archive_read_support_format_tar "struct archive *"
 .Ft int
 .Fn archive_read_support_format_zip "struct archive *"
@@ -189,30 +212,43 @@ Allocates and initializes a
 .Tn struct archive
 object suitable for reading from an archive.
 .It Xo
-.Fn archive_read_support_compression_all ,
 .Fn archive_read_support_compression_bzip2 ,
 .Fn archive_read_support_compression_compress ,
 .Fn archive_read_support_compression_gzip ,
-.Fn archive_read_support_compression_none
+.Fn archive_read_support_compression_lzma ,
+.Fn archive_read_support_compression_none ,
+.Fn archive_read_support_compression_xz
 .Xc
 Enables auto-detection code and decompression support for the
 specified compression.
+Returns
+.Cm ARCHIVE_OK
+if the compression is fully supported, or
+.Cm ARCHIVE_WARN
+if the compression is supported only through an external program.
+Note that decompression using an external program is usually slower than
+decompression through built-in libraries.
 Note that
 .Dq none
 is always enabled by default.
-For convenience,
-.Fn archive_read_support_compression_all
-enables all available decompression code.
+.It Fn archive_read_support_compression_all
+Enables all available decompression filters.
 .It Fn archive_read_support_compression_program
 Data is fed through the specified external program before being dearchived.
 Note that this disables automatic detection of the compression format,
 so it makes no sense to specify this in conjunction with any other
 decompression option.
+.It Fn archive_read_support_compression_program_signature
+This feeds data through the specified external program
+but only if the initial bytes of the data match the specified
+signature value.
 .It Xo
 .Fn archive_read_support_format_all ,
+.Fn archive_read_support_format_ar ,
 .Fn archive_read_support_format_cpio ,
 .Fn archive_read_support_format_empty ,
 .Fn archive_read_support_format_iso9660 ,
+.Fn archive_read_support_format_mtree ,
 .Fn archive_read_support_format_tar ,
 .Fn archive_read_support_format_zip
 .Xc
@@ -226,6 +262,17 @@ For convenience,
 .Fn archive_read_support_format_all
 enables support for all available formats.
 Only empty archives are supported by default.
+.It Fn archive_read_support_format_raw
+The
+.Dq raw
+format handler allows libarchive to be used to read arbitrary data.
+It treats any data stream as an archive with a single entry.
+The pathname of this entry is
+.Dq data ;
+all other e

svn commit: r191597 - head/lib/libarchive

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 20:23:22 2009
New Revision: 191597
URL: http://svn.freebsd.org/changeset/base/191597

Log:
  Symlink some additional man page entries.

Modified:
  head/lib/libarchive/Makefile

Modified: head/lib/libarchive/Makefile
==
--- head/lib/libarchive/MakefileMon Apr 27 20:18:01 2009
(r191596)
+++ head/lib/libarchive/MakefileMon Apr 27 20:23:22 2009
(r191597)
@@ -178,6 +178,7 @@ MLINKS+=archive_read.3 archive_read_ext
 MLINKS+=   archive_read.3 archive_read_finish.3
 MLINKS+=   archive_read.3 archive_read_new.3
 MLINKS+=   archive_read.3 archive_read_next_header.3
+MLINKS+=   archive_read.3 archive_read_next_header2.3
 MLINKS+=   archive_read.3 archive_read_open.3
 MLINKS+=   archive_read.3 archive_read_open2.3
 MLINKS+=   archive_read.3 archive_read_open_FILE.3
@@ -189,11 +190,17 @@ MLINKS+=  archive_read.3 archive_read_sup
 MLINKS+=   archive_read.3 archive_read_support_compression_bzip2.3
 MLINKS+=   archive_read.3 archive_read_support_compression_compress.3
 MLINKS+=   archive_read.3 archive_read_support_compression_gzip.3
+MLINKS+=   archive_read.3 archive_read_support_compression_lzma.3
 MLINKS+=   archive_read.3 archive_read_support_compression_none.3
 MLINKS+=   archive_read.3 archive_read_support_compression_program.3
+MLINKS+=   archive_read.3 
archive_read_support_compression_program_signature.3
+MLINKS+=   archive_read.3 archive_read_support_compression_xz.3
 MLINKS+=   archive_read.3 archive_read_support_format_all.3
+MLINKS+=   archive_read.3 archive_read_support_format_ar.3
 MLINKS+=   archive_read.3 archive_read_support_format_cpio.3
+MLINKS+=   archive_read.3 archive_read_support_format_empty.3
 MLINKS+=   archive_read.3 archive_read_support_format_iso9660.3
+MLINKS+=   archive_read.3 archive_read_support_format_raw.3
 MLINKS+=   archive_read.3 archive_read_support_format_tar.3
 MLINKS+=   archive_read.3 archive_read_support_format_zip.3
 MLINKS+=   archive_read_disk.3 archive_read_disk_entry_from_file.3
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191604 - head/lib/libarchive

2009-04-27 Thread Tim Kientzle
Author: kientzle
Date: Mon Apr 27 22:39:43 2009
New Revision: 191604
URL: http://svn.freebsd.org/changeset/base/191604

Log:
  Document the liblzma support.
  Unfortunately, liblzma itself is GPLed, so unlikely to become part of
  the FreeBSD base system.
  However, the core lzma compression/decompression code is public
  domain, so it should be feasible for someone to create a compatible
  library without the GPL strings.

Modified:
  head/lib/libarchive/Makefile

Modified: head/lib/libarchive/Makefile
==
--- head/lib/libarchive/MakefileMon Apr 27 22:06:49 2009
(r191603)
+++ head/lib/libarchive/MakefileMon Apr 27 22:39:43 2009
(r191604)
@@ -11,6 +11,9 @@ SHLIB_MAJOR= 4
 
 CFLAGS+=   -DPLATFORM_CONFIG_H=\"config_freebsd.h\"
 CFLAGS+=   -I${.OBJDIR}
+#Uncomment to build with full lzma/xz support via liblzma
+#CFLAGS+= -I/usr/local/include -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1
+#LDADD+= -L/usr/local/lib -llzma
 
 .if ${MK_OPENSSL} != "no"
 CFLAGS+=   -DWITH_OPENSSL
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r191904 - head/lib/libarchive

2009-05-07 Thread Tim Kientzle
Author: kientzle
Date: Thu May  7 23:01:03 2009
New Revision: 191904
URL: http://svn.freebsd.org/changeset/base/191904

Log:
  Partially revert r191171, which went too far in trying
  to eliminate some duplicated code.  In particular,
  archive_read_open_filename() has different close
  handling than archive_read_open_fd(), so delegating
  the former to the latter in the degenerate case
  (a NULL filename is treated as stdin) broke reading
  from pipelines.  In particular, this fixes occasional
  port failures that were seen when using "gunzip | tar"
  pipelines under /bin/csh.
  
  Thanks to Alexey Shuvaev for reporting this failure and
  patiently helping me to track down the cause.

Modified:
  head/lib/libarchive/archive_read_open_filename.c

Modified: head/lib/libarchive/archive_read_open_filename.c
==
--- head/lib/libarchive/archive_read_open_filename.cThu May  7 21:51:13 
2009(r191903)
+++ head/lib/libarchive/archive_read_open_filename.cThu May  7 23:01:03 
2009(r191904)
@@ -85,20 +85,32 @@ archive_read_open_filename(struct archiv
int fd;
 
archive_clear_error(a);
-   if (filename == NULL || filename[0] == '\0')
-   return (archive_read_open_fd(a, 0, block_size));
-
-   fd = open(filename, O_RDONLY | O_BINARY);
-   if (fd < 0) {
-   archive_set_error(a, errno, "Failed to open '%s'", filename);
-   return (ARCHIVE_FATAL);
+   if (filename == NULL || filename[0] == '\0') {
+   /* We used to invoke archive_read_open_fd(a,0,block_size)
+* here, but that doesn't (and shouldn't) handle the
+* end-of-file flush when reading stdout from a pipe.
+* Basically, read_open_fd() is intended for folks who
+* are willing to handle such details themselves.  This
+* API is intended to be a little smarter for folks who
+* want easy handling of the common case.
+*/
+   filename = ""; /* Normalize NULL to "" */
+   fd = 0;
+   } else {
+   fd = open(filename, O_RDONLY | O_BINARY);
+   if (fd < 0) {
+   archive_set_error(a, errno,
+   "Failed to open '%s'", filename);
+   return (ARCHIVE_FATAL);
+   }
}
if (fstat(fd, &st) != 0) {
archive_set_error(a, errno, "Can't stat '%s'", filename);
return (ARCHIVE_FATAL);
}
 
-   mine = (struct read_file_data *)malloc(sizeof(*mine) + 
strlen(filename));
+   mine = (struct read_file_data *)calloc(1,
+   sizeof(*mine) + strlen(filename));
b = malloc(block_size);
if (mine == NULL || b == NULL) {
archive_set_error(a, ENOMEM, "No memory");
@@ -117,15 +129,20 @@ archive_read_open_filename(struct archiv
if (S_ISREG(st.st_mode)) {
archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
/*
-* Skip is a performance optimization for anything
-* that supports lseek().  Generally, that only
-* includes regular files and possibly raw disk
-* devices, but there's no good portable way to detect
-* raw disks.
+* Enabling skip here is a performance optimization
+* for anything that supports lseek().  On FreeBSD
+* (and probably many other systems), only regular
+* files and raw disk devices support lseek() (on
+* other input types, lseek() returns success but
+* doesn't actually change the file pointer, which
+* just completely screws up the position-tracking
+* logic).  In addition, I've yet to find a portable
+* way to determine if a device is a raw disk device.
+* So I don't see a way to do much better than to only
+* enable this optimization for regular files.
 */
mine->can_skip = 1;
-   } else
-   mine->can_skip = 0;
+   }
return (archive_read_open2(a, mine,
NULL, file_read, file_skip, file_close));
 }
@@ -139,8 +156,11 @@ file_read(struct archive *a, void *clien
*buff = mine->buffer;
bytes_read = read(mine->fd, mine->buffer, mine->block_size);
if (bytes_read < 0) {
-   archive_set_error(a, errno, "Error reading '%s'",
-   mine->filename);
+   if (mine->filename[0] == '\0')
+   archive_set_error(a, errno, "Error reading stdin");
+   else
+   archive_set_error(a, errno, "Error reading '%s'",
+   mine->filename);
}
return (bytes_read);
 }
@@ -190,8 +210,15 @@ f

svn commit: r252013 - head/contrib/apr/include

2013-06-19 Thread Tim Kientzle
Author: kientzle
Date: Thu Jun 20 02:04:03 2013
New Revision: 252013
URL: http://svnweb.freebsd.org/changeset/base/252013

Log:
  Try to fix build of apr on FreeBSD/arm.

Modified:
  head/contrib/apr/include/apr_general.h

Modified: head/contrib/apr/include/apr_general.h
==
--- head/contrib/apr/include/apr_general.h  Thu Jun 20 00:00:33 2013
(r252012)
+++ head/contrib/apr/include/apr_general.h  Thu Jun 20 02:04:03 2013
(r252013)
@@ -76,7 +76,7 @@ typedef int   apr_signum_t;
  * @return offset
  */
 
-#if defined(CRAY) || (defined(__arm) && !defined(LINUX))
+#if defined(CRAY) || (defined(__arm) && !defined(LINUX) && 
!defined(__FreeBSD__))
 #ifdef __STDC__
 #define APR_OFFSET(p_type,field) _Offsetof(p_type,field)
 #else
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


  1   2   3   4   5   >