/* Create a tar archive.
- Copyright (C) 1985, 1992 Free Software Foundation
+ Copyright (C) 1988 Free Software Foundation
This file is part of GNU Tar.
extern int errno;
#endif
+#include "tar.h"
+#include "port.h"
+
#ifdef BSD42
#include <sys/file.h>
#else
#endif
#endif
-#include "tar.h"
-#include "port.h"
-
#ifndef __MSDOS__
#include <pwd.h>
#include <grp.h>
open_archive(0); /* Open for writing */
if(f_gnudump) {
- char *buf = ck_malloc(PATH_MAX);
+ char *buf = ck_malloc(NAME_MAX);
char *q,*bufp;
collect_and_sort_names();
while(p=name_from_list())
- dump_file(p,-1, 1);
+ dump_file(p,-1);
/* if(!f_dironly) { */
blank_name_list();
while(p=name_from_list()) {
for(q=gnu_list_name->dir_contents;q && *q;q+=strlen(q)+1) {
if(*q=='Y') {
strcpy(bufp,q+1);
- dump_file(buf,-1, 1);
+ dump_file(buf,-1);
}
}
}
} else {
p = name_next(1);
if(!p)
- dump_file(".", -1, 1);
+ dump_file(".", -1);
else {
- do dump_file(p, -1, 1);
+ do dump_file(p, -1);
while (p = name_next(1));
}
}
* Sets global "hstat" to stat() output for this file.
*/
void
-dump_file (p, curdev, toplevel)
+dump_file (p, curdev)
char *p; /* File name to dump */
int curdev; /* Device our parent dir was on */
- int toplevel; /* Whether we are a toplevel call */
{
union record *header;
char type;
union record *exhdr;
char save_linkflag;
extern time_t new_time;
- int critical_error = 0;
/* int sparse_ind = 0;*/
badperror:
msg_perror("can't add file %s",p);
badfile:
- if (!f_ignore_failed_read || critical_error)
- errors++;
+ errors++;
return;
}
/* We found a link. */
hstat.st_size = 0;
header = start_header(p, &hstat);
- if (header == NULL)
- {
- critical_error = 1;
- goto badfile;
- }
+ if (header == NULL) goto badfile;
while(!f_absolute_paths && *link_name == '/') {
static int link_warn = 0;
header->header.linkflag = LF_LINK;
finish_header(header);
/* FIXME: Maybe remove from list after all links found? */
- if (f_remove_files)
- {
- if (unlink (p) == -1)
- msg_perror ("cannot remove %s", p);
- }
return; /* We dumped it */
}
}
header = start_header(p, &hstat);
if (header == NULL)
- {
- critical_error = 1;
- goto badfile;
- }
+ goto badfile;
header->header.linkflag = LF_SPARSE;
header_moved++;
if (header == NULL) {
if(f>=0)
(void)close(f);
- critical_error = 1;
goto badfile;
}
}
extend: exhdr = findrec();
- if (exhdr == NULL)
- {
- critical_error = 1;
- goto badfile;
- }
+ if (exhdr == NULL) goto badfile;
bzero(exhdr->charptr, RECORDSIZE);
for (i = 0; i < SPARSE_EXT_HDR; i++) {
if (i+index_offset > upperbound)
while (sizeleft > 0) {
if(f_multivol) {
- save_name = p;
+ save_name = header->header.name;
save_sizeleft = sizeleft;
save_totsize = hstat.st_size;
}
if (f >= 0)
(void)close(f);
- if (f_remove_files)
- {
- if (unlink (p) == -1)
- msg_perror ("cannot remove %s", p);
- }
return;
/*
hstat.st_size = 0; /* Force 0 size on symlink */
header = start_header(p, &hstat);
- if (header == NULL)
- {
- critical_error = 1;
- goto badfile;
- }
+ if (header == NULL) goto badfile;
size = readlink(p, header->header.linkname, NAMSIZ);
if (size < 0) goto badperror;
if (size == NAMSIZ) {
header->header.linkname[size] = '\0';
header->header.linkflag = LF_SYMLINK;
finish_header(header); /* Nothing more to do to it */
- if (f_remove_files)
- {
- if (unlink (p) == -1)
- msg_perror ("cannot remove %s", p);
- }
return;
}
#endif
*/
header = start_header(namebuf, &hstat);
if (header == NULL)
- {
- critical_error = 1;
- goto badfile; /* eg name too long */
- }
+ goto badfile; /* eg name too long */
if (f_gnudump)
header->header.linkflag = LF_DUMPDIR;
* See if we are crossing from one file system to another,
* and avoid doing so if the user only wants to dump one file system.
*/
- if (f_local_filesys && toplevel && curdev != hstat.st_dev) {
+ if (f_local_filesys && curdev >= 0 && curdev != hstat.st_dev) {
if(f_verbose)
msg("%s: is on a different filesystem; not dumped",p);
return;
strcpy(namebuf+len, d->d_name);
if(f_exclude && check_exclude(namebuf))
continue;
- dump_file(namebuf, our_device, 0);
+ dump_file(namebuf, our_device);
}
closedir(dirp);
hstat.st_size = 0; /* Force 0 size */
header = start_header(p, &hstat);
- if (header == NULL)
- {
- critical_error = 1;
- goto badfile; /* eg name too long */
- }
+ if (header == NULL) goto badfile; /* eg name too long */
header->header.linkflag = type;
#if defined(S_IFBLK) || defined(S_IFCHR)
#endif
finish_header(header);
- if (f_remove_files)
- {
- if (unlink (p) == -1)
- msg_perror ("cannot remove %s", p);
- }
return;
unknown:
}
free(sparsearray);
-/* printf ("Amount actually written is (I hope) %d.\n", nwritten); */
+ printf ("Amount actually written is (I hope) %d.\n", nwritten);
/* userec(start+(count-1)/RECORDSIZE);*/
return 0;