mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-11-23 23:10:57 +07:00
tmpfiles: if we are supposed to write a string to a file, it's OK if we can't write the trailing newline
This commit is contained in:
parent
04fb63514d
commit
03ad1136ba
@ -597,7 +597,8 @@ int write_one_line_file(const char *fn, const char *line) {
|
||||
assert(fn);
|
||||
assert(line);
|
||||
|
||||
if (!(f = fopen(fn, "we")))
|
||||
f = fopen(fn, "we");
|
||||
if (!f)
|
||||
return -errno;
|
||||
|
||||
errno = 0;
|
||||
|
@ -617,8 +617,13 @@ static int create_item(Item *i) {
|
||||
iovec[1].iov_len = 1;
|
||||
|
||||
n = writev(fd, iovec, 2);
|
||||
if (n < 0 || (size_t) n != l+1) {
|
||||
log_error("Failed to write file %s: %s", i->path, n < 0 ? strerror(-n) : "Short");
|
||||
|
||||
/* It's OK if we don't write the trailing
|
||||
* newline, hence we check for l, instead of
|
||||
* l+1 here. Files in /sys often refuse
|
||||
* writing of the trailing newline. */
|
||||
if (n < 0 || (size_t) n < l) {
|
||||
log_error("Failed to write file %s: %s", i->path, n < 0 ? strerror(-n) : "Short write");
|
||||
close_nointr_nofail(fd);
|
||||
return n < 0 ? n : -EIO;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user