Index: head/usr.bin/Makefile =================================================================== --- head/usr.bin/Makefile (revision 176452) +++ head/usr.bin/Makefile (revision 176453) @@ -1,331 +1,332 @@ # From: @(#)Makefile 8.3 (Berkeley) 1/7/94 # $FreeBSD$ .include # XXX MISSING: deroff diction graph learn plot # spell spline struct xsend # XXX Use GNU versions: apropos bc dc diff grep ld man patch whatis # Moved to secure: bdes # SUBDIR= alias \ apply \ + ar \ asa \ at \ ${_atm} \ awk \ banner \ basename \ biff \ ${_bluetooth} \ brandelf \ bsdiff \ bzip2 \ bzip2recover \ ${_c89} \ ${_c99} \ ${_calendar} \ cap_mkdb \ ${_catman} \ chat \ checknr \ ${_chkey} \ chpass \ cksum \ cmp \ col \ colcrt \ colldef \ colrm \ column \ comm \ compile_et \ compress \ csplit \ ${_csup} \ ctags \ cut \ ${_dig} \ dirname \ du \ ee \ elf2aout \ elfdump \ enigma \ env \ expand \ false \ fetch \ file \ file2c \ find \ finger \ fmt \ fold \ from \ fstat \ fsync \ ftp \ gcore \ gencat \ getconf \ getent \ getopt \ ${_gprof} \ gzip \ head \ ${_hesinfo} \ hexdump \ ${_host} \ id \ indent \ ipcrm \ ipcs \ join \ jot \ kdump \ keylogin \ keylogout \ killall \ ktrace \ ktrdump \ lam \ last \ lastcomm \ ldd \ leave \ less \ lessecho \ lesskey \ ${_lex} \ limits \ locale \ locate \ lock \ lockf \ logger \ login \ logins \ logname \ look \ lorder \ lsvfs \ m4 \ mail \ make \ makewhatis \ mesg \ minigzip \ ministat \ mkdep \ mkfifo \ mklocale \ mkstr \ mktemp \ mkuzip \ msgs \ mt \ ${_nc} \ ncal \ ${_ncplist} \ ${_ncplogin} \ netstat \ newgrp \ ${_newkey} \ nfsstat \ nice \ nl \ nohup \ ${_nslookup} \ ${_nsupdate} \ opieinfo \ opiekey \ opiepasswd \ pagesize \ passwd \ paste \ pathchk \ pkill \ pr \ printenv \ printf \ procstat \ quota \ renice \ rev \ ${_rlogin} \ rpcgen \ rpcinfo \ rs \ ${_rsh} \ rup \ ruptime \ rusers \ rwall \ rwho \ script \ sed \ shar \ showmount \ ${_smbutil} \ sockstat \ split \ stat \ su \ systat \ tabs \ tail \ talk \ tar \ tcopy \ tee \ telnet \ tftp \ time \ tip \ top \ touch \ tput \ tr \ true \ truncate \ ${_truss} \ tset \ tsort \ tty \ ul \ uname \ unexpand \ unifdef \ uniq \ units \ unvis \ ${_usbhidaction} \ ${_usbhidctl} \ users \ uudecode \ uuencode \ uuidgen \ ${_vacation} \ vgrind \ vi \ vis \ vmstat \ w \ wall \ wc \ what \ whereis \ which \ who \ whois \ window \ write \ xargs \ xinstall \ ${_xlint} \ xstr \ ${_yacc} \ yes \ ${_ypcat} \ ${_ypmatch} \ ${_ypwhich} .if ${MACHINE_ARCH} != "arm" _truss= truss .endif .if ${MK_ATM} != "no" _atm= atm .endif .if ${MK_MAN} != "no" _catman= catman .endif .if ${MK_BIND_UTILS} != "no" _dig= dig _host= host _nslookup= nslookup _nsupdate= nsupdate .endif .if ${MK_BLUETOOTH} != "no" _bluetooth= bluetooth .endif .if ${MK_CALENDAR} != "no" _calendar= calendar .endif .if ${MK_OPENSSL} != "no" _chkey= chkey _newkey= newkey .if ${MK_LIBTHR} != "no" || ${MK_LIBKSE} != "no" _csup= csup .endif .endif .if ${MK_HESIOD} != "no" _hesinfo= hesinfo .endif .if ${MK_NETCAT} != "no" _nc= nc .endif .if ${MK_NIS} != "no" _ypcat= ypcat _ypmatch= ypmatch _ypwhich= ypwhich .endif .if ${MK_RCMDS} != "no" _rlogin= rlogin _rsh= rsh .endif .if ${MK_SENDMAIL} != "no" _vacation= vacation .endif .if ${MK_TOOLCHAIN} != "no" _c89= c89 _c99= c99 _gprof= gprof _lex= lex _xlint= xlint _yacc= yacc .endif .if ${MK_USB} != "no" _usbhidaction= usbhidaction _usbhidctl= usbhidctl .endif .if ${MACHINE_ARCH} == "i386" .if ${MK_NCP} != "no" _ncplist= ncplist _ncplogin= ncplogin .endif _smbutil= smbutil .endif .if ${MACHINE_ARCH} == "ia64" _smbutil= smbutil .endif .if ${MACHINE_ARCH} == "amd64" .if ${MK_NCP} != "no" _ncplist= ncplist _ncplogin= ncplogin .endif _smbutil= smbutil .endif .if ${MACHINE_ARCH} == "powerpc" _smbutil= smbutil .endif .include Index: head/usr.bin/ar/Makefile =================================================================== --- head/usr.bin/ar/Makefile (revision 176452) +++ head/usr.bin/ar/Makefile (revision 176453) @@ -1,12 +1,26 @@ # $FreeBSD$ +.if defined(WITH_BSDAR) PROG= ar -VERSION= 1.0.2 +.else +PROG= bsdar +.endif SRCS= ar.c read.c util.c write.c + WARNS?= 5 + DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ} ${LIBELF} LDADD= -larchive -lbz2 -lz -lelf -CFLAGS+= -DBSDAR_VERSION=\"${VERSION}\" + +.if defined(WITH_BSDAR) LINKS= ${BINDIR}/ar ${BINDIR}/ranlib +MLINKS= ar ranlib +.else +LINKS= ${BINDIR}/bsdar ${BINDIR}/bsdranlib +MLINKS= bsdar.1 bsdranlib.1 + +bsdar.1: ar.1 + ln -sf ${.ALLSRC} ${.TARGET} +.endif .include Index: head/usr.bin/ar/ar.h =================================================================== --- head/usr.bin/ar/ar.h (revision 176452) +++ head/usr.bin/ar/ar.h (revision 176453) @@ -1,119 +1,121 @@ /*- * Copyright (c) 2007 Kai Wang * 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 * in this position and unchanged. * 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. * * $FreeBSD$ */ +#define BSDAR_VERSION "1.0.2" + /* * ar(1) options. */ #define AR_A 0x0001 /* position-after */ #define AR_B 0x0002 /* position-before */ #define AR_C 0x0004 /* creating new archive */ #define AR_CC 0x0008 /* do not overwrite when extracting */ #define AR_J 0x0010 /* bzip2 compression */ #define AR_O 0x0020 /* preserve original mtime when extracting */ #define AR_S 0x0040 /* write archive symbol table */ #define AR_SS 0x0080 /* do not write archive symbol table */ #define AR_TR 0x0100 /* only keep first 15 chars for member name */ #define AR_U 0x0200 /* only extract or update newer members.*/ #define AR_V 0x0400 /* verbose mode */ #define AR_Z 0x0800 /* gzip compression */ #define DEF_BLKSZ 10240 /* default block size */ /* * Convenient wrapper for general libarchive error handling. */ #define AC(CALL) do { \ if ((CALL)) \ bsdar_errc(bsdar, EX_SOFTWARE, 0, "%s", \ archive_error_string(a)); \ } while (0) /* * In-memory representation of archive member(object). */ struct ar_obj { char *name; /* member name */ void *maddr; /* mmap start address */ uid_t uid; /* user id */ gid_t gid; /* group id */ mode_t md; /* octal file permissions */ size_t size; /* member size */ time_t mtime; /* modification time */ int fd; /* file descriptor */ dev_t dev; /* inode's device */ ino_t ino; /* inode's number */ TAILQ_ENTRY(ar_obj) objs; }; /* * Structure encapsulates the "global" data for "ar" program. */ struct bsdar { const char *filename; /* archive name. */ const char *posarg; /* position arg for modifiers -a, -b. */ char mode; /* program mode */ char compression; /* compression mode */ int options; /* command line options */ const char *progname; /* program name */ int argc; char **argv; /* * Fields for the archive string table. */ char *as; /* buffer for archive string table. */ size_t as_sz; /* current size of as table. */ size_t as_cap; /* capacity of as table buffer. */ /* * Fields for the archive symbol table. */ uint32_t s_cnt; /* current number of symbols. */ uint32_t *s_so; /* symbol offset table. */ size_t s_so_cap; /* capacity of so table buffer. */ char *s_sn; /* symbol name table */ size_t s_sn_cap; /* capacity of sn table buffer. */ size_t s_sn_sz; /* current size of sn table. */ /* Current member's offset (relative to the end of pseudo members.) */ off_t rela_off; TAILQ_HEAD(, ar_obj) v_obj; /* object(member) list */ }; void bsdar_errc(struct bsdar *, int _eval, int _code, const char *fmt, ...); void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); void ar_mode_d(struct bsdar *bsdar); void ar_mode_m(struct bsdar *bsdar); void ar_mode_p(struct bsdar *bsdar); void ar_mode_r(struct bsdar *bsdar); void ar_mode_s(struct bsdar *bsdar); void ar_mode_t(struct bsdar *bsdar); void ar_mode_x(struct bsdar *bsdar);