summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2005-03-14 00:30:35 +0000
committerkientzle <kientzle@FreeBSD.org>2005-03-14 00:30:35 +0000
commit7f4dba0f0e20721fa52a997a66609227b056a7d5 (patch)
tree1d5c1643e9c1aa45e915073cb250c8198496e276 /usr.bin
parentc46a8c03ead06bb66f941e909a3f4522490f3e7a (diff)
downloadFreeBSD-src-7f4dba0f0e20721fa52a997a66609227b056a7d5.zip
FreeBSD-src-7f4dba0f0e20721fa52a997a66609227b056a7d5.tar.gz
A handful of minor portability and style improvements.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tar/bsdtar.c2
-rw-r--r--usr.bin/tar/matching.c2
-rw-r--r--usr.bin/tar/write.c27
3 files changed, 16 insertions, 15 deletions
diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c
index 80f9135..f2ecf03 100644
--- a/usr.bin/tar/bsdtar.c
+++ b/usr.bin/tar/bsdtar.c
@@ -64,7 +64,7 @@ struct option {
#include "bsdtar.h"
-#ifdef linux
+#ifdef __linux
#define _PATH_DEFTAPE "/dev/st0"
#endif
diff --git a/usr.bin/tar/matching.c b/usr.bin/tar/matching.c
index 084ec4d..0aaff92 100644
--- a/usr.bin/tar/matching.c
+++ b/usr.bin/tar/matching.c
@@ -258,6 +258,8 @@ unmatched_inclusions(struct bsdtar *bsdtar)
#if defined(HAVE_FNMATCH) && defined(HAVE_FNM_LEADING_DIR)
/* Use system fnmatch() if it suits our needs. */
+/* On Linux, _GNU_SOURCE must be defined to get FNM_LEADING_DIR. */
+#define _GNU_SOURCE
#include <fnmatch.h>
static int
bsdtar_fnmatch(const char *pattern, const char *string)
diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c
index b3d9685..aace228 100644
--- a/usr.bin/tar/write.c
+++ b/usr.bin/tar/write.c
@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#ifdef linux
+#ifdef __linux
#include <ext2fs/ext2_fs.h>
#include <sys/ioctl.h>
#endif
@@ -122,7 +122,7 @@ static void setup_acls(struct bsdtar *, struct archive_entry *,
static void test_for_append(struct bsdtar *);
static void write_archive(struct archive *, struct bsdtar *);
static void write_entry(struct bsdtar *, struct archive *,
- struct stat *, const char *pathname,
+ const struct stat *, const char *pathname,
unsigned pathlen, const char *accpath);
static int write_file_data(struct bsdtar *, struct archive *,
int fd);
@@ -518,7 +518,7 @@ write_heirarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
FTSENT *ftsent;
int ftsoptions;
char *fts_argv[2];
-#ifdef linux
+#ifdef __linux
int fd, r;
unsigned long fflags;
#endif
@@ -590,7 +590,7 @@ write_heirarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
}
#endif
-#ifdef linux
+#ifdef __linux
/*
* Linux has a nodump flag too but to read it
* we have to open() the dir and do an ioctl on it...
@@ -659,7 +659,7 @@ write_heirarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
break;
#endif
-#ifdef linux
+#ifdef __linux
/*
* Linux has a nodump flag too but to read it
* we have to open() the file and do an ioctl on it...
@@ -719,13 +719,13 @@ write_heirarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
* Add a single filesystem object to the archive.
*/
static void
-write_entry(struct bsdtar *bsdtar, struct archive *a, struct stat *st,
+write_entry(struct bsdtar *bsdtar, struct archive *a, const struct stat *st,
const char *pathname, unsigned pathlen, const char *accpath)
{
struct archive_entry *entry;
int e;
int fd;
-#ifdef linux
+#ifdef __linux
int r;
unsigned long stflags;
#endif
@@ -736,10 +736,6 @@ write_entry(struct bsdtar *bsdtar, struct archive *a, struct stat *st,
fd = -1;
entry = archive_entry_new();
- /* Non-regular files get archived with zero size. */
- if (!S_ISREG(st->st_mode))
- st->st_size = 0;
-
/* Strip redundant "./" from start of filename. */
if (pathname != NULL && pathname[0] == '.' && pathname[1] == '/') {
pathname += 2;
@@ -796,7 +792,7 @@ write_entry(struct bsdtar *bsdtar, struct archive *a, struct stat *st,
archive_entry_set_fflags(entry, st->st_flags, 0);
#endif
-#ifdef linux
+#ifdef __linux
if ((S_ISREG(st->st_mode) || S_ISDIR(st->st_mode)) &&
((fd = open(accpath, O_RDONLY|O_NONBLOCK)) >= 0) &&
((r = ioctl(fd, EXT2_IOC_GETFLAGS, &stflags)), close(fd), r) >= 0 &&
@@ -825,6 +821,10 @@ write_entry(struct bsdtar *bsdtar, struct archive *a, struct stat *st,
}
}
+ /* Non-regular files get archived with zero size. */
+ if (!S_ISREG(st->st_mode))
+ archive_entry_set_size(entry, 0);
+
e = archive_write_header(a, entry);
if (e != ARCHIVE_OK) {
if (!bsdtar->verbose)
@@ -1267,8 +1267,7 @@ lookup_gname_helper(struct bsdtar *bsdtar, const char **name, id_t id)
}
/*
- * Test if the specified file is newer than what's already
- * in the archive.
+ * Test if the specified file is new enough to include in the archive.
*/
int
new_enough(struct bsdtar *bsdtar, const char *path, const struct stat *st)
OpenPOWER on IntegriCloud