2 * Copyright (c) 2003-2007 Tim Kientzle
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * $FreeBSD: src/usr.bin/tar/bsdtar_platform.h,v 1.24 2007/04/12 04:45:32 kientzle Exp $
29 * This header is the first thing included in any of the bsdtar
30 * source files. As far as possible, platform-specific issues should
31 * be dealt with here and not within individual source files.
34 #ifndef BSDTAR_PLATFORM_H_INCLUDED
35 #define BSDTAR_PLATFORM_H_INCLUDED
37 #if defined(PLATFORM_CONFIG_H)
38 /* Use hand-built config.h in environments that need it. */
39 #include PLATFORM_CONFIG_H
40 #elif defined(HAVE_CONFIG_H)
41 /* Most POSIX platforms use the 'configure' script to build config.h */
42 #include "../config.h"
44 /* Warn if bsdtar hasn't been (automatically or manually) configured. */
45 #error Oops: No config.h and no built-in configuration in bsdtar_platform.h.
46 #endif /* !HAVE_CONFIG_H */
48 /* No non-FreeBSD platform will have __FBSDID, so just define it here. */
50 #include <sys/cdefs.h> /* For __FBSDID */
52 #define __FBSDID(a) /* null */
55 #ifdef HAVE_LIBARCHIVE
56 /* If we're using the platform libarchive, include system headers. */
58 #include <archive_entry.h>
60 /* Otherwise, include user headers. */
62 #include "archive_entry.h"
66 * Does this platform have complete-looking POSIX-style ACL support,
67 * including some variant of the acl_get_perm() function (which was
68 * omitted from the POSIX.1e draft)?
70 #if HAVE_SYS_ACL_H && HAVE_ACL_PERMSET_T && HAVE_ACL_USER
71 #if HAVE_ACL_GET_PERM || HAVE_ACL_GET_PERM_NP
72 #define HAVE_POSIX_ACL 1
77 #include <acl/libacl.h>
81 #define ACL_GET_PERM acl_get_perm
83 #if HAVE_ACL_GET_PERM_NP
84 #define ACL_GET_PERM acl_get_perm_np
89 * Include "dirent.h" (or it's equivalent on several different platforms).
91 * This is slightly modified from the GNU autoconf recipe.
92 * In particular, FreeBSD includes d_namlen in it's dirent structure,
93 * so my configure script includes an explicit test for the d_namlen
98 # if HAVE_DIRENT_D_NAMLEN
99 # define DIRENT_NAMLEN(dirent) (dirent)->d_namlen
101 # define DIRENT_NAMLEN(dirent) strlen((dirent)->d_name)
104 # define dirent direct
105 # define DIRENT_NAMLEN(dirent) (dirent)->d_namlen
107 # include <sys/ndir.h>
110 # include <sys/dir.h>
119 * We need to be able to display a filesize using printf(). The type
120 * and format string here must be compatible with one another and
121 * large enough for any file.
124 #define BSDTAR_FILESIZE_TYPE uintmax_t
125 #define BSDTAR_FILESIZE_PRINTF "%ju"
127 #if HAVE_UNSIGNED_LONG_LONG
128 #define BSDTAR_FILESIZE_TYPE unsigned long long
129 #define BSDTAR_FILESIZE_PRINTF "%llu"
131 #define BSDTAR_FILESIZE_TYPE unsigned long
132 #define BSDTAR_FILESIZE_PRINTF "%lu"
136 #if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
137 #define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctimespec.tv_nsec
138 #define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtimespec.tv_nsec
140 #if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
141 #define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctim.tv_nsec
142 #define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtim.tv_nsec
144 #define ARCHIVE_STAT_CTIME_NANOS(st) (0)
145 #define ARCHIVE_STAT_MTIME_NANOS(st) (0)
149 #endif /* !BSDTAR_PLATFORM_H_INCLUDED */