]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/mountreq.c
Switch from GPLv2 to AGPLv3
[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    Bacula® - The Network Backup Solution
17
18    Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
19
20    The main author of Bacula is Kern Sibbald, with contributions from
21    many others, a complete list can be found in the file AUTHORS.
22    This program is Free Software; you can redistribute it and/or
23    modify it under the terms of version three of the GNU Affero General Public
24    License as published by the Free Software Foundation and included
25    in the file LICENSE.
26
27    This program is distributed in the hope that it will be useful, but
28    WITHOUT ANY WARRANTY; without even the implied warranty of
29    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30    General Public License for more details.
31
32    You should have received a copy of the GNU Affero General Public License
33    along with this program; if not, write to the Free Software
34    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
35    02110-1301, USA.
36
37    Bacula® is a registered trademark of Kern Sibbald.
38    The licensor of Bacula is the Free Software Foundation Europe
39    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
40    Switzerland, email:ftf@fsfeurope.org.
41 */
42
43 #include "bacula.h"
44 #include "dird.h"
45
46 /*
47  * Handle mount request
48  *  For now, we put the bsock in the UA's queue
49  */
50
51 /* Requests from the Storage daemon */
52
53
54 /* Responses  sent to Storage daemon */
55 #ifdef xxx
56 static char OK_mount[]  = "1000 OK MountVolume\n";
57 #endif
58
59 static BQUEUE mountq = {&mountq, &mountq};
60 static int num_reqs = 0;
61 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
62
63 typedef struct mnt_req_s {
64    BQUEUE bq;
65    BSOCK *bs;
66    JCR *jcr;
67 } MNT_REQ;
68
69
70 void mount_request(JCR *jcr, BSOCK *bs, char *buf)
71 {
72    MNT_REQ *mr;
73
74    mr = (MNT_REQ *) malloc(sizeof(MNT_REQ));
75    memset(mr, 0, sizeof(MNT_REQ));
76    mr->jcr = jcr;
77    mr->bs = bs;
78    P(mutex);
79    num_reqs++;
80    qinsert(&mountq, &mr->bq);
81    V(mutex);
82    return;
83 }