• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 14526975710

17 Apr 2025 09:06PM UTC coverage: 72.13% (+0.01%) from 72.117%
14526975710

push

github

yuwata
rules: Make ADB and fastboot work out-of-the-box

https://android.googlesource.com/platform/packages/modules/adb/+/d0db47dcd/adb.h#199
https://android.googlesource.com/platform/system/core/+/7199051aa/fastboot/fastboot.cpp#244

297093 of 411885 relevant lines covered (72.13%)

687643.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

32.61
/src/libudev/libudev-queue.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
/***
3
  Copyright © 2009 Alan Jenkins <alan-jenkins@tuffmail.co.uk>
4
***/
5

6
#include <errno.h>
7
#include <unistd.h>
8

9
#include "libudev.h"
10

11
#include "alloc-util.h"
12
#include "fd-util.h"
13
#include "io-util.h"
14
#include "udev-util.h"
15

16
/**
17
 * SECTION:libudev-queue
18
 * @short_description: access to currently active events
19
 *
20
 * This exports the current state of the udev processing queue.
21
 */
22

23
/**
24
 * udev_queue:
25
 *
26
 * Opaque object representing the current event queue in the udev daemon.
27
 */
28
struct udev_queue {
29
        struct udev *udev;
30
        unsigned n_ref;
31
        int fd;
32
};
33

34
/**
35
 * udev_queue_new:
36
 * @udev: udev library context
37
 *
38
 * The initial refcount is 1, and needs to be decremented to
39
 * release the resources of the udev queue context.
40
 *
41
 * Returns: the udev queue context, or #NULL on error.
42
 **/
43
_public_ struct udev_queue* udev_queue_new(struct udev *udev) {
1,784✔
44
        struct udev_queue *udev_queue;
1,784✔
45

46
        udev_queue = new(struct udev_queue, 1);
1,784✔
47
        if (!udev_queue)
1,784✔
48
                return_with_errno(NULL, ENOMEM);
×
49

50
        *udev_queue = (struct udev_queue) {
1,784✔
51
                .udev = udev,
52
                .n_ref = 1,
53
                .fd = -EBADF,
54
        };
55

56
        return udev_queue;
1,784✔
57
}
58

59
static struct udev_queue* udev_queue_free(struct udev_queue *udev_queue) {
1,784✔
60
        assert(udev_queue);
1,784✔
61

62
        safe_close(udev_queue->fd);
1,784✔
63
        return mfree(udev_queue);
1,784✔
64
}
65

66
/**
67
 * udev_queue_ref:
68
 * @udev_queue: udev queue context
69
 *
70
 * Take a reference of a udev queue context.
71
 *
72
 * Returns: the same udev queue context.
73
 **/
74

75
/**
76
 * udev_queue_unref:
77
 * @udev_queue: udev queue context
78
 *
79
 * Drop a reference of a udev queue context. If the refcount reaches zero,
80
 * the resources of the queue context will be released.
81
 *
82
 * Returns: #NULL
83
 **/
84
DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(struct udev_queue, udev_queue, udev_queue_free);
1,784✔
85

86
/**
87
 * udev_queue_get_udev:
88
 * @udev_queue: udev queue context
89
 *
90
 * Retrieve the udev library context the queue context was created with.
91
 *
92
 * Returns: the udev library context.
93
 **/
94
_public_ struct udev* udev_queue_get_udev(struct udev_queue *udev_queue) {
×
95
        assert_return_errno(udev_queue, NULL, EINVAL);
×
96

97
        return udev_queue->udev;
×
98
}
99

100
/**
101
 * udev_queue_get_kernel_seqnum:
102
 * @udev_queue: udev queue context
103
 *
104
 * This function is deprecated.
105
 *
106
 * Returns: 0.
107
 **/
108
_public_ unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue) {
×
109
        return 0;
×
110
}
111

112
/**
113
 * udev_queue_get_udev_seqnum:
114
 * @udev_queue: udev queue context
115
 *
116
 * This function is deprecated.
117
 *
118
 * Returns: 0.
119
 **/
