busybox/sysklogd
Christian Engelmayer 8de2e42201 syslogd: work around rename() not renaming hardlinks to themselves
Function log_locally() within the syslogd can potentially lock up when
restarting the daemon after a power loss in case the unplanned shutdown hit the
rename operation during logfile rotation.

While POSIX requires the rename operation to be atomic, many file systems such
as JFFS2 implement the rename operation in 2 steps by linking the new name
followed by unlinking the original name. In case of a power loss during the
rename the system can end up with /var/log/messages and /var/log/messages.0
being 2 hard links to the same file.

When the syslog daemon restarts in such a situation it will rediscover the need
to rotate the log files, however, POSIX also requires that rename does nothing
and reports success in case oldpath and newpath are existing hard links to the
same file. Looping through reopen: by (O_CREAT | O_APPEND), the daemon
eternally reopens the same file without succeeding to rotate.

Signed-off-by: Christian Engelmayer <christian.engelmayer@frequentis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-28 18:12:42 +02:00
..
Config.src small fixes atop syslog config patch 2011-04-16 20:15:14 +02:00
Kbuild.src *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
klogd.c *: remove "Options:" string from help texts 2011-06-05 03:58:28 +02:00
logger.c *: remove "Options:" string from help texts 2011-06-05 03:58:28 +02:00
logread.c *: remove "Options:" string from help texts 2011-06-05 03:58:28 +02:00
syslogd_and_logger.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
syslogd.c syslogd: work around rename() not renaming hardlinks to themselves 2011-10-28 18:12:42 +02:00