"Fossies" - the Fresh Open Source Software Archive 
Member "xorriso-1.5.4/libburn/ddlpa.h" (30 Jan 2021, 3972 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.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 See ../doc/ddlp.txt for a description of the protocol.
8 */
9
10 #ifndef DDLPA_H_INCLUDED
11 #define DDLPA_H_INCLUDED 1
12
13
14 /* An upper limit for the length of standard paths and sibling paths */
15 #define DDLPA_MAX_STD_LEN 15
16
17 /* An upper limit for the number of siblings */
18 #define DDLPA_MAX_SIBLINGS 5
19
20 struct ddlpa_lock {
21
22 /* Recorded input parameters of locking call */
23 char *path;
24 int path_is_valid;
25 int in_bus, in_target, in_lun;
26 int inbtl_is_valid;
27 int ddlpa_flags;
28 int o_flags;
29
30 /* Result of locking call */
31 char std_path[DDLPA_MAX_STD_LEN + 1];
32 int fd;
33 dev_t rdev;
34 dev_t dev;
35 ino_t ino;
36 int host, channel, id, lun, bus;
37 int hcilb_is_valid;
38 int num_siblings;
39 char sibling_paths[DDLPA_MAX_SIBLINGS][DDLPA_MAX_STD_LEN + 1];
40 int sibling_fds[DDLPA_MAX_SIBLINGS];
41 dev_t sibling_rdevs[DDLPA_MAX_SIBLINGS];
42 dev_t sibling_devs[DDLPA_MAX_SIBLINGS];
43 ino_t sibling_inodes[DDLPA_MAX_SIBLINGS];
44
45 /* Is NULL if all goes well. Else it may contain a text message. */
46 char *errmsg;
47 };
48
49
50
51 /** Lock a recorder by naming a device file path. Allocate a new container.
52 @param path Gives the file system path of the recorder
53 as known to the calling program.
54 @param o_flags flags for open(2). Do not use O_EXCL here because this
55 is done automatically whenever appropriate.
56 Advised is O_RDWR | O_LARGEFILE, eventually | O_NDELAY.
57 @param ddlpa_flags 0 = default behavior: the standard path will be opened
58 and treated by fcntl(F_SETLK)
59 DDLPA_OPEN_GIVEN_PATH causes the input parameter "path"
60 to be used with open(2) and fcntl(2).
61 DDLPA_ALLOW_MISSING_SGRCD allows to grant a lock
62 although not all three, a sg, a sr and a scd device
63 file have been found during sibling search. Normally
64 this is counted as failure due to EBUSY.
65 @param lockbundle gets allocated and then represents the locking state
66 @param errmsg if *errmsg is not NULL after the call, it contains an
67 error message. Then to be released by free(3).
68 It is NULL in case of success or lack of memory.
69 @return 0=success , else an errno compatible error number
70 */
71 int ddlpa_lock_path(char *path, int o_flags, int ddlpa_flags,
72 struct ddlpa_lock **lockbundle, char **errmsg);
73
74
75 /** Lock a recorder by naming a Bus,Target,Lun number triple.
76 Allocate a new container.
77 @param bus parameter to match ioctl(SCSI_IOCTL_GET_BUS_NUMBER)
78 @param target parameter to match ioctl(SCSI_IOCTL_GET_IDLUN) &0xff
79 @param lun parameter to match ioctl(SCSI_IOCTL_GET_IDLUN) &0xff00
80 @param o_flags see ddlpa_lock_path().
81 @param ddlpa_flags see ddlpa_lock_path(). Flag DDLPA_OPEN_GIVEN_PATH
82 will be ignored.
83 @param lockbundle see ddlpa_lock_path().
84 @param errmsg see ddlpa_lock_path().
85 @return 0=success , else an errno compatible error number
86 */
87 int ddlpa_lock_btl(int bus, int target, int lun,
88 int o_flags, int ddlpa_flags,
89 struct ddlpa_lock **lockbundle, char **errmsg);
90
91
92 /** Release the lock by closing all filedescriptors and freeing memory.
93 @param lockbundle the lock which is to be released.
94 *lockbundle will be set to NULL by this call.
95 @return 0=success , 1=failure
96 */
97 int ddlpa_destroy(struct ddlpa_lock **lockbundle);
98
99
100
101 /** Definitions of macros used in above functions */
102
103 #define DDLPA_OPEN_GIVEN_PATH 1
104 #define DDLPA_ALLOW_MISSING_SGRCD 2
105
106
107 #endif /* DDLPA_H_INCLUDED */