Fix savannah bug #63250
[tar.git] / src / system.c
blob9f8bbe4c8b2becba715c2074faa9685fa81518a8
1 /* System-dependent calls for tar.
3 Copyright 2003-2022 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 3, or (at your option) any later
8 version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #include <system.h>
19 #include <system-ioctl.h>
21 #include "common.h"
22 #include <priv-set.h>
23 #include <rmt.h>
24 #include <signal.h>
25 #include <wordsplit.h>
27 static _Noreturn void
28 xexec (const char *cmd)
30 char *argv[4];
32 argv[0] = (char *) "/bin/sh";
33 argv[1] = (char *) "-c";
34 argv[2] = (char *) cmd;
35 argv[3] = NULL;
37 execv ("/bin/sh", argv);
38 exec_fatal (cmd);
41 /* True if the archive is seekable via ioctl and MTIOCTOP,
42 or if it is not known whether it is seekable.
43 False if it is known to be not seekable. */
44 static bool mtioseekable_archive;
46 bool
47 mtioseek (bool count_files, off_t count)
49 if (mtioseekable_archive)
51 #ifdef MTIOCTOP
52 struct mtop operation;
53 operation.mt_op = (count_files
54 ? (count < 0 ? MTBSF : MTFSF)
55 : (count < 0 ? MTBSR : MTFSR));
56 if (! (count < 0
57 ? INT_SUBTRACT_WRAPV (0, count, &operation.mt_count)
58 : INT_ADD_WRAPV (count, 0, &operation.mt_count))
59 && (0 <= rmtioctl (archive, MTIOCTOP, &operation)
60 || (errno == EIO
61 && 0 <= rmtioctl (archive, MTIOCTOP, &operation))))
62 return true;
63 #endif
65 mtioseekable_archive = false;
67 return false;
70 #if MSDOS
72 bool
73 sys_get_archive_stat (void)
75 return 0;
78 bool
79 sys_file_is_archive (struct tar_stat_info *p)
81 return false;
84 void
85 sys_detect_dev_null_output (void)
87 static char const dev_null[] = "nul";
89 dev_null_output = (strcmp (archive_name_array[0], dev_null) == 0
90 || (! _isrmt (archive)));
93 void
94 sys_wait_for_child (pid_t child_pid, bool eof)
98 void
99 sys_spawn_shell (void)
101 spawnl (P_WAIT, getenv ("COMSPEC"), "-", 0);
104 /* stat() in djgpp's C library gives a constant number of 42 as the
105 uid and gid of a file. So, comparing an FTP'ed archive just after
106 unpack would fail on MSDOS. */
108 bool
109 sys_compare_uid (struct stat *a, struct stat *b)
111 return true;
114 bool
115 sys_compare_gid (struct stat *a, struct stat *b)
117 return true;
120 void
121 sys_compare_links (struct stat *link_data, struct stat *stat_data)
123 return true;
127 sys_truncate (int fd)
129 return write (fd, "", 0);
132 size_t
133 sys_write_archive_buffer (void)
135 return full_write (archive, record_start->buffer, record_size);
138 /* Set ARCHIVE for writing, then compressing an archive. */
139 void
140 sys_child_open_for_compress (void)
142 FATAL_ERROR ((0, 0, _("Cannot use compressed or remote archives")));
145 /* Set ARCHIVE for uncompressing, then reading an archive. */
146 void
147 sys_child_open_for_uncompress (void)
149 FATAL_ERROR ((0, 0, _("Cannot use compressed or remote archives")));
152 #else
154 extern union block *record_start; /* FIXME */
156 bool
157 sys_get_archive_stat (void)
159 bool remote = _isrmt (archive);
160 mtioseekable_archive = true;
161 if (!remote && 0 <= archive && fstat (archive, &archive_stat) == 0)
163 if (!S_ISCHR (archive_stat.st_mode))
164 mtioseekable_archive = false;
165 return true;
167 else
169 /* FIXME: This memset should not be needed. It is present only
170 because other parts of tar may incorrectly access
171 archive_stat even if it's not the archive status. */
172 memset (&archive_stat, 0, sizeof archive_stat);
174 return remote;
178 bool
179 sys_file_is_archive (struct tar_stat_info *p)
181 return (!dev_null_output && !_isrmt (archive)
182 && p->stat.st_dev == archive_stat.st_dev
183 && p->stat.st_ino == archive_stat.st_ino);
186 /* Detect if outputting to "/dev/null". */
187 void
188 sys_detect_dev_null_output (void)
190 static char const dev_null[] = "/dev/null";
191 static struct stat dev_null_stat;
193 dev_null_output = (strcmp (archive_name_array[0], dev_null) == 0
194 || (! _isrmt (archive)
195 && S_ISCHR (archive_stat.st_mode)
196 && (dev_null_stat.st_ino != 0
197 || stat (dev_null, &dev_null_stat) == 0)
198 && archive_stat.st_ino == dev_null_stat.st_ino
199 && archive_stat.st_dev == dev_null_stat.st_dev));
202 void
203 sys_wait_for_child (pid_t child_pid, bool eof)
205 if (child_pid)
207 int wait_status;
209 while (waitpid (child_pid, &wait_status, 0) == -1)
210 if (errno != EINTR)
212 waitpid_error (use_compress_program_option);
213 break;
216 if (WIFSIGNALED (wait_status))
218 int sig = WTERMSIG (wait_status);
219 if (!(!eof && sig == SIGPIPE))
220 FATAL_ERROR ((0, 0, _("Child died with signal %d"), sig));
222 else if (WEXITSTATUS (wait_status) != 0)
223 FATAL_ERROR ((0, 0, _("Child returned status %d"),
224 WEXITSTATUS (wait_status)));
228 void
229 sys_spawn_shell (void)
231 pid_t child;
232 const char *shell = getenv ("SHELL");
233 if (! shell)
234 shell = "/bin/sh";
235 child = xfork ();
236 if (child == 0)
238 priv_set_restore_linkdir ();
239 execlp (shell, "-sh", "-i", NULL);
240 exec_fatal (shell);
242 else
244 int wait_status;
245 while (waitpid (child, &wait_status, 0) == -1)
246 if (errno != EINTR)
248 waitpid_error (shell);
249 break;
254 bool
255 sys_compare_uid (struct stat *a, struct stat *b)
257 return a->st_uid == b->st_uid;
260 bool
261 sys_compare_gid (struct stat *a, struct stat *b)
263 return a->st_gid == b->st_gid;
266 bool
267 sys_compare_links (struct stat *link_data, struct stat *stat_data)
269 return stat_data->st_dev == link_data->st_dev
270 && stat_data->st_ino == link_data->st_ino;
274 sys_truncate (int fd)
276 off_t pos = lseek (fd, (off_t) 0, SEEK_CUR);
277 return pos < 0 ? -1 : ftruncate (fd, pos);
280 /* Return nonzero if NAME is the name of a regular file, or if the file
281 does not exist (so it would be created as a regular file). */
282 static int
283 is_regular_file (const char *name)
285 struct stat stbuf;
287 if (stat (name, &stbuf) == 0)
288 return S_ISREG (stbuf.st_mode);
289 else
290 return errno == ENOENT;
293 size_t
294 sys_write_archive_buffer (void)
296 return rmtwrite (archive, record_start->buffer, record_size);
299 #define PREAD 0 /* read file descriptor from pipe() */
300 #define PWRITE 1 /* write file descriptor from pipe() */
302 /* Duplicate file descriptor FROM into becoming INTO.
303 INTO is closed first and has to be the next available slot. */
304 static void
305 xdup2 (int from, int into)
307 if (from != into)
309 int status = close (into);
311 if (status != 0 && errno != EBADF)
313 int e = errno;
314 FATAL_ERROR ((0, e, _("Cannot close")));
316 status = dup (from);
317 if (status != into)
319 if (status < 0)
321 int e = errno;
322 FATAL_ERROR ((0, e, _("Cannot dup")));
324 abort ();
326 xclose (from);
330 /* Propagate any failure of the grandchild back to the parent. */
331 static _Noreturn void
332 wait_for_grandchild (pid_t pid)
334 int wait_status;
335 int exit_code = 0;
337 while (waitpid (pid, &wait_status, 0) == -1)
338 if (errno != EINTR)
340 waitpid_error (use_compress_program_option);
341 break;
344 if (WIFSIGNALED (wait_status))
345 raise (WTERMSIG (wait_status));
346 else if (WEXITSTATUS (wait_status) != 0)
347 exit_code = WEXITSTATUS (wait_status);
349 exit (exit_code);
352 /* Set ARCHIVE for writing, then compressing an archive. */
353 pid_t
354 sys_child_open_for_compress (void)
356 int parent_pipe[2];
357 int child_pipe[2];
358 pid_t grandchild_pid;
359 pid_t child_pid;
361 signal (SIGPIPE, SIG_IGN);
362 xpipe (parent_pipe);
363 child_pid = xfork ();
365 if (child_pid > 0)
367 /* The parent tar is still here! Just clean up. */
369 archive = parent_pipe[PWRITE];
370 xclose (parent_pipe[PREAD]);
371 return child_pid;
374 /* The new born child tar is here! */
376 set_program_name (_("tar (child)"));
377 signal (SIGPIPE, SIG_DFL);
379 xdup2 (parent_pipe[PREAD], STDIN_FILENO);
380 xclose (parent_pipe[PWRITE]);
382 /* Check if we need a grandchild tar. This happens only if either:
383 a) the file is to be accessed by rmt: compressor doesn't know how;
384 b) the file is not a plain file. */
386 if (!_remdev (archive_name_array[0])
387 && is_regular_file (archive_name_array[0]))
389 if (backup_option)
390 maybe_backup_file (archive_name_array[0], 1);
392 /* We don't need a grandchild tar. Open the archive and launch the
393 compressor. */
394 if (strcmp (archive_name_array[0], "-"))
396 archive = creat (archive_name_array[0], MODE_RW);
397 if (archive < 0)
399 int saved_errno = errno;
401 if (backup_option)
402 undo_last_backup ();
403 errno = saved_errno;
404 open_fatal (archive_name_array[0]);
406 xdup2 (archive, STDOUT_FILENO);
408 priv_set_restore_linkdir ();
409 xexec (use_compress_program_option);
412 /* We do need a grandchild tar. */
414 xpipe (child_pipe);
415 grandchild_pid = xfork ();
417 if (grandchild_pid == 0)
419 /* The newborn grandchild tar is here! Launch the compressor. */
421 set_program_name (_("tar (grandchild)"));
423 xdup2 (child_pipe[PWRITE], STDOUT_FILENO);
424 xclose (child_pipe[PREAD]);
425 priv_set_restore_linkdir ();
426 xexec (use_compress_program_option);
429 /* The child tar is still here! */
431 /* Prepare for reblocking the data from the compressor into the archive. */
433 xdup2 (child_pipe[PREAD], STDIN_FILENO);
434 xclose (child_pipe[PWRITE]);
436 if (strcmp (archive_name_array[0], "-") == 0)
437 archive = STDOUT_FILENO;
438 else
440 archive = rmtcreat (archive_name_array[0], MODE_RW, rsh_command_option);
441 if (archive < 0)
442 open_fatal (archive_name_array[0]);
445 /* Let's read out of the stdin pipe and write an archive. */
447 while (1)
449 size_t status = 0;
450 char *cursor;
451 size_t length;
453 /* Assemble a record. */
455 for (length = 0, cursor = record_start->buffer;
456 length < record_size;
457 length += status, cursor += status)
459 size_t size = record_size - length;
461 status = safe_read (STDIN_FILENO, cursor, size);
462 if (status == SAFE_READ_ERROR)
463 read_fatal (use_compress_program_option);
464 if (status == 0)
465 break;
468 /* Copy the record. */
470 if (status == 0)
472 /* We hit the end of the file. Write last record at
473 full length, as the only role of the grandchild is
474 doing proper reblocking. */
476 if (length > 0)
478 memset (record_start->buffer + length, 0, record_size - length);
479 status = sys_write_archive_buffer ();
480 if (status != record_size)
481 archive_write_error (status);
484 /* There is nothing else to read, break out. */
485 break;
488 status = sys_write_archive_buffer ();
489 if (status != record_size)
490 archive_write_error (status);
493 wait_for_grandchild (grandchild_pid);
496 static void
497 run_decompress_program (void)
499 int i;
500 const char *p, *prog = NULL;
501 struct wordsplit ws;
502 int wsflags = (WRDSF_DEFFLAGS | WRDSF_ENV | WRDSF_DOOFFS) & ~WRDSF_NOVAR;
504 ws.ws_env = (const char **) environ;
505 ws.ws_offs = 1;
507 for (p = first_decompress_program (&i); p; p = next_decompress_program (&i))
509 if (prog)
511 WARNOPT (WARN_DECOMPRESS_PROGRAM,
512 (0, errno, _("cannot run %s"), prog));
513 WARNOPT (WARN_DECOMPRESS_PROGRAM,
514 (0, 0, _("trying %s"), p));
516 if (wordsplit (p, &ws, wsflags))
517 FATAL_ERROR ((0, 0, _("cannot split string '%s': %s"),
518 p, wordsplit_strerror (&ws)));
519 wsflags |= WRDSF_REUSE;
520 memmove(ws.ws_wordv, ws.ws_wordv + ws.ws_offs,
521 sizeof(ws.ws_wordv[0])*ws.ws_wordc);
522 ws.ws_wordv[ws.ws_wordc] = (char *) "-d";
523 prog = p;
524 execvp (ws.ws_wordv[0], ws.ws_wordv);
525 ws.ws_wordv[ws.ws_wordc] = NULL;
527 if (!prog)
528 FATAL_ERROR ((0, 0, _("unable to run decompression program")));
529 exec_fatal (prog);
532 /* Set ARCHIVE for uncompressing, then reading an archive. */
533 pid_t
534 sys_child_open_for_uncompress (void)
536 int parent_pipe[2];
537 int child_pipe[2];
538 pid_t grandchild_pid;
539 pid_t child_pid;
541 xpipe (parent_pipe);
542 child_pid = xfork ();
544 if (child_pid > 0)
546 /* The parent tar is still here! Just clean up. */
548 archive = parent_pipe[PREAD];
549 xclose (parent_pipe[PWRITE]);
550 return child_pid;
553 /* The newborn child tar is here! */
555 set_program_name (_("tar (child)"));
556 signal (SIGPIPE, SIG_DFL);
558 xdup2 (parent_pipe[PWRITE], STDOUT_FILENO);
559 xclose (parent_pipe[PREAD]);
561 /* Check if we need a grandchild tar. This happens only if either:
562 a) we're reading stdin: to force unblocking;
563 b) the file is to be accessed by rmt: compressor doesn't know how;
564 c) the file is not a plain file. */
566 if (strcmp (archive_name_array[0], "-") != 0
567 && !_remdev (archive_name_array[0])
568 && is_regular_file (archive_name_array[0]))
570 /* We don't need a grandchild tar. Open the archive and launch the
571 uncompressor. */
573 archive = open (archive_name_array[0], O_RDONLY | O_BINARY, MODE_RW);
574 if (archive < 0)
575 open_fatal (archive_name_array[0]);
576 xdup2 (archive, STDIN_FILENO);
577 priv_set_restore_linkdir ();
578 run_decompress_program ();
581 /* We do need a grandchild tar. */
583 xpipe (child_pipe);
584 grandchild_pid = xfork ();
586 if (grandchild_pid == 0)
588 /* The newborn grandchild tar is here! Launch the uncompressor. */
590 set_program_name (_("tar (grandchild)"));
592 xdup2 (child_pipe[PREAD], STDIN_FILENO);
593 xclose (child_pipe[PWRITE]);
594 priv_set_restore_linkdir ();
595 run_decompress_program ();
598 /* The child tar is still here! */
600 /* Prepare for unblocking the data from the archive into the
601 uncompressor. */
603 xdup2 (child_pipe[PWRITE], STDOUT_FILENO);
604 xclose (child_pipe[PREAD]);
606 if (strcmp (archive_name_array[0], "-") == 0)
607 archive = STDIN_FILENO;
608 else
609 archive = rmtopen (archive_name_array[0], O_RDONLY | O_BINARY,
610 MODE_RW, rsh_command_option);
611 if (archive < 0)
612 open_fatal (archive_name_array[0]);
614 /* Let's read the archive and pipe it into stdout. */
616 while (1)
618 char *cursor;
619 size_t maximum;
620 size_t count;
621 size_t status;
623 clear_read_error_count ();
625 error_loop:
626 status = rmtread (archive, record_start->buffer, record_size);
627 if (status == SAFE_READ_ERROR)
629 archive_read_error ();
630 goto error_loop;
632 if (status == 0)
633 break;
634 cursor = record_start->buffer;
635 maximum = status;
636 while (maximum)
638 count = maximum < BLOCKSIZE ? maximum : BLOCKSIZE;
639 if (full_write (STDOUT_FILENO, cursor, count) != count)
640 write_error (use_compress_program_option);
641 cursor += count;
642 maximum -= count;
646 xclose (STDOUT_FILENO);
648 wait_for_grandchild (grandchild_pid);
653 static void
654 dec_to_env (char const *envar, uintmax_t num)
656 char buf[UINTMAX_STRSIZE_BOUND];
657 char *numstr;
659 numstr = STRINGIFY_BIGINT (num, buf);
660 if (setenv (envar, numstr, 1) != 0)
661 xalloc_die ();
664 static void
665 time_to_env (char const *envar, struct timespec t)
667 char buf[TIMESPEC_STRSIZE_BOUND];
668 if (setenv (envar, code_timespec (t, buf), 1) != 0)
669 xalloc_die ();
672 static void
673 oct_to_env (char const *envar, unsigned long num)
675 char buf[1+1+(sizeof(unsigned long)*CHAR_BIT+2)/3];
677 snprintf (buf, sizeof buf, "0%lo", num);
678 if (setenv (envar, buf, 1) != 0)
679 xalloc_die ();
682 static void
683 str_to_env (char const *envar, char const *str)
685 if (str)
687 if (setenv (envar, str, 1) != 0)
688 xalloc_die ();
690 else
691 unsetenv (envar);
694 static void
695 chr_to_env (char const *envar, char c)
697 char buf[2];
698 buf[0] = c;
699 buf[1] = 0;
700 if (setenv (envar, buf, 1) != 0)
701 xalloc_die ();
704 static void
705 stat_to_env (char *name, char type, struct tar_stat_info *st)
707 str_to_env ("TAR_VERSION", PACKAGE_VERSION);
708 str_to_env ("TAR_ARCHIVE", *archive_name_cursor);
709 dec_to_env ("TAR_VOLUME", archive_name_cursor - archive_name_array + 1);
710 dec_to_env ("TAR_BLOCKING_FACTOR", blocking_factor);
711 str_to_env ("TAR_FORMAT",
712 archive_format_string (current_format == DEFAULT_FORMAT ?
713 archive_format : current_format));
714 chr_to_env ("TAR_FILETYPE", type);
715 oct_to_env ("TAR_MODE", st->stat.st_mode);
716 str_to_env ("TAR_FILENAME", name);
717 str_to_env ("TAR_REALNAME", st->file_name);
718 str_to_env ("TAR_UNAME", st->uname);
719 str_to_env ("TAR_GNAME", st->gname);
720 time_to_env ("TAR_ATIME", st->atime);
721 time_to_env ("TAR_MTIME", st->mtime);
722 time_to_env ("TAR_CTIME", st->ctime);
723 dec_to_env ("TAR_SIZE", st->stat.st_size);
724 dec_to_env ("TAR_UID", st->stat.st_uid);
725 dec_to_env ("TAR_GID", st->stat.st_gid);
727 switch (type)
729 case 'b':
730 case 'c':
731 dec_to_env ("TAR_MINOR", minor (st->stat.st_rdev));
732 dec_to_env ("TAR_MAJOR", major (st->stat.st_rdev));
733 unsetenv ("TAR_LINKNAME");
734 break;
736 case 'l':
737 case 'h':
738 unsetenv ("TAR_MINOR");
739 unsetenv ("TAR_MAJOR");
740 str_to_env ("TAR_LINKNAME", st->link_name);
741 break;
743 default:
744 unsetenv ("TAR_MINOR");
745 unsetenv ("TAR_MAJOR");
746 unsetenv ("TAR_LINKNAME");
747 break;
751 static pid_t global_pid;
752 static void (*pipe_handler) (int sig);
755 sys_exec_command (char *file_name, int typechar, struct tar_stat_info *st)
757 int p[2];
759 xpipe (p);
760 pipe_handler = signal (SIGPIPE, SIG_IGN);
761 global_pid = xfork ();
763 if (global_pid != 0)
765 xclose (p[PREAD]);
766 return p[PWRITE];
769 /* Child */
770 xdup2 (p[PREAD], STDIN_FILENO);
771 xclose (p[PWRITE]);
773 stat_to_env (file_name, typechar, st);
775 priv_set_restore_linkdir ();
776 xexec (to_command_option);
779 void
780 sys_wait_command (void)
782 int status;
784 if (global_pid < 0)
785 return;
787 signal (SIGPIPE, pipe_handler);
788 while (waitpid (global_pid, &status, 0) == -1)
789 if (errno != EINTR)
791 global_pid = -1;
792 waitpid_error (to_command_option);
793 return;
796 if (WIFEXITED (status))
798 if (!ignore_command_error_option && WEXITSTATUS (status))
799 ERROR ((0, 0, _("%lu: Child returned status %d"),
800 (unsigned long) global_pid, WEXITSTATUS (status)));
802 else if (WIFSIGNALED (status))
804 WARN ((0, 0, _("%lu: Child terminated on signal %d"),
805 (unsigned long) global_pid, WTERMSIG (status)));
807 else
808 ERROR ((0, 0, _("%lu: Child terminated on unknown reason"),
809 (unsigned long) global_pid));
811 global_pid = -1;
815 sys_exec_info_script (const char **archive_name, int volume_number)
817 pid_t pid;
818 char uintbuf[UINTMAX_STRSIZE_BOUND];
819 int p[2];
820 static void (*saved_handler) (int sig);
822 xpipe (p);
823 saved_handler = signal (SIGPIPE, SIG_IGN);
825 pid = xfork ();
827 if (pid != 0)
829 /* Master */
831 int rc;
832 int status;
833 char *buf = NULL;
834 size_t size = 0;
835 FILE *fp;
837 xclose (p[PWRITE]);
838 fp = fdopen (p[PREAD], "r");
839 rc = getline (&buf, &size, fp);
840 fclose (fp);
842 if (rc > 0 && buf[rc-1] == '\n')
843 buf[--rc] = 0;
845 while (waitpid (pid, &status, 0) == -1)
846 if (errno != EINTR)
848 signal (SIGPIPE, saved_handler);
849 waitpid_error (info_script_option);
850 return -1;
853 signal (SIGPIPE, saved_handler);
855 if (WIFEXITED (status))
857 if (WEXITSTATUS (status) == 0 && rc > 0)
858 *archive_name = buf;
859 else
860 free (buf);
861 return WEXITSTATUS (status);
864 free (buf);
865 return -1;
868 /* Child */
869 setenv ("TAR_VERSION", PACKAGE_VERSION, 1);
870 setenv ("TAR_ARCHIVE", *archive_name, 1);
871 setenv ("TAR_VOLUME", STRINGIFY_BIGINT (volume_number, uintbuf), 1);
872 setenv ("TAR_BLOCKING_FACTOR",
873 STRINGIFY_BIGINT (blocking_factor, uintbuf), 1);
874 setenv ("TAR_SUBCOMMAND", subcommand_string (subcommand_option), 1);
875 setenv ("TAR_FORMAT",
876 archive_format_string (current_format == DEFAULT_FORMAT ?
877 archive_format : current_format), 1);
878 setenv ("TAR_FD", STRINGIFY_BIGINT (p[PWRITE], uintbuf), 1);
880 xclose (p[PREAD]);
882 priv_set_restore_linkdir ();
883 xexec (info_script_option);
886 void
887 sys_exec_checkpoint_script (const char *script_name,
888 const char *archive_name,
889 int checkpoint_number)
891 pid_t pid;
892 char uintbuf[UINTMAX_STRSIZE_BOUND];
894 pid = xfork ();
896 if (pid != 0)
898 /* Master */
900 int status;
902 while (waitpid (pid, &status, 0) == -1)
903 if (errno != EINTR)
905 waitpid_error (script_name);
906 break;
909 return;
912 /* Child */
913 setenv ("TAR_VERSION", PACKAGE_VERSION, 1);
914 setenv ("TAR_ARCHIVE", archive_name, 1);
915 setenv ("TAR_CHECKPOINT", STRINGIFY_BIGINT (checkpoint_number, uintbuf), 1);
916 setenv ("TAR_BLOCKING_FACTOR",
917 STRINGIFY_BIGINT (blocking_factor, uintbuf), 1);
918 setenv ("TAR_SUBCOMMAND", subcommand_string (subcommand_option), 1);
919 setenv ("TAR_FORMAT",
920 archive_format_string (current_format == DEFAULT_FORMAT ?
921 archive_format : current_format), 1);
922 priv_set_restore_linkdir ();
923 xexec (script_name);
926 #endif /* not MSDOS */