busybox/libbb
Denis Vlasenko 57abf9e947 libbb: make history saving/loading concurrent-safe
* all history writers always append (not overwrite) history files
* they reload history if they detect that file length has changed since last
write
* they trim history file only when it grows 4 times longer than MAXLINES
* they do this atomically by creating new file and renaming it to old

Unfortunately, this comes at a price:

function                                             old     new   delta
load_history                                           -     346    +346
read_line_input                                     3155    3358    +203
new_line_input_t                                      17      31     +14
...irrelevant small jitter...
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/5 up/down: 573/-13)           Total: 560 bytes
2009-03-22 19:00:05 +00:00
..
appletlib.c *: move get_sock_lsa and xwrite_str to libbb, use where appropriate 2009-03-09 00:12:37 +00:00
ask_confirmation.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
bb_askpass.c - add new applet mkpasswd(1) 2008-12-03 18:48:39 +00:00
bb_basename.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
bb_do_delay.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
bb_pwd.c libbb: add xgetgrnam too. ~0 code size change 2008-12-05 16:23:06 +00:00
bb_qsort.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
bb_strtod.c libbb: do not reject floating point strings like ".15" 2008-10-18 19:18:51 +00:00
bb_strtonum.c s/othervise/otherwise/g 2008-07-23 08:41:08 +00:00
change_identity.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
chomp.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
compare_string_array.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
concat_path_file.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
concat_subpath_file.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
Config.in - wrap overlong lines (Cristian Ionescu-Idbohrn) 2008-07-22 18:27:53 +00:00
copy_file.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
copyfd.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
correct_password.c - add new applet mkpasswd(1) 2008-12-03 18:48:39 +00:00
crc32.c Fix forgotten license comments 2008-12-07 00:52:58 +00:00
create_icmp6_socket.c Fix forgotten license comments 2008-12-07 00:52:58 +00:00
create_icmp_socket.c Fix forgotten license comments 2008-12-07 00:52:58 +00:00
default_error_retval.c Rename two config options: 2007-04-10 23:03:30 +00:00
device_open.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
die_if_bad_username.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
dump.c libbb: replace some memmove's with memcpy's (Ron (ron AT debian.org)) 2008-11-16 22:21:23 +00:00
error_msg_and_die.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
error_msg.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
execable.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
fclose_nonstdin.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
fflush_stdout_and_exit.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
fgets_str.c ftpd: fix command fetching to not do it in 1-byte reads; 2009-03-18 17:32:44 +00:00
find_mount_point.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
find_pid_by_name.c killall and sestatus also need ARGVN scanning 2009-02-14 01:36:11 +00:00
find_root_device.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
full_write.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
get_console.c *: code shrink by adding a wrapper around very common tcsetattr(0, TCSANOW, xx) op 2008-11-05 13:20:58 +00:00
get_last_path_component.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
get_line_from_file.c optimize config_read() (by Timo Teras <timo.teras AT iki.fi>) 2008-08-09 17:16:40 +00:00
getopt32.c gzip: fix gzip -dc case caused by using stale getopt state 2008-11-12 22:06:46 +00:00
getpty.c libbb: use ptsname_r, it's smaller 2008-08-17 12:47:19 +00:00
herror_msg_and_die.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
herror_msg.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
human_readable.c Fix forgotten license comments 2008-12-07 00:52:58 +00:00
inet_common.c Fix forgotten license comments 2008-12-07 00:52:58 +00:00
info_msg.c bb_info_msg: make it do atomic, unbuffered writes 2008-12-10 11:16:47 +00:00
inode_hash.c du: fix "du /dir /dir" case 2008-11-11 21:15:56 +00:00
isdirectory.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
Kbuild libbb: move crypt_make_salt() to pw_encrypt.c, reuse 2008-12-07 01:16:34 +00:00
kernel_version.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
last_char_is.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
lineedit_ptr_hack.c add forgotten files. I am forgetting it all the time :( 2008-04-22 18:07:41 +00:00
lineedit.c libbb: make history saving/loading concurrent-safe 2009-03-22 19:00:05 +00:00
llist.c libbb: shrink linked list ops (by xmaks AT email.cz) 2009-01-13 15:22:50 +00:00
login.c libbb: [x]fopen_for_{read,write} introduced and used. 2008-07-21 23:05:26 +00:00
loop.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
make_directory.c volume identification: abolish /proc/partitions and /proc/cdroms 2008-10-19 19:36:30 +00:00
makedev.c fix FAST_FUNC fallout 2008-06-28 04:58:55 +00:00
match_fstype.c mount: support "-O option"; stop trying to mount swap partitions 2009-03-14 22:57:20 +00:00
md5.c shrink sha hashing a bit more (remove wbuflen field from ctx), 2009-03-12 15:40:27 +00:00
md5prime.c libbb: disable a second md5 implementation which managed to creep in :) 2008-11-11 01:38:04 +00:00
messages.c *: rename ATTRIBUTE_XXX to just XXX. 2008-07-05 09:18:54 +00:00
mode_string.c taskset: fix some careless code in both fancy and non-fancy cases. 2008-07-11 13:57:08 +00:00
mtab_file.c trylink: produce even more info about final link stage 2007-08-12 20:58:27 +00:00
mtab.c libbb/mtab: fix xrealloc_vector fallout 2008-07-09 19:44:08 +00:00
obscure.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
parse_config.c - fix typo (thanks to Peter Kjellerstedt for noticing) 2009-02-23 16:21:53 +00:00
parse_mode.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
perror_msg_and_die.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
perror_msg.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
perror_nomsg_and_die.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
perror_nomsg.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
pidfile.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
print_flags.c libbb: fix print_flags() [fix somehow is only in 1.11.1?) 2008-07-20 13:47:51 +00:00
printable.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
process_escape_sequence.c libbb: document that we maybe will want to understand \e someday 2008-09-19 23:43:59 +00:00
procps.c libbb: password/group function helpers rewritten by Tito: 2008-12-02 22:56:59 +00:00
ptr_to_globals.c *: remove remaining instances of ".data" hack 2008-04-22 00:08:27 +00:00
pw_encrypt_des.c libbb: move crypt_make_salt() to pw_encrypt.c, reuse 2008-12-07 01:16:34 +00:00
pw_encrypt_md5.c libbb/crypt: code shrink 2008-12-04 15:29:35 +00:00
pw_encrypt_sha.c shrink sha hashing 2009-03-12 15:39:11 +00:00
pw_encrypt.c libbb: move crypt_make_salt() to pw_encrypt.c, reuse 2008-12-07 01:16:34 +00:00
read_key.c read_key is actually written by Rob, add him to copyright notice 2008-10-26 00:19:33 +00:00
read.c ftpd: fix command fetching to not do it in 1-byte reads; 2009-03-18 17:32:44 +00:00
README
recursive_action.c netstat: optional -p support by L. Gabriel Somlo <somlo AT cmu.edu> 2008-07-27 12:10:07 +00:00
remove_file.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
restricted_shell.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
rtc.c Fix forgotten license comments 2008-12-07 00:52:58 +00:00
run_shell.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
safe_gethostname.c sendmail: from Vladimir: 2008-06-30 13:30:21 +00:00
safe_poll.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
safe_strncpy.c fix all cases of strcpy on overlapping strings. 2008-07-22 20:16:55 +00:00
safe_write.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
selinux_common.c Fix forgotten license comments 2008-12-07 00:52:58 +00:00
setup_environment.c setup_environment: cd $HOME regardless of clear_env value. 2008-10-30 23:58:19 +00:00
sha1.c sha: merge K[] for sha256 and 512 2009-03-15 04:56:51 +00:00
signals.c init: preparatory patch, no code changes 2009-01-31 01:02:07 +00:00
simplify_path.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
skip_whitespace.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
speed_table.c ash,hush: add TODO for rare build failure 2008-11-25 01:36:03 +00:00
str_tolower.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
strrstr.c - update my name. No obj-code changes ;) 2008-09-25 12:13:34 +00:00
time.c libbb: shrink monotonic_XXX functions, introduce monotonic_ns 2008-06-29 02:25:53 +00:00
trim.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
u_signal_names.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
udp_io.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
update_passwd.c Fix forgotten license comments 2008-12-07 00:52:58 +00:00
uuencode.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
vdprintf.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
verror_msg.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
vfork_daemon_rexec.c Compatibility fixes: 2009-03-20 22:17:13 +00:00
warn_ignoring_args.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
wfopen_input.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
wfopen.c libbb: [x]fopen_for_{read,write} introduced and used. 2008-07-21 23:05:26 +00:00
write.c *: move get_sock_lsa and xwrite_str to libbb, use where appropriate 2009-03-09 00:12:37 +00:00
xatonum_template.c Fix forgotten license comments 2008-12-07 00:52:58 +00:00
xatonum.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
xconnect.c ftpd: EPSV and SIZE support. Tested to work on IPv6 too. 2009-03-09 13:01:08 +00:00
xfunc_die.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
xfuncs_printf.c *: move get_sock_lsa and xwrite_str to libbb, use where appropriate 2009-03-09 00:12:37 +00:00
xfuncs.c libbb: introduce and use xmalloc_ttyname (-32 in bss). 2008-12-23 23:36:47 +00:00
xgetcwd.c Fix forgotten license comments 2008-12-07 00:52:58 +00:00
xgethostbyname.c *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on 2008-06-27 02:52:20 +00:00
xreadlink.c ls: make readlink error to not disrupt output (try ls -l /proc/self/fd). 2009-03-21 19:11:23 +00:00
xrealloc_vector.c fix bug 4464 for real. I am dumb. 2008-08-06 08:44:09 +00:00
xregcomp.c grep: option to use GNU regex matching instead of POSIX one. 2008-08-09 16:15:14 +00:00

Please see the LICENSE file for copyright information (GPLv2)

libbb is BusyBox's utility library.  All of this stuff used to be stuffed into
a single file named utility.c.  When I split utility.c to create libbb, some of
the very oldest stuff ended up without their original copyright and licensing
information (which is now lost in the mists of time).  If you see something
that you wrote that is mis-attributed, do let me know so we can fix that up.

	Erik Andersen
	<andersen@codepoet.org>