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