X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fscan.c;h=655ee2924c69d75a30d59a026510fa9fd213699c;hb=a8397bfc69b83581e359e8c53b031e85ba10af2a;hp=98e9dd54ef238a7968ec3c84c6b57757768d6981;hpb=c37638750b04e222c9436d70c55d28193c58a86f;p=bacula%2Fbacula diff --git a/bacula/src/stored/scan.c b/bacula/src/stored/scan.c index 98e9dd54ef..655ee2924c 100644 --- a/bacula/src/stored/scan.c +++ b/bacula/src/stored/scan.c @@ -49,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; @@ -71,7 +75,7 @@ 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; } @@ -111,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. */ - 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)) { @@ -129,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; }