Mostly by adding static and removing excess extern qualifiers. Also
convert a few remaining non-ANSI function declarations to ANSI.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The logsave program is leaking a file descriptor when it forks and
execs the program which forks a process which hangs around. In the
case of /etc/init.d/checkroot, this would be fsck. This file
descriptor never gets closed, so it's still present when fsck runs
e2fsck, and then if e2fsck has its own logging enabled using (in
/etc/e2fsck.conf):
[options]
log_dir = /mnt
log_filename = e2fsck-%N.%h.INFO.%D-%T
log_dir_wait = true
then e2fsck will fork off a process waiting for /mnt to get remounted
read/write. This causes logsave to never get an EOF from its pipe, so
it hangs waiting for the read to fail --- which won't happen due to
the file descriptor leak which is still being held open by e2fsck's
forked child process. And so /etc/init.d/checkroot hangs, and the
root file system never gets remounted read/write, and we deadlock.
Fix the problem by closing the pipe fd so the logsave program doesn't
end up leaking it to its descendent processes.
Addresses-Debian-Bug: #682592
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The DEFS line in MCONFIG had gotten so long that it exceeded 4k, and
this was starting to cause some tools heartburn. It also made "make
V=1" almost useless, since trying to following the individual commands
run by make was lost in the noise of all of the defines.
So fix this by putting the configure-generated defines in lib/config.h
and the directory pathnames to lib/dirpaths.h.
In addition, clean up some vestigal defines in configure.in and in the
Makefiles to further shorten the cc command lines.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
These reflect either file descriptors which aren't tested
for failure, or closures of fd's which may have failed.
In setup_tdb(), test for failure of mkstemp and return
without trying to open the file (again).
In reserve_stdio_fds, rather than closing the "extra"
fd == 3 due to the way the loop is written, just
don't go that far by using while (fd <= 2).
In logsave, it forks and retries forever if open fails,
but at least make coverity happy by explicitly not
trying to close a negative file descriptor.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Some terminal programs may print wierd characters when they see the
\001 or \002 characters. So filter them out if the -s option
(skip_mode) is enabled.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fixed a potential bug where by partial returns from the write(2)
system call could some bytes to be lost when writing to the log file.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Solaris's header files are very picky about which C compiler can be
used for SUSv3 conformance. Use of C99 is not compatible with SUSv2
(_XOPEN_SOURCE=500), and C89 is not compatible with SUSv3
(_XOPEN_SOURCE=600). Since we need some SUSv3 functions, consistently
use SUSv3 so that e2fsprogs will build on Solaris using c99.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
* Change e2fsck to bracket its progress bar output with ctrl-A and ctrl-B
characters, so that logsave -s can omit writing the progress bar output
to the log file.
in a log file, even if the containing directory hasn't been
mounted yet (in which case the it saves the output in
memory until it can write out the logfile).