]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/mountreq.c
Fix bug #2343 where truncate of explicit Volume name truncates non-purged volumes
[bacula/bacula] / bacula / src / dird / mountreq.c
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2015 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    This notice must be preserved when any source code is 
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19 /*
20  *
21  *   Bacula Director -- mountreq.c -- handles the message channel
22  *    Mount request from the Storage daemon.
23  *
24  *     Kern Sibbald, March MMI
25  *
26  *    This routine runs as a thread and must be thread reentrant.
27  *
28  *  Basic tasks done here:
29  *      Handle Mount services.
30  *
31  */
32
33 #include "bacula.h"
34 #include "dird.h"
35
36 /*
37  * Handle mount request
38  *  For now, we put the bsock in the UA's queue
39  */
40
41 /* Requests from the Storage daemon */
42
43
44 /* Responses  sent to Storage daemon */
45 #ifdef xxx
46 static char OK_mount[]  = "1000 OK MountVolume\n";
47 #endif
48
49 static BQUEUE mountq = {&mountq, &mountq};
50 static int num_reqs = 0;
51 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
52
53 typedef struct mnt_req_s {
54    BQUEUE bq;
55    BSOCK *bs;
56    JCR *jcr;
57 } MNT_REQ;
58
59
60 void mount_request(JCR *jcr, BSOCK *bs, char *buf)
61 {
62    MNT_REQ *mreq;
63
64    mreq = (MNT_REQ *) malloc(sizeof(MNT_REQ));
65    memset(mreq, 0, sizeof(MNT_REQ));
66    mreq->jcr = jcr;
67    mreq->bs = bs;
68    P(mutex);
69    num_reqs++;
70    qinsert(&mountq, &mreq->bq);
71    V(mutex);
72    return;
73 }