From bd256e40ed97b9d778cf97726eb6b1eacf8f8abf Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sun, 28 Jun 2009 04:08:04 -0400 Subject: [PATCH] cpio doesn't need set_fmode(O_BINARY) any more so we can remove it. Also, fix up the uid/gid formatting to work properly on Windows (whose printf() functions don't support ISO C99). SVN-Revision: 1201 --- cpio/cpio.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/cpio/cpio.c b/cpio/cpio.c index a4cebd3aa..75cc8776d 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -126,12 +126,6 @@ main(int argc, char *argv[]) memset(cpio, 0, sizeof(*cpio)); cpio->buff = buff; cpio->buff_size = sizeof(buff); -#if defined(_WIN32) && !defined(__CYGWIN__) - /* Make sure open() function will be used with a binary mode. */ - /* on cygwin, we need something similar, but instead link against */ - /* a special startup object, binmode.o */ - _set_fmode(_O_BINARY); -#endif /* Need lafe_progname before calling lafe_warnc. */ if (*argv == NULL) @@ -693,7 +687,7 @@ entry_to_archive(struct cpio *cpio, struct archive_entry *entry) */ if (archive_entry_filetype(entry) == AE_IFREG) { if (archive_entry_size(entry) > 0) { - fd = open(srcpath, O_RDONLY); + fd = open(srcpath, O_RDONLY | O_BINARY); if (fd < 0) { lafe_warnc(errno, "%s: could not open file", srcpath); @@ -969,11 +963,11 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry) if (cpio->option_numeric_uid_gid) { /* Format numeric uid/gid for display. */ - snprintf(uids, sizeof(uids), "%jd", - (intmax_t)archive_entry_uid(entry)); + snprintf(uids, sizeof(uids), CPIO_FILESIZE_PRINTF, + (CPIO_FILESIZE_TYPE)archive_entry_uid(entry)); uname = uids; - snprintf(gids, sizeof(gids), "%jd", - (intmax_t)archive_entry_gid(entry)); + snprintf(gids, sizeof(gids), CPIO_FILESIZE_PRINTF, + (CPIO_FILESIZE_TYPE)archive_entry_gid(entry)); gname = gids; } else { /* Use uname if it's present, else lookup name from uid. */ -- 2.47.3