View | Details | Raw Unified
Collapse All | Expand All

(-) coreutils-5.2.1-r3.ebuild (+407 lines)
Added Link Here 
	EPATCH_SUFFIX="patch" epatch ${PATCHDIR}/generic
	EPATCH_SUFFIX="patch" epatch ${PATCHDIR}/generic
	EPATCH_SUFFIX="patch" epatch ${PATCHDIR}/extra
	EPATCH_SUFFIX="patch" epatch ${PATCHDIR}/extra
	# Patch to fix tails behaviour with fifos
	epatch ${FILESDIR}/coreutils-5.2.1-tail-fifo.patch
	use selinux && EPATCH_SUFFIX="patch" epatch ${PATCHDIR}/selinux
	use selinux && EPATCH_SUFFIX="patch" epatch ${PATCHDIR}/selinux
	# Sparc32 SMP bug fix -- see bug #46593
	# Sparc32 SMP bug fix -- see bug #46593
Added Link Here 
diff -urN coreutils-5.2.1/lib/Makefile.am coreutils-5.2.1.new/lib/Makefile.am
--- coreutils-5.2.1/lib/Makefile.am	2004-03-03 22:06:10.000000000 +0000
@@ -56,6 +56,7 @@
   exclude.c exclude.h \
   exit.h \
   exitfail.c exitfail.h \
   filemode.c filemode.h \
   file-type.c file-type.h \
   fopen-safer.c \
@@ -86,6 +87,7 @@
   modechange.c modechange.h \
   mountlist.h \
   offtostr.c \
   path-concat.c path-concat.h \
   pathmax.h \
   physmem.c physmem.h \
diff -urN coreutils-5.2.1/lib/fcntl-safer.h coreutils-5.2.1.new/lib/fcntl-safer.h
--- coreutils-5.2.1/lib/fcntl-safer.h	1970-01-01 01:00:00.000000000 +0100
@@ -0,0 +1,21 @@
diff -urN coreutils-5.2.1/lib/open-safer.c coreutils-5.2.1.new/lib/open-safer.c
--- coreutils-5.2.1/lib/open-safer.c	1970-01-01 01:00:00.000000000 +0100
@@ -0,0 +1,75 @@
diff -urN coreutils-5.2.1/m4/fcntl-safer.m4 coreutils-5.2.1.new/m4/fcntl-safer.m4
--- coreutils-5.2.1/m4/fcntl-safer.m4	1970-01-01 01:00:00.000000000 +0100
@@ -0,0 +1,29 @@
diff -urN coreutils-5.2.1/m4/prereq.m4 coreutils-5.2.1.new/m4/prereq.m4
--- coreutils-5.2.1/m4/prereq.m4	2003-12-18 10:33:33.000000000 +0000
@@ -23,6 +23,7 @@
   AC_REQUIRE([gl_ERROR])
   AC_REQUIRE([gl_EXCLUDE])
   AC_REQUIRE([gl_EXITFAIL])
   AC_REQUIRE([gl_FILEBLOCKS])
   AC_REQUIRE([gl_FILEMODE])
   AC_REQUIRE([gl_FILE_TYPE])
diff -urN coreutils-5.2.1/src/tail.c coreutils-5.2.1.new/src/tail.c
--- coreutils-5.2.1/src/tail.c	2005-01-06 18:23:57.266284528 +0000
@@ -35,6 +35,7 @@
 #include "argmatch.h"
 #include "c-strtod.h"
 #include "error.h"
 #include "inttostr.h"
 #include "posixver.h"
 #include "quote.h"
@@ -58,8 +59,9 @@
 /* Number of items to tail.  */
 #define DEFAULT_N_LINES 10
 
-/* A special value for dump_remainder's N_BYTES parameter.  */
-#define COPY_TO_EOF OFF_T_MAX
 
 /* FIXME: make Follow_name the default?  */
 #define DEFAULT_FOLLOW_MODE Follow_descriptor
@@ -99,12 +101,15 @@
   /* File descriptor on which the file is open; -1 if it's not open.  */
   int fd;
 
-  /* The size of the file the last time we checked.  */
   off_t size;