120
_public_ unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue) {
×
121
        return 0;
×
122
}
123

124
/**
125
 * udev_queue_get_udev_is_active:
126
 * @udev_queue: udev queue context
127
 *
128
 * Check if udev is active on the system.
129
 *
130
 * Returns: a flag indicating if udev is active.
131
 **/
132
_public_ int udev_queue_get_udev_is_active(struct udev_queue *udev_queue) {
1,783✔
133
        return access("/run/udev/control", F_OK) >= 0;
1,783✔
134
}
135

136
/**
137
 * udev_queue_get_queue_is_empty:
138
 * @udev_queue: udev queue context
139
 *
140
 * Check if udev is currently processing any events.
141
 *
142
 * Returns: a flag indicating if udev is currently handling events.
143
 **/
144
_public_ int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue) {
1✔
145
        return udev_queue_is_empty() > 0;
1✔
146
}
147

148
/**
149
 * udev_queue_get_seqnum_sequence_is_finished:
150
 * @udev_queue: udev queue context
151
 * @start: first event sequence number
152
 * @end: last event sequence number
153
 *
154
 * This function is deprecated, and equivalent to udev_queue_get_queue_is_empty().
155
 *
156
 * Returns: a flag indicating if udev is currently handling events.
157
 **/
158
_public_ int udev_queue_get_seqnum_sequence_is_finished(
×
159
                struct udev_queue *udev_queue,
160
                unsigned long long int start,
161
                unsigned long long int end) {
162

163
        return udev_queue_is_empty() > 0;
×
164
}
165

166
/**
167
 * udev_queue_get_seqnum_is_finished:
168
 * @udev_queue: udev queue context
169
 * @seqnum: sequence number
170
 *
171
 * This function is deprecated, and equivalent to udev_queue_get_queue_is_empty().
172
 *
173
 * Returns: a flag indicating if udev is currently handling events.
174
 **/
175
_public_ int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum) {
×
176
        return udev_queue_is_empty() > 0;
×
177
}
178

179
/**
180
 * udev_queue_get_queued_list_entry:
181
 * @udev_queue: udev queue context
182
 *
183
 * This function is deprecated.
184
 *
185
 * Returns: NULL.
186
 **/
187
_public_ struct udev_list_entry* udev_queue_get_queued_list_entry(struct udev_queue *udev_queue) {
×
188
        return_with_errno(NULL, ENODATA);
×
189
}
190

191
/**
192
 * udev_queue_get_fd:
193
 * @udev_queue: udev queue context
194
 *
195
 * Returns: a file descriptor to watch for a queue to become empty.
196
 */
197
_public_ int udev_queue_get_fd(struct udev_queue *udev_queue) {
×
198
        _cleanup_close_ int fd = -EBADF;
×
199

200
        assert_return(udev_queue, -EINVAL);
×
201

202
        if (udev_queue->fd >= 0)
×
203
                return udev_queue->fd;
204

205
        fd = inotify_init1(IN_CLOEXEC);
×
206
        if (fd < 0)
×
207
                return -errno;
×
208

209
        if (inotify_add_watch(fd, "/run/udev" , IN_DELETE) < 0)
×
210
                return -errno;
×
211

212
        return udev_queue->fd = TAKE_FD(fd);
×
213
}
214

215
/**
216
 * udev_queue_flush:
217
 * @udev_queue: udev queue context
218
 *
219
 * Returns: the result of clearing the watch for queue changes.
220
 */
221
_public_ int udev_queue_flush(struct udev_queue *udev_queue) {
×
222
        int r;
×
223

224
        assert_return(udev_queue, -EINVAL);
×
225

226
        if (udev_queue->fd < 0)
×
227
                return -EINVAL;
228

229
        r = flush_fd(udev_queue->fd);
×
230
        if (r < 0)
×
231
                return r;
×
232

233
        return 0;
234
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc