commit 4621b18618b1d3c20238138c1381c1bb881d962c8c330ac37bc90573463f7fcf Author: OBS User unknown Date: Mon Dec 18 23:15:29 2006 +0000 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/cpio?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/cpio-2.6-checksum.patch b/cpio-2.6-checksum.patch new file mode 100644 index 0000000..9a5384a --- /dev/null +++ b/cpio-2.6-checksum.patch @@ -0,0 +1,33 @@ +--- 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; diff --git a/cpio-2.6-chmodRaceC.patch b/cpio-2.6-chmodRaceC.patch new file mode 100644 index 0000000..394509c --- /dev/null +++ b/cpio-2.6-chmodRaceC.patch @@ -0,0 +1,247 @@ +--- 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, ×) < 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) diff --git a/cpio-2.6-dirTraversal.patch b/cpio-2.6-dirTraversal.patch new file mode 100644 index 0000000..f779ad0 --- /dev/null +++ b/cpio-2.6-dirTraversal.patch @@ -0,0 +1,193 @@ +--- 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 + #ifndef FNM_PATHNAME + #include +@@ -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. */ diff --git a/cpio-2.6-lfs.patch b/cpio-2.6-lfs.patch new file mode 100644 index 0000000..a7dde68 --- /dev/null +++ b/cpio-2.6-lfs.patch @@ -0,0 +1,170 @@ +--- 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; diff --git a/cpio-2.6-mt.patch b/cpio-2.6-mt.patch new file mode 100644 index 0000000..23eab4a --- /dev/null +++ b/cpio-2.6-mt.patch @@ -0,0 +1,713 @@ +--- 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 @@ + .IR count . + Equivalent to rewind followed by fsf + .IR count . +-.IP seek +-Seek to block number +-.IR count . + .IP eom + Space to the end of the recorded media on the tape + (for appending files onto tapes). +@@ -93,6 +90,69 @@ + then rewind it again. + .IP erase + Erase the tape. ++.IP fss ++(SCSI tapes) Forward space ++.I count ++setmarks. ++.IP bss ++(SCSI tapes) Backward space ++.I count ++setmarks. ++.IP "wset" ++(SCSI tapes) Write ++.I count ++setmarks at current position (only SCSI tape). ++.IP "eod, seod" ++Space to end of valid data. Used on streamer tape ++drives to append data to the logical and of tape. ++.IP setblk ++(SCSI tapes) Set the block size of the drive to ++.I count ++bytes per record. ++.IP setdensity ++(SCSI tapes) Set the tape density code to ++.I count. ++The proper codes to use with each drive should be looked up from the ++drive documentation. ++.IP drvbuffer ++(SCSI tapes) Set the tape drive buffer code to ++.I number. ++The proper value for unbuffered operation is zero and "normal" buffered ++operation one. The meanings of other values can be found in the drive ++documentation or, in case of a SCSI-2 drive, from the SCSI-2 standard. ++.IP stoptions ++(SCSI tapes) Set the driver options bits to ++.I count ++for the device. ++The bits can be set by oring the following values: 1 to enable write ++buffering, 2 to enable asynchronous writes, 4 to enable read ahead, ++8 to enable debugging output (if it has been compiled to the driver). ++.IP stwrthreshold ++(SCSI tapes) The write threshold for the tape device is set to ++.I count ++kilobytes. The value must be smaller than or equal to the driver ++buffer size. ++.IP seek ++(SCSI tapes) Seek to the ++.I count ++block on the tape. This operation is available on some ++Tandberg and Wangtek streamers and some SCSI-2 tape drives. ++.IP tell ++(SCSI tapes) Tell the current block on tape. This operation is available on some ++Tandberg and Wangtek streamers and some SCSI-2 tape drives. ++.IP densities ++(SCSI tapes) Write explanation of some common density codes to ++standard output. ++.IP datcompression ++(some SCSI-2 DAT tapes) Inquire or set the compression status ++(on/off). If the ++.I count ++is one the compression status is printed. If the ++.I count ++is zero, compression is disabled. Otherwise, compression is ++enabled. The command uses the SCSI ioctl to read and write the Data ++Compression Characteristics mode page (15). ONLY ROOT CAN USE THIS ++COMMAND. + .PP + .B mt + exits with a status of 0 if the operation succeeded, 1 if the +--- lib/system.h ++++ lib/system.h +@@ -473,10 +473,11 @@ + + #if HAVE_LOCALE_H + # include +-#endif ++#else + #if !HAVE_SETLOCALE + # define setlocale(category, locale) /* empty */ + #endif ++#endif + + #include + #if defined(HAVE_SYS_TIME_H) && defined(TIME_WITH_SYS_TIME) +--- src/Makefile.am ++++ src/Makefile.am +@@ -17,7 +17,7 @@ + + INCLUDES=-I. -I.. -I$(top_srcdir)/lib + +-bin_PROGRAMS=cpio @CPIO_MT_PROG@ ++bin_PROGRAMS=cpio mt + EXTRA_PROGRAMS=mt + + 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 @@ + static void + copyin_file (struct new_cpio_header* 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. */ + 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 @@ + for (i = 0; i < num_patterns + && skip_file == copy_matching_files; i++) + { +- if (fnmatch (save_patterns[i], file_hdr.c_name, 0) == 0) ++ if (fnmatch (save_patterns[lastpattern], file_hdr.c_name, 0) == 0) + skip_file = !copy_matching_files; ++ else if (++lastpattern >= num_patterns) ++ lastpattern = 0; + } + } + +@@ -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 + */ + ++/* Modified for the Linux SCSI tape driver by Brian Mays from code ++ written by Kai Makisara. ++ Last Modified: Tue Apr 23 15:37:54 EDT 1996 ++*/ + + /* 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 @@ + retension Rewind the tape, then wind it to the end of the reel, + then rewind it again. + erase Erase the tape. ++ fss (SCSI tapes) Forward space COUNT setmarks. ++ bss (SCSI tapes) Backward space COUNT setmarks. ++ wset (SCSI tapes) Write COUNT setmarks at current position ++ (only SCSI tape). ++ eod, seod Space to end of valid data. Used on streamer tape ++ drives to append data to the logical and of tape. ++ setblk (SCSI tapes) Set the block size of the drive to COUNT ++ bytes per record. ++ setdensity (SCSI tapes) Set the tape density code to COUNT. The ++ proper codes to use with each drive should be looked ++ up from the drive documentation. ++ drvbuffer (SCSI tapes) Set the tape drive buffer code to ++ NUMBER. The proper value for unbuffered operation is ++ zero and "normal" buffered operation one. The meanings ++ of other values can be found in the drive ++ documentation or, in case of a SCSI-2 drive, from the ++ SCSI-2 standard. ++ stoptions (SCSI tapes) Set the driver options bits to COUNT for ++ the device. The bits can be set by oring the ++ following values: 1 to enable write buffering, 2 to ++ enable asynchronous writes, 4 to enable read ahead, 8 ++ to enable debugging output (if it has been compiled to ++ the driver). ++ stwrthreshold ++ (SCSI tapes) The write threshold for the tape device ++ is set to COUNT kilobytes. The value must be smaller ++ than or equal to the driver buffer size. ++ seek (SCSI tapes) Seek to the COUNT block on the tape. ++ This operation is available on some Tandberg and ++ Wangtek streamers and some SCSI-2 tape drives. ++ tell (SCSI tapes) Tell the current block on tape. This ++ operation is available on some Tandberg and Wangtek ++ streamers and some SCSI-2 tape drives. ++ densities (SCSI tapes) Write explanation of some common density ++ codes to standard output. ++ datcompression ++ (some SCSI-2 DAT tapes) Inquire or set the compression ++ status (on/off). If the COUNT is one the compression ++ status is printed. If the COUNT is zero, compression ++ is disabled. Otherwise, compression is enabled. + + David MacKenzie */ + +@@ -104,6 +148,45 @@ + void exit (); + #endif + ++#include "../lib/argmatch.h" ++ ++#if defined(linux) || defined(__linux) ++#define MTDATCOMP 1000 /* Random unused number. */ ++#define MTDENS 1001 /* Random unused number. */ ++ ++struct densities { ++ int code; ++ char *name; ++} density_tbl[] = { ++ {0x00, "default"}, ++ {0x01, "NRZI (800 bpi)"}, ++ {0x02, "PE (1600 bpi)"}, ++ {0x03, "GCR (6250 bpi)"}, ++ {0x05, "QIC-45/60 (GCR, 8000 bpi)"}, ++ {0x06, "PE (3200 bpi)"}, ++ {0x07, "IMFM (6400 bpi)"}, ++ {0x08, "GCR (8000 bpi)"}, ++ {0x09, "GCR /37871 bpi)"}, ++ {0x0a, "MFM (6667 bpi)"}, ++ {0x0b, "PE (1600 bpi)"}, ++ {0x0c, "GCR (12960 bpi)"}, ++ {0x0d, "GCR (25380 bpi)"}, ++ {0x0f, "QIC-120 (GCR 10000 bpi)"}, ++ {0x10, "QIC-150/250 (GCR 10000 bpi)"}, ++ {0x11, "QIC-320/525 (GCR 16000 bpi)"}, ++ {0x12, "QIC-1350 (RLL 51667 bpi)"}, ++ {0x13, "DDS (61000 bpi)"}, ++ {0x14, "EXB-8200 (RLL 43245 bpi)"}, ++ {0x15, "EXB-8500 (RLL 45434 bpi)"}, ++ {0x16, "MFM 10000 bpi"}, ++ {0x17, "MFM 42500 bpi"}, ++ {0x24, "DDS-2"}, ++ {140, "EXB-8505 compressed"}, ++ {144, "EXB-8205 compressed"}, ++ {-1, NULL}}; ++#endif ++ ++ + char *opnames[] = + { + "eof", "weof", "fsf", "bsf", "fsr", "bsr", +@@ -113,6 +196,8 @@ + #endif + #ifdef MTEOM + "eom", ++ "eod", ++ "seod", + #endif + #ifdef MTRETEN + "retension", +@@ -127,6 +212,39 @@ + #ifdef MTSEEK + "seek", + #endif ++#ifdef MTTELL ++ "tell", ++#endif ++#ifdef MTFSS ++ "fss", ++#endif ++#ifdef MTBSS ++ "bss", ++#endif ++#ifdef MTWSM ++ "wset", ++#endif ++#ifdef MTSETBLK ++ "setblk", ++#endif ++#ifdef MTSETDENSITY ++ "setdensity", ++#endif ++#ifdef MTSETDRVBUFFER ++ "drvbuffer", ++#ifdef MT_ST_BOOLEANS ++ "stoptions", ++#endif ++#ifdef MT_ST_WRITE_THRESHOLD ++ "stwrthreshold", ++#endif ++#endif ++#ifdef MTDATCOMP ++ "datcompression", ++#endif ++#ifdef MTDENS ++ "densities", ++#endif + NULL + }; + +@@ -140,6 +258,8 @@ + #endif + #ifdef MTEOM + MTEOM, ++ MTEOM, ++ MTEOM, + #endif + #ifdef MTRETEN + MTRETEN, +@@ -154,9 +274,69 @@ + #ifdef MTSEEK + MTSEEK, + #endif ++#ifdef MTTELL ++ MTTELL, ++#endif ++#ifdef MTFSS ++ MTFSS, ++#endif ++#ifdef MTBSS ++ MTBSS, ++#endif ++#ifdef MTWSM ++ MTWSM, ++#endif ++#ifdef MTSETBLK ++ MTSETBLK, ++#endif ++#ifdef MTSETDENSITY ++ MTSETDENSITY, ++#endif ++#ifdef MTSETDRVBUFFER ++ MTSETDRVBUFFER, ++#ifdef MT_ST_BOOLEANS ++ MTSETDRVBUFFER, ++#endif ++#ifdef MT_ST_WRITE_THRESHOLD ++ MTSETDRVBUFFER, ++#endif ++#endif ++#ifdef MTDATCOMP ++ MTDATCOMP, ++#endif ++#ifdef MTDENS ++ MTDENS, ++#endif ++ 0 ++}; ++ ++char *cbnames[] = ++{ ++#ifdef MT_ST_BOOLEANS ++ "stoptions", ++#endif ++#ifdef MT_ST_WRITE_THRESHOLD ++ "stwrthreshold", ++#endif ++ NULL ++}; ++ ++int count_bits[] = ++{ ++#ifdef MT_ST_BOOLEANS ++ MT_ST_BOOLEANS, ++#endif ++#ifdef MT_ST_WRITE_THRESHOLD ++ MT_ST_WRITE_THRESHOLD, ++#endif + 0 + }; + ++#ifdef MT_TAPE_INFO ++ struct mt_tape_info tapes[] = MT_TAPE_INFO; ++#endif ++ ++ + struct option longopts[] = + { + {"file", 1, NULL, 'f'}, +@@ -199,10 +379,22 @@ + print_status (char *dev, int desc) + { + struct mtget status; ++#ifdef MT_TAPE_INFO ++ struct mt_tape_info *mt; ++#endif + + if (rmtioctl (desc, MTIOCGET, (char*)&status) == -1) + error (2, errno, "%s", dev); + ++#ifdef MT_TAPE_INFO ++ for (mt = tapes; mt->t_type; mt++) ++ if (mt->t_type == status.mt_type) break; ++ if (mt->t_type != 0) ++ { ++ printf ("drive type = %s\n", mt->t_name); ++ } ++ else ++#endif + 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 @@ + printf ("file number = %d\n", (int) status.mt_fileno); + printf ("block number = %d\n", (int) status.mt_blkno); + #endif ++#if defined(linux) || defined(__linux) ++ if (status.mt_type == MT_ISSCSI1 || ++ status.mt_type == MT_ISSCSI2) ++ { ++ int dens, i; ++ char *density; ++ dens = (status.mt_dsreg & MT_ST_DENSITY_MASK) >> MT_ST_DENSITY_SHIFT; ++ density = "unknown"; ++ for (i=0; density_tbl[i].code >= 0; i++) ++ if (density_tbl[i].code == dens) ++ { ++ density = density_tbl[i].name; ++ break; ++ } ++ printf("Tape block size %ld bytes. Density code 0x%x (%s).\n", ++ ((status.mt_dsreg & MT_ST_BLKSIZE_MASK) >> MT_ST_BLKSIZE_SHIFT), ++ dens, density); ++ ++ printf("Soft error count since last status=%ld\n", ++ (status.mt_erreg & MT_ST_SOFTERR_MASK) >> MT_ST_SOFTERR_SHIFT); ++ printf("General status bits on (%lx):\n", status.mt_gstat); ++ if (GMT_EOF(status.mt_gstat)) ++ printf(" EOF"); ++ if (GMT_BOT(status.mt_gstat)) ++ printf(" BOT"); ++ if (GMT_EOT(status.mt_gstat)) ++ printf(" EOT"); ++ if (GMT_SM(status.mt_gstat)) ++ printf(" SM"); ++ if (GMT_EOD(status.mt_gstat)) ++ printf(" EOD"); ++ if (GMT_WR_PROT(status.mt_gstat)) ++ printf(" WR_PROT"); ++ if (GMT_ONLINE(status.mt_gstat)) ++ printf(" ONLINE"); ++ if (GMT_D_6250(status.mt_gstat)) ++ printf(" D_6250"); ++ if (GMT_D_1600(status.mt_gstat)) ++ printf(" D_1600"); ++ if (GMT_D_800(status.mt_gstat)) ++ printf(" D_800"); ++ if (GMT_DR_OPEN(status.mt_gstat)) ++ printf(" DR_OPEN"); ++ if (GMT_IM_REP_EN(status.mt_gstat)) ++ printf(" IM_REP_EN"); ++ if (status.mt_gstat != 0) ++ putchar ('\n'); ++ } ++ else ++ { ++ printf("gstat = %0lx\n", status.mt_gstat); ++ } ++#endif ++} ++ ++ ++#if defined(linux) || defined(__linux) ++/*** Get and set the DAT compression (Mode Page 15) ***/ ++ ++#define MODE_SENSE 0x1a ++#define MODE_SELECT 0x15 ++ ++int ++read_mode_page(int fn, int page, int length, unsigned char *buffer, ++ int do_mask) ++{ ++ int result, *ip; ++ unsigned char tmpbuffer[30], *cmd; ++ ++ memset(tmpbuffer, 0, 14); ++ ip = (int *)&(tmpbuffer[0]); ++ *ip = 0; ++ *(ip+1) = length + 4; ++ ++ cmd = &(tmpbuffer[8]); ++ cmd[0] = MODE_SENSE; ++ cmd[1] = 8; ++ cmd[2] = page; ++ if (do_mask) ++ cmd[2] |= 0x40; /* Get changeable parameter mask */ ++ cmd[4] = length + 4; ++ ++ result = ioctl(fn, 1, tmpbuffer); ++ if (result) { ++ fprintf(stderr, "Can't read mode page. Are you sure you are root?\n"); ++ return 0; ++ } ++ memcpy(buffer, tmpbuffer + 8, length + 4); ++ return 1; ++} ++ ++ ++int ++write_mode_page(int fn, int page, int length, unsigned char *buffer) ++{ ++ int result, *ip; ++ unsigned char tmpbuffer[40], *cmd; ++ ++ memset(tmpbuffer, 0, 14); ++ ip = (int *)&(tmpbuffer[0]); ++ *ip = length + 4; ++ *(ip+1) = 0; ++ ++ cmd = &(tmpbuffer[8]); ++ cmd[0] = MODE_SELECT; ++ cmd[1] = 0x10; ++ cmd[4] = length + 4; ++ ++ memcpy(tmpbuffer + 14, buffer, length + 4); ++ tmpbuffer[14] = 0; /* reserved data length */ ++ tmpbuffer[18] &= 0x3f; /* reserved bits in page code byte */ ++ ++ result = ioctl(fn, 1, tmpbuffer); ++ if (result) { ++ fprintf(stderr, "Can't write mode page.\n"); ++ return 0; ++ } ++ return 1; + } + ++ ++int ++do_dat_compression(char *dev, int fn, int count) ++{ ++ int i; ++ unsigned char buffer[30], mask[30]; ++ ++ if (!read_mode_page(fn, 0x0f, 16, buffer, 0)) { ++ error (2, errno, "%s", dev); ++ } ++ ++ 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 (!write_mode_page(fn, 0x0f, 16, buffer)) { ++ error (2, errno, "%s", dev); ++ } ++ if (!read_mode_page(fn, 0x0f, 16, buffer, 0)) { /* Re-read to check */ ++ error (2, errno, "%s", dev); ++ } ++ } ++ ++ if (buffer[4+2] & 0x80) ++ printf("Compression on.\n"); ++ else ++ printf("Compression off.\n"); ++ ++ return 1; ++} ++#endif ++ ++#ifdef MTTELL ++void ++print_position (dev, desc) ++ char *dev; ++ int desc; ++{ ++ struct mtpos position; ++ ++ if (rmtioctl (desc, MTIOCPOS, &position) == -1) ++ error (2, errno, "%s", dev); ++ printf("At block %ld.\n", position.mt_blkno); ++ ++} ++#endif ++ ++ + void + usage (FILE *fp,int status) + { +@@ -277,7 +639,7 @@ + if (optind == argc) + usage (stderr, 1); + +- i = argmatch (argv[optind], opnames); ++ i = argmatch (argv[optind], opnames,NULL,0); + if (i < 0) + { + invalid_arg ("tape operation", argv[optind], i); +@@ -309,10 +671,29 @@ + #endif + } + ++#ifdef MTDENS ++ if (operation == MTDENS) ++ { ++ printf("Some SCSI tape density codes:\ncode explanation\n"); ++ for (i=0; density_tbl[i].code >= 0; i++) ++ printf("0x%02x %s\n", density_tbl[i].code, density_tbl[i].name); ++ exit (0); ++ } ++#endif ++ + if ( (operation == MTWEOF) + #ifdef MTERASE + || (operation == MTERASE) + #endif ++#ifdef MTWSM ++ || (operation == MTWSM) ++#endif ++#ifdef MTSETDRVBUFFER ++ || (operation == MTSETDRVBUFFER) ++#endif ++#ifdef MTDATCOMP ++ || (operation == MTDATCOMP) ++#endif + ) + tapedesc = rmtopen (tapedev, O_WRONLY, 0, rsh_command_option); + else +@@ -321,6 +702,17 @@ + error (1, errno, "%s", tapedev); + check_type (tapedev, tapedesc); + ++#ifdef MTDATCOMP ++ if (operation == MTDATCOMP) ++ do_dat_compression(tapedev, tapedesc, count); ++ else ++#endif ++#ifdef MTTELL ++ if (operation == MTTELL) ++ print_position (tapedev, tapedesc); ++ else ++#endif ++ { + if (operation == MTASF) + { + perform_operation (tapedev, tapedesc, MTREW, 1); +@@ -329,6 +721,7 @@ + perform_operation (tapedev, tapedesc, operation, count); + if (operation == MTNOP) + print_status (tapedev, tapedesc); ++ } + + if (rmtclose (tapedesc) == -1) + error (2, errno, "%s", tapedev); diff --git a/cpio-2.6-writeOutHeaderBufferOverflow.patch b/cpio-2.6-writeOutHeaderBufferOverflow.patch new file mode 100644 index 0000000..b38ab06 --- /dev/null +++ b/cpio-2.6-writeOutHeaderBufferOverflow.patch @@ -0,0 +1,555 @@ +--- 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 */ diff --git a/cpio-2.6.tar.bz2 b/cpio-2.6.tar.bz2 new file mode 100644 index 0000000..ae12cb8 --- /dev/null +++ b/cpio-2.6.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e60c5c370d451605fcb23e26cc37c18182f62009282ca73bf5dea4519e17360 +size 448452 diff --git a/cpio-lstat.patch b/cpio-lstat.patch new file mode 100644 index 0000000..bf9e7b7 --- /dev/null +++ b/cpio-lstat.patch @@ -0,0 +1,11 @@ +--- 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"]) diff --git a/cpio.changes b/cpio.changes new file mode 100644 index 0000000..bf93a3a --- /dev/null +++ b/cpio.changes @@ -0,0 +1,177 @@ +------------------------------------------------------------------- +Thu Sep 21 18:14:59 CEST 2006 - lmichnovic@suse.cz + +- fixed typo in cpio-2.6.dif; renamed to *-mt.patch +- united suffix of patches + +------------------------------------------------------------------- +Tue Sep 19 14:42:39 CEST 2006 - schwab@suse.de + +- Fix missing newline after mt status. + +------------------------------------------------------------------- +Mon Jul 24 15:56:13 CEST 2006 - rguenther@suse.de + +- remove useless build-dependency on rsh. + +------------------------------------------------------------------- +Wed Jan 25 21:30:02 CET 2006 - mls@suse.de + +- converted neededforbuild to BuildRequires + +------------------------------------------------------------------- +Tue Dec 6 15:24:09 CET 2005 - fehr@suse.de + +- add cpio-2.6-chmodRaceC.patch and cpio-2.6-dirTraversal.patch to + fix bug #80226 +- add cpio-2.6-writeOutHeaderBufferOverflow.patch to fix #133454 +- add cpio-2.6-checksum.patch fix wrong checksum on 64bit archs +- add cpio-2.6-lfs.patch to support large files on 32bit archs + +------------------------------------------------------------------- +Wed Aug 10 17:58:40 CEST 2005 - fehr@suse.de + +- fix call to setlocale to make multibyte characters work (#98902) + +------------------------------------------------------------------- +Thu Jun 30 18:59:02 CEST 2005 - fehr@suse.de + +- open with O_NONBLOCK option (#94449) + +------------------------------------------------------------------- +Wed May 4 15:04:04 CEST 2005 - ro@suse.de + +- properly detect lstat in configure + +------------------------------------------------------------------- +Wed Apr 27 12:17:58 CEST 2005 - snwint@suse.de + +- fix '--sparse' option check + +------------------------------------------------------------------- +Mon Apr 25 15:28:26 CEST 2005 - fehr@suse.de + +- update to cpio 2.6 + +------------------------------------------------------------------- +Mon Jan 24 12:19:31 CET 2005 - fehr@suse.de + +- fix problem with cpio not respecting umask (#50054) + +------------------------------------------------------------------- +Mon Jan 19 12:44:15 CET 2004 - ro@suse.de + +- fix build as user + +------------------------------------------------------------------- +Sun Jan 11 11:04:05 CET 2004 - adrian@suse.de + +- add %defattr + +------------------------------------------------------------------- +Thu Apr 24 12:20:23 CEST 2003 - ro@suse.de + +- fix install_info --delete call and move from preun to postun + +------------------------------------------------------------------- +Tue Apr 15 16:47:28 CEST 2003 - coolo@suse.de + +- use BuildRoot + +------------------------------------------------------------------- +Fri Feb 7 15:19:46 CET 2003 - fehr@suse.de + +- Use %install_info macro + +------------------------------------------------------------------- +Tue Sep 17 17:34:28 CEST 2002 - ro@suse.de + +- removed bogus self-provides + +------------------------------------------------------------------- +Tue Aug 13 21:29:02 CEST 2002 - mfabian@suse.de + +- add cpio-2.5-i18n-0.1.patch received from + "Mitsuru Chinen" + The patch just adds a setlocale (LC_ALL, ""). + +------------------------------------------------------------------- +Sun Jul 28 09:10:20 CEST 2002 - kukuk@suse.de + +- remove unused tetex from neededforbuild + +------------------------------------------------------------------- +Fri Jul 5 10:26:35 CEST 2002 - fehr@suse.de + +- update to new version 2.5 + +------------------------------------------------------------------- +Mon Dec 3 14:48:33 CET 2001 - fehr@suse.de + +- make the -c switch comatible to SVR4 (and compatible to RedHat) +- fix the man page accordingly +- add rsh to #needfobuild to allow remote file access again (#12543) + +------------------------------------------------------------------- +Sun Dec 3 16:07:35 CET 2000 - schwab@suse.de + +- Fix a few bugs and typos. + +------------------------------------------------------------------- +Tue Nov 28 11:32:08 MET 2000 - fehr@suse.de + +- add compile options for LFS + +------------------------------------------------------------------- +Mon Apr 17 12:01:34 MEST 2000 - fehr@suse.de + +- move cpio binary to /bin for compatibility with RedHat + +------------------------------------------------------------------- +Fri Feb 25 12:02:26 CET 2000 - kukuk@suse.de + +- remove Makefile.Linux +- use _infodir/_mandir + +------------------------------------------------------------------- +Mon Sep 13 17:23:57 CEST 1999 - bs@suse.de + +- ran old prepare_spec on spec file to switch to new prepare_spec. + +------------------------------------------------------------------- +Thu Sep 2 18:29:04 MEST 1999 - fehr@suse.de + +- Fix patch for broken header (cast to short instead of int) + +------------------------------------------------------------------- +Wed Aug 4 13:19:24 MEST 1999 - kukuk@suse.de + +- Add patch for broken header in oldascii format + +------------------------------------------------------------------- +Tue Sep 22 12:13:34 MEST 1998 - ro@suse.de + +- define _GNU_SOURCE for glibc where including getopt + +------------------------------------------------------------------- +Tue Sep 1 11:52:58 MEST 1998 - ro@suse.de + +- fixed strdup-macro problem + +---------------------------------------------------------------------------- +Thu Jun 5 11:08:05 MEST 1997 - florian@suse.de + + +- go through the list of regex in a more suitable way (from ma@suse.de) + + +---------------------------------------------------------------------------- +Sun Apr 13 23:04:29 MEST 1997 - florian@suse.de + + +- update to new version 2.4.2 + +- add Linux patches from RedHat + +- add patches from gnu.utils.bugs + diff --git a/cpio.spec b/cpio.spec new file mode 100644 index 0000000..18e8c12 --- /dev/null +++ b/cpio.spec @@ -0,0 +1,185 @@ +# +# spec file for package cpio (Version 2.6) +# +# Copyright (c) 2006 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. +# +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +# norootforbuild + +Name: cpio +URL: http://www.gnu.org/software/cpio/cpio.html +License: Other License(s), see package, GPL +Group: Productivity/Archiving/Compression +Autoreqprov: on +Version: 2.6 +Release: 26 +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 +PreReq: %install_info_prereq +BuildRoot: %{_tmppath}/%{name}-%{version}-build + +%description +This is GNU cpio, a program to manage archives of files. This package +also includes 'mt', a tape drive control program. Cpio copies files +into or out of a cpio or tar archive. An archive is a file that +contains other files plus information about them, such as their +pathname, owner, time stamps, and access permissions. The archive can +be another file on the disk, a magnetic tape, or a pipe. + +This package normally includes the program 'rmt', which provides remote +tape drive control. Because there is a compatible 'rmt' in the 'dump' +package, 'rmt' is not included in this package. If you are planning to +use the remote tape features provided by cpio, install the 'dump' +package as well. + + + +Authors: +-------- + David J. MacKenzie + Jim Meyering + +%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 +autoreconf --force --install +CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" \ +./configure DEFAULT_RMT_DIR=/sbin \ + --prefix=/usr \ + --mandir=%{_mandir} \ + --infodir=%{_infodir} \ + --libdir=%{_libdir} +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 + +%post +%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz + +%postun +%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz + +%files +%defattr(-,root,root) +/bin/cpio +/usr/bin/cpio +/usr/bin/mt +%doc %{_infodir}/cpio.info.gz +%doc %{_mandir}/man1/cpio.1.gz +%doc %{_mandir}/man1/mt.1.gz +/usr/share/locale/*/LC_MESSAGES/cpio.mo + +%changelog -n cpio +* Thu Sep 21 2006 - lmichnovic@suse.cz +- fixed typo in cpio-2.6.dif; renamed to *-mt.patch +- united suffix of patches +* Tue Sep 19 2006 - schwab@suse.de +- Fix missing newline after mt status. +* Mon Jul 24 2006 - rguenther@suse.de +- remove useless build-dependency on rsh. +* Wed Jan 25 2006 - mls@suse.de +- converted neededforbuild to BuildRequires +* Tue Dec 06 2005 - fehr@suse.de +- add cpio-2.6-chmodRaceC.patch and cpio-2.6-dirTraversal.patch to + fix bug #80226 +- add cpio-2.6-writeOutHeaderBufferOverflow.patch to fix #133454 +- add cpio-2.6-checksum.patch fix wrong checksum on 64bit archs +- add cpio-2.6-lfs.patch to support large files on 32bit archs +* Wed Aug 10 2005 - fehr@suse.de +- fix call to setlocale to make multibyte characters work (#98902) +* Thu Jun 30 2005 - fehr@suse.de +- open with O_NONBLOCK option (#94449) +* Wed May 04 2005 - ro@suse.de +- properly detect lstat in configure +* Wed Apr 27 2005 - snwint@suse.de +- fix '--sparse' option check +* Mon Apr 25 2005 - fehr@suse.de +- update to cpio 2.6 +* Mon Jan 24 2005 - fehr@suse.de +- fix problem with cpio not respecting umask (#50054) +* Mon Jan 19 2004 - ro@suse.de +- fix build as user +* Sun Jan 11 2004 - adrian@suse.de +- add %%defattr +* Thu Apr 24 2003 - ro@suse.de +- fix install_info --delete call and move from preun to postun +* Tue Apr 15 2003 - coolo@suse.de +- use BuildRoot +* Fri Feb 07 2003 - fehr@suse.de +- Use %%install_info macro +* Tue Sep 17 2002 - ro@suse.de +- removed bogus self-provides +* Tue Aug 13 2002 - mfabian@suse.de +- add cpio-2.5-i18n-0.1.patch received from + "Mitsuru Chinen" + The patch just adds a setlocale (LC_ALL, ""). +* Sun Jul 28 2002 - kukuk@suse.de +- remove unused tetex from neededforbuild +* Fri Jul 05 2002 - fehr@suse.de +- update to new version 2.5 +* Mon Dec 03 2001 - fehr@suse.de +- make the -c switch comatible to SVR4 (and compatible to RedHat) +- fix the man page accordingly +- add rsh to #needfobuild to allow remote file access again (#12543) +* Sun Dec 03 2000 - schwab@suse.de +- Fix a few bugs and typos. +* Tue Nov 28 2000 - fehr@suse.de +- add compile options for LFS +* Mon Apr 17 2000 - fehr@suse.de +- move cpio binary to /bin for compatibility with RedHat +* Fri Feb 25 2000 - kukuk@suse.de +- remove Makefile.Linux +- use _infodir/_mandir +* Mon Sep 13 1999 - bs@suse.de +- ran old prepare_spec on spec file to switch to new prepare_spec. +* Thu Sep 02 1999 - fehr@suse.de +- Fix patch for broken header (cast to short instead of int) +* Wed Aug 04 1999 - kukuk@suse.de +- Add patch for broken header in oldascii format +* Tue Sep 22 1998 - ro@suse.de +- define _GNU_SOURCE for glibc where including getopt +* Tue Sep 01 1998 - ro@suse.de +- fixed strdup-macro problem +* Thu Jun 05 1997 - florian@suse.de +- go through the list of regex in a more suitable way (from ma@suse.de) +* Sun Apr 13 1997 - florian@suse.de +- update to new version 2.4.2 +- add Linux patches from RedHat +- add patches from gnu.utils.bugs diff --git a/fix_umask.patch b/fix_umask.patch new file mode 100644 index 0000000..73a451c --- /dev/null +++ b/fix_umask.patch @@ -0,0 +1,18 @@ +--- 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 (); + diff --git a/open_nonblock.patch b/open_nonblock.patch new file mode 100644 index 0000000..536d74f --- /dev/null +++ b/open_nonblock.patch @@ -0,0 +1,34 @@ +--- 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; diff --git a/ready b/ready new file mode 100644 index 0000000..473a0f4 diff --git a/sparse.patch b/sparse.patch new file mode 100644 index 0000000..5a69686 --- /dev/null +++ b/sparse.patch @@ -0,0 +1,18 @@ +--- 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"))); diff --git a/use_new_ascii_format.patch b/use_new_ascii_format.patch new file mode 100644 index 0000000..130f1cc --- /dev/null +++ b/use_new_ascii_format.patch @@ -0,0 +1,22 @@ +--- doc/cpio.info ++++ doc/cpio.info 2005/04/25 12:11:02 +@@ -261,7 +261,8 @@ + Set the I/O block size to BLOCK-SIZE * 512 bytes. + + `-c' +- Use the old portable (ASCII) archive format. ++ Identical to "-H newc", use the new (SVR4) portable format. ++ If you wish the old portable (ASCII) archive format, use "-H odc" instead. + + `-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 @@ + case 'c': /* Use the old portable ASCII format. */ + if (archive_format != arf_unknown) + USAGE_ERROR ((0, 0, _("Archive format multiply defined"))); ++#define SVR4_COMPAT + #ifdef SVR4_COMPAT + archive_format = arf_newascii; /* -H newc. */ + #else diff --git a/use_sbin_rmt.patch b/use_sbin_rmt.patch new file mode 100644 index 0000000..552ba7b --- /dev/null +++ b/use_sbin_rmt.patch @@ -0,0 +1,20 @@ +--- lib/rtapelib.c ++++ lib/rtapelib.c 2005/04/25 12:16:06 +@@ -17,7 +17,7 @@ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +-/* The man page rmt(8) for /etc/rmt documents the remote mag tape protocol ++/* The man page rmt(8) for /sbin/rmt documents the remote mag tape protocol + which rdump and rrestore use. Unfortunately, the man page is *WRONG*. + The author of the routines I'm including originally wrote his code just + based on the man page, and it didn't work, so he went to the rdump source +@@ -265,7 +265,7 @@ + + #if WITH_REXEC + +-/* Execute /etc/rmt as user USER on remote system HOST using rexec. ++/* Execute /sbin/rmt as user USER on remote system HOST using rexec. + Return a file descriptor of a bidirectional socket for stdin and + stdout. If USER is zero, use the current username. +