-
-  /* The device and inode of the file the last time we checked.  */
   dev_t dev;
   ino_t ino;
 
   /* The specified name initially referred to a directory or some other
      type for which tail isn't meaningful.  Unlike for a permission problem
@@ -114,9 +119,6 @@
   /* See description of DEFAULT_MAX_N_... below.  */
   unsigned int n_unchanged_stats;
 
-  /* See description of DEFAULT_MAX_N_... below.  */
-  unsigned int n_consecutive_size_changes;
-
   /* A file is tailable if it exists, is readable, and is of type
      IS_TAILABLE_FILE_TYPE.  */
   int tailable;
@@ -154,7 +156,7 @@
 };
 
 /* When tailing a file by name, if there have been this many consecutive
-   iterations for which the size has remained the same, then open/fstat
    the file to determine if that file name is still associated with the
    same device/inode-number pair as before.  This option is meaningful only
    when following by name.  --max-unchanged-stats=N  */
@@ -162,16 +164,6 @@
 static unsigned long max_n_unchanged_stats_between_opens =
   DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS;
 
-/* This variable is used to ensure that a file that is unlinked or moved
-   aside, yet always growing will be recognized as having been renamed.
-   After detecting this many consecutive size changes for a file, open/fstat
-   the file to determine if that file name is still associated with the
-   same device/inode-number pair as before.  This option is meaningful only
-   when following by name.  --max-consecutive-size-changes=N  */
-#define DEFAULT_MAX_N_CONSECUTIVE_SIZE_CHANGES 200
-static unsigned long max_n_consecutive_size_changes_between_opens =
-  DEFAULT_MAX_N_CONSECUTIVE_SIZE_CHANGES;
-
 /* The name this program was run with.  */
 char *program_name;
 
@@ -194,11 +186,6 @@
   RETRY_OPTION = CHAR_MAX + 1,
   ALLOW_MISSING_OPTION,   /* deprecated, FIXME: remove in late 2004 */
   MAX_UNCHANGED_STATS_OPTION,
-
-  /* FIXME: remove this in 2001, unless someone can show a good
-     reason to keep it.  */
-  MAX_CONSECUTIVE_SIZE_CHANGES_OPTION,
-
   PID_OPTION,
   PRESUME_INPUT_PIPE_OPTION,
   LONG_FOLLOW_OPTION
@@ -212,8 +199,6 @@
   {"follow", optional_argument, NULL, LONG_FOLLOW_OPTION},
   {"lines", required_argument, NULL, 'n'},
   {"max-unchanged-stats", required_argument, NULL, MAX_UNCHANGED_STATS_OPTION},
-  {"max-consecutive-size-changes", required_argument, NULL,
-   MAX_CONSECUTIVE_SIZE_CHANGES_OPTION},
   {"pid", required_argument, NULL, PID_OPTION},
   {"presume-input-pipe", no_argument, NULL,
    PRESUME_INPUT_PIPE_OPTION}, /* do not document */
@@ -327,6 +312,28 @@
     error (EXIT_FAILURE, errno, _("write error"));
 }
 
 static void
 close_fd (int fd, const char *filename)
 {
@@ -347,6 +354,7 @@
 
 /* Read and output N_BYTES of file PRETTY_FILENAME starting at the current
    position in FD.  If N_BYTES is COPY_TO_EOF, then copy until end of file.
    Return the number of bytes read from the file.  */
 
 static uintmax_t
@@ -362,13 +370,22 @@
       size_t n = MIN (n_remaining, BUFSIZ);
       size_t bytes_read = safe_read (fd, buffer, n);
       if (bytes_read == SAFE_READ_ERROR)
-	error (EXIT_FAILURE, errno, _("error reading %s"),
-	       quote (pretty_filename));
       if (bytes_read == 0)
 	break;
       xwrite (STDOUT_FILENO, buffer, bytes_read);
-      n_remaining -= bytes_read;
       n_written += bytes_read;
     }
 
   return n_written;
@@ -822,21 +839,21 @@
 /* FIXME: describe */
 
 static void
