diff options
author | mm <mm@FreeBSD.org> | 2011-12-21 11:18:49 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2011-12-21 11:18:49 +0000 |
commit | 89ab30c75fb39b787137083c605fcb09563c2920 (patch) | |
tree | 61643326e8c3ea242090f87364bc9e05a889155f /contrib/libarchive/cpio | |
parent | 5fa2c01e289ce67d0d55ac9021d72da163545ae4 (diff) | |
download | FreeBSD-src-89ab30c75fb39b787137083c605fcb09563c2920.zip FreeBSD-src-89ab30c75fb39b787137083c605fcb09563c2920.tar.gz |
Strip unnecessary files and directories from contrib/libarchive
according to FREEBSD-Xlist
MFC after: 2 weeks
Diffstat (limited to 'contrib/libarchive/cpio')
-rw-r--r-- | contrib/libarchive/cpio/CMakeLists.txt | 51 | ||||
-rw-r--r-- | contrib/libarchive/cpio/cpio_windows.c | 338 | ||||
-rw-r--r-- | contrib/libarchive/cpio/cpio_windows.h | 72 | ||||
-rw-r--r-- | contrib/libarchive/cpio/test/CMakeLists.txt | 79 |
4 files changed, 0 insertions, 540 deletions
diff --git a/contrib/libarchive/cpio/CMakeLists.txt b/contrib/libarchive/cpio/CMakeLists.txt deleted file mode 100644 index ce500b1..0000000 --- a/contrib/libarchive/cpio/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -############################################ -# -# How to build bsdcpio -# -############################################ -IF(ENABLE_CPIO) - - SET(bsdcpio_SOURCES - cmdline.c - cpio.c - cpio.h - cpio_platform.h - ../libarchive_fe/err.c - ../libarchive_fe/err.h - ../libarchive_fe/lafe_platform.h - ../libarchive_fe/line_reader.c - ../libarchive_fe/line_reader.h - ../libarchive_fe/matching.c - ../libarchive_fe/matching.h - ../libarchive_fe/pathmatch.c - ../libarchive_fe/pathmatch.h - ) - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libarchive_fe) - IF(WIN32 AND NOT CYGWIN) - LIST(APPEND bsdcpio_SOURCES cpio_windows.c) - LIST(APPEND bsdcpio_SOURCES cpio_windows.h) - ENDIF(WIN32 AND NOT CYGWIN) - - # bsdcpio documentation - SET(bsdcpio_MANS bsdcpio.1) - - # How to build bsdcpio - ADD_EXECUTABLE(bsdcpio ${bsdcpio_SOURCES}) - IF(ENABLE_CPIO_SHARED) - TARGET_LINK_LIBRARIES(bsdcpio archive ${ADDITIONAL_LIBS}) - ELSE(ENABLE_CPIO_SHARED) - TARGET_LINK_LIBRARIES(bsdcpio archive_static ${ADDITIONAL_LIBS}) - SET_TARGET_PROPERTIES(bsdcpio PROPERTIES COMPILE_DEFINITIONS - LIBARCHIVE_STATIC) - ENDIF(ENABLE_CPIO_SHARED) - # Full path to the compiled executable (used by test suite) - GET_TARGET_PROPERTY(BSDCPIO bsdcpio LOCATION) - - # Installation rules - INSTALL(TARGETS bsdcpio RUNTIME DESTINATION bin) - INSTALL_MAN(${bsdcpio_MANS}) - -ENDIF(ENABLE_CPIO) - -# Test suite -add_subdirectory(test) diff --git a/contrib/libarchive/cpio/cpio_windows.c b/contrib/libarchive/cpio/cpio_windows.c deleted file mode 100644 index 420e01d..0000000 --- a/contrib/libarchive/cpio/cpio_windows.c +++ /dev/null @@ -1,338 +0,0 @@ -/*- - * Copyright (c) 2009 Michihiro NAKAJIMA - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#if defined(_WIN32) && !defined(__CYGWIN__) - -#include "cpio_platform.h" -#include <ctype.h> -#include <errno.h> -#include <fcntl.h> -#include <io.h> -#include <stddef.h> -#ifdef HAVE_SYS_UTIME_H -#include <sys/utime.h> -#endif -#include <sys/stat.h> -#include <process.h> -#include <stdlib.h> -#include <wchar.h> -#include <windows.h> -#include <sddl.h> - -#include "cpio.h" -#include "err.h" - -#define EPOC_TIME (116444736000000000ULL) - -static void cpio_dosmaperr(unsigned long); - -/* - * Prepend "\\?\" to the path name and convert it to unicode to permit - * an extended-length path for a maximum total path length of 32767 - * characters. - * see also http://msdn.microsoft.com/en-us/library/aa365247.aspx - */ -static wchar_t * -permissive_name(const char *name) -{ - wchar_t *wn, *wnp; - wchar_t *ws, *wsp; - DWORD l, len, slen, alloclen; - int unc; - - len = (DWORD)strlen(name); - wn = malloc((len + 1) * sizeof(wchar_t)); - if (wn == NULL) - return (NULL); - l = MultiByteToWideChar(CP_ACP, 0, name, len, wn, len); - if (l == 0) { - free(wn); - return (NULL); - } - wn[l] = L'\0'; - - /* Get a full path names */ - l = GetFullPathNameW(wn, 0, NULL, NULL); - if (l == 0) { - free(wn); - return (NULL); - } - wnp = malloc(l * sizeof(wchar_t)); - if (wnp == NULL) { - free(wn); - return (NULL); - } - len = GetFullPathNameW(wn, l, wnp, NULL); - free(wn); - wn = wnp; - - if (wnp[0] == L'\\' && wnp[1] == L'\\' && - wnp[2] == L'?' && wnp[3] == L'\\') - /* We have already permissive names. */ - return (wn); - - if (wnp[0] == L'\\' && wnp[1] == L'\\' && - wnp[2] == L'.' && wnp[3] == L'\\') { - /* Device names */ - if (((wnp[4] >= L'a' && wnp[4] <= L'z') || - (wnp[4] >= L'A' && wnp[4] <= L'Z')) && - wnp[5] == L':' && wnp[6] == L'\\') - wnp[2] = L'?';/* Not device names. */ - return (wn); - } - - unc = 0; - if (wnp[0] == L'\\' && wnp[1] == L'\\' && wnp[2] != L'\\') { - wchar_t *p = &wnp[2]; - - /* Skip server-name letters. */ - while (*p != L'\\' && *p != L'\0') - ++p; - if (*p == L'\\') { - wchar_t *rp = ++p; - /* Skip share-name letters. */ - while (*p != L'\\' && *p != L'\0') - ++p; - if (*p == L'\\' && p != rp) { - /* Now, match patterns such as - * "\\server-name\share-name\" */ - wnp += 2; - len -= 2; - unc = 1; - } - } - } - - alloclen = slen = 4 + (unc * 4) + len + 1; - ws = wsp = malloc(slen * sizeof(wchar_t)); - if (ws == NULL) { - free(wn); - return (NULL); - } - /* prepend "\\?\" */ - wcsncpy(wsp, L"\\\\?\\", 4); - wsp += 4; - slen -= 4; - if (unc) { - /* append "UNC\" ---> "\\?\UNC\" */ - wcsncpy(wsp, L"UNC\\", 4); - wsp += 4; - slen -= 4; - } - wcsncpy(wsp, wnp, slen); - free(wn); - ws[alloclen - 1] = L'\0'; - return (ws); -} - -static HANDLE -cpio_CreateFile(const char *path, DWORD dwDesiredAccess, DWORD dwShareMode, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, - DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) -{ - wchar_t *wpath; - HANDLE handle; - - handle = CreateFileA(path, dwDesiredAccess, dwShareMode, - lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, - hTemplateFile); - if (handle != INVALID_HANDLE_VALUE) - return (handle); - if (GetLastError() != ERROR_PATH_NOT_FOUND) - return (handle); - wpath = permissive_name(path); - if (wpath == NULL) - return (handle); - handle = CreateFileW(wpath, dwDesiredAccess, dwShareMode, - lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, - hTemplateFile); - free(wpath); - return (handle); -} - -#define WINTIME(sec, usec) ((Int32x32To64(sec, 10000000) + EPOC_TIME) + (usec * 10)) -static int -__hutimes(HANDLE handle, const struct __timeval *times) -{ - ULARGE_INTEGER wintm; - FILETIME fatime, fmtime; - - wintm.QuadPart = WINTIME(times[0].tv_sec, times[0].tv_usec); - fatime.dwLowDateTime = wintm.LowPart; - fatime.dwHighDateTime = wintm.HighPart; - wintm.QuadPart = WINTIME(times[1].tv_sec, times[1].tv_usec); - fmtime.dwLowDateTime = wintm.LowPart; - fmtime.dwHighDateTime = wintm.HighPart; - if (SetFileTime(handle, NULL, &fatime, &fmtime) == 0) { - errno = EINVAL; - return (-1); - } - return (0); -} - -int -futimes(int fd, const struct __timeval *times) -{ - - return (__hutimes((HANDLE)_get_osfhandle(fd), times)); -} - -int -utimes(const char *name, const struct __timeval *times) -{ - int ret; - HANDLE handle; - - handle = cpio_CreateFile(name, GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, NULL); - if (handle == INVALID_HANDLE_VALUE) { - cpio_dosmaperr(GetLastError()); - return (-1); - } - ret = __hutimes(handle, times); - CloseHandle(handle); - return (ret); -} - -/* - * The following function was modified from PostgreSQL sources and is - * subject to the copyright below. - */ -/*------------------------------------------------------------------------- - * - * win32error.c - * Map win32 error codes to errno values - * - * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group - * - * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/win32error.c,v 1.4 2008/01/01 19:46:00 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -/* -PostgreSQL Database Management System -(formerly known as Postgres, then as Postgres95) - -Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group - -Portions Copyright (c) 1994, The Regents of the University of California - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose, without fee, and without a written agreement -is hereby granted, provided that the above copyright notice and this -paragraph and the following two paragraphs appear in all copies. - -IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR -DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING -LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS -DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS -ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO -PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -*/ - -static const struct { - DWORD winerr; - int doserr; -} doserrors[] = -{ - { ERROR_INVALID_FUNCTION, EINVAL }, - { ERROR_FILE_NOT_FOUND, ENOENT }, - { ERROR_PATH_NOT_FOUND, ENOENT }, - { ERROR_TOO_MANY_OPEN_FILES, EMFILE }, - { ERROR_ACCESS_DENIED, EACCES }, - { ERROR_INVALID_HANDLE, EBADF }, - { ERROR_ARENA_TRASHED, ENOMEM }, - { ERROR_NOT_ENOUGH_MEMORY, ENOMEM }, - { ERROR_INVALID_BLOCK, ENOMEM }, - { ERROR_BAD_ENVIRONMENT, E2BIG }, - { ERROR_BAD_FORMAT, ENOEXEC }, - { ERROR_INVALID_ACCESS, EINVAL }, - { ERROR_INVALID_DATA, EINVAL }, - { ERROR_INVALID_DRIVE, ENOENT }, - { ERROR_CURRENT_DIRECTORY, EACCES }, - { ERROR_NOT_SAME_DEVICE, EXDEV }, - { ERROR_NO_MORE_FILES, ENOENT }, - { ERROR_LOCK_VIOLATION, EACCES }, - { ERROR_SHARING_VIOLATION, EACCES }, - { ERROR_BAD_NETPATH, ENOENT }, - { ERROR_NETWORK_ACCESS_DENIED, EACCES }, - { ERROR_BAD_NET_NAME, ENOENT }, - { ERROR_FILE_EXISTS, EEXIST }, - { ERROR_CANNOT_MAKE, EACCES }, - { ERROR_FAIL_I24, EACCES }, - { ERROR_INVALID_PARAMETER, EINVAL }, - { ERROR_NO_PROC_SLOTS, EAGAIN }, - { ERROR_DRIVE_LOCKED, EACCES }, - { ERROR_BROKEN_PIPE, EPIPE }, - { ERROR_DISK_FULL, ENOSPC }, - { ERROR_INVALID_TARGET_HANDLE, EBADF }, - { ERROR_INVALID_HANDLE, EINVAL }, - { ERROR_WAIT_NO_CHILDREN, ECHILD }, - { ERROR_CHILD_NOT_COMPLETE, ECHILD }, - { ERROR_DIRECT_ACCESS_HANDLE, EBADF }, - { ERROR_NEGATIVE_SEEK, EINVAL }, - { ERROR_SEEK_ON_DEVICE, EACCES }, - { ERROR_DIR_NOT_EMPTY, ENOTEMPTY }, - { ERROR_NOT_LOCKED, EACCES }, - { ERROR_BAD_PATHNAME, ENOENT }, - { ERROR_MAX_THRDS_REACHED, EAGAIN }, - { ERROR_LOCK_FAILED, EACCES }, - { ERROR_ALREADY_EXISTS, EEXIST }, - { ERROR_FILENAME_EXCED_RANGE, ENOENT }, - { ERROR_NESTING_NOT_ALLOWED, EAGAIN }, - { ERROR_NOT_ENOUGH_QUOTA, ENOMEM } -}; - -static void -cpio_dosmaperr(unsigned long e) -{ - int i; - - if (e == 0) { - errno = 0; - return; - } - - for (i = 0; i < sizeof(doserrors); i++) { - if (doserrors[i].winerr == e) { - errno = doserrors[i].doserr; - return; - } - } - - /* fprintf(stderr, "unrecognized win32 error code: %lu", e); */ - errno = EINVAL; - return; -} -#endif diff --git a/contrib/libarchive/cpio/cpio_windows.h b/contrib/libarchive/cpio/cpio_windows.h deleted file mode 100644 index 105bf69..0000000 --- a/contrib/libarchive/cpio/cpio_windows.h +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * Copyright (c) 2009 Michihiro NAKAJIMA - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ -#ifndef CPIO_WINDOWS_H -#define CPIO_WINDOWS_H 1 - -#include <io.h> -#include <string.h> - -#define getgrgid(id) NULL -#define getgrnam(name) NULL -#define getpwnam(name) NULL -#define getpwuid(id) NULL - -#ifdef _MSC_VER -#define snprintf sprintf_s -#define strdup _strdup -#define open _open -#define read _read -#define close _close -#endif - -struct passwd { - char *pw_name; - uid_t pw_uid; - gid_t pw_gid; -}; - -struct group { - char *gr_name; - gid_t gr_gid; -}; - -struct _timeval64i32 { - time_t tv_sec; - long tv_usec; -}; -#define __timeval _timeval64i32 - -extern int futimes(int fd, const struct __timeval *times); -#ifndef HAVE_FUTIMES -#define HAVE_FUTIMES 1 -#endif -extern int utimes(const char *name, const struct __timeval *times); -#ifndef HAVE_UTIMES -#define HAVE_UTIMES 1 -#endif - -#endif /* CPIO_WINDOWS_H */ diff --git a/contrib/libarchive/cpio/test/CMakeLists.txt b/contrib/libarchive/cpio/test/CMakeLists.txt deleted file mode 100644 index a822bcd..0000000 --- a/contrib/libarchive/cpio/test/CMakeLists.txt +++ /dev/null @@ -1,79 +0,0 @@ -############################################ -# -# How to build bsdcpio_test -# -############################################ -IF(ENABLE_CPIO AND ENABLE_TEST) - SET(bsdcpio_test_SOURCES - ../cmdline.c - ../../libarchive_fe/err.c - ../../libarchive_fe/pathmatch.c - main.c - test.h - test_0.c - test_basic.c - test_cmdline.c - test_format_newc.c - test_gcpio_compat.c - test_option_B_upper.c - test_option_C_upper.c - test_option_J_upper.c - test_option_L_upper.c - test_option_Z_upper.c - test_option_a.c - test_option_c.c - test_option_d.c - test_option_f.c - test_option_help.c - test_option_l.c - test_option_lzma.c - test_option_m.c - test_option_t.c - test_option_u.c - test_option_version.c - test_option_y.c - test_option_z.c - test_owner_parse.c - test_passthrough_dotdot.c - test_passthrough_reverse.c - test_pathmatch.c - ) - IF(WIN32 AND NOT CYGWIN) - LIST(APPEND bsdcpio_test_SOURCES ../cpio_windows.h) - ENDIF(WIN32 AND NOT CYGWIN) - - # - # Register target - # - ADD_EXECUTABLE(bsdcpio_test ${bsdcpio_test_SOURCES}) - SET_PROPERTY(TARGET bsdcpio_test PROPERTY COMPILE_DEFINITIONS LIST_H) - - # - # Generate list.h by grepping DEFINE_TEST() lines out of the C sources. - # - GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h - ${CMAKE_CURRENT_LIST_FILE} ${bsdcpio_test_SOURCES}) - SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_BINARY_DIR}) - - # list.h has a line DEFINE_TEST(testname) for every - # test. We can use that to define the tests for cmake by - # defining a DEFINE_TEST macro and reading list.h in. - MACRO (DEFINE_TEST _testname) - ADD_TEST_28( - NAME bsdcpio_${_testname} - COMMAND bsdcpio_test -vv - -p $<TARGET_FILE:bsdcpio> - -r ${CMAKE_CURRENT_SOURCE_DIR} - ${_testname}) - ENDMACRO (DEFINE_TEST _testname) - - INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h) - - # Experimental new test handling - ADD_CUSTOM_TARGET(run_bsdcpio_test - COMMAND bsdcpio_test -p ${BSDCPIO} -r ${CMAKE_CURRENT_SOURCE_DIR}) - ADD_DEPENDENCIES(run_bsdcpio_test bsdcpio) - ADD_DEPENDENCIES(run_all_tests run_bsdcpio_test) -ENDIF(ENABLE_CPIO AND ENABLE_TEST) - |