aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/tail.c
AgeCommit message (Collapse)Author
2021-07-04Fix tail -F with no arguments.Rob Landley
fstat() doesn't fail on stdin, so check for fd 0 explicitly so we don't try to access zero length array when optc was zero. (Plus can't reopen '-'.)
2021-07-04Teach tail -F to work on file that doesn't initially exist (neededRob Landley
new lib/ flag), allow -s to be fraction of a second, inline (anonymous) struct so globals.h isn't using an incomplete type, blank line in GLOBALS() between option args and other variables, collate tail_continue() to one function, add test.
2021-07-01tail: implement -F (and its companion -s).Elliott Hughes
(Based on someone else's patch.) Implementing -F with inotify is a lot more work (including more portability shims for macOS), so this is a simpler polling implementation. Also fix my earlier mistake where xnotify_add() wasn't actually an 'x' function that exits on failure.
2019-12-28Rename get_chunk()/dump_chunk() to read_chunk()/write_chunk().Rob Landley
2019-06-03Remove TAIL_SEEK config option, just always include it.Rob Landley
Yeah, it's twice the size and two codepaths, but seekable is the common case, it won't work in pipelines without a non-seek codepath, and the performance penalty not using seek on large files is a enormous.
2019-05-25Move notify.c into portability.c (collate the #ifdefs), move global variablesRob Landley
into a structure passed as arguments, add x prefix to functions that can fail, add overflow test.
2019-05-25tail: support -f on BSD too.Elliott Hughes
Factor out the inotify code and add a kqueue equivalent. Specifically tested on macOS 10.14, but I assume this works for other BSDs too, given that I worked from the FreeBSD man page...
2018-12-04Add FLAG(x) macro, expanding to (toys.optflags & FLAG_##x)Rob Landley
2018-12-04Clean up some --help formatting.Elliott Hughes
Be consistent about upper versus lower case. (Upper seems to have the majority, so I went with that, though I'm happy to provide the opposite patch as long as we're consistent!) Be consistent about using \t. (Though saving a few bytes seems like it might be better done in the code that generates help.h rather than directly in the source, since tabs make careful ASCII art layout hard enough that we regularly have things misaligned.) Remove trailing periods (most of which seem to have been added by me). Always use the US "human readable" rather than my British "human-readable", and be more consistent about declaring whether we're showing multiples of 1000 or 1024. Just say "verbose" rather than adding a useless "mode" or "output".
2018-08-25Convert more argument variables in GLOBALS() to new style.Rob Landley
2017-05-26Be more consistent about periods in help text.Elliott Hughes
2016-09-05Replace loopfiles' failok with WARN_ONLY open flag.Rob Landley
2016-04-16Fix tail -NUM again.Elliott Hughes
This time with a test.
2016-03-18Fix last commit (had newline before first ==> name <==) and add -f tests.Rob Landley
2016-03-18Fix "tail -f single_file".Josh Gao
TT.file_no was being incorrectly calculated as 0 when tail -f was passed a single argument.
2016-01-10Fix tail -f /does/not/exist.Elliott Hughes
Exit immediately if we don't actually have anything to -f --- it's -f's big brother -F that retries by name rather than by fd.
2015-12-21Cleanup tail -f.Rob Landley
2015-12-21Implement tail -f.Josh Gao
2015-12-09tail: use off_t instead of ssize_t for file offset.Josh Gao
2015-04-04To ensure that toybox can be installed alongside busybox withoutPaul Barker
confusing update-alternatives, the paths of the links installed by toybox should match those installed by busybox. This is accomplished by changing the flags of a few tools within toybox.
2015-03-27tail: add old -123 support and comment out #-f until it's actually implemented.Rob Landley
2014-11-19Fix "tail -c 10" segfault spotted by Lukasz Szpakowski.Rob Landley
Once we've read through the initial TT.bytes backlog we discard the extra data, meaning we adjust the remaining amount each time so the overflow is zero bytes. We were doing the adjustment right, but not zeroing out the overflow counter after we did so.
2014-10-27Fix use after free error spotted by ?ukasz Szpakowski.Rob Landley
2013-09-09Redo tail closer to the original design. Add more tests for large data sets. ↵Rob Landley
(Still no -f support yet.)
2013-08-31tail: Some fixesFelix Janda
- Rewrite most of the not lseek() logic - Change meaning of len in line_list - Use single instead of double linked list
2012-11-26Squash "type punned pointer" nonsense with a bigger hammer. (Sheesh.)Rob Landley
2012-11-13Reindent to two spaces per level. Remove vi: directives that haven't worked ↵Rob Landley
right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
2012-10-08New build infrastructure to generate FLAG_ macros and TT alias, #define ↵Rob Landley
FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
2012-08-25Regularize command headers, update links to standards documents.Rob Landley
2012-08-25Move commands into "posix", "lsb", and "other" menus/directories.Rob Landley