SHA256
1
0
forked from pool/cpio
OBS User unknown 2007-07-26 23:22:54 +00:00 committed by Git OBS Bridge
parent 4621b18618
commit b6424ba394
19 changed files with 269 additions and 1434 deletions

View File

@ -1,33 +0,0 @@
--- cpio-2.6/src/extern.h.checksum 2005-10-26 11:17:11.000000000 +0200
+++ cpio-2.6/src/extern.h 2005-10-26 11:15:42.000000000 +0200
@@ -66,7 +66,7 @@
extern int archive_des;
extern char *archive_name;
extern char *rsh_command_option;
-extern unsigned long crc;
+extern unsigned int crc;
extern int delayed_seek_count;
#ifdef DEBUG_CPIO
extern int debug_flag;
--- cpio-2.6/src/copyout.c.checksum 2005-10-26 11:17:11.000000000 +0200
+++ cpio-2.6/src/copyout.c 2005-10-26 11:20:01.000000000 +0200
@@ -311,7 +311,7 @@
file_hdr->c_gid, file_hdr->c_nlink, file_hdr->c_mtime,
file_hdr->c_filesize, file_hdr->c_dev_maj, file_hdr->c_dev_min,
file_hdr->c_rdev_maj, file_hdr->c_rdev_min, file_hdr->c_namesize,
- file_hdr->c_chksum);
+ file_hdr->c_chksum & 0xffffffff);
tape_buffered_write (ascii_header, out_des, 110L);
/* Write file name to output. */
--- cpio-2.6/src/global.c.checksum 2005-10-26 11:17:11.000000000 +0200
+++ cpio-2.6/src/global.c 2005-10-26 11:15:29.000000000 +0200
@@ -139,7 +139,7 @@
char *rsh_command_option = NULL;
/* CRC checksum. */
-unsigned long crc;
+unsigned int crc;
/* Input and output buffers. */
char *input_buffer, *output_buffer;

View File

