1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00
The systemd System and Service Manager
Go to file
Zbigniew Jędrzejewski-Szmek 2ac67221bb basic/fileio: fix reading of not-too-small virtual files
This code is trying to do two things: when reading a file with working
st.st_size, detect when the file size changes between the fstat() and our
allocation of the buffer based on the returned size, and the subsequent read().
When reading a file without st.st_size, read up to READ_FULL_BYTES_MAX.

But this second scenario was partially broken: we'd start with size = 4095, and
double the size up to three times, i.e. up to 32767. But we want to read up to
READ_FULL_BYTES_MAX.

So let's listentangle the two cases a bit: if a file returns non-zero st._size,
proceed as before. But if we don't know the size, let's immediately allocate
the buffer of maximum size of READ_FULL_BYTES_MAX. I think that allocating 4MB
and 1MB is going to take pretty much the same time as long as the memory is not
written to, so by allocating 1MB, 2MB, and 4MB, we wouldn't really be saving
anything internally, but wasting time on repeated reads, if the file is long
enough.

Also, don't do the seek if we know we're going to return an error immediately
after.

This should fix reading of any files in /proc, which all have size == 0. In
particular, various files read by coredump might be larger than 32767.

What about /sys? The file there return a fake value, usually 4096. So we'll
allocate a small buffer and read that.
2021-03-30 21:56:22 +02:00
.github docs: link to stable releases in the bug template 2021-03-25 20:38:45 +00:00
.lgtm/cpp-queries lgtm: complain about accept() [people should use accept4() instead, due to O_CLOEXEC] 2019-04-10 20:03:38 +02:00
.mkosi Move shared mkosi settings to a single file in mkosi.default.d/ 2021-01-06 12:10:58 +00:00
.semaphore ci: migrate to Semaphore CI 2.0 2021-01-15 20:18:29 +01:00
catalog license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
coccinelle coccinelle: filter out a couple of 'false-positive' transformations 2021-03-18 11:59:53 +01:00
docs Revert "fix wrong statement JOURNAL_FILE_FORMAT.md doc" 2021-03-30 10:26:54 +02:00
factory/etc man: move 'files' module in NSS 'hosts:' line before myhostname 2020-08-17 18:55:59 +02:00
hwdb.d Add READMEs in all .d directories 2021-03-26 09:35:07 +01:00
man man: document differences in clean exit status for Type=oneshot 2021-03-23 09:33:23 +01:00
mkosi.default.d mkosi: Enable InstallDirectory and SourceFileTransferFinal options 2021-01-06 23:28:34 +00:00
modprobe.d Add READMEs in all .d directories 2021-03-26 09:35:07 +01:00
network network: use IPMasquerade=both instead of yes 2021-02-24 15:01:43 +01:00
po po: Translated using Weblate (Korean) 2021-03-25 10:42:02 +01:00
presets license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
rules.d Add READMEs in all .d directories 2021-03-26 09:35:07 +01:00
shell-completion shell-completion: systemd-run: add missing options 2021-03-22 21:20:17 +01:00
src basic/fileio: fix reading of not-too-small virtual files 2021-03-30 21:56:22 +02:00
sysctl.d Add READMEs in all .d directories 2021-03-26 09:35:07 +01:00
sysusers.d Add READMEs in all .d directories 2021-03-26 09:35:07 +01:00
test shared/calendarspec: when mktime() moves us backwards, jump forward 2021-03-23 00:35:02 +01:00
tmpfiles.d Add READMEs in all .d directories 2021-03-26 09:35:07 +01:00
tools tools: exclude Weblate bot from "ninja git-contrib" 2021-03-17 16:53:14 +01:00
units units: make locale directory writable for systemd-localed 2021-03-29 12:33:36 +02:00
xorg scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
.clang-format clang-format: set SpaceBeforeParens to ControlStatementsExceptForEachMacros 2020-11-16 16:57:51 +09:00
.ctags editors: Prevent ctags from following symlinks 2019-02-15 11:01:20 -08:00
.dir-locals.el scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
.editorconfig editorconfig: add man configuration 2020-05-26 15:37:05 +02:00
.gitattributes udev: Extract RAM properties from DMI information 2020-12-16 18:32:29 +01:00
.gitignore Move shared mkosi settings to a single file in mkosi.default.d/ 2021-01-06 12:10:58 +00:00
.lgtm.yml lgtm: drop the TMPDIR/meson workaround 2020-03-03 20:27:42 +01:00
.mailmap mailmap: merge Weblate bot commiter into one 2021-03-17 16:53:10 +01:00
.packit.yml ci: revert back to --werror instead of -Dc_args=-Werror 2021-03-07 11:07:50 +01:00
.vimrc scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
.ycm_extra_conf.py ycm: add doc string for all the functions in configuration file 2017-11-29 13:21:49 -07:00
configure tree-wide: add spdx header on all scripts and helpers 2021-01-28 09:55:35 +01:00
LICENSE.GPL2 relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
LICENSE.LGPL2.1 licence: remove references to old FSF address 2012-12-17 11:41:31 +01:00
Makefile tree-wide: add spdx header on all scripts and helpers 2021-01-28 09:55:35 +01:00
meson_options.txt meson: fix warning about comparison between different types 2021-03-22 14:40:46 +01:00
meson.build units: make locale directory writable for systemd-localed 2021-03-29 12:33:36 +02:00
mkosi.build meson: Fix update-man-rules when the build dir is not a subdir of the project dir 2021-01-24 17:33:49 +00:00
NEWS Partially revert "correct incorrect command in NEWS (#19048)" 2021-03-22 21:33:03 +01:00
README README: add config_psi as requirement for systemd-oomd 2021-02-23 02:10:09 -08:00
README.md ci: point the Fossies badge to main 2021-01-21 20:08:44 +01:00
TODO update TODO 2021-03-23 14:43:07 +01:00

Systemd

System and Service Manager

Count of open issues over time Count of open pull requests over time Semaphore CI 2.0 Build Status
Coverity Scan Status
OSS-Fuzz Status
CIFuzz
CII Best Practices
Language Grade: C/C++
CentOS CI - CentOS 7
CentOS CI - Arch
CentOS CI - Arch (sanitizers)
Fossies codespell report
Packaging status

Details

Most documentation is available on systemd's web site.

Assorted, older, general information about systemd can be found in the systemd Wiki.

Information about build requirements is provided in the README file.

Consult our NEWS file for information about what's new in the most recent systemd versions.

Please see the Hacking guide for information on how to hack on systemd and test your modifications.

Please see our Contribution Guidelines for more information about filing GitHub Issues and posting GitHub Pull Requests.

When preparing patches for systemd, please follow our Coding Style Guidelines.

If you are looking for support, please contact our mailing list or join our IRC channel.

Stable branches with backported patches are available in the stable repo.