summaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-08-14 16:32:26 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2022-08-15 00:07:39 -0700
commit66be5a789e70f911170017754fc51e499998f90e (patch)
tree21faa71070e63be3bb9994a8daf0c8de8477ae1f /src/common.h
parentbadd509078d97c248b21d875dd239455887cfa0e (diff)
downloadtar-66be5a789e70f911170017754fc51e499998f90e.tar.gz
Avoid excess lseek etc.
* src/buffer.c, src/delete.c: Do not include system-ioctl.h. * src/buffer.c (guess_seekable_archive): Remove. This is now done by get_archive_status, in a different way. (get_archive_status): New function that gets archive_stat unless remote, and sets seekable_archive etc. (_open_archive): Prefer bool for boolean. (_open_archive, new_volume): Get archive status consistently by calling get_archive_status in both places. * src/buffer.c (backspace_output): * src/compare.c (verify_volume): * src/delete.c (move_archive): Let mtioseek worry about mtio. * src/common.h (archive_stat): New global, replacing ar_dev and ar_ino. All uses changed. * src/delete.c (move_archive): Check for integer overflow. Also report overflow if the archive position would go negative. * src/system.c: Include system-ioctl.h, for MTIOCTOP etc. (mtioseek): New function, which also checks for integer overflow. (sys_save_archive_dev_ino): Remove. (archive_stat): Now (sys_get_archive_stat): Also initialize mtioseekable_archive. (sys_file_is_archive): Don’t return true if the archive is /dev/null since it’s not a problem in that case. (sys_detect_dev_null_output): Cache dev_null_stat. doc: omit MS-DOS mentions in doc It’s really FAT32 we’re worried about now, not MS-DOS. And doschk is no longer a GNU program.
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/common.h b/src/common.h
index 62149113..58c1b6c1 100644
--- a/src/common.h
+++ b/src/common.h
@@ -392,9 +392,8 @@ struct name
char *caname; /* canonical name */
};
-/* Obnoxious test to see if dimwit is trying to dump the archive. */
-GLOBAL dev_t ar_dev;
-GLOBAL ino_t ar_ino;
+/* Status of archive file, or all zeros if remote. */
+GLOBAL struct stat archive_stat;
/* Flags for reading, searching, and fstatatting files. */
GLOBAL int open_read_flags;
@@ -402,6 +401,9 @@ GLOBAL int open_searchdir_flags;
GLOBAL int fstatat_flags;
GLOBAL int seek_option;
+
+/* true if archive if lseek should be used on the archive, 0 if it
+ should not be used. */
GLOBAL bool seekable_archive;
GLOBAL dev_t root_device;
@@ -896,7 +898,6 @@ void xattr_map_free (struct xattr_map *xattr_map);
/* Module system.c */
void sys_detect_dev_null_output (void);
-void sys_save_archive_dev_ino (void);
void sys_wait_for_child (pid_t, bool);
void sys_spawn_shell (void);
bool sys_compare_uid (struct stat *a, struct stat *b);
@@ -914,6 +915,7 @@ int sys_exec_info_script (const char **archive_name, int volume_number);
void sys_exec_checkpoint_script (const char *script_name,
const char *archive_name,
int checkpoint_number);
+bool mtioseek (bool count_files, off_t count);
/* Module compare.c */
void report_difference (struct tar_stat_info *st, const char *message, ...)