2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
29 * Definitions for locking and blocking functions in the SD
31 * Kern Sibbald, pulled out of dev.h June 2007
42 #define r_dlock() _r_dlock(__FILE__, __LINE__); /* in lock.c */
43 #define r_dunlock() _r_dunlock(__FILE__, __LINE__); /* in lock.c */
44 #define dlock() _dlock(__FILE__, __LINE__); /* in lock.c */
45 #define dunlock() _dunlock(__FILE__, __LINE__); /* in lock.c */
48 #define block_device(d, s) _block_device(__FILE__, __LINE__, (d), s)
49 #define unblock_device(d) _unblock_device(__FILE__, __LINE__, (d))
50 #define steal_device_lock(d, p, s) _steal_device_lock(__FILE__, __LINE__, (d), (p), s)
51 #define give_back_device_lock(d, p) _give_back_device_lock(__FILE__, __LINE__, (d), (p))
53 /* m_blocked states (mutually exclusive) */
55 BST_NOT_BLOCKED = 0, /* not blocked */
56 BST_UNMOUNTED, /* User unmounted device */
57 BST_WAITING_FOR_SYSOP, /* Waiting for operator to mount tape */
58 BST_DOING_ACQUIRE, /* Opening/validating/moving tape */
59 BST_WRITING_LABEL, /* Labeling a tape */
60 BST_UNMOUNTED_WAITING_FOR_SYSOP, /* User unmounted during wait for op */
61 BST_MOUNT, /* Mount request */
62 BST_DESPOOLING, /* Despooling -- i.e. multiple writes */
63 BST_RELEASING /* Releasing the device */
66 typedef struct s_steal_lock {
67 pthread_t no_wait_id; /* id of no wait thread */
68 int dev_blocked; /* state */
69 int dev_prev_blocked; /* previous blocked state */
73 * Used in unblock() call