X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fscan.c;h=655ee2924c69d75a30d59a026510fa9fd213699c;hb=a8397bfc69b83581e359e8c53b031e85ba10af2a;hp=5700ec214251256454fa39edd45d03ae13aec839;hpb=e670d56b052fe2d2a235c84b473e7d0119cd0787;p=bacula%2Fbacula diff --git a/bacula/src/stored/scan.c b/bacula/src/stored/scan.c index 5700ec2142..655ee2924c 100644 --- a/bacula/src/stored/scan.c +++ b/bacula/src/stored/scan.c @@ -8,19 +8,32 @@ * Version $Id$ */ /* - Copyright (C) 2006 Kern Sibbald + Bacula® - The Network Backup Solution - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2 as amended with additional clauses defined in the - file LICENSE in the main source directory. + Copyright (C) 2006-2006 Free Software Foundation Europe e.V. - 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 - the file LICENSE for additional details. + 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. - */ + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ #include "bacula.h" #include "stored.h" @@ -36,13 +49,17 @@ bool DEVICE::scan_dir_for_volume(DCR *dcr) 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; @@ -58,13 +75,13 @@ bool DEVICE::scan_dir_for_volume(DCR *dcr) 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; } len = strlen(mount_point); if (len > 0) { - need_slash = mount_point[len - 1] != '/'; + need_slash = !IsPathSeparator(mount_point[len - 1]); } entry = (struct dirent *)malloc(sizeof(struct dirent) + name_max + 1000); for ( ;; ) { @@ -98,8 +115,6 @@ bool DEVICE::scan_dir_for_volume(DCR *dcr) * this volume is really OK. If not, put back the desired * volume name, mark it not in changer and continue. */ - memcpy(&dcrVolCatInfo, &dcr->VolCatInfo, sizeof(dcrVolCatInfo)); - memcpy(&devVolCatInfo, &VolCatInfo, sizeof(devVolCatInfo)); /* 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)) { @@ -108,7 +123,7 @@ bool DEVICE::scan_dir_for_volume(DCR *dcr) /* This was not the volume we expected, but it is OK with * the Director, so use it. */ - memcpy(&VolCatInfo, &dcr->VolCatInfo, sizeof(VolCatInfo)); + VolCatInfo = dcr->VolCatInfo; /* structure assignment */ found = true; break; /* got a Volume */ } @@ -116,6 +131,12 @@ bool DEVICE::scan_dir_for_volume(DCR *dcr) 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; }