return;
    }
          
-   Dmsg2(29, "open_dev: device is disk %s (mode:%d)\n", archive_name.c_str(), mode);
+   Dmsg3(29, "open_dev: device is %s (mode:%d)\n", dev->is_dvd()?"DVD":"disk",
+         archive_name.c_str(), mode);
    dev->openmode = mode;
    
    /*
       Emsg0(M_ABORT, 0, _("Illegal mode given to open_dev.\n"));
    }
    /* If creating file, give 0640 permissions */
+   Dmsg2(29, "open(%s, 0x%x, 0640)\n", archive_name.c_str(), dev->mode);
    if ((dev->fd = open(archive_name.c_str(), dev->mode, 0640)) < 0) {
       berrno be;
       dev->dev_errno = errno;
          dev->part_size = filestat.st_size;
       }
    }
-   Dmsg4(29, "open_dev: disk fd=%d opened, part=%d/%d, part_size=%u\n", dev->fd, dev->part, dev->num_parts, dev->part_size);
+   Dmsg5(29, "open_dev: %s fd=%d opened, part=%d/%d, part_size=%u\n", 
+      dev->is_dvd()?"DVD":"disk", dev->fd, dev->part, dev->num_parts, 
+      dev->part_size);
    if (dev->is_dvd() && (dev->mode != OPEN_READ_ONLY) && 
        (dev->free_space_errno == 0 || dev->num_parts == dev->part)) {
       update_free_space_dev(dev);
 
    Copyright (C) 2005 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as ammended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
    char* icmd;
    int timeout;
    long long int free;
+   char ed1[50];
    
    icmd = dev->device->free_space_command;
    
    timeout = 3;
    
    while (1) {
-      char ed1[50];
       if (run_program_full_output(ocmd.c_str(), dev->max_open_wait/2, results) == 0) {
          Dmsg1(100, "Free space program run : %s\n", results);
          free = str_to_int64(results);
    }
    
    free_pool_memory(results);
-   Dmsg2(29, "update_free_space_dev: free_space=%lld, free_space_errno=%d\n", dev->free_space, dev->free_space_errno);
+   Dmsg2(29, "update_free_space_dev: free_space=%s, free_space_errno=%d\n", 
+      edit_uint64(dev->free_space, ed1), dev->free_space_errno);
    return;
 }
 
  *  - Close the fd
  *  - Reopen the device
  */
-int open_first_part(DEVICE *dev) {
-   int state;
-      
+int open_first_part(DEVICE *dev) 
+{
    Dmsg3(29, "open_first_part %s %s %d\n", dev->dev_name, dev->VolCatInfo.VolCatName, dev->openmode);
    if (dev->fd >= 0) {
       close(dev->fd);
    }
-   
    dev->fd = -1;
-   state = dev->state;
    dev->state &= ~ST_OPENED;
    
    dev->part_start = 0;
    dev->part = 0;
    
+   Dmsg2(50, "Call open_dev(dev, vol=%s, mode=%d",
+        dev->VolCatInfo.VolCatName, dev->openmode);
    if (open_dev(dev, dev->VolCatInfo.VolCatName, dev->openmode) < 0) {
+      Dmsg0(50, "open_dev() failed\n");
       return -1;
    }
-   dev->state = state;
+   Dmsg1(50, "Leave open_first_part state=%s\n", dev->is_open()?"open":"not open");
    return dev->fd;
 }