char *sublockname = NULL;
int groupwritable = 0, sublockfd, subfilefd;
struct stat st;
- size_t len;
int subdirfd = -1;
switch(typesub) {
exit(EXIT_FAILURE);
}
- subfilefd = openat(subdirfd, chstr, O_RDWR|O_CREAT|O_EXLOCK,
+ subfilefd = openat(subdirfd, chstr, O_RDWR|O_CREAT|O_EXLOCK|O_APPEND,
S_IRUSR|S_IWUSR|groupwritable);
if(subfilefd == -1) {
log_error(LOG_ARGS, "Could not open '%s/%s/%s'", list->dir, chstr);
exit(EXIT_FAILURE);
}
- lseek(subfilefd, 0L, SEEK_END);
- len = strlen(address);
- address[len] = '\n';
- writen(subfilefd, address, len + 1);
- address[len] = 0;
+ dprintf(subfilefd, "%s\n", address);
close(subfilefd);
close(sublockfd);
unlinkat(subdirfd, sublockname, 0);