* file named AUTHORS, in the root directory of this distribution.
*/
/*
- * $Id: amlabel.c,v 1.18.2.15.4.3.2.4 2003/01/01 23:28:53 martinea Exp $
+ * $Id: amlabel.c,v 1.18.2.15.4.3.2.4.2.4 2005/10/02 13:48:42 martinea Exp $
*
* write an Amanda label on a tape
*/
char *conf_tapelist_old;
unsigned long malloc_hist_1, malloc_size_1;
unsigned long malloc_hist_2, malloc_size_2;
- int fd;
+#ifdef HAVE_LINUX_ZFTAPE_H
+ int fd = -1;
+ int isa_zftape;
+#endif /* HAVE_LINUX_ZFTAPE_H */
int have_changer;
int force, tape_ok;
tape_t *tp;
int first_seg, last_seg;
#endif /* HAVE_LIBVTBLC */
- for(fd = 3; fd < FD_SETSIZE; fd++) {
- /*
- * Make sure nobody spoofs us with a lot of extra open files
- * that would cause an open we do to get a very high file
- * descriptor, which in turn might be used as an index into
- * an array (e.g. an fd_set).
- */
- close(fd);
- }
-
+ safe_fd(-1, 0);
safe_cd();
set_pname("amlabel");
}
#ifdef HAVE_LINUX_ZFTAPE_H
- if (is_zftape(tapename) == 1){
+ isa_zftape = is_zftape(tapename);
+ if (isa_zftape) {
if((fd = tape_open(tapename, O_WRONLY)) == -1) {
errstr = newstralloc2(errstr, "amlabel: ",
(errno == EACCES) ? "tape is write-protected"
printf("rewinding"); fflush(stdout);
#ifdef HAVE_LINUX_ZFTAPE_H
- if (is_zftape(tapename) == 1){
+ if (isa_zftape) {
if(tapefd_rewind(fd) == -1) {
putchar('\n');
error(strerror(errno));
printf("rewinding"); fflush(stdout);
#ifdef HAVE_LINUX_ZFTAPE_H
- if (is_zftape(tapename) == 1){
+ if (isa_zftape) {
if(tapefd_rewind(fd) == -1) {
putchar('\n');
error(strerror(errno));
printf(", writing label %s", label); fflush(stdout);
#ifdef HAVE_LINUX_ZFTAPE_H
- if (is_zftape(tapename) == 1){
+ if (isa_zftape) {
errstr = tapefd_wrlabel(fd, "X", label, tt_blocksize_kb * 1024);
if(errstr != NULL) {
putchar('\n');
}
#ifdef HAVE_LINUX_ZFTAPE_H
- if (is_zftape(tapename) == 1){
+ if (isa_zftape) {
tapefd_weof(fd, 1);
}
#endif /* HAVE_LINUX_ZFTAPE_H */
#ifdef HAVE_LINUX_ZFTAPE_H
- if (is_zftape(tapename) == 1){
+ if (isa_zftape) {
errstr = tapefd_wrendmark(fd, "X", tt_blocksize_kb * 1024);
if(errstr != NULL) {
putchar('\n');
}
#ifdef HAVE_LINUX_ZFTAPE_H
- if (is_zftape(tapename) == 1){
+ if (isa_zftape) {
tapefd_weof(fd, 1);
printf(",\nrewinding"); fflush(stdout);