-#ifdef HAVE_LINUX_ZFTAPE_H
- if (is_zftape(tapename) == 1){
- tapefd_weof(fd, 1);
- }
-#endif /* HAVE_LINUX_ZFTAPE_H */
-
-#ifdef HAVE_LINUX_ZFTAPE_H
- if (is_zftape(tapename) == 1){
- errstr = tapefd_wrendmark(fd, "X", tt_blocksize_kb * 1024);
- if(errstr != NULL) {
- putchar('\n');
- error(errstr);
- }
- }
- else
-#endif /* HAVE_LINUX_ZFTAPE_H */
- errstr = tape_wrendmark(tapename, "X", tt_blocksize_kb * 1024);
- if(errstr != NULL) {
- putchar('\n');
- error(errstr);
- }
-
-#ifdef HAVE_LINUX_ZFTAPE_H
- if (is_zftape(tapename) == 1){
- tapefd_weof(fd, 1);
-
- printf(",\nrewinding"); fflush(stdout);
-
- if(tapefd_rewind(fd) == -1) {
- putchar('\n');
- error(strerror(errno));
- }
- close(fd);
-#ifdef HAVE_LIBVTBLC
- /* update volume table */
- printf(", updating volume table"); fflush(stdout);
-
- if ((fd = raw_tape_open(rawtapedev, O_RDWR)) == -1) {
- if(errno == EACCES) {
- errstr = newstralloc(errstr,
- "updating volume table: raw tape device is write protected");
- } else {
- errstr = newstralloc2(errstr,
- "updating volume table: ", strerror(errno));
- }
- putchar('\n');
- error(errstr);
- }
- /* read volume table */
- if ((num_volumes = read_vtbl(fd, volumes, vtbl_buffer,
- &first_seg, &last_seg)) == -1 ) {
- errstr = newstralloc2(errstr,
- "reading volume table: ", strerror(errno));
- putchar('\n');
- error(errstr);
- }
- /* set date and volume label for first entry */
- vtbl_no = 0;
- datestr = NULL;
- if (set_date(datestr, volumes, num_volumes, vtbl_no)){
- errstr = newstralloc2(errstr,
- "setting date for entry 1: ", strerror(errno));
- putchar('\n');
- error(errstr);
- }
- if(set_label(label, volumes, num_volumes, vtbl_no)){
- errstr = newstralloc2(errstr,
- "setting label for entry 1: ", strerror(errno));
- putchar('\n');
- error(errstr);
- }
- /* set date and volume label for last entry */
- vtbl_no = 1;
- datestr = NULL;
- if (set_date(datestr, volumes, num_volumes, vtbl_no)){
- errstr = newstralloc2(errstr,
- "setting date for entry 2: ", strerror(errno));
- putchar('\n');
- error(errstr);
- }
- if(set_label("AMANDA Tape End", volumes, num_volumes, vtbl_no)){
- errstr = newstralloc2(errstr,
- "setting label for entry 2: ", strerror(errno));
- putchar('\n');
- error(errstr);
- }
- /* write volume table back */
- if (write_vtbl(fd, volumes, vtbl_buffer, num_volumes, first_seg,
- op_mode == trunc)) {
- errstr = newstralloc2(errstr,
- "writing volume table: ", strerror(errno));
- putchar('\n');
- error(errstr);
- }
- close(fd);
-#endif /* HAVE_LIBVTBLC */
- }
-#endif /* HAVE_LINUX_ZFTAPE_H */
-
- if (tape_ok) {
- printf(", checking label"); fflush(stdout);
-
- if((errstr = tape_rdlabel(tapename, &olddatestamp, &oldlabel)) != NULL) {
- putchar('\n');
- if (strcmp(errstr, "not an amanda tape") != 0)
- error(errstr);
- error("no label found, are you sure %s is non-rewinding?",
- tapename);
- }
-
- if (strcmp("X", olddatestamp) != 0 ||
- (strcmp(oldlabel, FAKE_LABEL) != 0
- && strcmp(label, oldlabel) != 0)) {
- putchar('\n');
- error("read label %s back, timestamp %s (expected X), what now?",
- oldlabel, olddatestamp);
- }
- amfree(oldlabel);
- amfree(olddatestamp);
-
- /* write tape list */
-
- /* make a copy */
- conf_tapelist_old = stralloc2(conf_tapelist, ".amlabel");
- if(write_tapelist(conf_tapelist_old)) {
- error("couldn't write tapelist: %s", strerror(errno));
- }
- amfree(conf_tapelist_old);
-
- /* XXX add cur_tape number to tape list structure */
- remove_tapelabel(label);
- add_tapelabel(0, label);
- if(write_tapelist(conf_tapelist)) {
- error("couldn't write tapelist: %s", strerror(errno));
- }
- } /* write tape list */
-
- if(have_changer) {
- /* Now we try to inform the changer, about the new label */
- changer_label(outslot,label);
- }
- printf(", done.\n");