-recheck (struct File_spec *f)
 {
   /* open/fstat the file and announce if dev/ino have changed */
   struct stat new_stats;
-  int fd;
   int fail = 0;
   int is_stdin = (STREQ (f->name, "-"));
   int was_tailable = f->tailable;
   int prev_errnum = f->errnum;
   int new_file;
 
   assert (valid_file_spec (f));
 
-  fd = (is_stdin ? STDIN_FILENO : open (f->name, O_RDONLY));
-
   /* If the open fails because the file doesn't exist,
      then mark the file as not tailable.  */
   f->tailable = !(reopen_inaccessible_files && fd == -1);
@@ -931,32 +948,24 @@
 
   if (new_file)
     {
-      /* Record new file info in f.  */
-      f->fd = fd;
-      f->size = 0; /* Start at the beginning of the file...  */
-      f->dev = new_stats.st_dev;
-      f->ino = new_stats.st_ino;
-      f->n_unchanged_stats = 0;
-      f->n_consecutive_size_changes = 0;
-      f->ignore = 0;
-      xlseek (f->fd, f->size, SEEK_SET, pretty_name (f));
     }
 }
 
-/* FIXME: describe */
 
-static unsigned int
-n_live_files (const struct File_spec *f, int n_files)
 {
   int i;
-  unsigned int n_live = 0;
 
   for (i = 0; i < n_files; i++)
-    {
-      if (f[i].fd >= 0)
-	++n_live;
-    }
-  return n_live;
 }
 
 /* Tail NFILES files forever, or until killed.
@@ -969,6 +978,9 @@
 static void
 tail_forever (struct File_spec *f, int nfiles, double sleep_interval)
 {
   int last;
   int writer_is_dead = 0;
 
@@ -977,90 +989,110 @@
   while (1)
     {
       int i;
-      int any_changed;
 
-      any_changed = 0;
       for (i = 0; i < nfiles; i++)
 	{
 	  struct stat stats;
 
 	  if (f[i].ignore)
 	    continue;
 
 	  if (f[i].fd < 0)
 	    {
-	      recheck (&f[i]);
 	      continue;
 	    }
 
-	  if (fstat (f[i].fd, &stats) < 0)
 	    {
-	      f[i].fd = -1;
-	      f[i].errnum = errno;
-	      error (0, errno, "%s", pretty_name (&f[i]));
-	      continue;
 	    }
 
-	  if (stats.st_size == f[i].size)
 	    {
-	      f[i].n_consecutive_size_changes = 0;
-	      if ((max_n_unchanged_stats_between_opens
-		   <= f[i].n_unchanged_stats++)
-		  && follow_mode == Follow_name)
 		{
-		  recheck (&f[i]);
-		  f[i].n_unchanged_stats = 0;
 		}
-	      continue;
-	    }
-
-	  /* Ensure that a file that's unlinked or moved aside, yet always
-	     growing will be recognized as having been renamed.  */
-	  if ((max_n_consecutive_size_changes_between_opens
-	       <= f[i].n_consecutive_size_changes++)
-	      && follow_mode == Follow_name)
-	    {
-	      f[i].n_consecutive_size_changes = 0;
-	      recheck (&f[i]);
-	      continue;
-	    }
-
-	  /* This file has changed size.  Print out what we can, and
-	     then keep looping.  */
-
-	  any_changed = 1;
-
-	  /* reset counter */
-	  f[i].n_unchanged_stats = 0;
 
-	  if (stats.st_size < f[i].size)
-	    {
-	      error (0, 0, _("%s: file truncated"), pretty_name (&f[i]));
-	      last = i;
-	      xlseek (f[i].fd, (off_t) stats.st_size, SEEK_SET,
-		      pretty_name (&f[i]));
-	      f[i].size = stats.st_size;
-	      continue;
-	    }
-
-	  if (i != last)
-	    {
-	      if (print_headers)
-		write_header (pretty_name (&f[i]));
-	      last = i;
-	    }
-	  f[i].size += dump_remainder (pretty_name (&f[i]), f[i].fd,
-				       COPY_TO_EOF);
 	}
 
-      if (n_live_files (f, nfiles) == 0 && ! reopen_inaccessible_files)
 	{
 	  error (0, 0, _("no files remaining"));
 	  break;
 	}
 
