-/*
- *
- * scan.c scan a directory (on a removable file) for a valid
- * Volume name. If found, open the file for append.
- *
- * Kern Sibbald, MMVI
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2006-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
modify it under the terms of version two of the GNU General Public
- License as published by the Free Software Foundation plus additions
- that are listed in the file LICENSE.
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Bacula® is a registered trademark of John Walker.
+ Bacula® is a registered trademark of Kern Sibbald.
The licensor of Bacula is the Free Software Foundation Europe
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * scan.c scan a directory (on a removable file) for a valid
+ * Volume name. If found, open the file for append.
+ *
+ * Kern Sibbald, MMVI
+ *
+ * Version $Id$
+ */
#include "bacula.h"
#include "stored.h"
int name_max;
char *mount_point;
VOLUME_CAT_INFO dcrVolCatInfo, devVolCatInfo;
+ char VolumeName[MAX_NAME_LENGTH];
struct stat statp;
bool found = false;
POOL_MEM fname(PM_FNAME);
bool need_slash = false;
int len;
-
+ dcrVolCatInfo = dcr->VolCatInfo; /* structure assignment */
+ devVolCatInfo = VolCatInfo; /* structure assignment */
+ bstrncpy(VolumeName, dcr->VolumeName, sizeof(VolumeName));
+
name_max = pathconf(".", _PC_NAME_MAX);
if (name_max < 1024) {
name_max = 1024;
berrno be;
dev_errno = errno;
Dmsg3(29, "scan_dir_for_vol: failed to open dir %s (dev=%s), ERR=%s\n",
- mount_point, print_name(), be.strerror());
+ mount_point, print_name(), be.bstrerror());
goto get_out;
}
* this volume is really OK. If not, put back the desired
* volume name, mark it not in changer and continue.
*/
- dcrVolCatInfo = dcr->VolCatInfo; /* structure assignment */
- devVolCatInfo = VolCatInfo; /* structure assignment */
/* Check if this is a valid Volume in the pool */
bstrncpy(dcr->VolumeName, result->d_name, sizeof(dcr->VolumeName));
if (!dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE)) {
closedir(dp);
get_out:
+ if (!found) {
+ /* Restore VolumeName we really wanted */
+ bstrncpy(dcr->VolumeName, VolumeName, sizeof(dcr->VolumeName));
+ dcr->VolCatInfo = dcrVolCatInfo; /* structure assignment */
+ VolCatInfo = devVolCatInfo; /* structure assignment */
+ }
sm_check(__FILE__, __LINE__, false);
return found;
}