Use "linux" instead of "LINUX" to control Linux-specific code.

Thanks to: David O'Brien for pointing this out.

Also, add in a few additional portability tweaks and make a few
more things conditional on features (HAVE_XXXX macros) rather
than platform.
This commit is contained in:
kientzle 2004-07-24 17:50:05 +00:00
parent 28f8e14f2f
commit 50e0c304f4
3 changed files with 18 additions and 8 deletions

View File

@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <wchar.h>
#ifdef LINUX
#ifdef HAVE_EXT2FS_EXT2_FS_H
#include <ext2fs/ext2_fs.h> /* for Linux file flags */
#endif

View File

@ -54,6 +54,7 @@
#define HAVE_CHFLAGS 1
#define HAVE_LUTIMES 1
#define HAVE_LCHMOD 1
#define HAVE_LCHOWN 1
#define HAVE_STRERROR_R 1
#define ARCHIVE_ERRNO_FILE_FORMAT EFTYPE
#define ARCHIVE_ERRNO_PROGRAMMER EINVAL
@ -98,6 +99,8 @@
#define ARCHIVE_ERRNO_FILE_FORMAT EILSEQ
#define ARCHIVE_ERRNO_PROGRAMMER EINVAL
#define ARCHIVE_ERRNO_MISC (-1)
#define HAVE_EXT2FS_EXT2_FS_H 1
#define HAVE_LCHOWN 1
#define HAVE_STRERROR_R 1
#define STRERROR_R_CHAR_P 1

View File

@ -43,7 +43,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
@ -827,7 +827,13 @@ set_ownership(struct archive *a, struct archive_entry *entry, int flags)
if (a->user_uid != 0 && a->user_uid != uid)
return (ARCHIVE_OK);
if (lchown(archive_entry_pathname(entry), uid, gid)) {
#ifdef HAVE_LCHOWN
if (lchown(archive_entry_pathname(entry), uid, gid))
#else
if (!S_ISLNK(archive_entry_mode(entry))
&& chown(archive_entry_pathname(entry), uid, gid) != 0)
#endif
{
archive_set_error(a, errno,
"Can't set user=%d/group=%d for %s", uid, gid,
archive_entry_pathname(entry));
@ -922,8 +928,8 @@ set_perm(struct archive *a, struct archive_entry *entry, int mode, int flags)
archive_set_error(a, errno, "Can't set permissions");
return (ARCHIVE_WARN);
}
} else {
#ifdef HAVE_LCHMOD
} else {
/*
* If lchmod() isn't supported, it's no big deal.
* Permissions on symlinks are actually ignored on
@ -1005,7 +1011,7 @@ set_fflags(struct archive *a, const char *name, mode_t mode,
{
struct extract *extract;
int ret;
#ifdef LINUX
#ifdef linux
int fd;
int err;
unsigned long newflags, oldflags;
@ -1034,9 +1040,9 @@ set_fflags(struct archive *a, const char *name, mode_t mode,
}
extract->pst = &extract->st;
}
#endif
#else
#ifdef linux
/* Linux has flags too, but no chflags syscall */
#ifdef LINUX
/*
* Linux has no define for the flags that are only settable
* by the root user...
@ -1071,7 +1077,8 @@ set_fflags(struct archive *a, const char *name, mode_t mode,
ret = ARCHIVE_WARN;
}
}
#endif
#endif /* linux */
#endif /* HAVE_CHFLAGS */
return (ret);
}