File tree 3 files changed +43
-0
lines changed
3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -322,6 +322,9 @@ void dump_cfg(const struct rpminspect *);
322
322
void * read_file_bytes (const char * path , off_t * len );
323
323
string_list_t * read_file (const char * );
324
324
325
+ /* io.c */
326
+ ssize_t full_write (int fd , const void * buf , size_t len );
327
+
325
328
/* release.c */
326
329
char * read_release (const rpmfile_t * );
327
330
const char * get_before_rel (struct rpminspect * );
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright The rpminspect Project Authors
3
+ * SPDX-License-Identifier: LGPL-3.0-or-later
4
+ */
5
+
6
+ #include <unistd.h>
7
+
8
+ /*
9
+ * Write *all* of the supplied buffer out to a fd.
10
+ * Do multiple writes if necessary.
11
+ * Returns the amount written, or -1 if error was seen
12
+ * on the very first write.
13
+ * The write will be incomplete only if an error occurs
14
+ * on one of subsequent writes.
15
+ */
16
+ ssize_t full_write (int fd , const void * buf , size_t len )
17
+ {
18
+ ssize_t total = 0 ;
19
+
20
+ while (len != 0 ) {
21
+ ssize_t cc = write (fd , buf , len );
22
+
23
+ if (cc < 0 ) {
24
+ if (total ) {
25
+ /* we already wrote some! */
26
+ /* user can do another write to know the error code */
27
+ return total ;
28
+ }
29
+
30
+ return cc ; /* write() returns -1 on failure. */
31
+ }
32
+
33
+ total += cc ;
34
+ buf = ((const char * )buf ) + cc ;
35
+ len -= cc ;
36
+ }
37
+
38
+ return total ;
39
+ }
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ librpminspect_sources = [
77
77
' inspect_upstream.c' ,
78
78
' inspect_virus.c' ,
79
79
' inspect_xml.c' ,
80
+ ' io.c' ,
80
81
' joinpath.c' ,
81
82
' koji.c' ,
82
83
' listfuncs.c' ,
You can’t perform that action at this time.
0 commit comments