diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/Makefile | 6 | ||||
-rw-r--r-- | usr.bin/ar/Makefile | 9 | ||||
-rw-r--r-- | usr.bin/ar/append.c | 83 | ||||
-rw-r--r-- | usr.bin/ar/ar.1 | 343 | ||||
-rw-r--r-- | usr.bin/ar/ar.5 | 145 | ||||
-rw-r--r-- | usr.bin/ar/ar.c | 223 | ||||
-rw-r--r-- | usr.bin/ar/archive.c | 329 | ||||
-rw-r--r-- | usr.bin/ar/archive.h | 103 | ||||
-rw-r--r-- | usr.bin/ar/contents.c | 90 | ||||
-rw-r--r-- | usr.bin/ar/delete.c | 90 | ||||
-rw-r--r-- | usr.bin/ar/extern.h | 53 | ||||
-rw-r--r-- | usr.bin/ar/extract.c | 133 | ||||
-rw-r--r-- | usr.bin/ar/misc.c | 140 | ||||
-rw-r--r-- | usr.bin/ar/move.c | 134 | ||||
-rw-r--r-- | usr.bin/ar/pathnames.h | 39 | ||||
-rw-r--r-- | usr.bin/ar/print.c | 84 | ||||
-rw-r--r-- | usr.bin/ar/replace.c | 172 | ||||
-rw-r--r-- | usr.bin/ranlib/Makefile | 9 | ||||
-rw-r--r-- | usr.bin/ranlib/build.c | 321 | ||||
-rw-r--r-- | usr.bin/ranlib/extern.h | 49 | ||||
-rw-r--r-- | usr.bin/ranlib/misc.c | 110 | ||||
-rw-r--r-- | usr.bin/ranlib/pathnames.h | 34 | ||||
-rw-r--r-- | usr.bin/ranlib/ranlib.1 | 96 | ||||
-rw-r--r-- | usr.bin/ranlib/ranlib.5 | 73 | ||||
-rw-r--r-- | usr.bin/ranlib/ranlib.c | 80 | ||||
-rw-r--r-- | usr.bin/ranlib/touch.c | 81 |
26 files changed, 3 insertions, 3026 deletions
diff --git a/usr.bin/Makefile b/usr.bin/Makefile index db74dbc89d0..5a680a2fe33 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile,v 1.131 2013/06/17 19:17:15 robert Exp $ +# $OpenBSD: Makefile,v 1.132 2013/07/05 21:37:19 miod Exp $ .include <bsd.own.mk> -SUBDIR= apply apropos ar arch asa at aucat audioctl awk banner \ +SUBDIR= apply apropos arch asa at aucat audioctl awk banner \ basename bc bdes bgplg \ biff cal calendar cap_mkdb cdio chpass cmp col colrm \ column comm compress cpp crontab csplit ctags cu cut \ @@ -18,7 +18,7 @@ SUBDIR= apply apropos ar arch asa at aucat audioctl awk banner \ newsyslog \ nfsstat nice nm nohup oldrdist pagesize passwd paste patch pctr \ pkg-config pkill \ - pr printenv printf quota radioctl ranlib rcs rdist rdistd \ + pr printenv printf quota radioctl rcs rdist rdistd \ readlink renice rev rpcgen rpcinfo rs rsh rup ruptime rusers rwall \ rwho sdiff script sed sendbug shar showmount skey \ skeyaudit skeyinfo skeyinit sndiod \ diff --git a/usr.bin/ar/Makefile b/usr.bin/ar/Makefile deleted file mode 100644 index 8c68dc46cb0..00000000000 --- a/usr.bin/ar/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $OpenBSD: Makefile,v 1.5 2013/07/05 21:29:51 miod Exp $ - -.include <bsd.own.mk> - -NOPROG= - -MAN+= ar.5 - -.include <bsd.prog.mk> diff --git a/usr.bin/ar/append.c b/usr.bin/ar/append.c deleted file mode 100644 index 139ddda52c0..00000000000 --- a/usr.bin/ar/append.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $OpenBSD: append.c,v 1.6 2009/10/27 23:59:35 deraadt Exp $ */ -/* $NetBSD: append.c,v 1.5 1995/03/26 03:27:37 glass Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/param.h> -#include <sys/stat.h> - -#include <err.h> -#include <fcntl.h> -#include <unistd.h> -#include <dirent.h> -#include <stdio.h> -#include <string.h> - -#include "archive.h" -#include "extern.h" - -/* - * append -- - * Append files to the archive - modifies original archive or creates - * a new archive if named archive does not exist. - */ -int -append(char **argv) -{ - int afd, fd, eval; - char *file; - CF cf; - struct stat sb; - - afd = open_archive(O_CREAT|O_RDWR); - if (lseek(afd, (off_t)0, SEEK_END) == (off_t)-1) - error(archive); - - /* Read from disk, write to an archive; pad on write. */ - SETCF(0, 0, afd, archive, WPAD); - for (eval = 0; (file = *argv++);) { - if ((fd = open(file, O_RDONLY)) < 0) { - warn("%s", file); - eval = 1; - continue; - } - if (options & AR_V) - (void)printf("q - %s\n", file); - cf.rfd = fd; - cf.rname = file; - put_arobj(&cf, &sb); - (void)close(fd); - } - close_archive(afd); - return (eval); -} diff --git a/usr.bin/ar/ar.1 b/usr.bin/ar/ar.1 deleted file mode 100644 index 3dcefd65114..00000000000 --- a/usr.bin/ar/ar.1 +++ /dev/null @@ -1,343 +0,0 @@ -.\" $OpenBSD: ar.1,v 1.18 2010/09/03 11:09:28 jmc Exp $ -.\" $NetBSD: ar.1,v 1.7 1995/08/18 15:05:11 pk Exp $ -.\" -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Hugh Smith at The University of Guelph. -.\" -.\" 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. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)ar.1 8.1 (Berkeley) 6/29/93 -.\" -.Dd $Mdocdate: September 3 2010 $ -.Dt AR 1 -.Os -.Sh NAME -.Nm ar -.Nd create and maintain library archives -.Sh SYNOPSIS -.Nm ar -.Fl d -.Op Fl \Tv -.Ar archive -.Op Ar -.Nm ar -.Fl m -.Op Fl \Tv -.Ar archive -.Op Ar -.Nm ar -.Fl m -.Op Fl abiTv -.Ar position archive -.Op Ar -.Nm ar -.Fl p -.Op Fl \Tv -.Ar archive -.Op Ar -.Nm ar -.Fl q -.Op Fl cTv -.Ar archive -.Op Ar -.Nm ar -.Fl r -.Op Fl cuTv -.Ar archive -.Op Ar -.Nm ar -.Fl r -.Op Fl abciuTv -.Ar position archive -.Op Ar -.Nm ar -.Fl t -.Op Fl \Tv -.Ar archive -.Op Ar -.Nm ar -.Fl x -.Op Fl CouTv -.Ar archive -.Op Ar -.Sh DESCRIPTION -The -.Nm -utility creates and maintains groups of files combined into an archive. -Once an archive has been created, new files can be added and existing -files can be extracted, deleted, or replaced. -.Pp -Files are named in the archive by a single component; i.e., if a file -referenced by a path containing a slash -.Pq Ql / -is archived it will be -named by the last component of that path. -When matching paths listed on the command line against file names stored -in the archive, only the last component of the path will be compared. -.Pp -All informational and error messages use the path listed on the command -line, if any was specified, otherwise the name in the archive is used. -If multiple files in the archive have the same name, and paths are listed -on the command line to -.Dq select -archive files for an operation, only the -.Em first -file with a matching name will be selected. -.Pp -The normal use of -.Nm -is for the creation and maintenance of libraries suitable for use with -the loader (see -.Xr ld 1 ) -although it is not restricted to this purpose. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl a -A positioning modifier used with the options -.Fl r -and -.Fl m . -The files are entered or moved -.Em after -the archive member -.Ar position , -which must be specified. -.It Fl b -A positioning modifier used with the options -.Fl r -and -.Fl m . -The files are entered or moved -.Em before -the archive member -.Ar position , -which must be specified. -.It Fl c -Whenever an archive is created, an informational message to that effect -is written to standard error. -If the -.Fl c -option is specified, -.Nm -creates the archive silently. -.It Fl C -Prevent extracted files from replacing like-named files in the file system. -.It Fl d -Delete the specified archive files. -.It Fl i -Identical to the -.Fl b -option. -.It Fl m -Move the specified archive files within the archive. -If one of the options -.Fl a , -.Fl b , -or -.Fl i -are specified, the files are moved before or after the -.Ar position -file in the archive. -If none of those options are specified, the files are moved -to the end of the archive. -.It Fl o -Set the access and modification times of extracted files to the -modification time of the file when it was entered into the archive. -This will fail if the user is not the owner of the extracted file -or the superuser. -.It Fl p -Write the contents of the specified archive files to the standard output. -If no files are specified, the contents of all the files in the archive -are written in the order they appear in the archive. -.It Fl q -(Quickly) append the specified files to the archive. -If the archive does not exist a new archive file is created. -Much faster than the -.Fl r -option, when creating a large archive -piece-by-piece, as no checking is done to see if the files already -exist in the archive. -.It Fl r -Replace or add the specified files to the archive. -If the archive does not exist a new archive file is created. -Files that replace existing files do not change the order of the files -within the archive. -New files are appended to the archive unless one of the options -.Fl a , -.Fl b , -or -.Fl i -is specified. -.It Fl T -Select and/or name archive members using only the first fifteen characters -of the archive member or command line file name. -The historic archive format had sixteen bytes for the name, but some -historic archiver and loader implementations were unable to handle names -that used the entire space. -This means that file names that are not unique in their first fifteen -characters can subsequently be confused. -A warning message is printed to the standard error if any file -names are truncated. -(See -.Xr ar 5 -for more information.) -.It Fl t -List the specified files in the order in which they appear in the archive, -each on a separate line. -If no files are specified, all files in the archive are listed. -.It Fl u -Update files. -When used with the -.Fl r -option, files in the archive will be replaced -only if the disk file has a newer modification time than the file in -the archive. -When used with the -.Fl x -option, files in the archive will be extracted -only if the archive file has a newer modification time than the file -on disk. -.It Fl v -Provide verbose output. -When used with the -.Fl d , -.Fl m , -.Fl q , -or -.Fl x -options, -.Nm -gives a file-by-file description of the archive modification. -This description consists of three, whitespace-separated fields: the -option letter, a dash -.Pq Ql - , -and the file name. -When used with the -.Fl r -option, -.Nm -displays the description as above, but the initial letter is an -.Sq a -if -the file is added to the archive and an -.Sq r -if the file replaces a file -already in the archive. -.Pp -When used with the -.Fl p -option, -the name of each printed file is written to the standard output before -the contents of the file, preceded by a single newline character, and -followed by two newline characters, enclosed in less-than -.Pq Ql < -and -greater-than -.Pq Ql > -characters. -.Pp -When used with the -.Fl t -option, -.Nm -displays an -.Dq ls -l -style listing of information about the members of -the archive. -This listing consists of eight, whitespace-separated fields: -the file permissions (see -.Xr strmode 3 ) , -the decimal user and group IDs, separated by a single slash -.Pq Ql / , -the file size (in bytes), the file modification time (in the -.Xr date 1 -format -.Dq %b %e %H:%M %Y ) , -and the name of the file. -.It Fl x -Extract the specified archive members into the files named by the command -line arguments. -If no members are specified, all the members of the archive are extracted into -the current directory. -.Pp -If the file does not exist, it is created; if it does exist, the owner -and group will be unchanged. -The file access and modification times are the time of the extraction -(but see the -.Fl o -option). -The file permissions will be set to those of the file when it was entered -into the archive; this will fail if the user is not the owner of the -extracted file or the superuser. -.El -.Sh ENVIRONMENT -.Bl -tag -width indent -compact -.It Ev TMPDIR -The pathname of the directory to use when creating temporary files. -.El -.Sh FILES -.Bl -tag -width ar.XXXXXXXXXX -compact -.It Pa /tmp -default temporary file directory -.It Pa ar.XXXXXXXXXX -temporary file names -.El -.Sh EXIT STATUS -.Ex -std ar -.Sh SEE ALSO -.Xr ld 1 , -.Xr ranlib 1 , -.Xr strmode 3 , -.Xr ar 5 -.Sh STANDARDS -By default, -.Nm -writes archives that may be incompatible with historic archives, as -the format used for storing archive members with names longer than -fifteen characters has changed. -This implementation of -.Nm -is backward compatible with previous versions of -.Nm -in that it can read and write (using the -.Fl T -option) historic archives. -The -.Fl T -option is provided for compatibility only, and will be deleted -in a future release. -See -.Xr ar 5 -for more information. -.Pp -The -.Nm -utility is expected to offer a superset of the -.St -p1003.2 -functionality. diff --git a/usr.bin/ar/ar.5 b/usr.bin/ar/ar.5 deleted file mode 100644 index 8fe48f94472..00000000000 --- a/usr.bin/ar/ar.5 +++ /dev/null @@ -1,145 +0,0 @@ -.\" $OpenBSD: ar.5,v 1.9 2007/05/31 19:20:07 jmc Exp $ -.\" $NetBSD: ar.5,v 1.2 1995/03/25 06:39:38 glass Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. 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. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)ar.5.5 8.1 (Berkeley) 6/9/93 -.\" -.Dd $Mdocdate: May 31 2007 $ -.Dt AR 5 -.Os -.Sh NAME -.Nm ar -.Nd archive (library) file format -.Sh SYNOPSIS -.Fd #include <ar.h> -.Sh DESCRIPTION -The archive command -.Nm ar -combines several files into one. -Archives are mainly used as libraries of object files intended to be -loaded using the link-editor -.Xr ld 1 . -.Pp -A file created with -.Nm ar -begins with the ``magic'' string "!<arch>\en". -The rest of the archive is made up of objects, each of which is composed -of a header for a file, a possible file name, and the file contents. -The header is portable between machine architectures, and, if the file -contents are printable, the archive is itself printable. -.Pp -The header is made up of six variable length -.Tn ASCII -fields, followed by a -two character trailer. -The fields are the object name (16 characters), the file last modification -time (12 characters), the user and group IDs (each 6 characters), the file -mode (8 characters) and the file size (10 characters). -All numeric fields are in decimal, except for the file mode which is in -octal. -.Pp -The modification time is the file -.Fa st_mtime -field, i.e., -.Dv CUT -seconds since -the Epoch. -The user and group IDs are the file -.Fa st_uid -and -.Fa st_gid -fields. -The file mode is the file -.Fa st_mode -field. -The file size is the file -.Fa st_size -field. -The two-byte trailer is the string "\`\en". -.Pp -Only the name field has any provision for overflow. -If any file name is more than 16 characters in length or contains an -embedded space, the string "#1/" followed by the -.Tn ASCII -length of the -name is written in the name field. -The file size (stored in the archive header) is incremented by the length -of the name. -The name is then written immediately following the archive header. -.Pp -Any unused characters in any of these fields are written as space -characters. -If any fields are their particular maximum number of characters in -length, there will be no separation between the fields. -.Pp -Objects in the archive are always an even number of bytes long; files -which are an odd number of bytes long are padded with a newline (`\en') -character, although the size in the header does not reflect this. -.Sh SEE ALSO -.Xr ar 1 , -.Xr stat 2 -.Sh STANDARDS -No archive format is currently specified by any standard. -.At V -has historically distributed archives in a different format from -all of the above. -.Sh HISTORY -There have been at least four -.Nm ar -formats. -The first was denoted by the leading ``magic'' number 0177555 (stored as -type int). -These archives were almost certainly created on a 16-bit machine, and -contain headers made up of five fields. -The fields are the object name (8 characters), the file last modification -time (type long), the user ID (type char), the file mode (type char) and -the file size (type unsigned int). -Files were padded to an even number of bytes. -.Pp -The second was denoted by the leading ``magic'' number 0177545 (stored as -type int). -These archives may have been created on either 16 or 32-bit machines, and -contain headers made up of six fields. -The fields are the object name (14 characters), the file last modification -time (type long), the user and group IDs (each type char), the file mode -(type int) and the file size (type long). -Files were padded to an even number of bytes. -.\" For more information on converting from this format see -.\" .Xr arcv 8 . -.Pp -The current archive format (without support for long character names and -names with embedded spaces) was introduced in -.Bx 4.0 . -The headers were the same as the current format, with the exception that -names longer than 16 characters were truncated, and names with embedded -spaces (and often trailing spaces) were not supported. -It has been extended for these reasons, -as described above. -This format first appeared in -.Bx 4.4 . diff --git a/usr.bin/ar/ar.c b/usr.bin/ar/ar.c deleted file mode 100644 index bbd527f277a..00000000000 --- a/usr.bin/ar/ar.c +++ /dev/null @@ -1,223 +0,0 @@ -/* $OpenBSD: ar.c,v 1.12 2009/10/27 23:59:35 deraadt Exp $ */ -/* $NetBSD: ar.c,v 1.5 1995/03/26 03:27:44 glass Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/param.h> - -#include <ar.h> -#include <dirent.h> -#include <err.h> -#include <paths.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "archive.h" -#include "extern.h" - -CHDR chdr; -u_int options; -char *archive, *envtmp, *posarg, *posname; -static void badoptions(char *); -static void usage(void); - -/* - * main -- - * main basically uses getopt to parse options and calls the appropriate - * functions. Some hacks that let us be backward compatible with 4.3 ar - * option parsing and sanity checking. - */ -int -main(int argc, char *argv[]) -{ - int c; - char *p; - int (*fcall)(char **); - - if (argc < 3) - usage(); - - /* - * Historic versions didn't require a '-' in front of the options. - * Fix it, if necessary. - */ - if (*argv[1] != '-') { - size_t len; - - len = (u_int)(strlen(argv[1]) + 2); - if (!(p = malloc(len))) - err(1, NULL); - *p = '-'; - (void)strlcpy(p + 1, argv[1], len - 1); - argv[1] = p; - } - - while ((c = getopt(argc, argv, "abcCdilmopqrTtuvx")) != -1) { - switch(c) { - case 'a': - options |= AR_A; - break; - case 'b': - case 'i': - options |= AR_B; - break; - case 'c': - options |= AR_C; - break; - case 'C': - options |= AR_CC; - break; - case 'd': - options |= AR_D; - fcall = delete; - break; - case 'l': /* not documented, compatibility only */ - envtmp = "."; - break; - case 'm': - options |= AR_M; - fcall = move; - break; - case 'o': - options |= AR_O; - break; - case 'p': - options |= AR_P; - fcall = print; - break; - case 'q': - options |= AR_Q; - fcall = append; - break; - case 'r': - options |= AR_R; - fcall = replace; - break; - case 'T': - options |= AR_TR; - break; - case 't': - options |= AR_T; - fcall = contents; - break; - case 'u': - options |= AR_U; - break; - case 'v': - options |= AR_V; - break; - case 'x': - options |= AR_X; - fcall = extract; - break; - default: - usage(); - } - } - - argv += optind; - argc -= optind; - - /* One of -dmpqrtx required. */ - if (!(options & (AR_D|AR_M|AR_P|AR_Q|AR_R|AR_T|AR_X))) { - warnx("one of options -dmpqrtx is required"); - usage(); - } - /* Only one of -a and -bi allowed. */ - if (options & AR_A && options & AR_B) { - warnx("only one of -a and -[bi] options allowed"); - usage(); - } - /* -ab require a position argument. */ - if (options & (AR_A|AR_B)) { - if (!(posarg = *argv++)) { - warnx("no position operand specified"); - usage(); - } - posname = rname(posarg); - } - /* -d only valid with -Tv. */ - if (options & AR_D && options & ~(AR_D|AR_TR|AR_V)) - badoptions("-d"); - /* -m only valid with -abiTv. */ - if (options & AR_M && options & ~(AR_A|AR_B|AR_M|AR_TR|AR_V)) - badoptions("-m"); - /* -p only valid with -Tv. */ - if (options & AR_P && options & ~(AR_P|AR_TR|AR_V)) - badoptions("-p"); - /* -q only valid with -cTv. */ - if (options & AR_Q && options & ~(AR_C|AR_Q|AR_TR|AR_V)) - badoptions("-q"); - /* -r only valid with -abcuTv. */ - if (options & AR_R && options & ~(AR_A|AR_B|AR_C|AR_R|AR_U|AR_TR|AR_V)) - badoptions("-r"); - /* -t only valid with -Tv. */ - if (options & AR_T && options & ~(AR_T|AR_TR|AR_V)) - badoptions("-t"); - /* -x only valid with -CouTv. */ - if (options & AR_X && options & ~(AR_O|AR_U|AR_TR|AR_V|AR_X|AR_CC)) - badoptions("-x"); - - if (!(archive = *argv++)) { - warnx("no archive specified"); - usage(); - } - - exit((*fcall)(argv)); -} - -static void -badoptions(char *arg) -{ - - warnx("illegal option combination for %s", arg); - usage(); -} - -static void -usage(void) -{ - - (void)fprintf(stderr, "usage: ar -d [-Tv] archive file ...\n"); - (void)fprintf(stderr, "\tar -m [-Tv] archive file ...\n"); - (void)fprintf(stderr, "\tar -m [-abiTv] position archive file ...\n"); - (void)fprintf(stderr, "\tar -p [-Tv] archive [file ...]\n"); - (void)fprintf(stderr, "\tar -q [-cTv] archive file ...\n"); - (void)fprintf(stderr, "\tar -r [-cuTv] archive file ...\n"); - (void)fprintf(stderr, "\tar -r [-abciuTv] position archive file ...\n"); - (void)fprintf(stderr, "\tar -t [-Tv] archive [file ...]\n"); - (void)fprintf(stderr, "\tar -x [-CouTv] archive [file ...]\n"); - exit(1); -} diff --git a/usr.bin/ar/archive.c b/usr.bin/ar/archive.c deleted file mode 100644 index b56f7c45b9c..00000000000 --- a/usr.bin/ar/archive.c +++ /dev/null @@ -1,329 +0,0 @@ -/* $OpenBSD: archive.c,v 1.13 2013/04/17 20:17:32 deraadt Exp $ */ -/* $NetBSD: archive.c,v 1.7 1995/03/26 03:27:46 glass Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/param.h> -#include <sys/stat.h> - -#include <ar.h> -#include <dirent.h> -#include <err.h> -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "archive.h" -#include "extern.h" - -typedef struct ar_hdr HDR; -static char hb[sizeof(HDR) + 1]; /* real header */ - -int -open_archive(int mode) -{ - int created, fd, nr; - char buf[SARMAG]; - - created = 0; - if (mode & O_CREAT) { - mode |= O_EXCL; - if ((fd = open(archive, mode, DEFFILEMODE)) >= 0) { - /* POSIX.2 puts create message on stderr. */ - if (!(options & AR_C)) - warnx("creating archive %s", archive); - created = 1; - goto opened; - } - if (errno != EEXIST) - error(archive); - mode &= ~O_EXCL; - } - if ((fd = open(archive, mode, DEFFILEMODE)) < 0) - error(archive); - - /* - * Attempt to place a lock on the opened file - if we get an - * error then someone is already working on this library (or - * it's going across NFS). - */ -opened: if (flock(fd, LOCK_EX|LOCK_NB) && errno != EOPNOTSUPP) - error(archive); - - /* - * If not created, O_RDONLY|O_RDWR indicates that it has to be - * in archive format. - */ - if (!created && - ((mode & O_ACCMODE) == O_RDONLY || (mode & O_ACCMODE) == O_RDWR)) { - if ((nr = read(fd, buf, SARMAG) != SARMAG)) { - if (nr >= 0) - badfmt(); - error(archive); - } else if (bcmp(buf, ARMAG, SARMAG)) - badfmt(); - } else if (write(fd, ARMAG, SARMAG) != SARMAG) - error(archive); - return (fd); -} - -void -close_archive(int fd) -{ - - (void)close(fd); /* Implicit unlock. */ -} - -/* Convert ar header field to an integer. */ -#define AR_ATOI(from, to, len, base) { \ - memmove(buf, from, len); \ - buf[len] = '\0'; \ - to = strtol(buf, NULL, base); \ -} - -/* - * get_arobj -- - * read the archive header for this member - */ -int -get_arobj(int fd) -{ - struct ar_hdr *hdr; - int len, nr; - char *p, buf[20]; - - nr = read(fd, hb, sizeof(HDR)); - if (nr != sizeof(HDR)) { - if (!nr) - return (0); - if (nr < 0) - error(archive); - badfmt(); - } - - hdr = (struct ar_hdr *)hb; - if (strncmp(hdr->ar_fmag, ARFMAG, sizeof(ARFMAG) - 1)) - badfmt(); - - /* Convert the header into the internal format. */ -#define DECIMAL 10 -#define OCTAL 8 - - /* XXX ar_date 2038 */ - AR_ATOI(hdr->ar_date, chdr.date, sizeof(hdr->ar_date), DECIMAL); - AR_ATOI(hdr->ar_uid, chdr.uid, sizeof(hdr->ar_uid), DECIMAL); - AR_ATOI(hdr->ar_gid, chdr.gid, sizeof(hdr->ar_gid), DECIMAL); - AR_ATOI(hdr->ar_mode, chdr.mode, sizeof(hdr->ar_mode), OCTAL); - AR_ATOI(hdr->ar_size, chdr.size, sizeof(hdr->ar_size), DECIMAL); - - /* Leading spaces should never happen. */ - if (hdr->ar_name[0] == ' ') - badfmt(); - - /* - * Long name support. Set the "real" size of the file, and the - * long name flag/size. - */ - if (!bcmp(hdr->ar_name, AR_EFMT1, sizeof(AR_EFMT1) - 1)) { - chdr.lname = len = atoi(hdr->ar_name + sizeof(AR_EFMT1) - 1); - if (len <= 0 || len > MAXNAMLEN) - badfmt(); - nr = read(fd, chdr.name, len); - if (nr != len) { - if (nr < 0) - error(archive); - badfmt(); - } - chdr.name[len] = 0; - chdr.size -= len; - } else { - chdr.lname = 0; - memmove(chdr.name, hdr->ar_name, sizeof(hdr->ar_name)); - - /* Strip trailing spaces, null terminate. */ - for (p = chdr.name + sizeof(hdr->ar_name) - 1; *p == ' '; --p); - *++p = '\0'; - } - return (1); -} - -static int already_written; - -/* - * put_arobj -- - * Write an archive member to a file. - */ -void -put_arobj(CF *cfp, struct stat *sb) -{ - int lname; - char *name; - struct ar_hdr *hdr; - off_t size; - uid_t uid; - gid_t gid; - - /* - * If passed an sb structure, reading a file from disk. Get stat(2) - * information, build a name and construct a header. (Files are named - * by their last component in the archive.) If not, then just write - * the last header read. - */ - if (sb) { - name = rname(cfp->rname); - (void)fstat(cfp->rfd, sb); - - /* - * If not truncating names and the name is too long or contains - * a space, use extended format 1. - */ - lname = strlen(name); - uid = sb->st_uid; - gid = sb->st_gid; - if (uid > USHRT_MAX) { - warnx("warning: uid %u truncated to %u", uid, - USHRT_MAX); - uid = USHRT_MAX; - } - if (gid > USHRT_MAX) { - warnx("warning: gid %u truncated to %u", gid, - USHRT_MAX); - gid = USHRT_MAX; - } - if (options & AR_TR) { - if (lname > OLDARMAXNAME) { - (void)fflush(stdout); - warnx("warning: file name %s truncated to %.*s", - name, OLDARMAXNAME, name); - (void)fflush(stderr); - } - (void)snprintf(hb, sizeof hb, - HDR3, name, (long long)sb->st_mtimespec.tv_sec, - uid, gid, sb->st_mode, sb->st_size, ARFMAG); - lname = 0; - } else if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) - (void)snprintf(hb, sizeof hb, - HDR1, AR_EFMT1, lname, - (long long)sb->st_mtimespec.tv_sec, - uid, gid, sb->st_mode, sb->st_size + lname, ARFMAG); - else { - lname = 0; - (void)snprintf(hb, sizeof hb, - HDR2, name, (long long)sb->st_mtimespec.tv_sec, - uid, gid, sb->st_mode, sb->st_size, ARFMAG); - } - size = sb->st_size; - } else { - lname = chdr.lname; - name = chdr.name; - size = chdr.size; - } - - if (write(cfp->wfd, hb, sizeof(HDR)) != sizeof(HDR)) - error(cfp->wname); - if (lname) { - if (write(cfp->wfd, name, lname) != lname) - error(cfp->wname); - already_written = lname; - } - copy_ar(cfp, size); - already_written = 0; -} - -/* - * copy_ar -- - * Copy size bytes from one file to another - taking care to handle the - * extra byte (for odd size files) when reading archives and writing an - * extra byte if necessary when adding files to archive. The length of - * the object is the long name plus the object itself; the variable - * already_written gets set if a long name was written. - * - * The padding is really unnecessary, and is almost certainly a remnant - * of early archive formats where the header included binary data which - * a PDP-11 required to start on an even byte boundary. (Or, perhaps, - * because 16-bit word addressed copies were faster?) Anyhow, it should - * have been ripped out long ago. - */ -void -copy_ar(CF *cfp, off_t size) -{ - static char pad = '\n'; - off_t sz; - int from, nr, nw, off, to; - char buf[8*1024]; - - if (!(sz = size)) - return; - - from = cfp->rfd; - to = cfp->wfd; - sz = size; - while (sz && (nr = read(from, buf, MIN(sz, sizeof(buf)))) > 0) { - sz -= nr; - for (off = 0; off < nr; nr -= off, off += nw) - if ((nw = write(to, buf + off, nr)) < 0) - error(cfp->wname); - } - if (sz) { - if (nr == 0) - badfmt(); - error(cfp->rname); - } - - if (cfp->flags & RPAD && (size + chdr.lname) & 1 && - (nr = read(from, buf, 1)) != 1) { - if (nr == 0) - badfmt(); - error(cfp->rname); - } - if (cfp->flags & WPAD && (size + already_written) & 1 && - write(to, &pad, 1) != 1) - error(cfp->wname); -} - -/* - * skip_arobj - - * Skip over an object -- taking care to skip the pad bytes. - */ -void -skip_arobj(int fd) -{ - off_t len; - - len = chdr.size + (chdr.size + chdr.lname & 1); - if (lseek(fd, len, SEEK_CUR) == (off_t)-1) - error(archive); -} diff --git a/usr.bin/ar/archive.h b/usr.bin/ar/archive.h deleted file mode 100644 index 233f98348d5..00000000000 --- a/usr.bin/ar/archive.h +++ /dev/null @@ -1,103 +0,0 @@ -/* $OpenBSD: archive.h,v 1.7 2013/04/17 20:17:32 deraadt Exp $ */ -/* $NetBSD: archive.h,v 1.6 1995/03/25 06:39:43 glass Exp $ */ - -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)archive.h 8.3 (Berkeley) 4/2/94 - */ - -/* Ar(1) options. */ -#define AR_A 0x0001 -#define AR_B 0x0002 -#define AR_C 0x0004 -#define AR_D 0x0008 -#define AR_M 0x0010 -#define AR_O 0x0020 -#define AR_P 0x0040 -#define AR_Q 0x0080 -#define AR_R 0x0100 -#define AR_T 0x0200 -#define AR_TR 0x0400 -#define AR_U 0x0800 -#define AR_V 0x1000 -#define AR_X 0x2000 -#define AR_CC 0x4000 -extern u_int options; - -/* Set up file copy. */ -#define SETCF(from, fromname, to, toname, pad) { \ - cf.rfd = from; \ - cf.rname = fromname; \ - cf.wfd = to; \ - cf.wname = toname; \ - cf.flags = pad; \ -} - -/* File copy structure. */ -typedef struct { - int rfd; /* read file descriptor */ - char *rname; /* read name */ - int wfd; /* write file descriptor */ - char *wname; /* write name */ -#define NOPAD 0x00 /* don't pad */ -#define RPAD 0x01 /* pad on reads */ -#define WPAD 0x02 /* pad on writes */ - u_int flags; /* pad flags */ -} CF; - -/* Header structure internal format. */ -typedef struct { - off_t size; /* size of the object in bytes */ - time_t date; /* date */ - int lname; /* size of the long name in bytes */ - gid_t gid; /* group */ - uid_t uid; /* owner */ - u_short mode; /* permissions */ - char name[MAXNAMLEN + 1]; /* name */ -} CHDR; - -/* Header format strings. */ -#define HDR1 "%s%-13d%-12lld%-6u%-6u%-8o%-10qd%2s" -#define HDR2 "%-16.16s%-12lld%-6u%-6u%-8o%-10qd%2s" - -#define OLDARMAXNAME 15 -#define HDR3 "%-16.15s%-12lld%-6u%-6u%-8o%-10qd%2s" - - -struct stat; - -void close_archive(int); -void copy_ar(CF *, off_t); -int get_arobj(int); -int open_archive(int); -void put_arobj(CF *, struct stat *); -void skip_arobj(int); diff --git a/usr.bin/ar/contents.c b/usr.bin/ar/contents.c deleted file mode 100644 index 74f55575817..00000000000 --- a/usr.bin/ar/contents.c +++ /dev/null @@ -1,90 +0,0 @@ -/* $OpenBSD: contents.c,v 1.5 2009/10/27 23:59:35 deraadt Exp $ */ -/* $NetBSD: contents.c,v 1.5 1995/03/26 03:27:49 glass Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/param.h> -#include <sys/stat.h> -#include <sys/time.h> - -#include <ar.h> -#include <dirent.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <tzfile.h> -#include <unistd.h> - -#include "archive.h" -#include "extern.h" - -/* - * contents -- - * Handles t[v] option - opens the archive and then reads headers, - * skipping member contents. - */ -int -contents(char **argv) -{ - int afd, all; - struct tm *tp; - char *file, buf[25]; - - afd = open_archive(O_RDONLY); - - for (all = !*argv; get_arobj(afd);) { - if (all) - file = chdr.name; - else if (!(file = files(argv))) - goto next; - if (options & AR_V) { - (void)strmode(chdr.mode, buf); - (void)printf("%s %6d/%-6d %8qd ", - buf + 1, chdr.uid, chdr.gid, chdr.size); - tp = localtime(&chdr.date); - (void)strftime(buf, sizeof(buf), "%b %e %H:%M %Y", tp); - (void)printf("%s %s\n", buf, file); - } else - (void)printf("%s\n", file); - if (!all && !*argv) - break; -next: skip_arobj(afd); - } - close_archive(afd); - - if (*argv) { - orphans(argv); - return (1); - } - return (0); -} diff --git a/usr.bin/ar/delete.c b/usr.bin/ar/delete.c deleted file mode 100644 index 583df4b2e2e..00000000000 --- a/usr.bin/ar/delete.c +++ /dev/null @@ -1,90 +0,0 @@ -/* $OpenBSD: delete.c,v 1.6 2009/10/27 23:59:35 deraadt Exp $ */ -/* $NetBSD: delete.c,v 1.5 1995/03/26 03:27:52 glass Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/param.h> -#include <sys/stat.h> - -#include <ar.h> -#include <dirent.h> -#include <fcntl.h> -#include <stdio.h> -#include <unistd.h> - -#include "archive.h" -#include "extern.h" -#include "pathnames.h" - -/*- - * delete -- - * Deletes named members from the archive. - */ -int -delete(char **argv) -{ - CF cf; - off_t size; - int afd, tfd; - char *file; - - afd = open_archive(O_RDWR); - tfd = tmp(); - - /* Read and write to an archive; pad on both. */ - SETCF(afd, archive, tfd, tname, RPAD|WPAD); - while (get_arobj(afd)) { - if (*argv && (file = files(argv))) { - if (options & AR_V) - (void)printf("d - %s\n", file); - skip_arobj(afd); - continue; - } - put_arobj(&cf, NULL); - } - - size = lseek(tfd, (off_t)0, SEEK_CUR); - (void)lseek(tfd, (off_t)0, SEEK_SET); - (void)lseek(afd, (off_t)SARMAG, SEEK_SET); - SETCF(tfd, tname, afd, archive, NOPAD); - copy_ar(&cf, size); - (void)close(tfd); - (void)ftruncate(afd, size + SARMAG); - close_archive(afd); - - if (*argv) { - orphans(argv); - return (1); - } - return (0); -} diff --git a/usr.bin/ar/extern.h b/usr.bin/ar/extern.h deleted file mode 100644 index 602de1d6486..00000000000 --- a/usr.bin/ar/extern.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: extern.h,v 1.4 2003/06/03 02:56:05 millert Exp $ */ -/* $NetBSD: extern.h,v 1.4 1995/03/25 06:39:46 glass Exp $ */ - -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)extern.h 8.3 (Berkeley) 4/2/94 - */ - -int append(char **); -void badfmt(void); -int compare(char *); -int contents(char **); -int delete(char **); -void error(char *); -int extract(char **); -char *files(char **argv); -int move(char **); -void orphans(char **argv); -int print(char **); -int replace(char **); -char *rname(char *); -int tmp(void); - -extern char *archive; -extern char *posarg, *posname; /* positioning file name */ -extern char *tname; /* temporary file "name" */ -extern CHDR chdr; /* converted header */ diff --git a/usr.bin/ar/extract.c b/usr.bin/ar/extract.c deleted file mode 100644 index 32ca1d94a15..00000000000 --- a/usr.bin/ar/extract.c +++ /dev/null @@ -1,133 +0,0 @@ -/* $OpenBSD: extract.c,v 1.8 2009/10/27 23:59:35 deraadt Exp $ */ -/* $NetBSD: extract.c,v 1.5 1995/03/26 03:27:53 glass Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/param.h> -#include <sys/time.h> -#include <sys/stat.h> - -#include <dirent.h> -#include <err.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -#include "archive.h" -#include "extern.h" - -/* - * extract -- - * Extract files from the named archive - if member names given only - * extract those members otherwise extract all members. If 'o' option - * selected modify date of newly created file to be same as archive - * members date otherwise date is time of extraction. Does not modify - * archive. - */ -int -extract(char **argv) -{ - char *file; - int afd, all, eval, tfd; - struct timeval tv[2]; - struct stat sb; - CF cf; - - eval = 0; - tv[0].tv_usec = tv[1].tv_usec = 0; - - afd = open_archive(O_RDONLY); - - /* Read from an archive, write to disk; pad on read. */ - SETCF(afd, archive, 0, 0, RPAD); - for (all = !*argv; get_arobj(afd);) { - if (all) - file = chdr.name; - else if (!(file = files(argv))) { - skip_arobj(afd); - continue; - } - - if (options & AR_U && !stat(file, &sb) && - sb.st_mtime > chdr.date) - continue; - - if (options & AR_CC) { - /* -C means do not overwrite existing files */ - if ((tfd = open(file, O_WRONLY|O_CREAT|O_EXCL, - S_IWUSR)) < 0) { - skip_arobj(afd); - eval = 1; - continue; - } - } else { - if ((tfd = open(file, O_WRONLY|O_CREAT|O_TRUNC, - S_IWUSR)) < 0) { - warn("%s", file); - skip_arobj(afd); - eval = 1; - continue; - } - } - - if (options & AR_V) - (void)printf("x - %s\n", file); - - cf.wfd = tfd; - cf.wname = file; - copy_ar(&cf, chdr.size); - - if (fchmod(tfd, (mode_t)chdr.mode)) { - warn("chmod: %s", file); - eval = 1; - } - if (options & AR_O) { - tv[0].tv_sec = tv[1].tv_sec = chdr.date; - if (futimes(tfd, tv)) { - warn("utimes: %s", file); - eval = 1; - } - } - (void)close(tfd); - if (!all && !*argv) - break; - } - close_archive(afd); - - if (*argv) { - orphans(argv); - return (1); - } - return (0); -} diff --git a/usr.bin/ar/misc.c b/usr.bin/ar/misc.c deleted file mode 100644 index 4c4c57b87d6..00000000000 --- a/usr.bin/ar/misc.c +++ /dev/null @@ -1,140 +0,0 @@ -/* $OpenBSD: misc.c,v 1.7 2009/10/27 23:59:35 deraadt Exp $ */ -/* $NetBSD: misc.c,v 1.6 1995/03/26 03:27:55 glass Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/param.h> - -#include <dirent.h> -#include <err.h> -#include <errno.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "archive.h" -#include "extern.h" -#include "pathnames.h" - -char *tname = "temporary file"; /* temporary file "name" */ - -int -tmp(void) -{ - extern char *envtmp; - sigset_t set, oset; - static int first; - int fd; - char path[MAXPATHLEN]; - - if (!first && !envtmp) { - envtmp = getenv("TMPDIR"); - first = 1; - } - - if (envtmp) - (void)snprintf(path, sizeof(path), "%s/%s", envtmp, - _NAME_ARTMP); - else - strlcpy(path, _PATH_ARTMP, sizeof(path)); - - sigfillset(&set); - (void)sigprocmask(SIG_BLOCK, &set, &oset); - if ((fd = mkstemp(path)) == -1) - error(tname); - (void)unlink(path); - (void)sigprocmask(SIG_SETMASK, &oset, NULL); - return (fd); -} - -/* - * files -- - * See if the current file matches any file in the argument list; if it - * does, remove it from the argument list. - */ -char * -files(char **argv) -{ - char **list, *p; - - for (list = argv; *list; ++list) - if (compare(*list)) { - p = *list; - for (; (list[0] = list[1]); ++list) - continue; - return (p); - } - return (NULL); -} - -void -orphans(char **argv) -{ - - for (; *argv; ++argv) - warnx("%s: not found in archive", *argv); -} - -char * -rname(char *path) -{ - char *ind; - - return ((ind = strrchr(path, '/')) ? ind + 1 : path); -} - -int -compare(char *dest) -{ - - if (options & AR_TR) - return (!strncmp(chdr.name, rname(dest), OLDARMAXNAME)); - return (!strcmp(chdr.name, rname(dest))); -} - -void -badfmt(void) -{ - - errno = EFTYPE; - err(1, "%s", archive); -} - -void -error(char *name) -{ - - err(1, "%s", name); -} diff --git a/usr.bin/ar/move.c b/usr.bin/ar/move.c deleted file mode 100644 index 5cae8cd063f..00000000000 --- a/usr.bin/ar/move.c +++ /dev/null @@ -1,134 +0,0 @@ -/* $OpenBSD: move.c,v 1.6 2009/10/27 23:59:35 deraadt Exp $ */ -/* $NetBSD: move.c,v 1.5 1995/03/26 03:27:57 glass Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/param.h> -#include <sys/stat.h> - -#include <ar.h> -#include <dirent.h> -#include <err.h> -#include <fcntl.h> -#include <stdio.h> -#include <unistd.h> - -#include "archive.h" -#include "extern.h" -#include "pathnames.h" - -/* - * move -- - * Change location of named members in archive - if 'b' or 'i' option - * selected then named members are placed before 'posname'. If 'a' - * option selected members go after 'posname'. If no options, members - * are moved to end of archive. - */ -int -move(char **argv) -{ - CF cf; - off_t size, tsize; - int afd, curfd, mods, tfd1, tfd2, tfd3; - char *file; - - afd = open_archive(O_RDWR); - mods = options & (AR_A|AR_B); - - tfd1 = tmp(); /* Files before key file. */ - tfd2 = tmp(); /* Files selected by user. */ - tfd3 = tmp(); /* Files after key file. */ - - /* - * Break archive into three parts -- selected entries and entries - * before and after the key entry. If positioning before the key, - * place the key at the beginning of the after key entries and if - * positioning after the key, place the key at the end of the before - * key entries. Put it all back together at the end. - */ - - /* Read and write to an archive; pad on both. */ - SETCF(afd, archive, 0, tname, RPAD|WPAD); - for (curfd = tfd1; get_arobj(afd);) { - if (*argv && (file = files(argv))) { - if (options & AR_V) - (void)printf("m - %s\n", file); - cf.wfd = tfd2; - put_arobj(&cf, NULL); - continue; - } - if (mods && compare(posname)) { - mods = 0; - if (options & AR_B) - curfd = tfd3; - cf.wfd = curfd; - put_arobj(&cf, NULL); - if (options & AR_A) - curfd = tfd3; - } else { - cf.wfd = curfd; - put_arobj(&cf, NULL); - } - } - - if (mods) { - warnx("%s: archive member not found", posarg); - close_archive(afd); - return (1); - } - (void)lseek(afd, (off_t)SARMAG, SEEK_SET); - - SETCF(tfd1, tname, afd, archive, NOPAD); - tsize = size = lseek(tfd1, (off_t)0, SEEK_CUR); - (void)lseek(tfd1, (off_t)0, SEEK_SET); - copy_ar(&cf, size); - - tsize += size = lseek(tfd2, (off_t)0, SEEK_CUR); - (void)lseek(tfd2, (off_t)0, SEEK_SET); - cf.rfd = tfd2; - copy_ar(&cf, size); - - tsize += size = lseek(tfd3, (off_t)0, SEEK_CUR); - (void)lseek(tfd3, (off_t)0, SEEK_SET); - cf.rfd = tfd3; - copy_ar(&cf, size); - - (void)ftruncate(afd, tsize + SARMAG); - close_archive(afd); - - if (*argv) { - orphans(argv); - return (1); - } - return (0); -} diff --git a/usr.bin/ar/pathnames.h b/usr.bin/ar/pathnames.h deleted file mode 100644 index 7f042dda2c8..00000000000 --- a/usr.bin/ar/pathnames.h +++ /dev/null @@ -1,39 +0,0 @@ -/* $OpenBSD: pathnames.h,v 1.4 2003/06/03 02:56:05 millert Exp $ */ -/* $NetBSD: pathnames.h,v 1.4 1995/03/25 06:39:50 glass Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - */ - -#define _NAME_ARTMP "ar.XXXXXXXXXX" -#define _PATH_ARTMP "/tmp/ar.XXXXXXXXXX" diff --git a/usr.bin/ar/print.c b/usr.bin/ar/print.c deleted file mode 100644 index 41e34b045c7..00000000000 --- a/usr.bin/ar/print.c +++ /dev/null @@ -1,84 +0,0 @@ -/* $OpenBSD: print.c,v 1.5 2009/10/27 23:59:35 deraadt Exp $ */ -/* $NetBSD: print.c,v 1.5 1995/03/26 03:27:59 glass Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/param.h> - -#include <dirent.h> -#include <fcntl.h> -#include <stdio.h> -#include <unistd.h> - -#include "archive.h" -#include "extern.h" - -/* - * print -- - * Prints archive members on stdout - if member names given only - * print those members, otherwise print all members. - */ -int -print(char **argv) -{ - CF cf; - int afd, all; - char *file; - - afd = open_archive(O_RDONLY); - - /* Read from an archive, write to stdout; pad on read. */ - SETCF(afd, archive, STDOUT_FILENO, "stdout", RPAD); - for (all = !*argv; get_arobj(afd);) { - if (all) - file = chdr.name; - else if (!(file = files(argv))) { - skip_arobj(afd); - continue; - } - if (options & AR_V) { - (void)printf("\n<%s>\n\n", file); - (void)fflush(stdout); - } - copy_ar(&cf, chdr.size); - if (!all && !*argv) - break; - } - close_archive(afd); - - if (*argv) { - orphans(argv); - return (1); - } - return (0); -} diff --git a/usr.bin/ar/replace.c b/usr.bin/ar/replace.c deleted file mode 100644 index ffc59591a94..00000000000 --- a/usr.bin/ar/replace.c +++ /dev/null @@ -1,172 +0,0 @@ -/* $OpenBSD: replace.c,v 1.7 2009/10/27 23:59:35 deraadt Exp $ */ -/* $NetBSD: replace.c,v 1.6 1995/03/26 03:28:01 glass Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/param.h> -#include <sys/stat.h> - -#include <ar.h> -#include <dirent.h> -#include <err.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -#include "archive.h" -#include "extern.h" - -/* - * replace -- - * Replace or add named members to archive. Entries already in the - * archive are swapped in place. Others are added before or after - * the key entry, based on the a, b and i options. If the u option - * is specified, modification dates select for replacement. - */ -int -replace(char **argv) -{ - char *file; - int afd, curfd, errflg, exists, mods, sfd, tfd1, tfd2; - struct stat sb; - CF cf; - off_t size, tsize; - - errflg = 0; - /* - * If doesn't exist, simply append to the archive. There's - * a race here, but it's pretty short, and not worth fixing. - */ - exists = !stat(archive, &sb); - afd = open_archive(O_CREAT|O_RDWR); - - if (!exists) { - tfd1 = -1; - tfd2 = tmp(); - goto append; - } - - tfd1 = tmp(); /* Files before key file. */ - tfd2 = tmp(); /* Files after key file. */ - - /* - * Break archive into two parts -- entries before and after the key - * entry. If positioning before the key, place the key at the - * beginning of the after key entries and if positioning after the - * key, place the key at the end of the before key entries. Put it - * all back together at the end. - */ - mods = (options & (AR_A|AR_B)); - for (curfd = tfd1; get_arobj(afd);) { - if (*argv && (file = files(argv))) { - if ((sfd = open(file, O_RDONLY)) < 0) { - errflg = 1; - warn("%s", file); - goto useold; - } - (void)fstat(sfd, &sb); - if (options & AR_U && sb.st_mtime <= chdr.date) { - close(sfd); - goto useold; - } - - if (options & AR_V) - (void)printf("r - %s\n", file); - - /* Read from disk, write to an archive; pad on write */ - SETCF(sfd, file, curfd, tname, WPAD); - put_arobj(&cf, &sb); - (void)close(sfd); - skip_arobj(afd); - continue; - } - - if (mods && compare(posname)) { - mods = 0; - if (options & AR_B) - curfd = tfd2; - /* Read and write to an archive; pad on both. */ - SETCF(afd, archive, curfd, tname, RPAD|WPAD); - put_arobj(&cf, NULL); - if (options & AR_A) - curfd = tfd2; - } else { - /* Read and write to an archive; pad on both. */ -useold: SETCF(afd, archive, curfd, tname, RPAD|WPAD); - put_arobj(&cf, NULL); - } - } - - if (mods) { - warnx("%s: archive member not found", posarg); - close_archive(afd); - return (1); - } - - /* Append any left-over arguments to the end of the after file. */ -append: while ((file = *argv++)) { - if (options & AR_V) - (void)printf("a - %s\n", file); - if ((sfd = open(file, O_RDONLY)) < 0) { - errflg = 1; - warn("%s", file); - continue; - } - (void)fstat(sfd, &sb); - /* Read from disk, write to an archive; pad on write. */ - SETCF(sfd, file, - options & (AR_A|AR_B) ? tfd1 : tfd2, tname, WPAD); - put_arobj(&cf, &sb); - (void)close(sfd); - } - - (void)lseek(afd, (off_t)SARMAG, SEEK_SET); - - SETCF(tfd1, tname, afd, archive, NOPAD); - if (tfd1 != -1) { - tsize = size = lseek(tfd1, (off_t)0, SEEK_CUR); - (void)lseek(tfd1, (off_t)0, SEEK_SET); - copy_ar(&cf, size); - } else - tsize = 0; - - tsize += size = lseek(tfd2, (off_t)0, SEEK_CUR); - (void)lseek(tfd2, (off_t)0, SEEK_SET); - cf.rfd = tfd2; - copy_ar(&cf, size); - - (void)ftruncate(afd, tsize + SARMAG); - close_archive(afd); - return (errflg); -} diff --git a/usr.bin/ranlib/Makefile b/usr.bin/ranlib/Makefile deleted file mode 100644 index 04d7c95aea6..00000000000 --- a/usr.bin/ranlib/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $OpenBSD: Makefile,v 1.5 2013/07/05 21:29:51 miod Exp $ - -.include <bsd.own.mk> - -NOPROG= - -MAN+= ranlib.5 - -.include <bsd.prog.mk> diff --git a/usr.bin/ranlib/build.c b/usr.bin/ranlib/build.c deleted file mode 100644 index c88c7b807d3..00000000000 --- a/usr.bin/ranlib/build.c +++ /dev/null @@ -1,321 +0,0 @@ -/* $OpenBSD: build.c,v 1.14 2013/04/17 20:17:33 deraadt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/types.h> -#include <sys/stat.h> -#include <errno.h> -#include <fcntl.h> -#include <a.out.h> -#include <dirent.h> -#include <unistd.h> -#include <ar.h> -#include <limits.h> -#include <ranlib.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <archive.h> -#include <err.h> -#include "byte.c" -#include "extern.h" - - -extern CHDR chdr; /* converted header */ - -typedef struct _rlib { - struct _rlib *next; /* next structure */ - off_t pos; /* offset of defining archive file */ - char *sym; /* symbol */ - int symlen; /* strlen(sym) */ -} RLIB; -RLIB *rhead, **pnext; - -static FILE *fp; -static long symcnt; /* symbol count */ -static long tsymlen; /* total string length */ - -static int rexec(); -static void symobj(); - -int -build(void) -{ - CF cf; - int afd, tfd; - int current_mid; - off_t size; - - current_mid = -1; - afd = open_archive(O_RDWR); - fp = fdopen(afd, "r+"); - tfd = tmp(); - - SETCF(afd, archive, tfd, tname, RPAD|WPAD); - - /* Read through the archive, creating list of symbols. */ - symcnt = tsymlen = 0; - pnext = &rhead; - while(get_arobj(afd)) { - int new_mid; - - if (!strcmp(chdr.name, RANLIBMAG)) { - skip_arobj(afd); - continue; - } - new_mid = rexec(afd, tfd); - if (new_mid != -1) { - if (current_mid == -1) - current_mid = new_mid; - else if (new_mid != current_mid) - errx(1, "Mixed object format archive: %d / %d", - new_mid, current_mid); - } - put_arobj(&cf, (struct stat *)NULL); - } - *pnext = NULL; - - /* Create the symbol table. Endianess the same as last mid seen */ - symobj(current_mid); - - /* Copy the saved objects into the archive. */ - size = lseek(tfd, (off_t)0, SEEK_CUR); - (void)lseek(tfd, (off_t)0, SEEK_SET); - SETCF(tfd, tname, afd, archive, NOPAD); - copy_ar(&cf, size); - (void)ftruncate(afd, lseek(afd, (off_t)0, SEEK_CUR)); - (void)close(tfd); - - /* Set the time. */ - settime(afd); - close_archive(afd); - return(0); -} - -/* - * rexec - * Read the exec structure; ignore any files that don't look - * exactly right. Return MID. - * return -1 for files that don't look right. - * XXX it's hard to be sure when to ignore files, and when to error - * out. - */ -static int -rexec(int rfd, int wfd) -{ - RLIB *rp; - long nsyms; - int nr, symlen; - char *strtab = 0; - char *sym; - struct exec ebuf; - struct nlist nl; - off_t r_off, w_off; - long strsize; - int result = -1; - - /* Get current offsets for original and tmp files. */ - r_off = lseek(rfd, (off_t)0, SEEK_CUR); - w_off = lseek(wfd, (off_t)0, SEEK_CUR); - - /* Read in exec structure. */ - nr = read(rfd, (char *)&ebuf, sizeof(struct exec)); - if (nr != sizeof(struct exec)) - goto bad; - - /* Check magic number and symbol count. */ - if (BAD_OBJECT(ebuf) || ebuf.a_syms == 0) - goto bad; - fix_header_order(&ebuf); - - /* Seek to string table. */ - if (lseek(rfd, N_STROFF(ebuf) + r_off, SEEK_SET) == (off_t)-1) { - if (errno == EINVAL) - goto bad; - else - error(archive); - } - - /* Read in size of the string table. */ - nr = read(rfd, (char *)&strsize, sizeof(strsize)); - if (nr != sizeof(strsize)) - goto bad; - - strsize = fix_32_order(strsize, N_GETMID(ebuf)); - - /* Read in the string table. */ - strsize -= sizeof(strsize); - strtab = (char *)emalloc(strsize); - nr = read(rfd, strtab, strsize); - if (nr != strsize) - goto bad; - - /* Seek to symbol table. */ - if (fseek(fp, N_SYMOFF(ebuf) + r_off, SEEK_SET) == (off_t)-1) - goto bad; - - result = N_GETMID(ebuf); - /* For each symbol read the nlist entry and save it as necessary. */ - nsyms = ebuf.a_syms / sizeof(struct nlist); - while (nsyms--) { - if (!fread((char *)&nl, sizeof(struct nlist), 1, fp)) { - if (feof(fp)) - badfmt(); - error(archive); - } - fix_nlist_order(&nl, N_GETMID(ebuf)); - - /* Ignore if no name or local. */ - if (!nl.n_un.n_strx || !(nl.n_type & N_EXT)) - continue; - - /* - * If the symbol is an undefined external and the n_value - * field is non-zero, keep it. - */ - if ((nl.n_type & N_TYPE) == N_UNDF && !nl.n_value) - continue; - - /* First four bytes are the table size. */ - sym = strtab + nl.n_un.n_strx - sizeof(long); - symlen = strlen(sym) + 1; - - rp = (RLIB *)emalloc(sizeof(RLIB)); - rp->sym = (char *)emalloc(symlen); - bcopy(sym, rp->sym, symlen); - rp->symlen = symlen; - rp->pos = w_off; - - /* Build in forward order for "ar -m" command. */ - *pnext = rp; - pnext = &rp->next; - - ++symcnt; - tsymlen += symlen; - } - -bad: if (nr < 0) - error(archive); - free(strtab); - (void)lseek(rfd, (off_t)r_off, SEEK_SET); - return result; -} - -/* - * symobj -- - * Write the symbol table into the archive, computing offsets as - * writing. Use the right format depending on mid. - */ -static void -symobj(int mid) -{ - RLIB *rp, *rnext; - struct ranlib rn; - char hb[sizeof(struct ar_hdr) + 1], pad; - long ransize, size, stroff; - uid_t uid; - gid_t gid; - - /* Rewind the archive, leaving the magic number. */ - if (fseek(fp, (off_t)SARMAG, SEEK_SET) == (off_t)-1) - error(archive); - - /* Size of the ranlib archive file, pad if necessary. */ - ransize = sizeof(long) + - symcnt * sizeof(struct ranlib) + sizeof(long) + tsymlen; - if (ransize & 01) { - ++ransize; - pad = '\n'; - } else - pad = '\0'; - - uid = getuid(); - if (uid > USHRT_MAX) { - warnx("warning: uid %u truncated to %u", uid, USHRT_MAX); - uid = USHRT_MAX; - } - gid = getgid(); - if (gid > USHRT_MAX) { - warnx("warning: gid %u truncated to %u", gid, USHRT_MAX); - gid = USHRT_MAX; - } - - /* Put out the ranlib archive file header. */ -#define DEFMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) - (void)snprintf(hb, sizeof hb, HDR2, RANLIBMAG, (long long)0, uid, gid, - DEFMODE & ~umask(0), (off_t)ransize, ARFMAG); - if (!fwrite(hb, sizeof(struct ar_hdr), 1, fp)) - error(tname); - - /* First long is the size of the ranlib structure section. */ - size = fix_32_order(symcnt * sizeof(struct ranlib), mid); - if (!fwrite((char *)&size, sizeof(size), 1, fp)) - error(tname); - - /* Offset of the first archive file. */ - size = SARMAG + sizeof(struct ar_hdr) + ransize; - - /* - * Write out the ranlib structures. The offset into the string - * table is cumulative, the offset into the archive is the value - * set in rexec() plus the offset to the first archive file. - */ - for (rp = rhead, stroff = 0; rp; rp = rp->next) { - rn.ran_un.ran_strx = stroff; - stroff += rp->symlen; - rn.ran_off = size + rp->pos; - fix_ranlib_order(&rn, mid); - if (!fwrite((char *)&rn, sizeof(struct ranlib), 1, fp)) - error(archive); - } - - /* Second long is the size of the string table. */ - - size = fix_32_order(tsymlen, mid); - if (!fwrite((char *)&size, sizeof(size), 1, fp)) - error(tname); - - /* Write out the string table. */ - for (rp = rhead; rp; rp = rnext) { - if (!fwrite(rp->sym, rp->symlen, 1, fp)) - error(tname); - rnext = rp->next; - free(rp); - } - rhead = NULL; - - if (pad && !fwrite(&pad, sizeof(pad), 1, fp)) - error(tname); - - (void)fflush(fp); -} diff --git a/usr.bin/ranlib/extern.h b/usr.bin/ranlib/extern.h deleted file mode 100644 index 3d27857931c..00000000000 --- a/usr.bin/ranlib/extern.h +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: extern.h,v 1.5 2008/01/13 20:31:19 chl Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -/* misc.c */ -extern int tmp(void); -extern void *emalloc(size_t); -extern void badfmt(void); -extern void error(const char *); -extern const char *rname(const char *); -extern char *tname; /* temporary file "name" */ - -/* touch.c */ -extern int touch(void); -extern void settime(int); - -/* build.c */ -extern int build(void); - -/* main.c */ -extern char *archive; /* archive name */ - diff --git a/usr.bin/ranlib/misc.c b/usr.bin/ranlib/misc.c deleted file mode 100644 index b5189923ae6..00000000000 --- a/usr.bin/ranlib/misc.c +++ /dev/null @@ -1,110 +0,0 @@ -/* $OpenBSD: misc.c,v 1.11 2009/10/27 23:59:42 deraadt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/param.h> -#include <signal.h> -#include <errno.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "pathnames.h" -#include "extern.h" - -char *tname = "temporary file"; - -int -tmp(void) -{ - static char *envtmp; - sigset_t set, oset; - static int first; - int fd; - char path[MAXPATHLEN]; - - if (!first) { - envtmp = getenv("TMPDIR"); - first = 1; - } - - if (envtmp) - (void)snprintf(path, sizeof(path), "%s/%s", envtmp, - _NAME_RANTMP); - else - strlcpy(path, _PATH_RANTMP, sizeof(path)); - - sigemptyset(&set); - sigaddset(&set, SIGHUP); - sigaddset(&set, SIGINT); - sigaddset(&set, SIGQUIT); - sigaddset(&set, SIGTERM); - (void)sigprocmask(SIG_BLOCK, &set, &oset); - if ((fd = mkstemp(path)) == -1) - error(tname); - (void)unlink(path); - (void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); - return(fd); -} - -void * -emalloc(size_t len) -{ - void *p; - - if (!(p = malloc(len))) - error(archive); - return(p); -} - -const char * -rname(const char *path) -{ - const char *ind; - - return((ind = strrchr(path, '/')) ? ind + 1 : path); -} - -void -badfmt(void) -{ - errno = EFTYPE; - error(archive); -} - -void -error(const char *name) -{ - - err(1, "%s", name); -} diff --git a/usr.bin/ranlib/pathnames.h b/usr.bin/ranlib/pathnames.h deleted file mode 100644 index ca2978c1cf2..00000000000 --- a/usr.bin/ranlib/pathnames.h +++ /dev/null @@ -1,34 +0,0 @@ -/* * $OpenBSD: pathnames.h,v 1.4 2003/06/03 02:56:14 millert Exp $*/ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: @(#)pathnames.h 5.2 (Berkeley) 4/16/91 - */ - -#define _NAME_RANTMP "ranlib.XXXXXXXXXX" -#define _PATH_RANTMP "/tmp/ranlib.XXXXXXXXXX" diff --git a/usr.bin/ranlib/ranlib.1 b/usr.bin/ranlib/ranlib.1 deleted file mode 100644 index 95e57e8a3c6..00000000000 --- a/usr.bin/ranlib/ranlib.1 +++ /dev/null @@ -1,96 +0,0 @@ -.\" $OpenBSD: ranlib.1,v 1.11 2007/08/06 19:16:06 sobrado Exp $ -.\" -.\" Copyright (c) 1990 Regents of the University of California. -.\" 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. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" from: @(#)ranlib.1 6.7 (Berkeley) 5/9/91 -.\" -.Dd $Mdocdate: August 6 2007 $ -.Dt RANLIB 1 -.Os -.Sh NAME -.Nm ranlib -.Nd table-of-contents for archive libraries -.Sh SYNOPSIS -.Nm ranlib -.Op Fl t -.Ar -.Sh DESCRIPTION -.Nm ranlib -creates a table of external references for archive libraries, -normally used by the loader, -.Xr ld 1 . -This table is named -.Dq __.SYMDEF -and is prepended to the archive. -Files in the archive which are not executable and symbols which are -uninteresting to the loader are ignored. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl t -Set the modification time of the -.Pa __.SYMDEF -file. -This time is compared by the loader with the modification time of the -archive to verify that the table is up-to-date with respect to the -archive. -If the modification time has been changed without any change to the -archive (for example, by a -.Xr cp 1 ) , -the -.Fl t -option can be used to -.Dq touch -the modification time so that it -appears that the table is up-to-date. -This is also useful after using the -.Fl t -option of -.Xr make 1 . -.El -.Sh ENVIRONMENT -.Bl -tag -width TMPDIR -.It Ev TMPDIR -The pathname of the directory to use when creating temporary files. -.El -.Sh FILES -.Bl -tag -width /tmp/ranlib.XXXXXXXXXX -compact -.It Pa /tmp/ranlib.XXXXXXXXXX -temporary files -.El -.Sh SEE ALSO -.Xr ar 1 , -.Xr ld 1 , -.Xr lorder 1 , -.Xr nm 1 , -.Xr ranlib 5 -.Sh HISTORY -A -.Nm ranlib -command appeared in -.At v7 . diff --git a/usr.bin/ranlib/ranlib.5 b/usr.bin/ranlib/ranlib.5 deleted file mode 100644 index 19191b17a7c..00000000000 --- a/usr.bin/ranlib/ranlib.5 +++ /dev/null @@ -1,73 +0,0 @@ -.\" $OpenBSD: ranlib.5,v 1.7 2007/05/31 19:20:14 jmc Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" 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. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" from: @(#)ranlib.5.5 5.2 (Berkeley) 5/10/91 -.\" -.Dd $Mdocdate: May 31 2007 $ -.Dt RANLIB 5 -.Os -.Sh NAME -.Nm ranlib -.Nd archive (library) table-of-contents format -.Sh SYNOPSIS -.Fd #include <ranlib.h> -.Sh DESCRIPTION -The archive table-of-contents command -.Nm ranlib -creates a table of contents for archives, containing object files, to -be used by the link-editor -.Xr ld 1 . -It operates on archives created with the utility -.Xr ar 1 . -.Pp -The -.Nm ranlib -function -prepends a new file to the archive which has three separate parts. -The first part is a standard archive header, which has a special name -field, -.Dq __.SYMDEF . -.Pp -The second part is a -.Li long -followed by a list of ranlib structures. -The long is the size, in bytes, of the list of ranlib structures. -Each of the ranlib structures consists of a zero based offset into the -next section (a string table of symbols) and an offset from the beginning -of the archive to the start of the archive file which defines the symbol. -The actual number of ranlib structures is this number divided by the size -of an individual ranlib structure. -.Pp -The third part is a -.Li long -followed by a string table. -The long is the size, in bytes, of the string table. -.Sh SEE ALSO -.Xr ar 1 , -.Xr ranlib 1 diff --git a/usr.bin/ranlib/ranlib.c b/usr.bin/ranlib/ranlib.c deleted file mode 100644 index 3bf23e76671..00000000000 --- a/usr.bin/ranlib/ranlib.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $OpenBSD: ranlib.c,v 1.8 2009/10/27 23:59:42 deraadt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/types.h> -#include <dirent.h> -#include <stdio.h> -#include <stdlib.h> -#include <archive.h> -#include "extern.h" - -CHDR chdr; -u_int options; /* UNUSED -- keep open_archive happy */ - -char *archive; - -static void usage(void); - -int -main(int argc, char *argv[]) -{ - int ch, eval, tflag; - - tflag = 0; - while ((ch = getopt(argc, argv, "t")) != -1) - switch(ch) { - case 't': - tflag = 1; - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if (!*argv) - usage(); - - for (eval = 0; archive = *argv++;) - eval |= tflag ? touch() : build(); - exit(eval); -} - -static void -usage(void) -{ - (void)fprintf(stderr, "usage: ranlib [-t] file ...\n"); - exit(1); -} diff --git a/usr.bin/ranlib/touch.c b/usr.bin/ranlib/touch.c deleted file mode 100644 index c6b02194b72..00000000000 --- a/usr.bin/ranlib/touch.c +++ /dev/null @@ -1,81 +0,0 @@ -/* $OpenBSD: touch.c,v 1.9 2013/04/02 05:01:23 deraadt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Hugh Smith at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include <sys/types.h> -#include <fcntl.h> -#include <dirent.h> -#include <ranlib.h> -#include <ar.h> -#include <time.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> -#include <archive.h> -#include "extern.h" - -extern CHDR chdr; /* converted header */ - -int -touch(void) -{ - int afd; - - afd = open_archive(O_RDWR); - - if (!get_arobj(afd) || - strncmp(RANLIBMAG, chdr.name, sizeof(RANLIBMAG) - 1)) { - (void)fprintf(stderr, - "ranlib: %s: no symbol table.\n", archive); - return(1); - } - settime(afd); - close_archive(afd); - return(0); -} - -void -settime(int afd) -{ - struct ar_hdr *hdr; - off_t size; - char buf[50]; - - size = SARMAG + sizeof(hdr->ar_name); - if (lseek(afd, size, SEEK_SET) == (off_t)-1) - error(archive); - (void)snprintf(buf, sizeof buf, - "%-12lld", (long long)time(NULL) + RANLIBSKEW); - if (write(afd, buf, sizeof(hdr->ar_date)) != sizeof(hdr->ar_date)) - error(archive); -} |