@ -1,247 +0,0 @@
--- cpio-2.6/src/copyin.c.chmodRaceC 2005-07-01 14:23:04.000000000 +0200
+++ cpio-2.6/src/copyin.c 2005-07-01 14:46:34.000000000 +0200
@@ -184,11 +184,12 @@
static int
try_existing_file(struct new_cpio_header* file_hdr, int in_file_des,
- int *existing_dir)
+ int *existing_dir, mode_t *existing_mode)
{
struct stat file_stat;
*existing_dir = false;
+ *existing_mode = 0;
if (lstat (file_hdr->c_name, &file_stat) == 0)
{
if (S_ISDIR (file_stat.st_mode)
@@ -198,6 +199,7 @@
we are trying to create, don't complain about
it. */
*existing_dir = true;
+ *existing_mode = file_stat.st_mode;
return 0;
}
else if (!unconditional_flag
@@ -389,19 +391,20 @@
continue;
}
- if (close (out_file_des) < 0)
- error (0, errno, "%s", d->header.c_name);
-
/* File is now copied; set attributes. */
if (!no_chown_flag)
- if ((chown (d->header.c_name,
+ if ((fchown (out_file_des,
set_owner_flag ? set_owner : d->header.c_uid,
set_group_flag ? set_group : d->header.c_gid) < 0)
&& errno != EPERM)
error (0, errno, "%s", d->header.c_name);
/* chown may have turned off some permissions we wanted. */
- if (chmod (d->header.c_name, (int) d->header.c_mode) < 0)
+ if (fchmod (out_file_des, (int) d->header.c_mode) < 0)
error (0, errno, "%s", d->header.c_name);
+
+ if (close (out_file_des) < 0)
+ error (0, errno, "%s", d->header.c_name);
+
if (retain_time_flag)
{
times.actime = times.modtime = d->header.c_mtime;
@@ -557,6 +560,19 @@
write (out_file_des, "", 1);
delayed_seek_count = 0;
}
+
+ /* File is now copied; set attributes. */
+ if (!no_chown_flag)
+ if ((fchown (out_file_des,
+ set_owner_flag ? set_owner : file_hdr->c_uid,
+ set_group_flag ? set_group : file_hdr->c_gid) < 0)
+ && errno != EPERM)
+ error (0, errno, "%s", file_hdr->c_name);
+
+ /* chown may have turned off some permissions we wanted. */
+ if (fchmod (out_file_des, (int) file_hdr->c_mode) < 0)
+ error (0, errno, "%s", file_hdr->c_name);
+
if (close (out_file_des) < 0)
error (0, errno, "%s", file_hdr->c_name);
@@ -567,18 +583,6 @@
file_hdr->c_name, crc, file_hdr->c_chksum);
}
- /* File is now copied; set attributes. */
- if (!no_chown_flag)
- if ((chown (file_hdr->c_name,
- set_owner_flag ? set_owner : file_hdr->c_uid,
- set_group_flag ? set_group : file_hdr->c_gid) < 0)
- && errno != EPERM)
- error (0, errno, "%s", file_hdr->c_name);
-
- /* chown may have turned off some permissions we wanted. */
- if (chmod (file_hdr->c_name, (int) file_hdr->c_mode) < 0)
- error (0, errno, "%s", file_hdr->c_name);
-
if (retain_time_flag)
{
struct utimbuf times; /* For setting file times. */
@@ -589,7 +593,7 @@
if (utime (file_hdr->c_name, &times) < 0)
error (0, errno, "%s", file_hdr->c_name);
}
-
+
tape_skip_padding (in_file_des, file_hdr->c_filesize);
if (file_hdr->c_nlink > 1
&& (archive_format == arf_newascii || archive_format == arf_crcascii) )
@@ -603,7 +607,7 @@
}
static void
-copyin_directory(struct new_cpio_header* file_hdr, int existing_dir)
+copyin_directory(struct new_cpio_header* file_hdr, int existing_dir, mode_t existing_mode)
{
int res; /* Result of various function calls. */
#ifdef HPUX_CDF
@@ -646,14 +650,23 @@
cdf_flag = 1;
}
#endif
- res = mkdir (file_hdr->c_name, file_hdr->c_mode);
+ res = mkdir (file_hdr->c_name, file_hdr->c_mode & ~077);
}
- else
- res = 0;
+ else
+ {
+ if (!no_chown_flag && (existing_mode & 077) != 0
+ && chmod (file_hdr->c_name, existing_mode & 07700) < 0)
+ {
+ error (0, errno, "%s: chmod", file_hdr->c_name);
+ return;
+ }
+ res = 0;
+ }
+
if (res < 0 && create_dir_flag)
{
create_all_directories (file_hdr->c_name);
- res = mkdir (file_hdr->c_name, file_hdr->c_mode);
+ res = mkdir (file_hdr->c_name, file_hdr->c_mode & ~077);
}
if (res < 0)
{
@@ -742,12 +755,12 @@
return;
}
- res = mknod (file_hdr->c_name, file_hdr->c_mode,
+ res = mknod (file_hdr->c_name, file_hdr->c_mode & ~077,
makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min));
if (res < 0 && create_dir_flag)
{
create_all_directories (file_hdr->c_name);
- res = mknod (file_hdr->c_name, file_hdr->c_mode,
+ res = mknod (file_hdr->c_name, file_hdr->c_mode & ~077,
makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min));
}
if (res < 0)
@@ -826,9 +839,10 @@
copyin_file (struct new_cpio_header* file_hdr, int in_file_des)
{
int existing_dir=0;
+ mode_t existing_mode;
if (!to_stdout_option
- && try_existing_file (file_hdr, in_file_des, &existing_dir) < 0)
+ && try_existing_file (file_hdr, in_file_des, &existing_dir, &existing_mode) < 0)
return;
/* Do the real copy or link. */
@@ -839,7 +853,7 @@
break;
case CP_IFDIR:
- copyin_directory(file_hdr, existing_dir);
+ copyin_directory(file_hdr, existing_dir, existing_mode);
break;
case CP_IFCHR:
--- cpio-2.6/src/copypass.c.chmodRaceC 2004-09-06 14:09:04.000000000 +0200
+++ cpio-2.6/src/copypass.c 2005-07-01 14:50:46.000000000 +0200
@@ -181,19 +181,25 @@
}
if (close (in_file_des) < 0)
error (0, errno, "%s", input_name.ds_string);
- if (close (out_file_des) < 0)
- error (0, errno, "%s", output_name.ds_string);
-
+ /*
+ * Avoid race condition.
+ * Set chown and chmod before closing the file desc.
+ * pvrabec@redhat.com
+ */
/* Set the attributes of the new file. */
if (!no_chown_flag)
- if ((chown (output_name.ds_string,
+ if ((fchown (out_file_des,
set_owner_flag ? set_owner : in_file_stat.st_uid,
set_group_flag ? set_group : in_file_stat.st_gid) < 0)
&& errno != EPERM)
error (0, errno, "%s", output_name.ds_string);
/* chown may have turned off some permissions we wanted. */
- if (chmod (output_name.ds_string, in_file_stat.st_mode) < 0)
+ if (fchmod (out_file_des, in_file_stat.st_mode) < 0)
error (0, errno, "%s", output_name.ds_string);
+
+ if (close (out_file_des) < 0)
+ error (0, errno, "%s", output_name.ds_string);
+
if (reset_time_flag)
{
times.actime = in_file_stat.st_atime;
@@ -240,15 +246,24 @@
cdf_flag = 1;
}
#endif
- res = mkdir (output_name.ds_string, in_file_stat.st_mode);
+ res = mkdir (output_name.ds_string, in_file_stat.st_mode & ~077);
}
else
- res = 0;
+ {
+ if (!no_chown_flag && (out_file_stat.st_mode & 077) != 0
+ && chmod (output_name.ds_string, out_file_stat.st_mode & 07700) < 0)
+ {
+ error (0, errno, "%s: chmod", output_name.ds_string);
+ continue;
+ }
+ res = 0;
+ }
+
if (res < 0 && create_dir_flag)
{
create_all_directories (output_name.ds_string);
- res = mkdir (output_name.ds_string, in_file_stat.st_mode);
+ res = mkdir (output_name.ds_string, in_file_stat.st_mode & ~077);
}
if (res < 0)
{
@@ -311,12 +326,12 @@
if (link_res < 0)
{
- res = mknod (output_name.ds_string, in_file_stat.st_mode,
+ res = mknod (output_name.ds_string, in_file_stat.st_mode & ~077,
in_file_stat.st_rdev);
if (res < 0 && create_dir_flag)
{
create_all_directories (output_name.ds_string);
- res = mknod (output_name.ds_string, in_file_stat.st_mode,
+ res = mknod (output_name.ds_string, in_file_stat.st_mode & ~077,
in_file_stat.st_rdev);
}
if (res < 0)

View File

@ -1,193 +0,0 @@
--- cpio-2.6/doc/cpio.1.dirTraversal 2005-05-17 13:18:23.554759017 +0200
+++ cpio-2.6/doc/cpio.1 2005-05-17 13:19:08.178249507 +0200
@@ -20,7 +20,7 @@
[\-\-unconditional] [\-\-verbose] [\-\-block-size=blocks] [\-\-swap-halfwords]
[\-\-io-size=bytes] [\-\-pattern-file=file] [\-\-format=format]
[\-\-owner=[user][:.][group]] [\-\-no-preserve-owner] [\-\-message=message]
-[\-\-force\-local] [\-\-no\-absolute\-filenames] [\-\-sparse]
+[\-\-force\-local] [\-\-absolute\-filenames] [\-\-sparse]
[\-\-only\-verify\-crc] [\-\-quiet] [\-\-rsh-command=command] [\-\-help]
[\-\-version] [pattern...] [< archive]
--- cpio-2.6/doc/cpio.info.dirTraversal 2005-05-17 13:20:29.473392159 +0200
+++ cpio-2.6/doc/cpio.info 2005-05-17 13:30:53.812050889 +0200
@@ -203,7 +203,7 @@
[--swap-halfwords] [--io-size=bytes] [--pattern-file=file]
[--format=format] [--owner=[user][:.][group]]
[--no-preserve-owner] [--message=message] [--help] [--version]
- [-no-absolute-filenames] [--sparse] [-only-verify-crc] [-quiet]
+ [--absolute-filenames] [--sparse] [-only-verify-crc] [-quiet]
[--rsh-command=command] [pattern...] [< archive]

@@ -359,9 +359,9 @@
Show numeric UID and GID instead of translating them into names
when using the `--verbose option'.
-`--no-absolute-filenames'
- Create all files relative to the current directory in copy-in
- mode, even if they have an absolute file name in the archive.
+`--absolute-filenames'
+ Do not strip leading file name components that contain ".."
+ and leading slashes from file names in copy-in mode
`--no-preserve-owner'
Do not change the ownership of the files; leave them owned by the
--- cpio-2.6/src/main.c.dirTraversal 2005-05-17 12:10:15.952492515 +0200
+++ cpio-2.6/src/main.c 2005-05-17 12:10:15.965490607 +0200
@@ -41,6 +41,7 @@
enum cpio_options {
NO_ABSOLUTE_FILENAMES_OPTION=256,
+ ABSOLUTE_FILENAMES_OPTION,
NO_PRESERVE_OWNER_OPTION,
ONLY_VERIFY_CRC_OPTION,
RENAME_BATCH_FILE_OPTION,
@@ -134,6 +135,8 @@
N_("In copy-in mode, read additional patterns specifying filenames to extract or list from FILE"), 210},
{"no-absolute-filenames", NO_ABSOLUTE_FILENAMES_OPTION, 0, 0,
N_("Create all files relative to the current directory"), 210},
+ {"absolute-filenames", ABSOLUTE_FILENAMES_OPTION, 0, 0,
+ N_("do not strip leading file name components that contain \"..\" and leading slashes from file names"), 210},
{"only-verify-crc", ONLY_VERIFY_CRC_OPTION, 0, 0,
N_("When reading a CRC format archive in copy-in mode, only verify the CRC's of each file in the archive, don't actually extract the files"), 210},
{"rename", 'r', 0, 0,
@@ -393,7 +396,11 @@
break;
case NO_ABSOLUTE_FILENAMES_OPTION: /* --no-absolute-filenames */
- no_abs_paths_flag = true;
+ abs_paths_flag = false;
+ break;
+
+ case ABSOLUTE_FILENAMES_OPTION: /* --absolute-filenames */
+ abs_paths_flag = true;
break;
case NO_PRESERVE_OWNER_OPTION: /* --no-preserve-owner */
@@ -638,7 +638,7 @@
_("--append is used but no archive file name is given (use -F or -O options")));
CHECK_USAGE(rename_batch_file, "--rename-batch-file", "--create");
- CHECK_USAGE(no_abs_paths_flag, "--no-absolute-pathnames", "--create");
+ CHECK_USAGE(abs_paths_flag, "--absolute-pathnames", "--create");
CHECK_USAGE(sparse_flag, "--sparse", "--create");
CHECK_USAGE(input_archive_name, "-I", "--create");
if (archive_name && output_archive_name)
@@ -659,7 +666,7 @@
CHECK_USAGE(rename_flag, "--rename", "--pass-through");
CHECK_USAGE(append_flag, "--append", "--pass-through");
CHECK_USAGE(rename_batch_file, "--rename-batch-file", "--pass-through");
- CHECK_USAGE(no_abs_paths_flag, "--no-absolute-pathnames",
+ CHECK_USAGE(abs_paths_flag, "--absolute-pathnames",
"--pass-through");
CHECK_USAGE(to_stdout_option, "--to-stdout", "--pass-through");
--- cpio-2.6/src/copyin.c.dirTraversal 2005-05-17 12:10:15.957491781 +0200
+++ cpio-2.6/src/copyin.c 2005-05-17 12:10:15.962491047 +0200
@@ -25,6 +25,7 @@
#include "dstring.h"
#include "extern.h"
#include "defer.h"
+#include "dirname.h"
#include <rmt.h>
#ifndef FNM_PATHNAME
#include <fnmatch.h>
@@ -1349,6 +1350,53 @@
}
}
+/* Return a safer suffix of FILE_NAME, or "." if it has no safer
+ suffix. Check for fully specified file names and other atrocities. */
+
+static const char *
+safer_name_suffix (char const *file_name)
+{
+ char const *p;
+
+ /* Skip file system prefixes, leading file name components that contain
+ "..", and leading slashes. */
+
+ size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (file_name);
+
+ for (p = file_name + prefix_len; *p;)
+ {
+ if (p[0] == '.' && p[1] == '.' && (ISSLASH (p[2]) || !p[2]))
+ prefix_len = p + 2 - file_name;
+
+ do
+ {
+ char c = *p++;
+ if (ISSLASH (c))
+ break;
+ }
+ while (*p);
+ }
+
+ for (p = file_name + prefix_len; ISSLASH (*p); p++)
+ continue;
+ prefix_len = p - file_name;
+
+ if (prefix_len)
+ {
+ char *prefix = alloca (prefix_len + 1);
+ memcpy (prefix, file_name, prefix_len);
+ prefix[prefix_len] = '\0';
+
+
+ error (0, 0, _("Removing leading `%s' from member names"), prefix);
+ }
+
+ if (!*p)
+ p = ".";
+
+ return p;
+}
+
/* Read the collection from standard input and create files
in the file system. */
@@ -1459,18 +1507,11 @@
/* Do we have to ignore absolute paths, and if so, does the filename
have an absolute path? */
- if (no_abs_paths_flag && file_hdr.c_name && file_hdr.c_name [0] == '/')
+ if (!abs_paths_flag && file_hdr.c_name && file_hdr.c_name [0])
{
- char *p;
+ const char *p = safer_name_suffix (file_hdr.c_name);
- p = file_hdr.c_name;
- while (*p == '/')
- ++p;
- if (*p == '\0')
- {
- strcpy (file_hdr.c_name, ".");
- }
- else
+ if (p != file_hdr.c_name)
{
/* Debian hack: file_hrd.c_name is sometimes set to
point to static memory by code in tar.c. This
--- cpio-2.6/src/extern.h.dirTraversal 2005-05-17 12:10:15.944493689 +0200
+++ cpio-2.6/src/extern.h 2005-05-17 12:10:15.963490900 +0200
@@ -46,7 +46,7 @@
extern int sparse_flag;
extern int quiet_flag;
extern int only_verify_crc_flag;
-extern int no_abs_paths_flag;
+extern int abs_paths_flag;
extern unsigned int warn_option;
/* Values for warn_option */
--- cpio-2.6/src/global.c.dirTraversal 2004-09-08 12:23:44.000000000 +0200
+++ cpio-2.6/src/global.c 2005-05-17 12:10:15.964490753 +0200
@@ -100,7 +100,7 @@
int only_verify_crc_flag = false;
/* If true, don't use any absolute paths, prefix them by `./'. */
-int no_abs_paths_flag = false;
+int abs_paths_flag = false;
#ifdef DEBUG_CPIO
/* If true, print debugging information. */

View File

@ -1,170 +0,0 @@
--- cpio-2.6/src/copyin.c.lfs 2005-07-01 13:48:05.000000000 +0200
+++ cpio-2.6/src/copyin.c 2005-07-01 13:48:18.000000000 +0200
@@ -106,7 +106,7 @@
header type. */
static void
-tape_skip_padding (int in_file_des, int offset)
+tape_skip_padding (int in_file_des, unsigned long offset)
{
int pad;
--- cpio-2.6/src/extern.h.lfs 2004-09-08 12:49:57.000000000 +0200
+++ cpio-2.6/src/extern.h 2005-07-01 13:47:20.000000000 +0200
@@ -161,13 +161,13 @@
void tape_empty_output_buffer P_((int out_des));
void disk_empty_output_buffer P_((int out_des));
void swahw_array P_((char *ptr, int count));
-void tape_buffered_write P_((char *in_buf, int out_des, long num_bytes));
+void tape_buffered_write P_((char *in_buf, int out_des, unsigned long num_bytes));
void tape_buffered_read P_((char *in_buf, int in_des, long num_bytes));
int tape_buffered_peek P_((char *peek_buf, int in_des, int num_bytes));
-void tape_toss_input P_((int in_des, long num_bytes));
-void copy_files_tape_to_disk P_((int in_des, int out_des, long num_bytes));
-void copy_files_disk_to_tape P_((int in_des, int out_des, long num_bytes, char *filename));
-void copy_files_disk_to_disk P_((int in_des, int out_des, long num_bytes, char *filename));
+void tape_toss_input P_((int in_des, unsigned long num_bytes));
+void copy_files_tape_to_disk P_((int in_des, int out_des, unsigned long num_bytes));
+void copy_files_disk_to_tape P_((int in_des, int out_des, unsigned long num_bytes, char *filename));
+void copy_files_disk_to_disk P_((int in_des, int out_des, unsigned long num_bytes, char *filename));
void warn_if_file_changed P_((char *file_name, unsigned long old_file_size,
unsigned long old_file_mtime));
void create_all_directories P_((char *name));
--- cpio-2.6/src/util.c.lfs 2004-09-08 12:44:49.000000000 +0200
+++ cpio-2.6/src/util.c 2005-07-01 13:56:49.000000000 +0200
@@ -207,7 +207,7 @@
Exit with an error if end of file is reached. */
static int
-disk_fill_input_buffer (int in_des, int num_bytes)
+disk_fill_input_buffer (int in_des, unsigned long num_bytes)
{
in_buff = input_buffer;
num_bytes = (num_bytes < DISK_IO_BLOCK_SIZE) ? num_bytes : DISK_IO_BLOCK_SIZE;
@@ -227,9 +227,9 @@
When `out_buff' fills up, flush it to file descriptor OUT_DES. */
void
-tape_buffered_write (char *in_buf, int out_des, long num_bytes)
+tape_buffered_write (char *in_buf, int out_des, unsigned long num_bytes)
{
- register long bytes_left = num_bytes; /* Bytes needing to be copied. */
+ register unsigned long bytes_left = num_bytes; /* Bytes needing to be copied. */
register long space_left; /* Room left in output buffer. */
while (bytes_left > 0)
@@ -254,9 +254,9 @@
When `out_buff' fills up, flush it to file descriptor OUT_DES. */
void
-disk_buffered_write (char *in_buf, int out_des, long num_bytes)
+disk_buffered_write (char *in_buf, int out_des, unsigned long num_bytes)
{
- register long bytes_left = num_bytes; /* Bytes needing to be copied. */
+ register unsigned long bytes_left = num_bytes; /* Bytes needing to be copied. */
register long space_left; /* Room left in output buffer. */
while (bytes_left > 0)
@@ -376,9 +376,9 @@
/* Skip the next NUM_BYTES bytes of file descriptor IN_DES. */
void
-tape_toss_input (int in_des, long num_bytes)
+tape_toss_input (int in_des, unsigned long num_bytes)
{
- register long bytes_left = num_bytes; /* Bytes needing to be copied. */
+ register unsigned long bytes_left = num_bytes; /* Bytes needing to be copied. */
register long space_left; /* Bytes to copy from input buffer. */
while (bytes_left > 0)
@@ -404,12 +404,12 @@
}
static void
-write_nuls_to_file (long num_bytes, int out_des,
+write_nuls_to_file (unsigned long num_bytes, int out_des,
void (*writer) (char *in_buf, int out_des, long num_bytes))
{
- long blocks;
+ unsigned long blocks;
long extra_bytes;
- long i;
+ unsigned long i;
blocks = num_bytes / 512;
extra_bytes = num_bytes % 512;
@@ -428,10 +428,10 @@
NUM_BYTES is the number of bytes to copy. */
void
-copy_files_tape_to_disk (int in_des, int out_des, long num_bytes)
+copy_files_tape_to_disk (int in_des, int out_des, unsigned long num_bytes)
{
- long size;
- long k;
+ unsigned long size;
+ unsigned long k;
while (num_bytes > 0)
{
@@ -458,13 +458,13 @@
NUM_BYTES is the number of bytes to copy. */
void
-copy_files_disk_to_tape (int in_des, int out_des, long num_bytes,
+copy_files_disk_to_tape (int in_des, int out_des, unsigned long num_bytes,
char *filename)
{
- long size;
- long k;
+ unsigned long size;
+ unsigned long k;
int rc;
- long original_num_bytes;
+ unsigned long original_num_bytes;
original_num_bytes = num_bytes;
@@ -476,10 +476,10 @@
num_bytes : DISK_IO_BLOCK_SIZE))
{
if (rc > 0)
- error (0, 0, _("File %s shrunk by %ld bytes, padding with zeros"),
+ error (0, 0, _("File %s shrunk by %lld bytes, padding with zeros"),
filename, num_bytes);
else
- error (0, 0, _("Read error at byte %ld in file %s, padding with zeros"),
+ error (0, 0, _("Read error at byte %lld in file %s, padding with zeros"),
original_num_bytes - num_bytes, filename);
write_nuls_to_file (num_bytes, out_des, tape_buffered_write);
break;
@@ -505,12 +505,12 @@
NUM_BYTES is the number of bytes to copy. */
void
-copy_files_disk_to_disk (int in_des, int out_des, long num_bytes,
+copy_files_disk_to_disk (int in_des, int out_des, unsigned long num_bytes,
char *filename)
{
- long size;
- long k;
- long original_num_bytes;
+ unsigned long size;
+ unsigned long k;
+ unsigned long original_num_bytes;
int rc;
original_num_bytes = num_bytes;
@@ -520,10 +520,10 @@
if (rc = disk_fill_input_buffer (in_des, num_bytes))
{
if (rc > 0)
- error (0, 0, _("File %s shrunk by %ld bytes, padding with zeros"),
+ error (0, 0, _("File %s shrunk by %lld bytes, padding with zeros"),
filename, num_bytes);
else
- error (0, 0, _("Read error at byte %ld in file %s, padding with zeros"),
+ error (0, 0, _("Read error at byte %lld in file %s, padding with zeros"),
original_num_bytes - num_bytes, filename);
write_nuls_to_file (num_bytes, out_des, disk_buffered_write);
break;

View File

@ -1,555 +0,0 @@
--- cpio-2.6/src/copyout.c
+++ cpio-2.6/src/copyout.c
@@ -159,7 +159,7 @@
}
/* We are about to put a file into a newc or crc archive that is
- multiply linked. We have already seen and defered all of the
+ multiply linked. We have already seen and deferred all of the
other links to the file but haven't written them into the archive.
Write the other links into the archive, and remove them from the
deferouts list. */
@@ -231,8 +231,10 @@
file_hdr.c_filesize,
header->c_name);
- write_out_header (&file_hdr, out_file_des);
- copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize, header->c_name);
+ if (write_out_header (&file_hdr, out_file_des))
+ return;
+ copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize,
+ header->c_name);
warn_if_file_changed(header->c_name, file_hdr.c_filesize, file_hdr.c_mtime);
if (archive_format == arf_tar || archive_format == arf_ustar)
@@ -288,153 +290,311 @@
}
}
-
-/* Write out header FILE_HDR, including the file name, to file
- descriptor OUT_DES. */
+/* FIXME: These two defines should be defined in paxutils */
+#define LG_8 3
+#define LG_16 4
+
+/* FIXME: to_ascii could be used instead of to_oct() and to_octal() from tar,
+ so it should be moved to paxutils too.
+ Allowed values for logbase are: 1 (binary), 2, 3 (octal), 4 (hex) */
+int
+to_ascii (char *where, uintmax_t v, size_t digits, unsigned logbase)
+{
+ static char codetab[] = "0123456789ABCDEF";
+ int i = digits;
+
+ do
+ {
+ where[--i] = codetab[(v & ((1 << logbase) - 1))];
+ v >>= logbase;
+ }
+ while (i);
+
+ return v != 0;
+}
+
+static void
+field_width_error (const char *filename, const char *fieldname)
+{
+ error (0, 0, _("%s: field width not sufficient for storing %s"),
+ filename, fieldname);
+}
+
+static void
+field_width_warning (const char *filename, const char *fieldname)
+{
+ if (warn_option & CPIO_WARN_TRUNCATE)
+ error (0, 0, _("%s: truncating %s"), filename, fieldname);
+}
void
-write_out_header (struct new_cpio_header *file_hdr, int out_des)
+to_ascii_or_warn (char *where, uintmax_t n, size_t digits,
+ unsigned logbase,
+ const char *filename, const char *fieldname)
+{
+ if (to_ascii (where, n, digits, logbase))
+ field_width_warning (filename, fieldname);
+}
+
+int
+to_ascii_or_error (char *where, uintmax_t n, size_t digits,
+ unsigned logbase,
+ const char *filename, const char *fieldname)
{
- if (archive_format == arf_newascii || archive_format == arf_crcascii)
+ if (to_ascii (where, n, digits, logbase))
{
- char ascii_header[112];
- char *magic_string;
+ field_width_error (filename, fieldname);
+ return 1;
+ }
+ return 0;
+}
- if (archive_format == arf_crcascii)
- magic_string = "070702";
- else
- magic_string = "070701";
- sprintf (ascii_header,
- "%6s%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx",
- magic_string,
- file_hdr->c_ino, file_hdr->c_mode, file_hdr->c_uid,
- file_hdr->c_gid, file_hdr->c_nlink, file_hdr->c_mtime,
- file_hdr->c_filesize, file_hdr->c_dev_maj, file_hdr->c_dev_min,
- file_hdr->c_rdev_maj, file_hdr->c_rdev_min, file_hdr->c_namesize,
- file_hdr->c_chksum & 0xffffffff);
- tape_buffered_write (ascii_header, out_des, 110L);
-
- /* Write file name to output. */
- tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
- tape_pad_output (out_des, file_hdr->c_namesize + 110);
- }
- else if (archive_format == arf_oldascii || archive_format == arf_hpoldascii)
- {
- char ascii_header[78];
- dev_t dev;
- dev_t rdev;
+int
+write_out_new_ascii_header (const char *magic_string,
+ struct new_cpio_header *file_hdr, int out_des)
+{
+ char ascii_header[110];
+ char *p;
- if (archive_format == arf_oldascii)
- {
- dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
- rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
- }
- else
- {
- /* HP/UX cpio creates archives that look just like ordinary archives,
- but for devices it sets major = 0, minor = 1, and puts the
- actual major/minor number in the filesize field. */
- switch (file_hdr->c_mode & CP_IFMT)
- {
- case CP_IFCHR:
- case CP_IFBLK:
+ p = stpcpy (ascii_header, magic_string);
+ to_ascii_or_warn (p, file_hdr->c_ino, 8, LG_16,
+ file_hdr->c_name, _("inode number"));
+ p += 8;
+ to_ascii_or_warn (p, file_hdr->c_mode, 8, LG_16, file_hdr->c_name,
+ _("file mode"));
+ p += 8;
+ to_ascii_or_warn (p, file_hdr->c_uid, 8, LG_16, file_hdr->c_name,
+ _("uid"));
+ p += 8;
+ to_ascii_or_warn (p, file_hdr->c_gid, 8, LG_16, file_hdr->c_name,
+ _("gid"));
+ p += 8;
+ to_ascii_or_warn (p, file_hdr->c_nlink, 8, LG_16, file_hdr->c_name,
+ _("number of links"));
+ p += 8;
+ to_ascii_or_warn (p, file_hdr->c_mtime, 8, LG_16, file_hdr->c_name,
+ _("modification time"));
+ p += 8;
+ if (to_ascii_or_error (p, file_hdr->c_filesize, 8, LG_16, file_hdr->c_name,
+ _("file size")))
+ return 1;
+ p += 8;
+ if (to_ascii_or_error (p, file_hdr->c_dev_maj, 8, LG_16, file_hdr->c_name,
+ _("device major number")))
+ return 1;
+ p += 8;
+ if (to_ascii_or_error (p, file_hdr->c_dev_min, 8, LG_16, file_hdr->c_name,
+ _("device minor number")))
+ return 1;
+ p += 8;
+ if (to_ascii_or_error (p, file_hdr->c_rdev_maj, 8, LG_16, file_hdr->c_name,
+ _("rdev major")))
+ return 1;
+ p += 8;
+ if (to_ascii_or_error (p, file_hdr->c_rdev_min, 8, LG_16, file_hdr->c_name,
+ _("rdev minor")))
+ return 1;
+ p += 8;
+ if (to_ascii_or_error (p, file_hdr->c_namesize, 8, LG_16, file_hdr->c_name,
+ _("name size")))
+ return 1;
+ p += 8;
+ to_ascii (p, file_hdr->c_chksum & 0xffffffff, 8, LG_16);
+
+ tape_buffered_write (ascii_header, out_des, sizeof ascii_header);
+
+ /* Write file name to output. */
+ tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
+ tape_pad_output (out_des, file_hdr->c_namesize + sizeof ascii_header);
+ return 0;
+}
+
+int
+write_out_old_ascii_header (dev_t dev, dev_t rdev,
+ struct new_cpio_header *file_hdr, int out_des)
+{
+ char ascii_header[76];
+ char *p = ascii_header;
+
+ to_ascii (p, file_hdr->c_magic, 6, LG_8);
+ p += 6;
+ to_ascii_or_warn (p, dev, 6, LG_8, file_hdr->c_name, _("device number"));
+ p += 6;
+ to_ascii_or_warn (p, file_hdr->c_ino, 6, LG_8, file_hdr->c_name,
+ _("inode number"));
+ p += 6;
+ to_ascii_or_warn (p, file_hdr->c_mode, 6, LG_8, file_hdr->c_name,
+ _("file mode"));
+ p += 6;
+ to_ascii_or_warn (p, file_hdr->c_uid, 6, LG_8, file_hdr->c_name, _("uid"));
+ p += 6;
+ to_ascii_or_warn (p, file_hdr->c_gid, 6, LG_8, file_hdr->c_name, _("gid"));
+ p += 6;
+ to_ascii_or_warn (p, file_hdr->c_nlink, 6, LG_8, file_hdr->c_name,
+ _("number of links"));
+ p += 6;
+ to_ascii_or_warn (p, rdev, 6, LG_8, file_hdr->c_name, _("rdev"));
+ p += 6;
+ to_ascii_or_warn (p, file_hdr->c_mtime, 11, LG_8, file_hdr->c_name,
+ _("modification time"));
+ p += 11;
+ if (to_ascii_or_error (p, file_hdr->c_namesize, 6, LG_8, file_hdr->c_name,
+ _("name size")))
+ return 1;
+ p += 6;
+ if (to_ascii_or_error (p, file_hdr->c_filesize, 11, LG_8, file_hdr->c_name,
+ _("file size")))
+ return 1;
+
+ tape_buffered_write (ascii_header, out_des, sizeof ascii_header);
+
+ /* Write file name to output. */
+ tape_buffered_write (file_hdr->c_name, out_des, file_hdr->c_namesize);
+ return 0;
+}
+
+void
+hp_compute_dev (struct new_cpio_header *file_hdr, dev_t *pdev, dev_t *prdev)
+{
+ /* HP/UX cpio creates archives that look just like ordinary archives,
+ but for devices it sets major = 0, minor = 1, and puts the
+ actual major/minor number in the filesize field. */
+ switch (file_hdr->c_mode & CP_IFMT)
+ {
+ case CP_IFCHR:
+ case CP_IFBLK:
#ifdef CP_IFSOCK
- case CP_IFSOCK:
+ case CP_IFSOCK:
#endif
#ifdef CP_IFIFO
- case CP_IFIFO:
+ case CP_IFIFO:
#endif
- file_hdr->c_filesize = makedev (file_hdr->c_rdev_maj,
- file_hdr->c_rdev_min);
- rdev = 1;
- break;
- default:
- dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
- rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
- break;
- }
- }
+ file_hdr->c_filesize = makedev (file_hdr->c_rdev_maj,
+ file_hdr->c_rdev_min);
+ *pdev = *prdev = makedev (0, 1);
+ break;
+
+ default:
+ *pdev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
+ *prdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
+ break;
+ }
+}
- if ((warn_option & CPIO_WARN_TRUNCATE) && (file_hdr->c_ino >> 16) != 0)
- error (0, 0, _("%s: truncating inode number"), file_hdr->c_name);
+int
+write_out_binary_header (dev_t rdev,
+ struct new_cpio_header *file_hdr, int out_des)
+{
+ struct old_cpio_header short_hdr;
- /* Debian hack: The type of dev_t has changed in glibc. Fixed output
- to ensure that a long int is passed to sprintf. This has been
- reported to "bug-gnu-utils@prep.ai.mit.edu". (1998/5/26) -BEM */
- sprintf (ascii_header,
- "%06ho%06lo%06lo%06lo%06lo%06lo%06lo%06lo%011lo%06lo%011lo",
- file_hdr->c_magic & 0xFFFF, (long) dev & 0xFFFF,
- file_hdr->c_ino & 0xFFFF, file_hdr->c_mode & 0xFFFF,
- file_hdr->c_uid & 0xFFFF, file_hdr->c_gid & 0xFFFF,
- file_hdr->c_nlink & 0xFFFF, (long) rdev & 0xFFFF,
- file_hdr->c_mtime, file_hdr->c_namesize & 0xFFFF,
- file_hdr->c_filesize);
- tape_buffered_write (ascii_header, out_des, 76L);
+ short_hdr.c_magic = 070707;
+ short_hdr.c_dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
- /* Write file name to output. */
- tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
- }
- else if (archive_format == arf_tar || archive_format == arf_ustar)
- {
- write_out_tar_header (file_hdr, out_des);
- }
- else
- {
- struct old_cpio_header short_hdr;
+ if ((warn_option & CPIO_WARN_TRUNCATE) && (file_hdr->c_ino >> 16) != 0)
+ error (0, 0, _("%s: truncating inode number"), file_hdr->c_name);
- short_hdr.c_magic = 070707;
- short_hdr.c_dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
+ short_hdr.c_ino = file_hdr->c_ino & 0xFFFF;
+ if (short_hdr.c_ino != file_hdr->c_ino)
+ field_width_warning (file_hdr->c_name, _("inode number"));
+
+ short_hdr.c_mode = file_hdr->c_mode & 0xFFFF;
+ if (short_hdr.c_mode != file_hdr->c_mode)
+ field_width_warning (file_hdr->c_name, _("file mode"));
+
+ short_hdr.c_uid = file_hdr->c_uid & 0xFFFF;
+ if (short_hdr.c_uid != file_hdr->c_uid)
+ field_width_warning (file_hdr->c_name, _("uid"));
+
+ short_hdr.c_gid = file_hdr->c_gid & 0xFFFF;
+ if (short_hdr.c_gid != file_hdr->c_gid)
+ field_width_warning (file_hdr->c_name, _("gid"));
+
+ short_hdr.c_nlink = file_hdr->c_nlink & 0xFFFF;
+ if (short_hdr.c_nlink != file_hdr->c_nlink)
+ field_width_warning (file_hdr->c_name, _("number of links"));
+
+ short_hdr.c_rdev = rdev;
+ short_hdr.c_mtimes[0] = file_hdr->c_mtime >> 16;
+ short_hdr.c_mtimes[1] = file_hdr->c_mtime & 0xFFFF;
+
+ short_hdr.c_namesize = file_hdr->c_namesize & 0xFFFF;
+ if (short_hdr.c_namesize != file_hdr->c_namesize)
+ {
+ field_width_error (file_hdr->c_name, _("name size"));
+ return 1;
+ }
+
+ short_hdr.c_filesize = file_hdr->c_filesize;
+ if (short_hdr.c_filesize != file_hdr->c_filesize)
+ {
+ field_width_error (file_hdr->c_name, _("file size"));
+ return 1;
+ }
+
+ short_hdr.c_filesizes[0] = file_hdr->c_filesize >> 16;
+ short_hdr.c_filesizes[1] = file_hdr->c_filesize & 0xFFFF;
- if ((warn_option & CPIO_WARN_TRUNCATE) && (file_hdr->c_ino >> 16) != 0)
- error (0, 0, _("%s: truncating inode number"), file_hdr->c_name);
+ /* Output the file header. */
+ tape_buffered_write ((char *) &short_hdr, out_des, 26);
- short_hdr.c_ino = file_hdr->c_ino & 0xFFFF;
- short_hdr.c_mode = file_hdr->c_mode & 0xFFFF;
- short_hdr.c_uid = file_hdr->c_uid & 0xFFFF;
- short_hdr.c_gid = file_hdr->c_gid & 0xFFFF;
- short_hdr.c_nlink = file_hdr->c_nlink & 0xFFFF;
- if (archive_format != arf_hpbinary)
- short_hdr.c_rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
- else
- {
- switch (file_hdr->c_mode & CP_IFMT)
- {
- /* HP/UX cpio creates archives that look just like ordinary
- archives, but for devices it sets major = 0, minor = 1, and
- puts the actual major/minor number in the filesize field. */
- case CP_IFCHR:
- case CP_IFBLK:
-#ifdef CP_IFSOCK
- case CP_IFSOCK:
-#endif
-#ifdef CP_IFIFO
- case CP_IFIFO:
-#endif
- file_hdr->c_filesize = makedev (file_hdr->c_rdev_maj,
- file_hdr->c_rdev_min);
- short_hdr.c_rdev = makedev (0, 1);
- break;
- default:
- short_hdr.c_rdev = makedev (file_hdr->c_rdev_maj,
- file_hdr->c_rdev_min);
- break;
- }
- }
- short_hdr.c_mtimes[0] = file_hdr->c_mtime >> 16;
- short_hdr.c_mtimes[1] = file_hdr->c_mtime & 0xFFFF;
+ /* Write file name to output. */
+ tape_buffered_write (file_hdr->c_name, out_des, file_hdr->c_namesize);
- short_hdr.c_namesize = file_hdr->c_namesize & 0xFFFF;
+ tape_pad_output (out_des, file_hdr->c_namesize + 26);
+ return 0;
+}
- short_hdr.c_filesizes[0] = file_hdr->c_filesize >> 16;
- short_hdr.c_filesizes[1] = file_hdr->c_filesize & 0xFFFF;
+
+/* Write out header FILE_HDR, including the file name, to file
+ descriptor OUT_DES. */
- /* Output the file header. */
- tape_buffered_write ((char *) &short_hdr, out_des, 26L);
+int
+write_out_header (struct new_cpio_header *file_hdr, int out_des)
+{
+ dev_t dev;
+ dev_t rdev;
+
+ switch (archive_format)
+ {
+ case arf_newascii:
+ return write_out_new_ascii_header ("070701", file_hdr, out_des);
+
+ case arf_crcascii:
+ return write_out_new_ascii_header ("070702", file_hdr, out_des);
+
+ case arf_oldascii:
+ return write_out_old_ascii_header (makedev (file_hdr->c_dev_maj,
+ file_hdr->c_dev_min),
+ makedev (file_hdr->c_rdev_maj,
+ file_hdr->c_rdev_min),
+ file_hdr, out_des);
+
+ case arf_hpoldascii:
+ hp_compute_dev (file_hdr, &dev, &rdev);
+ return write_out_old_ascii_header (dev, rdev, file_hdr, out_des);
+
+ case arf_tar:
+ case arf_ustar:
+ if (is_tar_filename_too_long (file_hdr->c_name))
+ {
+ error (0, 0, _("%s: file name too long"), file_hdr->c_name);
+ return 1;
+ }
+ write_out_tar_header (file_hdr, out_des); /* FIXME: No error checking */
+ return 0;
- /* Write file name to output. */
- tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
+ case arf_binary:
+ return write_out_binary_header (makedev (file_hdr->c_rdev_maj,
+ file_hdr->c_rdev_min),
+ file_hdr, out_des);
+
+ case arf_hpbinary:
+ hp_compute_dev (file_hdr, &dev, &rdev);
+ /* FIXME: dev ignored. Should it be? */
+ return write_out_binary_header (rdev, file_hdr, out_des);
- tape_pad_output (out_des, file_hdr->c_namesize + 26);
+ default:
+ abort ();
}
}
@@ -593,14 +753,7 @@
file_hdr.c_namesize = strlen (p) + 1;
}
#endif
- if ((archive_format == arf_tar || archive_format == arf_ustar)
- && is_tar_filename_too_long (file_hdr.c_name))
- {
- error (0, 0, _("%s: file name too long"),
- file_hdr.c_name);
- continue;
- }
-
+
/* Copy the named file to the output. */
switch (file_hdr.c_mode & CP_IFMT)
{
@@ -613,7 +766,8 @@
file_hdr.c_dev_min)))
{
file_hdr.c_tar_linkname = otherfile;
- write_out_header (&file_hdr, out_file_des);
+ if (write_out_header (&file_hdr, out_file_des))
+ continue;
break;
}
}
@@ -643,7 +797,8 @@
file_hdr.c_filesize,
input_name.ds_string);
- write_out_header (&file_hdr, out_file_des);
+ if (write_out_header (&file_hdr, out_file_des))
+ continue;
copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize, input_name.ds_string);
warn_if_file_changed(input_name.ds_string, file_hdr.c_filesize,
file_hdr.c_mtime);
@@ -673,7 +828,8 @@
case CP_IFDIR:
file_hdr.c_filesize = 0;
- write_out_header (&file_hdr, out_file_des);
+ if (write_out_header (&file_hdr, out_file_des))
+ continue;
break;
case CP_IFCHR:
@@ -702,14 +858,16 @@
file_hdr.c_mode = (file_stat.st_mode & 07777);
file_hdr.c_mode |= CP_IFREG;
file_hdr.c_tar_linkname = otherfile;
- write_out_header (&file_hdr, out_file_des);
+ if (write_out_header (&file_hdr, out_file_des))
+ continue;
break;
}
add_inode (file_hdr.c_ino, file_hdr.c_name,
file_hdr.c_dev_maj, file_hdr.c_dev_min);
}
file_hdr.c_filesize = 0;
- write_out_header (&file_hdr, out_file_des);
+ if (write_out_header (&file_hdr, out_file_des))
+ continue;
break;
#ifdef CP_IFLNK
@@ -738,12 +896,14 @@
{
link_name[link_size] = '\0';
file_hdr.c_tar_linkname = link_name;
- write_out_header (&file_hdr, out_file_des);
+ if (write_out_header (&file_hdr, out_file_des))
+ continue;
}
}
else
{
- write_out_header (&file_hdr, out_file_des);
+ if (write_out_header (&file_hdr, out_file_des))
+ continue;
tape_buffered_write (link_name, out_file_des, link_size);
tape_pad_output (out_file_des, link_size);
}
--- cpio-2.6/src/extern.h
+++ cpio-2.6/src/extern.h
@@ -112,7 +112,7 @@
void print_name_with_quoting P_((char *p));
/* copyout.c */
-void write_out_header P_((struct new_cpio_header *file_hdr, int out_des));
+int write_out_header P_((struct new_cpio_header *file_hdr, int out_des));
void process_copy_out P_((void));
/* copypass.c */

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6e60c5c370d451605fcb23e26cc37c18182f62009282ca73bf5dea4519e17360
size 448452

View File

@ -0,0 +1,70 @@
--- src/copyin.c
+++ src/copyin.c
@@ -108,7 +108,7 @@
header type. */
static void
-tape_skip_padding (int in_file_des, int offset)
+tape_skip_padding (int in_file_des, off_t offset)
{
int pad;
--- src/extern.h
+++ src/extern.h
@@ -166,8 +166,8 @@
void copy_files_tape_to_disk (int in_des, int out_des, off_t num_bytes);
void copy_files_disk_to_tape (int in_des, int out_des, off_t num_bytes, char *filename);
void copy_files_disk_to_disk (int in_des, int out_des, off_t num_bytes, char *filename);
-void warn_if_file_changed (char *file_name, unsigned long old_file_size,
- off_t old_file_mtime);
+void warn_if_file_changed (char *file_name, off_t old_file_size,
+ time_t old_file_mtime);
void create_all_directories (char *name);
void prepare_append (int out_file_des);
char *find_inode_file (unsigned long node_num,
--- src/util.c
+++ src/util.c
@@ -441,8 +441,8 @@
void
copy_files_tape_to_disk (int in_des, int out_des, off_t num_bytes)
{
- long size;
- long k;
+ off_t size;
+ off_t k;
while (num_bytes > 0)
{
@@ -472,8 +472,8 @@
copy_files_disk_to_tape (int in_des, int out_des, off_t num_bytes,
char *filename)
{
- long size;
- long k;
+ off_t size;
+ off_t k;
int rc;
off_t original_num_bytes;
@@ -525,8 +525,8 @@
copy_files_disk_to_disk (int in_des, int out_des, off_t num_bytes,
char *filename)
{
- long size;
- long k;
+ off_t size;
+ off_t k;
off_t original_num_bytes;
int rc;
@@ -567,8 +567,8 @@
/* Warn if file changed while it was being copied. */
void
-warn_if_file_changed (char *file_name, unsigned long old_file_size,
- off_t old_file_mtime)
+warn_if_file_changed (char *file_name, off_t old_file_size,
+ time_t old_file_mtime)
{
struct stat new_file_stat;
if ((*xstat) (file_name, &new_file_stat) < 0)

View File

@ -1,11 +1,3 @@
--- Makefile.am
+++ Makefile.am
@@ -19,4 +19,4 @@
AUTOMAKE_OPTIONS = gnits 1.8 dist-bzip2 std-options
-SUBDIRS = doc headers lib rmt src po tests
+SUBDIRS = doc headers lib src po tests
--- doc/mt.1
+++ doc/mt.1
@@ -76,9 +76,6 @@
@ -90,7 +82,7 @@
exits with a status of 0 if the operation succeeded, 1 if the
--- lib/system.h
+++ lib/system.h
@@ -473,10 +473,11 @@
@@ -431,10 +431,11 @@
#if HAVE_LOCALE_H
# include <locale.h>
@ -102,10 +94,10 @@
+#endif
#include <time.h>
#if defined(HAVE_SYS_TIME_H) && defined(TIME_WITH_SYS_TIME)
#ifdef TIME_WITH_SYS_TIME
--- src/Makefile.am
+++ src/Makefile.am
@@ -17,7 +17,7 @@
@@ -18,7 +18,7 @@
INCLUDES=-I. -I.. -I$(top_srcdir)/lib
@ -116,80 +108,24 @@
cpio_SOURCES = \
--- src/copyin.c
+++ src/copyin.c
@@ -176,7 +176,7 @@
#endif
if (crc != file_hdr->c_chksum)
{
- error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
+ error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
file_hdr->c_name, crc, file_hdr->c_chksum);
}
}
@@ -541,7 +541,7 @@
if (archive_format == arf_crcascii)
{
if (crc != file_hdr->c_chksum)
- error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
+ error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
file_hdr->c_name, crc, file_hdr->c_chksum);
}
tape_skip_padding (in_file_des, file_hdr->c_filesize);
@@ -563,7 +563,7 @@
if (archive_format == arf_crcascii)
{
if (crc != file_hdr->c_chksum)
- error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
+ error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
file_hdr->c_name, crc, file_hdr->c_chksum);
}
@@ -825,7 +825,7 @@
@@ -768,7 +768,7 @@
static void
copyin_file (struct new_cpio_header* file_hdr, int in_file_des)
copyin_file (struct cpio_file_stat* file_hdr, int in_file_des)
{
- int existing_dir;
+ int existing_dir=0;
if (!to_stdout_option
&& try_existing_file (file_hdr, in_file_des, &existing_dir) < 0)
@@ -897,7 +897,7 @@
}
tbuf[16] = '\0';
- printf ("%s %3u ", mbuf, file_hdr->c_nlink);
+ printf ("%s %3lu ", mbuf, file_hdr->c_nlink);
if (numeric_uid)
printf ("%-8u %-8u ", (unsigned int) file_hdr->c_uid,
@@ -908,7 +908,7 @@
if ((file_hdr->c_mode & CP_IFMT) == CP_IFCHR
|| (file_hdr->c_mode & CP_IFMT) == CP_IFBLK)
- printf ("%3u, %3u ", file_hdr->c_rdev_maj,
+ printf ("%3lu, %3lu ", file_hdr->c_rdev_maj,
file_hdr->c_rdev_min);
else
printf ("%8lu ", file_hdr->c_filesize);
@@ -1342,14 +1342,15 @@
process_copy_in ()
{
char done = false; /* True if trailer reached. */
- FILE *tty_in; /* Interactive file for rename option. */
- FILE *tty_out; /* Interactive file for rename option. */
- FILE *rename_in; /* Batch file for rename option. */
+ FILE *tty_in=NULL; /* Interactive file for rename option. */
+ FILE *tty_out=NULL; /* Interactive file for rename option. */
+ FILE *rename_in=NULL; /* Batch file for rename option. */
struct stat file_stat; /* Output file stat record. */
struct new_cpio_header file_hdr; /* Output header information. */
@@ -1355,6 +1355,7 @@
int in_file_des; /* Input file descriptor. */
char skip_file; /* Flag for use with patterns. */
int i; /* Loop index variable. */
+ int lastpattern = 0;
/* Initialize the copy in. */
if (pattern_file_name)
@@ -1477,8 +1478,10 @@
umask (0); /* Reset umask to preserve modes of
created files */
@@ -1463,8 +1464,10 @@
for (i = 0; i < num_patterns
&& skip_file == copy_matching_files; i++)
{
@ -201,20 +137,11 @@
}
}
@@ -1530,7 +1533,7 @@
tape_skip_padding (in_file_des, file_hdr.c_filesize);
if (crc != file_hdr.c_chksum)
{
- error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
+ error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
file_hdr.c_name, crc, file_hdr.c_chksum);
}
/* Debian hack: -v and -V now work with --only-verify-crc.
--- src/mt.c
+++ src/mt.c
@@ -16,6 +16,10 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
@@ -17,6 +17,10 @@
02110-1301 USA
*/
+/* Modified for the Linux SCSI tape driver by Brian Mays from code
+ written by Kai Makisara.
@ -223,7 +150,7 @@
/* If -f is not given, the environment variable TAPE is used;
if that is not set, a default device defined in sys/mtio.h is used.
@@ -50,6 +54,46 @@
@@ -51,6 +55,46 @@
retension Rewind the tape, then wind it to the end of the reel,
then rewind it again.
erase Erase the tape.
@ -270,7 +197,7 @@
David MacKenzie <djm@gnu.ai.mit.edu> */
@@ -104,6 +148,45 @@
@@ -105,6 +149,45 @@
void exit ();
#endif
@ -316,7 +243,7 @@
char *opnames[] =
{
"eof", "weof", "fsf", "bsf", "fsr", "bsr",
@@ -113,6 +196,8 @@
@@ -114,6 +197,8 @@
#endif
#ifdef MTEOM
"eom",
@ -325,7 +252,7 @@
#endif
#ifdef MTRETEN
"retension",
@@ -127,6 +212,39 @@
@@ -128,6 +213,39 @@
#ifdef MTSEEK
"seek",
#endif
@ -365,7 +292,7 @@
NULL
};
@@ -140,6 +258,8 @@
@@ -141,6 +259,8 @@
#endif
#ifdef MTEOM
MTEOM,
@ -374,7 +301,7 @@
#endif
#ifdef MTRETEN
MTRETEN,
@@ -154,9 +274,69 @@
@@ -155,9 +275,69 @@
#ifdef MTSEEK
MTSEEK,
#endif
@ -411,9 +338,9 @@
+#ifdef MTDENS
+ MTDENS,
+#endif
+ 0
+};
+
0
};
+char *cbnames[] =
+{
+#ifdef MT_ST_BOOLEANS
@ -433,9 +360,9 @@
+#ifdef MT_ST_WRITE_THRESHOLD
+ MT_ST_WRITE_THRESHOLD,
+#endif
0
};
+ 0
+};
+
+#ifdef MT_TAPE_INFO
+ struct mt_tape_info tapes[] = MT_TAPE_INFO;
+#endif
@ -444,7 +371,7 @@
struct option longopts[] =
{
{"file", 1, NULL, 'f'},
@@ -199,10 +379,22 @@
@@ -200,10 +380,22 @@
print_status (char *dev, int desc)
{
struct mtget status;
@ -453,7 +380,7 @@
+#endif
if (rmtioctl (desc, MTIOCGET, (char*)&status) == -1)
error (2, errno, "%s", dev);
error (2, errno, _("%s: rmtioctl failed"), dev);
+#ifdef MT_TAPE_INFO
+ for (mt = tapes; mt->t_type; mt++)
@ -467,7 +394,7 @@
printf ("drive type = %d\n", (int) status.mt_type);
#if defined(hpux) || defined(__hpux)
printf ("drive status (high) = %d\n", (int) status.mt_dsreg1);
@@ -216,8 +408,178 @@
@@ -217,7 +409,177 @@
printf ("file number = %d\n", (int) status.mt_fileno);
printf ("block number = %d\n", (int) status.mt_blkno);
#endif
@ -589,8 +516,8 @@
+ return 0;
+ }
+ return 1;
}
+}
+
+
+int
+do_dat_compression(char *dev, int fn, int count)
@ -602,14 +529,14 @@
+ error (2, errno, "%s", dev);
+ }
+
+ if (count != 1) {
+ if (count != -1) {
+ if (count == 0)
+ buffer[4+2] &= 0x7f;
+ else
+ buffer[4+2] |= 0x80;
+ if (read_mode_page(fn, 0x0f, 16, mask, 1))
+ for (i=2; i < 16; i++)
+ buffer[4+i] |= mask[4+i];
+/* if (read_mode_page(fn, 0x0f, 16, mask, 1))
+ for (i=3; i < 16; i++)
+ buffer[4+i] |= mask[4+i]; bug #223494 */
+ if (!write_mode_page(fn, 0x0f, 16, buffer)) {
+ error (2, errno, "%s", dev);
+ }
@ -624,7 +551,7 @@
+ printf("Compression off.\n");
+
+ return 1;
+}
}
+#endif
+
+#ifdef MTTELL
@ -642,11 +569,10 @@
+}
+#endif
+
+
void
usage (FILE *fp,int status)
{
@@ -277,7 +639,7 @@
@@ -276,7 +638,7 @@
if (optind == argc)
usage (stderr, 1);
@ -654,8 +580,8 @@
+ i = argmatch (argv[optind], opnames,NULL,0);
if (i < 0)
{
invalid_arg ("tape operation", argv[optind], i);
@@ -309,10 +671,29 @@
argmatch_invalid ("tape operation", argv[optind], i);
@@ -308,10 +670,29 @@
#endif
}
@ -685,8 +611,8 @@
)
tapedesc = rmtopen (tapedev, O_WRONLY, 0, rsh_command_option);
else
@@ -321,6 +702,17 @@
error (1, errno, "%s", tapedev);
@@ -320,6 +701,17 @@
error (1, errno, _("%s: rmtopen failed"), tapedev);
check_type (tapedev, tapedesc);
+#ifdef MTDATCOMP
@ -703,11 +629,11 @@
if (operation == MTASF)
{
perform_operation (tapedev, tapedesc, MTREW, 1);
@@ -329,6 +721,7 @@
@@ -328,6 +720,7 @@
perform_operation (tapedev, tapedesc, operation, count);
if (operation == MTNOP)
print_status (tapedev, tapedesc);
+ }
if (rmtclose (tapedesc) == -1)
error (2, errno, "%s", tapedev);
error (2, errno, _("%s: rmtclose failed"), tapedev);

19
cpio-2.9-no_rmt.patch Normal file
View File

@ -0,0 +1,19 @@
--- Makefile.am
+++ Makefile.am
@@ -19,4 +19,4 @@
AUTOMAKE_OPTIONS = gnits 1.8 dist-bzip2 std-options
-SUBDIRS = doc headers lib rmt src po tests
+SUBDIRS = doc headers lib src po tests
--- Makefile.in
+++ Makefile.in
@@ -300,7 +300,7 @@
target_alias = @target_alias@
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = gnits 1.8 dist-bzip2 std-options
-SUBDIRS = doc headers lib rmt src po tests
+SUBDIRS = doc headers lib src po tests
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive

View File

@ -0,0 +1,34 @@
--- src/mt.c
+++ src/mt.c
@@ -694,9 +694,9 @@
|| (operation == MTDATCOMP)
#endif
)
- tapedesc = rmtopen (tapedev, O_WRONLY, 0, rsh_command_option);
+ tapedesc = rmtopen (tapedev, O_WRONLY | O_NONBLOCK, 0, rsh_command_option);
else
- tapedesc = rmtopen (tapedev, O_RDONLY, 0, rsh_command_option);
+ tapedesc = rmtopen (tapedev, O_RDONLY | O_NONBLOCK, 0, rsh_command_option);
if (tapedesc == -1)
error (1, errno, _("%s: rmtopen failed"), tapedev);
check_type (tapedev, tapedesc);
--- src/util.c
+++ src/util.c
@@ -753,14 +753,14 @@
copy_in = process_copy_in;
if (copy_function == copy_in)
- fd = rmtopen (file, O_RDONLY | O_BINARY, MODE_RW, rsh_command_option);
+ fd = rmtopen (file, O_RDONLY | O_BINARY | O_NONBLOCK, MODE_RW, rsh_command_option);
else
{
if (!append_flag)
- fd = rmtopen (file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, MODE_RW,
+ fd = rmtopen (file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_NONBLOCK, MODE_RW,
rsh_command_option);
else
- fd = rmtopen (file, O_RDWR | O_BINARY, MODE_RW, rsh_command_option);
+ fd = rmtopen (file, O_RDWR | O_BINARY | O_NONBLOCK, MODE_RW, rsh_command_option);
}
return fd;

View File

@ -1,6 +1,6 @@
--- doc/cpio.info
+++ doc/cpio.info 2005/04/25 12:11:02
@@ -261,7 +261,8 @@
@@ -262,7 +262,8 @@
Set the I/O block size to BLOCK-SIZE * 512 bytes.
`-c'
@ -11,11 +11,11 @@
`-C IO-SIZE, --io-size=IO-SIZE'
Set the I/O block size to IO-SIZE bytes.
--- src/main.c
+++ src/main.c 2005/04/25 12:12:09
@@ -302,6 +302,7 @@
+++ src/main.c
@@ -337,6 +337,7 @@
case 'c': /* Use the old portable ASCII format. */
if (archive_format != arf_unknown)
USAGE_ERROR ((0, 0, _("Archive format multiply defined")));
error (0, EXIT_FAILURE, _("Archive format multiply defined"));
+#define SVR4_COMPAT
#ifdef SVR4_COMPAT
archive_format = arf_newascii; /* -H newc. */

3
cpio-2.9.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bb9a5fa693a8f4ef4685eb447cea1dc5b787e37c302569928ef74df460724707
size 758195

View File

@ -1,11 +0,0 @@
--- configure.ac
+++ configure.ac
@@ -92,7 +92,7 @@
AC_CONFIG_LINKS(src/fnmatch.h:headers/fnmatch.h)
fi
-AC_CHECK_FUNCS(lchown endpwent endgrent)
+AC_CHECK_FUNCS(lchown endpwent endgrent lstat)
AC_FUNC_VPRINTF
AC_FUNC_ALLOCA
AC_CHECK_LIB(nsl, gethostname, [LIBS="$LIBS -lnsl"])

View File

@ -1,3 +1,45 @@
-------------------------------------------------------------------
Wed Jul 25 13:14:53 CEST 2007 - lmichnovic@suse.cz
- fixed types of variables for LFS support (*lfs_correction.patch)
-------------------------------------------------------------------
Tue Jul 24 15:50:44 CEST 2007 - lmichnovic@suse.cz
- adjusted *mt.patch to fix compression handling [#223494]
-------------------------------------------------------------------
Fri Jul 20 11:01:31 CEST 2007 - lmichnovic@suse.cz
- update to version 2.9
- obsoletes *lstat.patch
* Licensed under the GPLv3.
* Bugfixes: Honor umask when creating intermediate directories,
not specified in the archive (debian bug #430053). (This bug
is only in version 2.8)
* 2.8:
* Option --owner can be used in copy-out mode, allowing
to uniformly override the ownership of the files being added
to the archive.
* Bugfixes:
- Symlinks were handled incorrectly in copy-out mode. (This
bug was only in version 2.7)
- Fix handling of large files. {obsoletes lfs.patch}
o Fix setting the file permissions in copy-out mode.
o Fix CAN-2005-1111 {obsoletes chmodRaceC.patch}
* 2.7:
* Improved error checking and diagnostics
* Fixed CAN-1999-1572 {obsoletes writeOutHeaderBufferOverflow.patch}
* Allow to use --sparse in both copy-in and copy-pass.
* Fix bug that eventually caused copying out the same
hard-linked file several times to archive.
* Fix several LFS-related issues. {obsoletes lfs.patch}
* Fix Debian bug #335580.
- obsoletes *dirTraversal.patch implemented with option
--no-absolute-pathnames; option --absolute-pathnames is still possible
- obsoletes *checksum.patch, fix_umask.patch, sparse.patch
- using lang macro
-------------------------------------------------------------------
Thu Sep 21 18:14:59 CEST 2006 - lmichnovic@suse.cz

View File

@ -1,7 +1,7 @@
#
# spec file for package cpio (Version 2.6)
# spec file for package cpio (Version 2.9)
#
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
@ -12,25 +12,19 @@
Name: cpio
URL: http://www.gnu.org/software/cpio/cpio.html
License: Other License(s), see package, GPL
License: GPL v2 or later
Group: Productivity/Archiving/Compression
Autoreqprov: on
Version: 2.6
Release: 26
Version: 2.9
Release: 2
Summary: A Backup and Archiving Utility
Source: cpio-2.6.tar.bz2
Patch: cpio-2.6-mt.patch
Patch1: use_new_ascii_format.patch
Patch2: use_sbin_rmt.patch
Patch3: fix_umask.patch
Patch4: sparse.patch
Patch5: cpio-lstat.patch
Patch6: open_nonblock.patch
Patch7: cpio-2.6-dirTraversal.patch
Patch8: cpio-2.6-chmodRaceC.patch
Patch9: cpio-2.6-lfs.patch
Patch10: cpio-2.6-checksum.patch
Patch11: cpio-2.6-writeOutHeaderBufferOverflow.patch
Source: cpio-2.9.tar.bz2
Patch1: cpio-2.9-no_rmt.patch
Patch2: cpio-2.9-use_new_ascii_format.patch
Patch3: cpio-2.9-mt.patch
Patch4: cpio-2.9-use_sbin_rmt.patch
Patch5: cpio-2.9-open_nonblock.patch
Patch6: cpio-2.9-lfs_correction.patch
PreReq: %install_info_prereq
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -52,28 +46,24 @@ package as well.
Authors:
--------
David J. MacKenzie <djm@gnu.ai.mit.edu>
David J. MacKenzie <djm@gnu.org>
Jim Meyering <meyering@na-net.ornl.gov>
%prep
%setup
%patch
%patch1
%patch2
%patch3
%patch4
%patch5
%patch6
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
chmod 755 .
chmod u+w *
chmod a+r *
%build
gettextize -f
aclocal -I m4
autoreconf --force --install
CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" \
./configure DEFAULT_RMT_DIR=/sbin \
@ -84,11 +74,11 @@ CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" \
make
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/{usr/bin,bin}
make prefix=$RPM_BUILD_ROOT/usr infodir=$RPM_BUILD_ROOT/%_infodir mandir=$RPM_BUILD_ROOT/%_mandir install
mv $RPM_BUILD_ROOT/usr/bin/cpio $RPM_BUILD_ROOT/bin
ln -sf ../../bin/cpio $RPM_BUILD_ROOT/usr/bin/cpio
%find_lang %{name}
%post
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz
@ -96,7 +86,7 @@ ln -sf ../../bin/cpio $RPM_BUILD_ROOT/usr/bin/cpio
%postun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz
%files
%files -f %{name}.lang
%defattr(-,root,root)
/bin/cpio
/usr/bin/cpio
@ -104,9 +94,42 @@ ln -sf ../../bin/cpio $RPM_BUILD_ROOT/usr/bin/cpio
%doc %{_infodir}/cpio.info.gz
%doc %{_mandir}/man1/cpio.1.gz
%doc %{_mandir}/man1/mt.1.gz
/usr/share/locale/*/LC_MESSAGES/cpio.mo
#/usr/share/locale/*/LC_MESSAGES/cpio.mo
%changelog -n cpio
%changelog
* Wed Jul 25 2007 - lmichnovic@suse.cz
- fixed types of variables for LFS support (*lfs_correction.patch)
* Tue Jul 24 2007 - lmichnovic@suse.cz
- adjusted *mt.patch to fix compression handling [#223494]
* Fri Jul 20 2007 - lmichnovic@suse.cz
- update to version 2.9
- obsoletes *lstat.patch
* Licensed under the GPLv3.
* Bugfixes: Honor umask when creating intermediate directories,
not specified in the archive (debian bug #430053). (This bug
is only in version 2.8)
* 2.8:
* Option --owner can be used in copy-out mode, allowing
to uniformly override the ownership of the files being added
to the archive.
* Bugfixes:
- Symlinks were handled incorrectly in copy-out mode. (This
bug was only in version 2.7)
- Fix handling of large files. {obsoletes lfs.patch}
o Fix setting the file permissions in copy-out mode.
o Fix CAN-2005-1111 {obsoletes chmodRaceC.patch}
* 2.7:
* Improved error checking and diagnostics
* Fixed CAN-1999-1572 {obsoletes writeOutHeaderBufferOverflow.patch}
* Allow to use --sparse in both copy-in and copy-pass.
* Fix bug that eventually caused copying out the same
hard-linked file several times to archive.
* Fix several LFS-related issues. {obsoletes lfs.patch}
* Fix Debian bug #335580.
- obsoletes *dirTraversal.patch implemented with option
--no-absolute-pathnames; option --absolute-pathnames is still possible
- obsoletes *checksum.patch, fix_umask.patch, sparse.patch
- using lang macro
* Thu Sep 21 2006 - lmichnovic@suse.cz
- fixed typo in cpio-2.6.dif; renamed to *-mt.patch
- united suffix of patches

View File

@ -1,18 +0,0 @@
--- src/main.c.orig Mon Jul 10 16:06:34 2000
+++ src/main.c Mon Jul 10 16:06:47 2000
@@ -498,7 +498,6 @@
char *argv[];
{
program_name = argv[0];
- umask (0);
#ifdef __TURBOC__
_fmode = O_BINARY; /* Put stdin and stdout in binary mode. */
@@ -509,6 +508,7 @@
#endif
process_args (argc, argv);
+ umask (0);
initialize_buffers ();

View File

@ -1,34 +0,0 @@
--- src/mt.c
+++ src/mt.c 2005/06/30 16:51:10
@@ -314,9 +314,9 @@
|| (operation == MTERASE)
#endif
)
- tapedesc = rmtopen (tapedev, O_WRONLY, 0, rsh_command_option);
+ tapedesc = rmtopen (tapedev, O_WRONLY|O_NONBLOCK, 0, rsh_command_option);
else
- tapedesc = rmtopen (tapedev, O_RDONLY, 0, rsh_command_option);
+ tapedesc = rmtopen (tapedev, O_RDONLY|O_NONBLOCK, 0, rsh_command_option);
if (tapedesc == -1)
error (1, errno, "%s", tapedev);
check_type (tapedev, tapedesc);
--- src/util.c
+++ src/util.c 2005/06/30 16:51:51
@@ -800,14 +800,14 @@
copy_in = process_copy_in;
if (copy_function == copy_in)
- fd = rmtopen (file, O_RDONLY | O_BINARY, 0666, rsh_command_option);
+ fd = rmtopen (file, O_RDONLY | O_BINARY | O_NONBLOCK, 0666, rsh_command_option);
else
{
if (!append_flag)
- fd = rmtopen (file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666,
+ fd = rmtopen (file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_NONBLOCK, 0666,
rsh_command_option);
else
- fd = rmtopen (file, O_RDWR | O_BINARY, 0666, rsh_command_option);
+ fd = rmtopen (file, O_RDWR | O_BINARY | O_NONBLOCK, 0666, rsh_command_option);
}
return fd;

View File

@ -1,18 +0,0 @@
--- src/main.c
+++ src/main.c
@@ -585,7 +585,6 @@
CHECK_USAGE(reset_time_flag, "--reset", "--extract");
CHECK_USAGE(xstat != lstat, "--dereference", "--extract");
CHECK_USAGE(append_flag, "--append", "--extract");
- CHECK_USAGE(sparse_flag, "--sparse", "--extract");
CHECK_USAGE(output_archive_name, "-O", "--extract");
if (to_stdout_option)
{
@@ -633,6 +632,7 @@
CHECK_USAGE(rename_batch_file, "--rename-batch-file", "--create");
CHECK_USAGE(no_abs_paths_flag, "--no-absolute-pathnames", "--create");
+ CHECK_USAGE(sparse_flag, "--sparse", "--create");
CHECK_USAGE(input_archive_name, "-I", "--create");
if (archive_name && output_archive_name)
USAGE_ERROR ((0, 0, _("Both -O and -F are used in copy-out mode")));