X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fdird%2Fbsr.c;h=2b2e77526e362bdc9e5be97118da1d7ab64b9203;hb=3f8a3a045ea058657030f588a10f786449d00e0d;hp=96ff865de5254dbf5918c12d9853ebaad3f25d70;hpb=0eab712b22255cdd2cfdb9afb9156ed117fcf4c8;p=bacula%2Fbacula diff --git a/bacula/src/dird/bsr.c b/bacula/src/dird/bsr.c index 96ff865de5..2b2e77526e 100644 --- a/bacula/src/dird/bsr.c +++ b/bacula/src/dird/bsr.c @@ -11,7 +11,7 @@ */ /* - Copyright (C) 2002-2005 Kern Sibbald + Copyright (C) 2002-2006 Kern Sibbald This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -53,6 +53,27 @@ static void free_findex(RBSR_FINDEX *fi) } } +/* + * Get storage device name from Storage resource + */ +static bool get_storage_device(char *device, char *storage) +{ + STORE *store; + if (storage[0] == 0) { + return false; + } + store = (STORE *)GetResWithName(R_STORAGE, storage); + if (!store) { + return false; + } + DEVICE *dev = (DEVICE *)(store->device->first()); + if (!dev) { + return false; + } + bstrncpy(device, dev->hdr.name, MAX_NAME_LENGTH); + return true; +} + /* * Our data structures were not designed completely * correctly, so the file indexes cover the full @@ -170,6 +191,9 @@ bool complete_bsr(UAContext *ua, RBSR *bsr) return true; } +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static uint32_t uniq = 0; + void make_unique_restore_filename(UAContext *ua, POOLMEM **fname) { JCR *jcr = ua->jcr; @@ -178,10 +202,16 @@ void make_unique_restore_filename(UAContext *ua, POOLMEM **fname) Mmsg(fname, "%s", ua->argv[i]); jcr->unlink_bsr = false; } else { - Mmsg(fname, "%s/%s.restore.%s.bsr", working_directory, my_name, - jcr->Job); + P(mutex); + uniq++; + V(mutex); + Mmsg(fname, "%s/%s.restore.%u.bsr", working_directory, my_name, uniq); jcr->unlink_bsr = true; } + if (jcr->RestoreBootstrap) { + free(jcr->RestoreBootstrap); + } + jcr->RestoreBootstrap = bstrdup(*fname); } /* @@ -278,6 +308,7 @@ static uint32_t write_bsr(UAContext *ua, RESTORE_CTX &rx, FILE *fd) bool first = true; char *p; JobId_t JobId; + char device[MAX_NAME_LENGTH]; RBSR *bsr; if (*rx.JobIds == 0) { for (bsr=rx.bsr; bsr; bsr=bsr->next) { @@ -293,6 +324,12 @@ static uint32_t write_bsr(UAContext *ua, RESTORE_CTX &rx, FILE *fd) } fprintf(fd, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName); fprintf(fd, "MediaType=\"%s\"\n", bsr->VolParams[i].MediaType); + if (get_storage_device(device, bsr->VolParams[i].Storage)) { + fprintf(fd, "Device=\"%s\"\n", device); + } + if (bsr->VolParams[i].Slot > 0) { + fprintf(fd, "Slot=%d\n", bsr->VolParams[i].Slot); + } fprintf(fd, "VolSessionId=%u\n", bsr->VolSessionId); fprintf(fd, "VolSessionTime=%u\n", bsr->VolSessionTime); if (bsr->VolParams[i].StartFile == bsr->VolParams[i].EndFile) { @@ -346,6 +383,12 @@ static uint32_t write_bsr(UAContext *ua, RESTORE_CTX &rx, FILE *fd) } fprintf(fd, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName); fprintf(fd, "MediaType=\"%s\"\n", bsr->VolParams[i].MediaType); + if (get_storage_device(device, bsr->VolParams[i].Storage)) { + fprintf(fd, "Device=\"%s\"\n", device); + } + if (bsr->VolParams[i].Slot > 0) { + fprintf(fd, "Slot=%d\n", bsr->VolParams[i].Slot); + } fprintf(fd, "VolSessionId=%u\n", bsr->VolSessionId); fprintf(fd, "VolSessionTime=%u\n", bsr->VolSessionTime); if (bsr->VolParams[i].StartFile == bsr->VolParams[i].EndFile) {