+static int dbglevel = 10;
+
+static FTAPE_INFO *get_tape(int fd)
+{
+ if (fd >= NB_TAPE_LIST) {
+ /* error */
+ return NULL;
+ }
+
+ return &tape_list[fd];
+}
+
+static FTAPE_INFO *new_volume(int fd, const char *file)
+{
+ FTAPE_INFO *tape = get_tape(fd);
+ if (!tape) {
+ return NULL;
+ }
+ memset(tape, 0, sizeof(FTAPE_INFO));
+
+ tape->fd = fd;
+ tape->file = bstrdup(file);
+
+ nb = read(tape->fd, &tape->format, FTAPE_HEADER_SIZE);
+ if (nb != FTAPE_HEADER_SIZE) { /* new tape ? */
+
+ }
+ tape->format.file_index = mmap(NULL,
+ tape->format.max_file_mark * sizeof(off_t),
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, fileno(fd), FTAPE_HEADER_SIZE);
+
+ if (!tape->format.file_index) {
+ /* error */
+ }
+
+ tape->format.data_start =
+ FTAPE_HEADER_SIZE + sizeof(off_t)* tape->format.max_file_mark ;
+
+ return tape;
+}
+
+static int free_volume(int fd)
+{
+ FTAPE_INFO *tape = get_tape(fd);
+
+ if (tape) {
+ munmap(tape->format.file_index, tape->format.max_file_mark * sizeof(off_t));
+ free(tape->file);
+ free(tape);
+ }
+}
+