Skip to content

Conversation

zonque
Copy link
Member

@zonque zonque commented Jul 6, 2015

Implement the idea of @poettering in #483.

zonque added 3 commits July 6, 2015 17:31
Add a flag to control whether write_string_stream() should always enforce a
trailing newline character in the file.
Merge write_string_file(), write_string_file_no_create() and
write_string_file_atomic() into write_string_file() and provide a flags mask
that allows combinations of atomic writing, newline appending and automatic
file creation. Change all users accordingly.
The latest consolidation cleanup of write_string_file() revealed some users
of that helper which should have used write_string_file_no_create() in the
past but didn't. Basically, all existing users that write to files in /sys
and /proc should not expect to write to a file which is not yet existant.
@zonque zonque changed the title Fileio fileio: consolidate write_string_file*() Jul 6, 2015
@poettering
Copy link
Member

Like it, but I think write_string_stream() should also take the flags parameter, instead of a bool. Seems simpler and more uniform that way, even if not all flags make sense for it.

@zonque
Copy link
Member Author

zonque commented Jul 8, 2015

Uh, really? All that write_string_stream() cares about is whether or not to enforce a newline. It cannot operate atomically, it doesn't create a file or anything. Giving it the same flags parameter really confuses users IMO.

poettering added a commit that referenced this pull request Jul 8, 2015
fileio: consolidate write_string_file*()
@poettering poettering merged commit 1434eb3 into systemd:master Jul 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants