From d19facff5c8843dca2adc724ab2e6f5962464aa5 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 2 Apr 2003 15:45:28 +0000 Subject: [PATCH] Add uname to client, various fixes git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@411 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/cats/sql_create.c | 2 +- bacula/src/cats/sql_update.c | 4 ++- bacula/src/dird/newvol.c | 28 +++++++++++++++++---- bacula/src/dird/verify.c | 2 +- bacula/src/lib/sha1.h | 48 ++++++++++++++++++------------------ bacula/src/stored/dircmd.c | 7 ++++++ 6 files changed, 59 insertions(+), 32 deletions(-) diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index 50becdf9b6..9c693e1c01 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -234,7 +234,7 @@ db_create_media_record(void *jcr, B_DB *mdb, MEDIA_DBR *mr) if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 0) { - Mmsg1(&mdb->errmsg, _("Media record %s already exists\n"), mr->VolumeName); + Mmsg1(&mdb->errmsg, _("Volume \"%s\" already exists\n."), mr->VolumeName); sql_free_result(mdb); db_unlock(mdb); return 0; diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index eea89901cc..4bda78419d 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -155,9 +155,11 @@ db_update_client_record(void *jcr, B_DB *mdb, CLIENT_DBR *cr) { int stat; char ed1[50], ed2[50]; + CLIENT_DBR tcr; db_lock(mdb); - if (!db_create_client_record(jcr, mdb, cr)) { + memcpy(&tcr, cr, sizeof(tcr)); + if (!db_create_client_record(jcr, mdb, &tcr)) { db_unlock(mdb); return 0; } diff --git a/bacula/src/dird/newvol.c b/bacula/src/dird/newvol.c index 0b66a86a2b..1b1f277d61 100644 --- a/bacula/src/dird/newvol.c +++ b/bacula/src/dird/newvol.c @@ -59,13 +59,30 @@ int newVolume(JCR *jcr, MEDIA_DBR *mr) bstrncpy(mr->MediaType, jcr->store->media_type, sizeof(mr->MediaType)); bstrncpy(name, pr.LabelFormat, sizeof(name)); if (strchr(name, (int)'%') != NULL) { - db_unlock(jcr->db); Jmsg(jcr, M_ERROR, 0, _("Illegal character in Label Format\n")); - return 0; + goto bail_out; + } + /* See if volume already exists */ + mr->VolumeName[0] = 0; + for (int i=pr.NumVols+1; i<(int)pr.NumVols+11; i++) { + MEDIA_DBR tmr; + memset(&tmr, 0, sizeof(tmr)); + sprintf(num, "%04d", i); + bstrncpy(tmr.VolumeName, name, sizeof(tmr.VolumeName)); + bstrncat(tmr.VolumeName, num, sizeof(tmr.VolumeName)); + if (db_get_media_record(jcr, jcr->db, &tmr)) { + Jmsg(jcr, M_WARNING, 0, +_("Wanted to create Volume \"%s\", but it already exists. Trying again.\n"), + tmr.VolumeName); + continue; + } + bstrncpy(mr->VolumeName, tmr.VolumeName, sizeof(mr->VolumeName)); + } + if (mr->VolumeName[0] == 0) { + Jmsg(jcr, M_ERROR, 0, _("Too many failures. Giving up creating Volume.\n")); + goto bail_out; } - sprintf(num, "%04d", ++pr.NumVols); - bstrncpy(mr->VolumeName, name, sizeof(mr->VolumeName)); - bstrncat(mr->VolumeName, num, sizeof(mr->VolumeName)); + pr.NumVols++; if (db_create_media_record(jcr, jcr->db, mr) && db_update_pool_record(jcr, jcr->db, &pr)) { db_unlock(jcr->db); @@ -76,6 +93,7 @@ int newVolume(JCR *jcr, MEDIA_DBR *mr) } } } +bail_out: db_unlock(jcr->db); return 0; } diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index d42d91bfc9..0fc3ddbf6d 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -323,7 +323,7 @@ static void verify_cleanup(JCR *jcr, int TermCode) msg_type = M_ERROR; /* Generate error message */ break; case JS_Cancelled: - term_msg = _("Verify Cancelled"); + term_msg = _("Verify Canceled"); break; case JS_Differences: term_msg = _("Verify Differences"); diff --git a/bacula/src/lib/sha1.h b/bacula/src/lib/sha1.h index dc10392e22..4bcf470d28 100644 --- a/bacula/src/lib/sha1.h +++ b/bacula/src/lib/sha1.h @@ -2,15 +2,15 @@ * sha1.h * * Description: - * This is the header file for code which implements the Secure - * Hashing Algorithm 1 as defined in FIPS PUB 180-1 published - * April 17, 1995. + * This is the header file for code which implements the Secure + * Hashing Algorithm 1 as defined in FIPS PUB 180-1 published + * April 17, 1995. * - * Many of the variable names in this code, especially the - * single character names, were used because those were the names - * used in the publication. + * Many of the variable names in this code, especially the + * single character names, were used because those were the names + * used in the publication. * - * Please read the file sha1.c for more information. + * Please read the file sha1.c for more information. * * Full Copyright Statement * @@ -55,10 +55,10 @@ /* * If you do not have the ISO standard stdint.h header file, then you * must typdef the following: - * name meaning - * uint32_t unsigned 32 bit integer - * uint8_t unsigned 8 bit integer (i.e., unsigned char) - * int_least16_t integer of >= 16 bits + * name meaning + * uint32_t unsigned 32 bit integer + * uint8_t unsigned 8 bit integer (i.e., unsigned char) + * int32_t integer of 32 bits * */ @@ -67,9 +67,9 @@ enum { shaSuccess = 0, - shaNull, /* Null pointer parameter */ - shaInputTooLong, /* input data too long */ - shaStateError /* called Input after Result */ + shaNull, /* Null pointer parameter */ + shaInputTooLong, /* input data too long */ + shaStateError /* called Input after Result */ }; #endif #define SHA1HashSize 20 @@ -82,15 +82,15 @@ typedef struct SHA1Context { uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */ - uint32_t Length_Low; /* Message length in bits */ - uint32_t Length_High; /* Message length in bits */ + uint32_t Length_Low; /* Message length in bits */ + uint32_t Length_High; /* Message length in bits */ - /* Index into message block array */ - int_least16_t Message_Block_Index; - uint8_t Message_Block[64]; /* 512-bit message blocks */ + /* Index into message block array */ + int32_t Message_Block_Index; + uint8_t Message_Block[64]; /* 512-bit message blocks */ - int Computed; /* Is the digest computed? */ - int Corrupted; /* Is the message digest corrupted? */ + int Computed; /* Is the digest computed? */ + int Corrupted; /* Is the message digest corrupted? */ } SHA1Context; /* @@ -99,9 +99,9 @@ typedef struct SHA1Context int SHA1Init(SHA1Context *); int SHA1Update(SHA1Context *, - const uint8_t *, - unsigned int); + const uint8_t *, + unsigned int); int SHA1Final(SHA1Context *, - uint8_t Message_Digest[SHA1HashSize]); + uint8_t Message_Digest[SHA1HashSize]); #endif diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index b8327afc5d..de421646e7 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -216,6 +216,13 @@ static int cancel_cmd(JCR *cjcr) if (jcr->file_bsock) { bnet_sig(jcr->file_bsock, BNET_TERMINATE); } + /* If thread waiting on mount, wake him */ + if (jcr->device && jcr->device->dev && + (jcr->device->dev->dev_blocked == BST_WAITING_FOR_SYSOP || + jcr->device->dev->dev_blocked == BST_UNMOUNTED || + jcr->device->dev->dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP)) { + pthread_cond_signal(&jcr->device->dev->wait_next_vol); + } bnet_fsend(dir, _("3000 Job %s marked to be cancelled.\n"), jcr->Job); free_jcr(jcr); } -- 2.39.5