]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/mountreq.c
Fix breaks in bextract + in restore print only volumes to be actually used
[bacula/bacula] / bacula / src / dird / mountreq.c
1 /*
2  *
3  *   Bacula Director -- mountreq.c -- handles the message channel
4  *    Mount request from the Storage daemon.
5  *
6  *     Kern Sibbald, March MMI
7  *
8  *    This routine runs as a thread and must be thread reentrant.
9  *
10  *  Basic tasks done here:
11  *      Handle Mount services.
12  *
13  *   Version $Id$
14  */
15 /*
16    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
17
18    This program is free software; you can redistribute it and/or
19    modify it under the terms of the GNU General Public License as
20    published by the Free Software Foundation; either version 2 of
21    the License, or (at your option) any later version.
22
23    This program is distributed in the hope that it will be useful,
24    but WITHOUT ANY WARRANTY; without even the implied warranty of
25    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26    General Public License for more details.
27
28    You should have received a copy of the GNU General Public
29    License along with this program; if not, write to the Free
30    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
31    MA 02111-1307, USA.
32
33  */
34
35 #include "bacula.h"
36 #include "dird.h"
37
38 /*
39  * Handle mount request
40  *  For now, we put the bsock in the UA's queue
41  */
42
43 /* Requests from the Storage daemon */
44
45
46 /* Responses  sent to Storage daemon */
47 #ifdef xxx
48 static char OK_mount[]  = "1000 OK MountVolume\n";
49 #endif
50
51 static BQUEUE mountq = {&mountq, &mountq};
52 static int num_reqs = 0;
53 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
54
55 typedef struct mnt_req_s {
56    BQUEUE bq;
57    BSOCK *bs;
58    JCR *jcr;
59 } MNT_REQ;
60
61
62 void mount_request(JCR *jcr, BSOCK *bs, char *buf)
63 {
64    MNT_REQ *mr;
65
66    mr = (MNT_REQ *) malloc(sizeof(MNT_REQ));
67    memset(mr, 0, sizeof(MNT_REQ));
68    mr->jcr = jcr;
69    mr->bs = bs;
70    P(mutex);
71    num_reqs++;
72    qinsert(&mountq, &mr->bq);
73    V(mutex);
74    return;
75 }