data_extract_all: do not complain if directory exists on mkdir
authorDenis Vlasenko <vda.linux@googlemail.com>
Fri, 17 Oct 2008 14:03:56 +0000 (14:03 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Fri, 17 Oct 2008 14:03:56 +0000 (14:03 -0000)
rpm/cpio: move "20653 blocks" printout from get_header_cpio to cpio_main -
rpm doesn't want to have that

archival/cpio.c
archival/libunarchive/data_extract_all.c
archival/libunarchive/get_header_cpio.c

index 37b6b5cceab5f962c44027040605e4bfe08fc1f7..d39640d24f6cb9dd70d913065ffffda4859c2c6d 100644 (file)
@@ -344,5 +344,8 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
        while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
                continue;
 
+       /* see get_header_cpio */
+       printf("%lu blocks\n", (unsigned long)(ptrdiff_t)(archive_handle->ah_priv[2]));
+
        return EXIT_SUCCESS;
 }
index a67587d72e6ef37c96c0c09ed3d366192df5f703..8b1ee2a6ea29f0e37a3cdbcd00fc7934d556d286 100644 (file)
@@ -77,7 +77,9 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
                }
                case S_IFDIR:
                        res = mkdir(file_header->name, file_header->mode);
-                       if ((res == -1) && (errno != EISDIR)
+                       if ((res == -1)
+                        && (errno != EISDIR) /* btw, Linux doesn't return this */
+                        && (errno != EEXIST)
                         && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
                        ) {
                                bb_perror_msg("cannot make dir %s", file_header->name);
index 93f6c61aa0c633590343c07916f744b0db8d9cf3..302f122331b4d399f546a3c98a1b699b1d55de97 100644 (file)
@@ -27,6 +27,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
 
 #define hardlinks_to_create (*(hardlinks_t **)(&archive_handle->ah_priv[0]))
 #define created_hardlinks   (*(hardlinks_t **)(&archive_handle->ah_priv[1]))
+#define block_count         (archive_handle->ah_priv[2])
 //     if (!archive_handle->ah_priv_inited) {
 //             archive_handle->ah_priv_inited = 1;
 //             hardlinks_to_create = NULL;
@@ -76,7 +77,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
 
        if (strcmp(file_header->name, "TRAILER!!!") == 0) {
                /* Always round up. ">> 9" divides by 512 */
-               printf("%"OFF_FMT"u blocks\n", (archive_handle->offset + 511) >> 9);
+               block_count = (void*)(ptrdiff_t) ((archive_handle->offset + 511) >> 9);
                goto create_hardlinks;
        }