summaryrefslogtreecommitdiff
path: root/src/ls.c
AgeCommit message (Collapse)Author
2007-07-23Update all copyright notices to use the newer form.Jim Meyering
2007-07-15ls --color: Don't stat symlinks when neither ORPHAN nor MISSING attribute ↵Jim Meyering
has a color. * src/ls.c (main): Don't set check_symlink_color when C_EXEC is colored, unless ln=target (aka color_symlink_as_referent) is set. (gobble_file): Set f->linkok = true also when !check_symlink_color. http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/10608/focus=10927 Reported by Jeremy Maitin-Shepard. * tests/strace: New file, contents extracted from... * tests/mv/atomic: ...here. Source strace. * tests/ls/stat-free-symlinks: New file. Test for the above. Use strace to ensure that in this corner case, ls does not call stat. * tests/ls/Makefile.am (TESTS): Add stat-free-symlinks. * tests/Makefile.am (EXTRA_DIST): Add strace.
2007-07-14Remove long-deprecated options.Jim Meyering
* NEWS: Mention this. * src/df.c, src/ls.c: Remove --kilobytes option. * src/du.c: Remove --kilobytes and --megabytes options. * src/who.c: Remove -i and --idle options. * src/ptx.c: Remove --copyright option. Signed-off-by: Jim Meyering <jim@meyering.net>
2007-07-10Change "version 2" to "version 3" in all copyright notices.Jim Meyering
2007-07-08Use <wchar.h>, not "wcwidth.h".Jim Meyering
* src/wc.c: Now that gnulib provides the POSIX-specified <wchar.h>, include it and <wctype.h>, rather than "wcwidth.h". * src/ls.c: Include <wchar.h>, rather than "wcwidth.h".
2007-06-18Use mreadlink_with_size (doesn't exit), not xreadlink_with_size.Jim Meyering
* bootstrap.conf (gnulib_modules): Add readlink-with-size. Remove xreadlink and xreadlink-with-size. * src/copy.c (copy_internal): Use mreadlink_with_size, not xreadlink_with_size. * src/ls.c (get_link_name): Likewise. * src/readlink.c (main): Likewise. * src/stat.c (print_stat): Likewise.
2007-04-24ls --color once again colors dangling symlinks correctlyEric Blake
* src/ls.c (gobble_file): Much like the 2007-04-07 fix, add a term to the expression that decides whether we need stat and/or lstat calls. Reported by Andreas Frische.
2007-04-10ls: don't form or compute the length of strings that won't be used.Jim Meyering
* src/ls.c (gobble_file): Form and compute length of strings for block size, owner, group, author, major+minor numbers and file size only if they'll actually be used. I.e., don't form most of them when not producing long format output.
2007-04-07Fix a bug in how the LS_COLORS ln=target attribute is handled.Eric Blake
* src/ls.c (gobble_file): Use "stat" (not lstat) also when the ln=target attribute applies. Reported by Kirk Kelsey.
2007-04-02* src/ls.c (print_horizontal): Fix bug reported by Mike Frysinger:Paul Eggert
ls -x DIR would sometimes output the wrong string in place of the first entry. * NEWS: Mention the bug fix. * tests/ls/x-option: New file. * tests/ls/Makefile.am (TESTS): Add x-option.
2007-03-29* src/ls.c (gobble_file): Don't call getfilecon unless print_scontext.Jim Meyering
Upon failed getfilecon, accept not just ENOTSUP, but also ENODATA.
2007-03-29ls: Add support for SELinux and a slightly modified -Z option.Jim Meyering
I started with the patches from Red Hat. The entries below tell how the code evolved. * src/ls.c (print_long_format, print_file_name_and_frills): When there is no security context (due to getfilecon/lgetfilecon failing with e.g. ENOTSUP), print it as "?", not "". * src/ls.c (print_file_name_and_frills): Make -Z work without -l. (length_of_file_name_and_frills): Likewise. * src/ls.c: Remove the --lcontext and --scontext options. Change the way -Z, --context work so that it no longer implies -l. Thus, -Z -l will work like -lcontext and -Z without -l will work like --scontext. Adjust tests to reflect new 'ls -l' syntax -- affects only systems with SELinux when operating on a file with no ACL. These tests assumed that everything before the first space on each line is the 10-byte mode string. But there may also be a "+" in the 11th column, just before the space. However, note that this is not new. The same thing would have happened even without the change below, when listing a file with an ACL. * tests/chmod/equals, tests/cp/cp-parents, tests/cp/fail-perm: * tests/cp/link-preserve, tests/install/basic-1, tests/misc/mknod: * tests/mkdir/parents, tests/mkdir/special-1, tests/mv/partition-perm: Don't make compilation depend on USE_ACL. An SELinux security context counts as an "alternate access control method", so ls must output a "+" for each file with a security context. * src/ls.c [struct fileinfo] (have_acl): Declare unconditionally. (FILE_HAS_ACL): Remove macro definition. Use f->have_acl directly. (gobble_file): Record whether a file has a security context, and update the condition used to determine whether to print the "+". (gobble_file): Call getfilecon/lgetfilecon also when format == long_format, so that we get the "+". * src/ls.c (gobble_file): Add a comment explaining why (with a security context option) ls doesn't exit nonzero due to e.g., getfilecon failing with errno == ENOTSUP. * src/ls.c (gobble_file): Ignore failure of getfilecon if it's due to ENOTSUP. * src/ls.c (gobble_file): Factor out three small blocks using getfilecon and lgetfilecon. Don't ignore return value from getfilecon and lgetfilecon. * src/ls.c (print_long_format): Don't use ?: (empty 2nd arg with C ternary operator). (print_scontext_format): Likewise. (print_scontext): Declare to be "bool", not int. Adjust uses. * src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): Add $(LIB_SELINUX). * tests/misc/chcon: New file. * tests/misc/chcon-fail: New file. * tests/Makefile.am (check-root): Run new, root-only misc/chcon test. * tests/misc/Makefile.am (TESTS): Add chcon and chcon-fail. * tests/misc/Makefile.am (TESTS): Add selinux. * tests/misc/selinux: New file. * tests/help-version: Skip chcon.
2007-03-28Help translators include translation team's web or email address.Jim Meyering
* src/system.h (emit_bug_reporting_address): New function. * src/base64.c: Use it rather than a literal printf. * src/basename.c, src/cat.c, src/chgrp.c, src/chmod.c: * src/chown.c, src/chroot.c, src/cksum.c, src/comm.c, src/cp.c: * src/csplit.c, src/cut.c, src/date.c, src/dd.c, src/df.c: * src/dircolors.c, src/dirname.c, src/du.c, src/echo.c, src/env.c: * src/expand.c, src/expr.c, src/factor.c, src/fmt.c, src/fold.c: * src/head.c, src/hostid.c, src/hostname.c, src/id.c, src/install.c: * src/join.c, src/kill.c, src/link.c, src/ln.c, src/logname.c: * src/ls.c, src/md5sum.c, src/mkdir.c, src/mkfifo.c, src/mknod.c: * src/mv.c, src/nice.c, src/nl.c, src/nohup.c, src/od.c: * src/paste.c, src/pathchk.c, src/pinky.c, src/pr.c, src/printenv.c: * src/printf.c, src/ptx.c, src/pwd.c, src/readlink.c, src/rm.c: * src/rmdir.c, src/seq.c, src/setuidgid.c, src/shred.c, src/shuf.c: * src/sleep.c, src/sort.c, src/split.c, src/stat.c, src/stty.c: * src/su.c, src/sum.c, src/sync.c, src/system.h, src/tac.c: * src/tail.c, src/tee.c, src/test.c, src/touch.c, src/tr.c: * src/true.c, src/tsort.c, src/tty.c, src/uname.c, src/unexpand.c: * src/uniq.c, src/unlink.c, src/uptime.c, src/users.c, src/wc.c: * src/who.c, src/whoami.c, src/yes.c: Likewise.
2007-03-01* bootstrap.conf (gnulib_modules): Replace xreadlink withBruno Haible
xreadlink-with-size. Add xreadlink. * src/copy.c (copy_internal): Update. * src/ls.c (is_directory): Update. * src/stat.c (print_stat): Update. * src/readlink.c (main): Use the one-argument xreadlink function.
2007-02-10* src/csplit.c (usage): Use two spaces (not one) to separateJim Meyering
each option string from its description, so help2man formats the derived man page properly. Reported by Thomas Huriaux in <http://bugs.debian.org/410407>. * src/df.c (usage): Likewise. * src/du.c (usage): Likewise. * src/install.c (usage): Likewise. * src/ls.c (usage): Likewise.
2007-01-29Plug a leak in ls.Jim Meyering
* src/ls.c (print_dir): Don't leak a "DIR"+fd upon failure to determine dev/inode or upon detecting a symlink loop.
2007-01-29* src/ls.c: Rename three global variables.Jim Meyering
(cwd_file): Rename from 'files'. (cwd_n_alloc): Rename from 'nfiles'. (cwd_n_used): Rename from 'files_index'.
2007-01-29Shave 8 bytes off the size of "struct fileinfo".Jim Meyering
* src/ls.c (fileinfo): Put all members of type "bool" together.
2007-01-29Modify "ls" to sort its data faster, using the new gnulib mpsortPaul Eggert
module rather than qsort. This is particularly a win in environments where strcoll is slow, since mpsort typically calls strcoll less often than qsort does. * bootstrap.conf (gnulib_modules): Add mpsort. * src/ls.c: Include mpsort.h. (sorted_file, sorted_file_alloc): New vars, for a new vector of pointers to the file info, for speed. (clear_files, extract_dirs_from_files, sort_files, print_current_files): (print_many_per_line, print_horizontal, print_with_commas): (calculate_columns): Set and use new vector. (initialize_ordering_vector): New function.
2007-01-20Standardize on list of signals when an app catches signals.Paul Eggert
* src/csplit.c (main): Also catch SIGALRM, SIGPIPE, SIGPOLL, SIGPROF, SIGVTALRM, SIGXCPU, SIGXFSZ. * src/ls.c (main): Likewise (except SIGPIPE was already caught). Note that ls.c is special, as it also catches SIGTSTP. * src/sort.c (main): Likewise. Also catch SIGQUIT. More details in <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9510>.
2007-01-02Now, "ls -FRL" always follows symbolic links on Linux.Paul Eggert
* NEWS: Mention this bug fix. * src/ls.c (gobble_file): Fix bug reported by Nobuyuki Tsuchimura in http://lists.gnu.org/archive/html/bug-coreutils/2006-12/msg00152.html where "ls -FRL" didn't follow a symbolic link in some cases on Linux. * tests/ls/follow-slink: Add a test for this case. Signed-off-by: Jim Meyering <jim@meyering.net>
2006-11-27Improve the check for departures from C89, and fix the departuresPaul Eggert
I found. * Makefile.maint (my-distcheck): Also check for C89 compatibility as best we can with GCC. * src/stat.c (PRINTF_OPTION): Omit comma before } in enum declaration; C89 doesn't allow this. * src/dcgen: Don't generate string literals longer than what C89 requires support for. * src/cut.c (usage): Don't use string literals longer than what C89 requires support for. * src/date.c (usage): Likewise. * src/dd.c (usage): Likewise. * src/du.c (usage): Likewise. * src/ls.c (usage): Likewise. * src/od.c (usage): Likewise. * src/readlink.c (usage): Likewise. * src/seq.c (usage): Likewise. * src/shred.c (usage): Likewise.
2006-11-16* bootstrap.conf (gnulib_modules): Add sys_stat, since we use it directly too.Paul Eggert
* lib/.cvsignore, lib/.gitignore: Add root-dev-ino.c, root-dev-ino.h. * m4/.cvsignore, m4/.gitignore: Add root-dev-ino.m4. * src/ls.c (DIRED_FPUTS_LITERAL, PUSH_CURRENT_DIRED_POS): Omit unnecessary parenthesization of args. * src/od.c (EQUAL_BLOCKS): Likewise. * src/system.h (STREQ, ASSIGN_STRDUPA): Likewise.
2006-10-11* src/ls.c (usage): Correct description of -s, --size.Jim Meyering
It works even without -l. Suggestion from Karl Berry.
2006-10-10* src/ls.c (quote_name): Use initializer rather than memset toPaul Eggert
initialize an object to zero. This is easier to read and is less likely to introduce an runtime error due to a mixup. It causes gcc -W to issue a warning, but you can work around this by appending -Wno-missing-field-initializers. * src/pathchk.c (portable_chars_only): Likewise. * src/shred.c (main): Likewise. * src/stty.c (main): Likewise. * src/tr.c (card_of_complement): Likewise. * src/wc.c (wc): Likewise.
2006-09-03Don't include dirname.h, since system.h does it now.Paul Eggert
2006-08-28* src/copy.c (copy_internal): Don't test whether macros likePaul Eggert
S_ISLNK are defined, since they're always defined now. * src/cp.c (main): Likewise. * src/ln.c (main): Likewise. * src/ls.c (get_link_name, make_link_name): Likewise. * src/mkfifo.c (usage): Likewise. * src/who.c (S_IWGRP): Likewise.
2006-08-27* src/system.h (DOT_OR_DOTDOT): Remove macro. Rewrite as a...Jim Meyering
(dot_or_dotdot): ...new static inline function. * src/remove.c (rm_1): Reflect this renaming. * src/ls.c (basename_is_dot_or_dotdot): Likewise.
2006-08-26"ls --color" would highlight other-writable and sticky directoriesJim Meyering
no differently than regular directories on a file system with dirent.d_type support. * NEWS: Say the above. * src/ls.c (gobble_file): With --color, also stat the file when we know it is a directory. Derived from an anonymous one-line fix and bug report: <https://savannah.gnu.org/bugs/?15043>. * tests/ls/color-dtype-dir: New file. Test for the above fix. * tests/ls/Makefile.am (TESTS): Add color-dtype-dir.
2006-08-23(SA_RESTART): Fallback define.Paul Eggert
2006-08-21Add a bootstrap procedure, so that the CVS version contains fewerPaul Eggert
files and we bootstrap the rest from gnulib, gettext, etc. * README-cvs: New file. * bootstrap: New file. * bootstrap.conf: New file. * .x-sc_trailing_blank: Remove config-log, .gdb-history. Add .po. * configure.ac (AC_PREREQ): Move here from m4/*.m4, for benefit of gnulib-tool. (gl_DEFAULT_POSIX2_VERSION, gl_USE_SYSTEM_EXTENSIONS, gl_PERL): (gl_IGNORE_UNUSED_LIBRARIES): Remove; now done by gnulib. (gl_EARLY): Add. (gl_MACROS): Call just after gl_EARLY, just for clarity. * src/c99-to-c98.diff: Remove patch to ls.c; no longer needed. * src/kill.c (strtoimax): Remove decl. * src/ls.c: Include "wcwidth.h" instead of rolling it ourselves. * src/wc.c: Likewise. * src/ls.c (sort_files): Rewrite to avoid need for C99-style declaration, so that we don't need to patch this file. * src/printf.c (strtoimax, strtoumax): Remove decls. * src/su.c: Include getpass.h. (getpass): remove. * src/system.h: Include mempcpy.h, stpcpy.h, strpbrk.h. Include inttypes.h unconditionally; remove decls it handles. * lib/Makefile.am: include gnulib.mk, so that we can remove most of this file. (AM_CPPFLAGS): Don't mention -I$(srcdir), since that's now done for us. (noinst_LIBRARIES, LDDADD, DEFS): Remove. (libcoreutils_a_SOURCES): Trim down greatly, just to the files that aren't in gnulib. Remove defns gnulib does for us. * m4/check-decl.m4 (gl_CHECK_DECLS): Don't include stdio.h, string.h, stdlib.h, unistd.h, sys/time.h, time.h. Use AC_CHECK_DECLS_ONCE for free, getenv, geteuid, getlogin, getuid, lseek, malloc, memchr, realloc. Don't check for getutent, memrchr, nanosleep, stpcpy, strndup, strnlen, strstr, strtoul, strtoull. (_gl_DECL_HEADERS): Remove; all uses removed. * m4/jm-macros.m4 (gl_MACROS): Move AC_PREREQ into configure.ac for the benefit of gnulib-tool. Call gl_INIT. Do not call or require macros that gnulib will handle for us. Don't check for fchmod, hasmntopt, isascii, lchown, listmntent, mempcpy, realpath, wcrtomb, tzset. (gl_CHECK_ALL_HEADERS): Don't check for sys/statvfs.h, sys/vfs.h, sys/mount.h. (gl_CHECK_ALL_TYPES): Require AC_TYPE_UNSIGNED_LONG_LONG_INT. Don't check for struct stat.st_blksize. Don't require AC_STRUCT_ST_DM_MODE, gt_TYPE_SSIZE_T, gl_AC_TYPE_UINT32_T, gl_AC_TYPE_UINTMAX_T, gl_AC_TYPE_UINTPTR_T, gl_AC_TYPE_UNSIGNED_LONG_LONG. * m4/prereq.m4 (gl_PREREQ): Require gl_FUNC_XFTS, gl_ROOT_DEV_INO. Don't require macros that gnulib does for us. * m4/stat-prog.m4 (cu_PREREQ_STAT_PROG): Don't check for sys/sysmacros.h. Don't check for statvfs. Use AC_CHECK_HEADERS_ONCE for netinet/in.h, nfs/nfs_clnt.h, nfs/vfs.h. Don't require gl_AC_TYPE_LONG_LONG, gt_HEADER_INTTYPES_H.
2006-08-17ls -CF would misalign columns in some cases.Jim Meyering
* src/ls.c (get_type_indicator): New function. extracted from... (print_type_indicator): ...here. Use it. (length_of_file_name_and_frills): Use it here, too, rather than assuming stat.st_mode is valid. Reported by Andreas Schwab, here: <http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/7774> FIXME: add a test for this: FYI, I did ls -CF /proc and visually inspected the result.
2006-08-09Add a compile-time check to ensure that filetypeJim Meyering
and filetype_letter have the same number of elements.
2006-07-26* src/ls.c (print_color_indicator): Test for S_IFREG first, ratherJim Meyering
than having the code test for all of the other types first. Hoist the set-uid/gid-testing code "up" into this new block. Classify any other type of file (e.g., S_TYPEISSHM, etc.) as C_ORPHAN, not as C_FILE. * doc/coreutils.texi (What information is listed): Mention that missing pieces of information are marked with "?". From Paul Eggert.
2006-07-26Checking in a change from Paul.Jim Meyering
2006-07-25 Paul Eggert <eggert@cs.ucla.edu> * src/ls.c (DT_INIT): Remove. All uses removed. (enum filetype): Use an ordinary enum rather than trying to keep the values in sync with DT_FIFO etc. That way, we don't have to make special assumptions about them. All uses changed. (whiteout): New constant member of enum filetype. (filetype_letter): New constant, for use with enum filetype. (FILETYPE_INDICATORS): New initializer list. (print_dir): Add case for DT_WHT. (gobble_file): If stat fails, don't discard information from readdir; instead, preserve it so it can be printed. (print_long_format): Fall back on readdir result if stat info is not available. Use "?" to denote each unknown mode char, instead of an overall "?", since we now know some of the mode typically. (print_type_indicator): Now that MODE isn't necessarily useful, guard all uses. Now that two blocks in the type-checking tree can set "type = C_FILE", move the suffix-handling code out and down.
2006-07-26Prepare for the above change.Jim Meyering
* src/ls.c [struct fileinfo] (stat_ok): Rename from stat_failed, and adjust uses. From a patch by Paul Eggert.
2006-07-26* src/ls.c: Correct indentation/formatting in a few places.Jim Meyering
2006-07-25* src/ls.c (gobble_file): When handling a stat-failed entry,Jim Meyering
print the entry name not the absolute_name -- to be consistent with the usual case. * tests/ls/stat-failed: Update accordingly.
2006-07-25* src/dircolors.hin: Mention that ORPHAN refers not just to dangling symlinks.Jim Meyering
2006-07-25Get --dired offsets right when handling stat-failed entries.Jim Meyering
* src/ls.c (print_long_format): Be careful to increment P by the appropriate amount, even when inode_number_width and nlink_width are zero. * tests/ls/stat-failed: Test for the above.
2006-07-25* src/ls.c (gobble_file) [USE_ACL]: Don't use-uninitialized theJim Meyering
have_acl member. That would happen for a directory with both a non-stat'able entry and one with an ACL.
2006-07-25* src/ls.c (gobble_file): Make it so failure to stat aJim Meyering
non-command-line file provokes an exit status of 1, not 0. Say "cannot access" rather than "cannot stat". * tests/ls/stat-failed: New file/test, for the above. * tests/ls/Makefile.am (TESTS): Add stat-failed.
2006-07-25* src/ls.c: Declare stat_failed to be "bool", not "int" everywhere.Jim Meyering
2006-07-25* src/ls.c [enum filetype] (command_line): Remove member. Not needed.Jim Meyering
Replace all occurrences of "type == command_line" with the equivalent, "command_line_arg".
2006-07-25* src/ls.c: Apply the stat-failed parts of Red Hat'sJim Meyering
coreutils-selinux.patch. From Ulrich Drepper. This makes it so files not mentioned on the command line (e.g., names read from a directory that *is* mentioned on the command line) for which stat fails are still listed. With --color, such files are colored just like ORPHANs (aka dangling symlinks).
2006-07-21(FILE_TYPE_INDICATOR_OPTION): Reposition this new name so the list remains ↵Jim Meyering
alphabetized.
2006-07-21Fix another bug: ls --indicator-style=file-type would callJim Meyering
stat for a symlink, even though it wasn't always needed. In some cases, that unnecessary stat would cause ls to fail. * src/ls.c (gobble_file): Don't treat symlinks specially (in requiring a stat syscall). Remove the offending exclusion. * NEWS: Mention the fix. * tests/ls/stat-dtype: New file/test, for the above fix. Also exercises the new df feature, below.
2006-07-20Fix a bug: ls --file-type worked like --indicator-style=slash,Jim Meyering
rather than like --indicator-style=file-type. (FILE_TYPE_INDICATOR_OPTION): New enum member. (long_options): Map "file-type" to FILE_TYPE_INDICATOR_OPTION, not to 'p'. (decode_switches): Handle new case: FILE_TYPE_INDICATOR_OPTION.
2006-07-19* src/ls.c (print_dir): Give a better diagnostic for failed opendir.Jim Meyering
2006-07-09Adjust to today's renaming changes in system.h.Paul Eggert