aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
Commit message (Collapse)AuthorAgeFilesLines
* Remove a duplicate fclose() that snuck into r316501Alan Somers2017-04-051-1/+0
| | | | | | | | | | | Reported by: Coverity CID: 1373338 MFC after: 20 days X-MFC-With: 316501 Sponsored by: Spectra Logic Corp Notes: svn path=/head/; revision=316523
* Fix file descriptor and memory leaks in pr(1)Alan Somers2017-04-048-46/+172
| | | | | | | | | | | | | | | Also, hook NetBSD's pr test into the build, and add three more test cases. Reported by: Coverity, Valgrind CID: 271650 271651 271652 271653 271654 271655 271656 271656 CID: 271657 271658 271659 1006939 1006940 1006941 1006942 1009098 Reviewed by: ngie MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9137 Notes: svn path=/head/; revision=316501
* strcpy => strlcpy, strcat => strlcatAlan Somers2017-04-044-7/+7
| | | | | | | | | | | | Reported by: Coverity CID: 1006703 978863 1006745 1347163 Reviewed by: cem MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D10192 Notes: svn path=/head/; revision=316500
* bsdgrep(1): Fix errors with invalid expressionsConrad Meyer2017-04-041-2/+2
| | | | | | | | | | | | | Invalid expressions with an ultimate compiled pattern length of 0 (e.g., "grep -E {") were not taken into account and caused a segfault while trying to fill in the good suffix table. Submitted by: Kyle Evans <kevans91 at ksu.edu> Reviewed by: me Differential Revision: https://reviews.freebsd.org/D10113 Notes: svn path=/head/; revision=316495
* bsdgrep(1): Rip out "xmalloc" bitsConrad Meyer2017-04-046-463/+31
| | | | | | | | | | | | | | | | xmalloc was a debug malloc implementation, but the x{malloc,calloc,free} functions default to calling the malloc(3) equivalents. Instead of relying on this malloc shim, we can devise better ways to debug malloc issues that aren't misleading upon initial inspection. (I.e., using jemalloc's various built-in debugging capabilities.) Submitted by: Kyle Evans <kevans91 at ksu.edu> Reviewed by: emaste, cem Differential Revision: https://reviews.freebsd.org/D10269 Notes: svn path=/head/; revision=316492
* bsdgrep: revert color changes from r316477Ed Maste2017-04-041-2/+2
| | | | | | | | | | | | | r316477 changed the color output to match exactly the in-tree GNU grep, but introduces unnecessary escape sequences. Submitted by: Kyle Evans <kevans91 at ksu.edu> Reported by: ache MFC after: 1 month MFC with: r316477 Notes: svn path=/head/; revision=316491
* bsdgrep: Initialize vars to avoid a false positive GCC warningEd Maste2017-04-041-0/+3
| | | | | | | | | Reported by: lwhsu MFC after: 1 month MFC with: r316477 Notes: svn path=/head/; revision=316489
* bsdgrep(1): create rgrep linkConrad Meyer2017-04-042-1/+7
| | | | | | | | | | | | | | Create a convenience rgrep link for bsdgrep(1) that observes 'grep -r' behavior. A follow-up to r316473. Submitted by: Kyle Evans <kevans91 at ksu.edu> Reviewed by: emaste (earlier version), cem Differential Revision: https://reviews.freebsd.org/D10109 Notes: svn path=/head/; revision=316484
* bsdgrep: fix matching behaviourEd Maste2017-04-031-17/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Set REG_NOTBOL if we've already matched beginning of line and we're examining later parts - For each pattern we examine, apply it to the remaining bits of the line rather than (potentially) smaller subsets - Check for REG_NOSUB after we've looked at all patterns initially matching the line - Keep track of the last match we made to later determine if we're simply not matching any longer or if we need to proceed another byte because we hit a zero-length match - Match the earliest and longest bit of each line before moving the beginning of what we match to further in the line, past the end of the longest match; this generally matches how gnugrep(1) seems to behave, and seems like pretty good behavior to me - Finally, bail out of printing any matches if we were set to print all (empty pattern) but -o (output matches) was set PR: 195763, 180990, 197555, 197531, 181263, 209116 Submitted by: "Kyle Evans" <kevans91@ksu.edu> Reviewed by: cem MFC after: 1 month Relnotes: Yes Differential Revision: https://reviews.freebsd.org/D10104 Notes: svn path=/head/; revision=316477
* bsdgrep: treat rgrep as grep -rEd Maste2017-04-031-0/+3
| | | | | | | Submitted by: Kyle Evans <kevans91@ksu.edu> Notes: svn path=/head/; revision=316473
* Revert debugging that was accidently committed in r316314Allan Jude2017-03-311-8/+1
| | | | Notes: svn path=/head/; revision=316315
* fix top(1) ZFS compressed ARC supportAllan Jude2017-03-312-4/+12
| | | | | | | | | | | top(1) read the wrong amount of data from sysctl, uint64_t instead of boolean_t, resulting in the stats not showing in many cases. X-MFC-With: r315435 Sponsored by: ScaleEngine Inc. Notes: svn path=/head/; revision=316314
* Add support for capturing 'struct ptrace_lwpinfo' for signalsTycho Nightingale2017-03-306-4/+129
| | | | | | | | | | | | resulting in a process dumping core in the corefile. Also extend procstat to view select members of 'struct ptrace_lwpinfo' from the contents of the note. Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316286
* Add some useful examples to the sed man page.Brad Davis2017-03-271-1/+31
| | | | | | | | | Reviewed by: wblock, bcr MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D9958 Notes: svn path=/head/; revision=316030
* diff: Show nanoseconds in -u/-c header line.Jilles Tjoelker2017-03-264-15/+23
| | | | | | | | | | | | | | | Show nanoseconds in the -u/-c header line. The present portability conditionals cannot handle the POSIX standard st_mtim, so remove them and unconditionally use st_mtim. PR: 218018 Reported by: jbeich Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10145 Notes: svn path=/head/; revision=316002
* Provide proper contemporary function prototypes for many of the functionsRobert Watson2017-03-261-1/+1
| | | | | | | | | | | | | | | | | implemented in top(1), rather than relying on K&R prototypes, which can cause problems on targets where there are multiple incompatible calling conventions and the compiler requires argument information to select the correct one. (There's a bit more to do here, since it looks like top(1) also sometimes provides prototypes for various curses functions rather than relying on the header file...) Sponsored by: DARPA, AFRL MFC after: 1 week Notes: svn path=/head/; revision=315990
* diff: Fix mtime of file1 in -u/-c header line.Jilles Tjoelker2017-03-264-4/+22
| | | | | | | | | PR: 218018 Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10140 Notes: svn path=/head/; revision=315985
* MFV r315875:Martin Matuska2017-03-241-0/+1
| | | | | | | | | | | | | | | Sync libarchive with vendor. Vendor changes (FreeBSD-related): - store extended attributes with extattr_set_link() if no fd is provided - add extended attribute tests to libarchive and bsdtar - fix tar's test_option_acls - support the UF_HIDDEN file flag X-MFC with: 315636 Notes: svn path=/head/; revision=315876
* diff(1): document remaining long optionsEnji Cooper2017-03-231-15/+85
| | | | | | | | | | While here, try and tie together some of the short options with their long option equivalents, where possible. Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315779
* Rename tests from <foo> to <foo>_test to match the FreeBSD test suiteEnji Cooper2017-03-2312-8/+9
| | | | | | | | | | | | | naming scheme usr.bin/diff/diff_test was renamed to usr.bin/diff/netbsd_diff_test to avoid collisions with the renamed FreeBSD test. MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315776
* Use MIN macros from sys/param.hBaptiste Daroussin2017-03-221-1/+1
| | | | Notes: svn path=/head/; revision=315747
* Use strndup(3) instead of malloc + memcpyBaptiste Daroussin2017-03-221-3/+2
| | | | Notes: svn path=/head/; revision=315746
* Use MAX and MIN macros from sys/param.hBaptiste Daroussin2017-03-221-12/+9
| | | | Notes: svn path=/head/; revision=315743
* diff(1): fix SYNOPSIS section noting non-existent option, --no-ignore-caseEnji Cooper2017-03-221-6/+6
| | | | | | | | | | `--no-ignore-case` should be `--no-ignore-file-name-case` per code for compatibility with [g]diff(1). Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315726
* Shut up gcc.Gleb Smirnoff2017-03-211-1/+1
| | | | Notes: svn path=/head/; revision=315671
* Hide struct inpcb, struct tcpcb from the userland.Gleb Smirnoff2017-03-215-214/+90
| | | | | | | | | | | | | | | | | | | | | | | This is a painful change, but it is needed. On the one hand, we avoid modifying them, and this slows down some ideas, on the other hand we still eventually modify them and tools like netstat(1) never work on next version of FreeBSD. We maintain a ton of spares in them, and we already got some ifdef hell at the end of tcpcb. Details: - Hide struct inpcb, struct tcpcb under _KERNEL || _WANT_FOO. - Make struct xinpcb, struct xtcpcb pure API structures, not including kernel structures inpcb and tcpcb inside. Export into these structures the fields from inpcb and tcpcb that are known to be used, and put there a ton of spare space. - Make kernel and userland utilities compilable after these changes. - Bump __FreeBSD_version. Reviewed by: rrs, gnn Differential Revision: D10018 Notes: svn path=/head/; revision=315662
* Cache tzdata when running under capsicumBaptiste Daroussin2017-03-201-0/+1
| | | | | | | | PR: 217957 Reported by: tobik@ Notes: svn path=/head/; revision=315649
* Port the getaddrinfo(1) utility from NetBSDEric van Gyzen2017-03-205-0/+597
| | | | | | | | | | | | | Submitted by: Lohith Bellad <lohithbsd@gmail.com> Reviewed by: hiren (earlier rev), ae Obtained from: NetBSD MFC after: 1 week Relnotes: yes Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D9365 Notes: svn path=/head/; revision=315640
* MFV r315633, 315635:Martin Matuska2017-03-203-0/+3
| | | | | | | | | | | | | | | | | | Sync libarchive with vendor Vendor changes/bugfixes (FreeBSD-related): PR 867 (bsdcpio): show numeric uid/gid when names are not found PR 870 (seekable zip): accept files with valid ZIP64 EOCD headers PR 880 (pax): Fix handling of "size" pax header keyword PR 887 (crypto): Discard 3072 bytes instead of 1024 of first keystream OSS-Fuzz issue 806 (mtree): rework mtree_atol10 integer parser Break ACL read/write code into platform-specific source files Unbreak static dependency on libbz2 MFC after: 1 week Notes: svn path=/head/; revision=315636
* diff(1): add --strip-trailing-cr to last example in the SYNOPSISEnji Cooper2017-03-191-1/+2
| | | | | | | | | | | This syncs the last example in the SYNOPSIS with the other examples. Reviewed by: bapt Sponsored by: Dell EMC Isilon Differential Revision: D10017 Notes: svn path=/head/; revision=315590
* Temporary readd GNU diffBaptiste Daroussin2017-03-191-1/+0
| | | | | | | | etcupdate requires --change-group-format it is not easy to implement in bsd diff so for now readd GNU diff Notes: svn path=/head/; revision=315565
* Improve decoding of last arguments to ioctl() and sendto().John Baldwin2017-03-191-2/+2
| | | | | | | | | | | Decode the last argument to ioctl() as a pointer rather than an int. Eventually this could use 'int' for the _IOWINT() case and pointers for all others. The last argument to sendto() is a socklen_t value, not a pointer. Notes: svn path=/head/; revision=315525
* Decode arguments to madvise().John Baldwin2017-03-192-1/+6
| | | | Notes: svn path=/head/; revision=315524
* Add a Sizet type for 'size_t' values and use it instead of Int.John Baldwin2017-03-192-11/+14
| | | | | | | | Various size_t arguments were previously decoded as Int values instead which would have truncated values above 2^31 on 64-bit systems. Notes: svn path=/head/; revision=315523
* Decode arguments passed to kldsym() and kldunloadf().John Baldwin2017-03-182-1/+13
| | | | | | | | This does not currently decode the kld_sym_lookup structure passed to kldsym(). Notes: svn path=/head/; revision=315509
* Decode arguments passed to getfsstat().John Baldwin2017-03-182-1/+7
| | | | | | | | Note that this does not yet decode the statfs structures returned by getfsstat(). Notes: svn path=/head/; revision=315504
* Decode flock() operation.John Baldwin2017-03-182-1/+6
| | | | Notes: svn path=/head/; revision=315502
* Decode file flags passed to *chflags*().John Baldwin2017-03-182-3/+17
| | | | | | | While here, decode arguments passed to fchflags() and chflagsat(). Notes: svn path=/head/; revision=315500
* Decode arguments passed to posix_fadvise().John Baldwin2017-03-182-1/+7
| | | | Notes: svn path=/head/; revision=315497
* Decode the arguments passed to cap_fcntls_get() and cap_fcntls_limit().John Baldwin2017-03-182-0/+31
| | | | Notes: svn path=/head/; revision=315496
* Add ZFS compressed ARC stats to top(1)Allan Jude2017-03-171-6/+33
| | | | | | | | | | | | | | | | | | | | | Provides: amount of compressed data logical size of compressed data (how much it would have taken uncompressed) compression ratio (logical size : total ARC size) Overhead (space consumed for compression headers) Example output: ARC: 31G Total, 18G MFU, 9067M MRU, 2236K Anon, 615M Header, 2947M Other 25G Compressed, 54G Uncompressed, 1.76:1 Ratio, 2265M Overhead Reviewed by: jpaetzel, smh, imp, jhb (previous version) MFC after: 2 week Relnotes: yes Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D9829 Notes: svn path=/head/; revision=315435
* Automate the handling of QUAD_ALIGN and QUAD_SLOTS.John Baldwin2017-03-151-28/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the offset in a system call description specified the array index of the start of a system call argument. For most system call arguments this was the same as the index of the argument in the function signature. 64-bit arguments (off_t and id_t values) passed on 32-bit platforms use two slots in the array however. This was handled by adding (QUAD_SLOTS - 1) to the slot indicies of any subsequent arguments after a 64-bit argument (though written as ("{ Quad, 1 }, { Int, 1 + QUAD_SLOTS }" rather than "{ Quad, 1 }, { Int, 2 + QUAD_SLOTS - 1 }"). If a system call contained multiple 64-bit arguments (such as posix_fadvise()), then additional arguments would need to use 'QUAD_SLOTS * 2' but remember to subtract 2 from the initial number, etc. In addition, 32-bit powerpc requires 64-bit arguments to be 64-bit aligned, so if the effective index in the array of a 64-bit argument is odd, it needs QUAD_ALIGN added to the current and any subsequent slots. However, if the effective index in the array of a 64-bit argument was even, QUAD_ALIGN was omitted. This approach was messy and error prone. This commit replaces it with automated pre-processing of the system call table to do fixups for 64-bit argument offsets. The offset in a system call description now indicates the index of an argument in the associated function call's signature. A fixup function is run against each decoded system call description during startup on 32-bit platforms. The fixup function maintains an 'offset' value which holds an offset to be added to each remaining system call argument's index. Initially offset is 0. When a 64-bit system call argument is encountered, the offset is first aligned to a 64-bit boundary (only on powerpc) and then incremented to account for the second argument slot used by the argument. This modified 'offset' is then applied to any remaining arguments. This approach does require a few things that were not previously required: 1) Each system call description must now list arguments in ascending order (existing ones all do) without using duplicate slots in the register array. A new assert() should catch any future descriptions which violate this rule. 2) A system call description is still permitted to omit arguments (though none currently do), but if the call accepts 64-bit arguments those cannot be omitted or incorrect results will be displated on 32-bit systems. Tested on: amd64 and i386 Notes: svn path=/head/; revision=315336
* Remove duplicate argument from linux_stat64() decoding.John Baldwin2017-03-151-2/+2
| | | | Notes: svn path=/head/; revision=315335
* Decode arguments to chflagsat().John Baldwin2017-03-151-0/+2
| | | | Notes: svn path=/head/; revision=315334
* diff(1): sort long options under -D example in SYNOPSYSEnji Cooper2017-03-151-2/+2
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315319
* Do not die on system built without CAPSICUMBaptiste Daroussin2017-03-151-1/+2
| | | | Notes: svn path=/head/; revision=315309
* Integrate contrib/netbsd-tests/usr.bin/diff/t_diff.sh in asEnji Cooper2017-03-151-0/+10
| | | | | | | | | | | | | | .../usr.bin/diff/diff_test Some minor adjustment needed to be done for :same as it currently has the test script hardcoded into the test, instead of using an idiom like $(dirname $0) MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315293
* mkimg(1): let calloc(3) do the multiplication.Pedro F. Giffuni2017-03-131-3/+3
| | | | | | | | Reviewed by: marcel MFC after: 1 week Notes: svn path=/head/; revision=315212
* Do not die if cap_rights_limit reports ENOSYSBaptiste Daroussin2017-03-131-2/+4
| | | | | | | Reported by: mmel Notes: svn path=/head/; revision=315197
* Readd codes that creates a tmp file for diffing stdout or devicesBaptiste Daroussin2017-03-121-2/+48
| | | | Notes: svn path=/head/; revision=315180