summaryrefslogtreecommitdiffstats
path: root/bin/ls/ls.c
Commit message (Collapse)AuthorAgeFilesLines
* Get rid of major/minor number distinction.ed2011-09-281-25/+16
| | | | | | | | | | | | | | | | | | | | | | As of FreeBSD 6, devices can only be opened through devfs. These device nodes don't have major and minor numbers anymore. The st_rdev field in struct stat is simply based a copy of st_ino. Simply display device numbers as hexadecimal, using "%#jx". This is allowed by POSIX, since it explicitly states things like the following (example taken from ls(1)): "If the file is a character special or block special file, the size of the file may be replaced with implementation-defined information associated with the device in question." This makes the output of these commands more compact. For example, ls(1) now uses approximately four columns less. While there, simplify the column length calculation from ls(1) by calling snprintf() with a NULL buffer. Don't be afraid; if needed one can still obtain individual major/minor numbers using stat(1).
* Make sure that FTS_COMFOLLOW is not set when the -P option is in effect.jh2010-02-081-2/+6
| | | | | | | | | | Otherwise the -i option will show the inode number of the referenced file for symbolic links given on the command line. Similarly, the file color was printed according to the link target in colorized output. PR: bin/102394 Reviewed by: jilles MFC after: 2 weeks
* Fixes for ls(1) long format (-l) output:jh2010-01-241-8/+20
| | | | | | | | | | - Allow -h option to work if the listing contains at least one device file. - Align major and minor device numbers correctly to the size field. PR: bin/125678 Approved by: trasz (mentor) MFC after: 1 month
* Print full path in the error message. It's possible that fts(3)jh2010-01-241-1/+1
| | | | | | | | | | provides an empty fts_name and reporting the full path is more appropriate especially with the -R option. PR: bin/107515 Submitted by: bde Approved by: trasz (mentor) MFC after: 1 week
* ls: Make -p not inhibit following symlinks.jilles2009-10-131-1/+1
| | | | | | | | | According to the man page, when neither -H/-L nor -F/-d/-l are given, -H is implied. This agrees with POSIX, GNU ls and Solaris ls. This means that -p, although it is very similar to -F, does not prevent the implicit following of symlinks. PR: standards/128546
* Add -D option to specify exact format of date and time output with ls -l.grog2008-04-041-2/+6
|
* Change the -S and -t options to override each other so that the last onejhb2006-03-241-0/+3
| | | | specified wins to make their interaction less confusing.
* Fix a bug such that if you enabled sorting by size (-S) and enabled ajhb2006-03-241-4/+4
| | | | | | | | | flag to use a time other than modtime (-c, -u, or -U), the output would actually be sorted by the specified time rather than size. This does alter the behavior in the case where both -S and -t are specified. Now, -S is always preferred. Previously, -t was preferred if one of -c, -u, or -U was specified, and -S was preferred otherwise. Perhaps -S and -t should override each other (last one specified wins).
* Add a new -U flag to instruct ls to use the birthtime for printing orjhb2006-03-241-2/+14
| | | | | | | sorting. Submitted by: Andrzej Tobola ato at iem dot pw dot edu dot pl MFC after: 1 week
* Having three options (-a, -A, -I) controlling the output of dottedru2005-11-161-11/+7
| | | | | | | | | | | files is too much and hard to follow. Instead, make the -I option just mean "do not automatically set -A for root". That is, if -A is explicitly set, -I is ignored. Also, document -I in usage(). (The ls.c diff is better viewed relative to rev. 1.80.) No objection: mux Silence from: mnag MFC after: 3 days
* Add a -I option to disable the automatic -A flag for the super-user.mux2005-11-101-8/+16
| | | | | | PR: bin/86710 Submitted by: Marcus Alves Grando MFC after: 3 days
* Add the -S option to sort files by size. NetBSD and OpenBSD alreadydd2005-06-031-6/+15
| | | | | | | | have this option with identical semantics (sorting large files first). -r can be used to reverse the sort if that is desired. PR: 81625 Submitted by: Kostas Blekos <mplekos@physics.upatras.gr>, keramida
* /*- or .\"- or #- to begin license clauses.imp2005-01-101-1/+1
|
* If we are asked to print the total number of blocks, do so even if wedas2004-06-081-12/+14
| | | | | | | | | | | | | have no entries to print (either due to an empty directory or an error). This makes the -l and -s options more consistent, like Solaris and (Debian) Linux. To make this happen, tweak two optimizations on the second call to display(): - Don't skip display() altogether, even if list == NULL. - Don't skip the call to the printfn in display() if we need to print the total. PR: 45723
* Plug small memory leak.le2004-06-031-0/+1
| | | | | | PR: bin/67392 Submitted by: Matthew Emmerton <matt@gsicomp.on.ca> MFC in: 1 week
* Remove clause 3 from the UCB licenses.markm2004-04-061-4/+0
| | | | OK'ed by: imp, core
* Do something sensible if both -h and -k are given.obrien2003-12-011-0/+1
| | | | Approved by: re(scottl)
* Fix a bazillion warnings. This makes almost the whole of src/bin/*markm2003-05-031-34/+32
| | | | | | WARNS=6, std=c99 clean. Tested on: i386, alpha
* When mac_from_text() fails with -Z, print "-" rather than "" so thatrwatson2003-04-261-1/+1
| | | | | | | scripts parsing ls(1) output can still count columns. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Improve handling of symlink targets when listing MAC labels: don'trwatson2002-12-181-6/+13
| | | | | | | | do the wrong thing when the symlink doesn't have a target, by considering !f_label in the construction of ch_options. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Use warn() instead of perror() or fprintf() where appropriate.tjr2002-11-061-8/+4
|
* Do not include <sys/syslimits.h> directly; it is not intended for generalwollman2002-10-271-1/+0
| | | | consumption.
* Attempt improved use of fts results: use the correct path to therwatson2002-10-241-4/+14
| | | | | | | | | | object to retrieve label information on, rather than directly consuming the fts-provided paths (none of which are quite right). This is based on the similar readlink() code, and may contain the same bugs. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Teach "ls -Z" to use the policy-agnostic MAC label interfaces ratherrwatson2002-10-241-29/+61
| | | | | | | | | | | than the LOMAC-specific interfaces for listing MAC labels. This permits ls to view MAC labels in a manner similar to getfmac, when ls is used with the -l argument. Next generation LOMAC will use the MAC Framework so should "just" work with this and other policies. Not the prettiest code in the world, but then, neither is ls(1). Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Print non-printing characters in directory names, as well as file names,tjr2002-10-181-4/+7
| | | | | | | as `?' or `\ooo', depending on whether the -b or -B flags were used. PR: 43995 MFC after: 1 month
* Make the threatened fts(3) ABI fix. FTSENT now avoids the use of the structwollman2002-09-211-2/+2
| | | | | | | | | | | | | | | | hack, thereby allowing future extensions to the structure (e.g., for extended attributes) without rebreaking the ABI. FTSENT now contains a pointer to the parent stream, which fts_compar() can then take advantage of, avoiding the undefined behavior previously warned about. As a consequence of this change, the prototype of the comparison function passed to fts_open() has changed to reflect the required amount of constness for its use. All callers in the tree are updated to use the correct prototype. Comparison functions can now make use of the new parent pointer to access the new stream-specific private data pointer, which is intended to assist creation of reentrant library routines which use fts(3) internally. Not objected to in spirit by: -arch
* Replace various spellings with FALLTHROUGH which is lint()ablecharnier2002-08-251-10/+10
|
* Fix typos; each file has at least one s/seperat/separat/schweikh2002-08-111-1/+1
| | | | | | | | | | (I skipped those in contrib/, gnu/ and crypto/) While I was at it, fixed a lot more found by ispell that I could identify with certainty to be errors. All of these were in comments or text, not in actual code. Suggested by: bde MFC after: 3 days
* err() is documented as allowing NULL for the format string but GCC isn'tdillon2002-07-101-4/+4
| | | | happy about it any more so change the usage to make buildworld work again.
* Consistently use __FBSDIDobrien2002-06-301-4/+2
|
* Ignore empty COLUMNS environment variable. COLUMNS should take precedencetjr2002-06-041-5/+5
| | | | over TTY width found via ioctl() (SUSv3)
* Add missing options required by SUSv3:tjr2002-05-191-4/+27
| | | | | | | | -m List files across the page, separated by commas. -p Print a slash after directory names -x Same as -C but sort across the columns rather than down Submitted by: Kyle Martin <mkm@ieee.org>
* restore missing default case removed in ls.c:r1.57billf2002-05-151-0/+3
| | | | | | add break statements to default cases where missing. Submitted by: bde
* Make 'user' and 'group' const as to not discard the qualifier from thejmallett2002-05-151-1/+2
| | | | | functions we use to assign them. Doesn't seem to be anything else that relies on these being non-const.
* Remove an empty default case to make this syntactically correct. Not therejmallett2002-05-151-1/+0
| | | | is as good as blaknk.
* Fixed divots that I created when I moved prototypes of group_from_gidimp2002-02-191-0/+2
| | | | | | | and user_from_uid to grp.h and pwd.h. Update the man pages. Submitted by: David Malone Pointy hat to: imp
* Use __FBSDID() and clean up the vendor tags.markm2002-02-031-5/+6
|
* WARNS=4 fixes, plus a healthy dose of fixes inspired by lint.markm2002-02-031-41/+56
|
* Fix unused variable.imp2002-02-021-0/+1
|
* o __P has been reovedimp2002-02-021-18/+11
| | | | | | | | | o Old-style K&R declarations have been converted to new C89 style o register has been removed o prototype for main() has been removed (gcc3 makes it an error) o int main(int argc, char *argv[]) is the preferred main definition. o Attempt to not break style(9) conformance for declarations more than they already are.
* Force raw printing of non-printable characters via the -w option.joe2001-12-291-1/+6
| | | | PR: bin/28007
* Restore these files to shiny KNF.joe2001-12-291-39/+45
|
* Add a new flag, -h which when combined with the -l option causesjoe2001-12-281-1/+5
| | | | | | | | file sizes to be displayed with unit suffixes; Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the number of digits to three or less. Submitted by: nik
* Mop up some warnings.joe2001-12-281-1/+1
|
* Revamp the colour support to allow for bold characters. Coloursjoe2001-12-281-0/+4
| | | | | | | | are now defined using the characters a-h and A-H for the bold variants. The old way using 0-7 for the colours still works, but prints a message asking the user to switch. PR: bin/27374
* Add LOMAC options (the "Z" flag in both cases) to display extra informationgreen2001-11-261-9/+33
| | | | | | in ls(1) and ps(1). Sponsored by: DARPA, NAI Labs
* Un-deprecate the -G flag at obrien's request. Colour sequences are stilljoe2000-08-131-6/+5
| | | | | dependent upon the output being directed to a terminal however. (Use the CLICOLOR_FORCE variable to force output).
* Correct spelling: depricated -> deprecated.joe2000-08-121-1/+1
|
* A change to the way that colours are switched on in ls. The -Gjoe2000-08-121-15/+20
| | | | | | | | | | | | | | flag has been depricated, although it still works with a warning message, and replaced with an environment variable CLICOLOR (command line interface colour). This could be used by other tools that want to be able to control colour output. In addition if the environment variable CLICOLOR_FORCE is defined colour sequences are output irrespective of whether the output is directed to a terminal (as long as TERM references a colour capable terminal of course ;) PR: bin/20291 and bin/20483
* make sure we do not write out non-printable characters in file namesassar2000-07-041-2/+0
| | | | | | | and symbolic links (by default) PR: bin/19354 Reviewed by: silence on -current
OpenPOWER on IntegriCloud