-      /* If none of the files changed size, sleep.  */
-      if (!any_changed)
 	{
 	  if (writer_is_dead)
 	    break;
@@ -1189,8 +1221,8 @@
 	 which lseek (... SEEK_END) works.  */
       if ( ! presume_input_pipe
 	   && S_ISREG (stats.st_mode)
-	   && (start_pos = lseek (fd, (off_t) 0, SEEK_CUR)) != -1
-	   && start_pos < (end_pos = lseek (fd, (off_t) 0, SEEK_END)))
 	{
 	  *read_pos = end_pos;
 	  if (end_pos != 0 && file_lines (pretty_filename, fd, n_lines,
@@ -1250,7 +1282,7 @@
     }
   else
     {
-      fd = open (f->name, O_RDONLY);
     }
 
   f->tailable = !(reopen_inaccessible_files && fd == -1);
@@ -1310,17 +1342,10 @@
 	    }
 	  else
 	    {
-	      f->fd = fd;
-
 	      /* Note: we must use read_pos here, not stats.st_size,
 		 to avoid a race condition described by Ken Raeburn:
 	http://mail.gnu.org/archive/html/bug-textutils/2003-05/msg00007.html */
-	      f->size = read_pos;
-	      f->dev = stats.st_dev;
-	      f->ino = stats.st_ino;
-	      f->n_unchanged_stats = 0;
-	      f->n_consecutive_size_changes = 0;
-	      f->ignore = 0;
 	    }
 	}
       else
@@ -1577,18 +1602,6 @@
 	    }
 	  break;
 
-	case MAX_CONSECUTIVE_SIZE_CHANGES_OPTION:
-	  /* --max-consecutive-size-changes=N */
-	  if (xstrtoul (optarg, NULL, 10,
-			&max_n_consecutive_size_changes_between_opens, "")
-	      != LONGINT_OK)
-	    {
-	      error (EXIT_FAILURE, 0,
-		   _("%s: invalid maximum number of consecutive size changes"),
-		     optarg);
-	    }
-	  break;
-
 	case PID_OPTION:
 	  {
 	    strtol_error s_err;
@@ -1744,14 +1757,7 @@
     exit_status |= tail_file (&F[i], n_units);
 
   if (forever)
-    {
-      /* This fflush appears to be required only on Solaris 5.7.  */
-      if (fflush (stdout) < 0)
-	error (EXIT_FAILURE, errno, _("write error"));
-
-      SETVBUF (stdout, NULL, _IONBF, 0);
-      tail_forever (F, n_files, sleep_interval);
-    }
 
   if (have_read_stdin && close (STDIN_FILENO) < 0)
     error (EXIT_FAILURE, errno, "-");
diff -urN coreutils-5.2.1/src/tail.c.orig coreutils-5.2.1.new/src/tail.c.orig
--- coreutils-5.2.1/src/tail.c.orig	2004-01-21 22:27:02.000000000 +0000
@@ -1352,7 +1352,7 @@
   const char *p = argv[1];
   const char *n_string = NULL;
   const char *n_string_end;
-  bool obsolete_usage;
 
   int t_from_start;
   int t_count_lines;
@@ -1365,11 +1365,12 @@
     return 0;
 
   obsolete_usage = (posix2_version () < 200112);
 
   /* If P starts with `+' and the POSIX version predates 1003.1-2001,
      or if P starts with `-N' (where N is a digit), or `-l', then it
      is obsolescent.  Return zero otherwise.  */
-  if (! ((p[0] == '+' && obsolete_usage)
 	 || (p[0] == '-' && (p[1] == 'l' || ISDIGIT (p[1])))))
     return 0;
 
@@ -1486,10 +1487,11 @@
 
       if (! obsolete_usage)
 	{
-	  error (0, 0, _("`%s' option is obsolete; use `%s-%c %.*s'"),
 		 argv[1], t_forever ? " -f" : "", t_count_lines ? 'n' : 'c',
 		 (int) (n_string_end - n_string), n_string);
-	  usage (EXIT_FAILURE);
 	}
 
       /* Set globals.  */