chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
libudev: rework list handling
[elogind.git]
/
extras
/
collect
/
collect.c
diff --git
a/extras/collect/collect.c
b/extras/collect/collect.c
index 0a852f2db239b2d4050a3ec3b90371c273ddf3ee..14184a5e058977361d9927afce60005e8517d806 100644
(file)
--- a/
extras/collect/collect.c
+++ b/
extras/collect/collect.c
@@
-31,9
+31,9
@@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include "../../list.h"
+#include "../../
udev/
list.h"
-#define TMPFILE "/dev/.udev/collect"
+#define TMPFILE
UDEV_PREFIX
"/dev/.udev/collect"
#define BUFSIZE 16
#define UDEV_ALARM_TIMEOUT 180
#define BUFSIZE 16
#define UDEV_ALARM_TIMEOUT 180
@@
-53,7
+53,7
@@
static LIST_HEAD(bunch);
static int debug;
/* This can increase dynamically */
static int debug;
/* This can increase dynamically */
-static
in
t bufsize = BUFSIZE;
+static
size_
t bufsize = BUFSIZE;
static void sig_alrm(int signo)
{
static void sig_alrm(int signo)
{
@@
-147,7
+147,7
@@
static int checkout(int fd)
if (!ptr && word < (buf + len)) {
bufsize = bufsize << 1;
if (debug)
if (!ptr && word < (buf + len)) {
bufsize = bufsize << 1;
if (debug)
- fprintf(stderr, "ID overflow, restarting with size %
d
\n", bufsize);
+ fprintf(stderr, "ID overflow, restarting with size %
zi
\n", bufsize);
free(buf);
lseek(fd, 0, SEEK_SET);
goto restart;
free(buf);
lseek(fd, 0, SEEK_SET);
goto restart;
@@
-271,7
+271,18
@@
static int missing(int fd)
if (him->state == STATE_NONE) {
ret++;
} else {
if (him->state == STATE_NONE) {
ret++;
} else {
- sprintf(buf, "%s ", him->name);
+ while (strlen(him->name)+1 >= bufsize) {
+ char *tmpbuf;
+
+ bufsize = bufsize << 1;
+ tmpbuf = realloc(buf, bufsize);
+ if (!tmpbuf) {
+ free(buf);
+ return -1;
+ }
+ buf = tmpbuf;
+ }
+ snprintf(buf, strlen(him->name)+2, "%s ", him->name);
write(fd, buf, strlen(buf));
}
}
write(fd, buf, strlen(buf));
}
}