"Fossies" - the Fresh Open Source Software Archive 
Member "xorriso-1.5.4/libburn/ddlpa_1.h" (30 Jan 2021, 5672 Bytes) of package /linux/misc/xorriso-1.5.4.pl02.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "ddlpa_1.h" see the
Fossies "Dox" file reference documentation.
1
2 /* ddlpa
3 Implementation of Delicate Device Locking Protocol level A.
4 Copyright (C) 2007 Thomas Schmitt <scdbackup@gmx.net>
5 Provided under any of the following licenses: GPL, LGPL, BSD. Choose one.
6 */
7
8 #ifndef DDLPA_H_INCLUDED
9 #define DDLPA_H_INCLUDED 1
10
11
12 /* >>> For now : do not encapsulate the details of struct ddlpa_lock */
13 #ifndef DDLPA_H_NOT_ENCAPSULATED
14 #define DDLPA_H_NOT_ENCAPSULATED 1
15 #endif
16
17
18 #ifndef DDLPA_H_NOT_ENCAPSULATED
19
20 /** Container for locking state and parameters.
21 */
22 struct ddlpa_lock;
23
24
25 #else /* ! DDLPA_H_NOT_ENCAPSULATED */
26
27
28 /* An upper limit for the length of standard paths and sibling paths */
29 #define DDLPA_MAX_STD_LEN 15
30
31 /* An upper limit for the number of siblings */
32 #define DDLPA_MAX_SIBLINGS 5
33
34 struct ddlpa_lock {
35
36 /* Recorded input parameters of locking call */
37 char *path;
38 int path_is_valid;
39 int in_bus, in_target, in_lun;
40 int inbtl_is_valid;
41 int ddlpa_flags;
42 int o_flags;
43
44 /* Result of locking call */
45 char std_path[DDLPA_MAX_STD_LEN + 1];
46 int fd;
47 dev_t rdev;
48 dev_t dev;
49 ino_t ino;
50 int host, channel, id, lun, bus;
51 int hcilb_is_valid;
52 int num_siblings;
53 char sibling_paths[DDLPA_MAX_SIBLINGS][DDLPA_MAX_STD_LEN + 1];
54 int sibling_fds[DDLPA_MAX_SIBLINGS];
55 dev_t sibling_rdevs[DDLPA_MAX_SIBLINGS];
56 dev_t sibling_devs[DDLPA_MAX_SIBLINGS];
57 ino_t sibling_inodes[DDLPA_MAX_SIBLINGS];
58
59 /* Is NULL if all goes well. Else it may contain a text message. */
60 char *errmsg;
61 };
62
63 #endif /* DDLPA_H_NOT_ENCAPSULATED */
64
65
66
67 /** Lock a recorder by naming a device file path. Allocate a new container.
68 @param path Gives the file system path of the recorder
69 as known to the calling program.
70 @param o_flags flags for open(2)
71 @param ddlpa_flags 0 = default behavior: the standard path will be opened
72 and treated by fcntl(F_SETLK)
73 DDLPA_OPEN_GIVEN_PATH causes the input parameter "path"
74 to be used with open(2) and fcntl(2). Caution: This
75 weakens the fcntl part of DDLP-A.
76 DDLPA_ALLOW_MISSING_SGRCD allows to grant a lock
77 although not both, a sg and a sr|scd device, have been
78 found during sibling search. Normally this is counted
79 as failure due to EBUSY.
80 @param lockbundle gets allocated and then represents the locking state
81 @param errmsg if *errmsg is not NULL after the call, it contains an
82 error message. Then to be released by free(3).
83 It is NULL in case of success or lack of memory.
84 @return 0=success , 1=failure
85 */
86 int ddlpa_lock_path(char *path, int o_flags, int ddlpa_flags,
87 struct ddlpa_lock **lockbundle, char **errmsg);
88
89
90 /** Lock a recorder by naming a Bus,Target,Lun number triple.
91 Allocate a new container.
92 @param bus parameter to match ioctl(SCSI_IOCTL_GET_BUS_NUMBER)
93 @param target parameter to match ioctl(SCSI_IOCTL_GET_IDLUN) &0xff
94 @param lun parameter to match ioctl(SCSI_IOCTL_GET_IDLUN) &0xff00
95 @param o_flags flags for open(2)
96 @param ddlpa_flags see ddlpa_lock_path(). Flag DDLPA_OPEN_GIVEN_PATH
97 will be ignored.
98 @param lockbundle see ddlpa_lock_path().
99 @param errmsg see ddlpa_lock_path().
100 @return 0=success , 1=failure
101 */
102 int ddlpa_lock_btl(int bus, int target, int lun,
103 int o_flags, int ddlpa_flags,
104 struct ddlpa_lock **lockbundle, char **errmsg);
105
106
107 /** Release the lock by closing all filedescriptors and freeing memory.
108 @param lockbundle the lock which is to be released.
109 *lockbundle will be set to NULL by this call.
110 @return 0=success , 1=failure
111 */
112 int ddlpa_destroy(struct ddlpa_lock **lockbundle);
113
114
115
116 #ifndef DDLPA_H_NOT_ENCAPSULATED
117
118 /** Obtain the file descriptor for doing serious work on the recorder.
119 @param lockbundle the lock which has been activated either by
120 ddlpa_lock_path() or ddlpa_lock_btl()
121 @return the file descriptor
122 */
123 int ddlpa_get_fd(struct ddlpa_lock *lockbundle);
124
125 /** Obtain the path which was used to open the file descriptor.
126 @param lockbundle the lock
127 @return a pointer to the path string.
128 Do not alter that string ! Do not free(3) it !
129 */
130 char *ddlpa_get_fd_path(struct ddlpa_lock *lockbundle);
131
132
133 /* Obtain info about the standard path and eventual locked siblings.
134 @param lockbundle the lock to inquire
135 @param std_path a pointer to the string with the standard path.
136 Do not alter that string ! Do not free(3) it !
137 @param num_siblings Tells the number of elements in sibling_*[].
138 0 and 1 will be the most frequent values.
139 @param sibling_paths Tells the device file paths of the opened sibling
140 device representations
141 Do not alter those strings ! Do not free(3) them !
142 @param sibling_fds Contains the opened file descriptors on sibling_paths
143 @return 0=success , 1=failure (will hardly happen)
144 */
145 int ddlpa_get_siblings(struct ddlpa_lock *lockbundle,
146 char **std_path, int *num_siblings,
147 char ***sibling_paths, int **sibling_fds);
148
149 #endif /* ! DDLPA_H_NOT_ENCAPSULATED */
150
151
152 /** Definitions of macros used in above functions */
153
154 #define DDLPA_OPEN_GIVEN_PATH 1
155 #define DDLPA_ALLOW_MISSING_SGRCD 2
156
157
158 #endif /* DDLPA_H_INCLUDED */