Compare commits

...

72 Commits

Author SHA1 Message Date
Jim Meyering
51155d32a3 *** empty log message *** 2000-07-01 15:36:44 +00:00
Jim Meyering
7dbb61f30e *** empty log message *** 2000-07-01 14:06:55 +00:00
Jim Meyering
73202c14e6 . 2000-07-01 14:03:02 +00:00
Jim Meyering
a784ac670f . 2000-07-01 13:58:19 +00:00
Jim Meyering
1002386cc5 *** empty log message *** 2000-07-01 13:43:51 +00:00
Jim Meyering
9657d66244 Remove a `FIXME' comment and fix the associated problem. 2000-07-01 13:43:46 +00:00
Jim Meyering
9a4135570b . 2000-07-01 13:35:52 +00:00
Jim Meyering
7d25895457 *** empty log message *** 2000-07-01 13:35:33 +00:00
Jim Meyering
1ce3f3cca5 Use MOUNTED_FS_STAT_DEV instead of MOUNTED_NEXT_DEV,
per change in ../m4/ls-mntd-fs.m4.
(read_filesystem_list): Ignore symbolic links.
2000-07-01 13:35:28 +00:00
Jim Meyering
879717eafa (jm_LIST_MOUNTED_FILESYSTEMS): Rename BeOS specific
macro from MOUNTED_NEXT_DEV to MOUNTED_FS_STAT_DEV.
2000-07-01 13:31:20 +00:00
Jim Meyering
f00cefa62b *** empty log message *** 2000-07-01 11:01:18 +00:00
Jim Meyering
13133639a4 (TESTS_ENVIRONMENT): Define host_triplet for use in the dangling-symlink test. 2000-07-01 11:01:14 +00:00
Jim Meyering
994724bf67 *** empty log message *** 2000-07-01 11:00:10 +00:00
Jim Meyering
95e3f911e2 Warn about the problem, rather
than failing on some very recent (at least 2.3.99) versions of
the Linux kernel.  Suggestion from Ulrich Drepper.
2000-07-01 10:59:56 +00:00
Jim Meyering
f59a68b49a *** empty log message *** 2000-07-01 09:09:37 +00:00
Jim Meyering
f6d2d9b74c *** empty log message *** 2000-07-01 09:05:13 +00:00
Jim Meyering
c52dea43b7 Put double quotes around use of $cross_compiling. 2000-07-01 09:04:56 +00:00
Jim Meyering
1e4dca2dd1 . 2000-07-01 07:13:53 +00:00
Jim Meyering
7a17620c53 *** empty log message *** 2000-06-30 13:25:12 +00:00
Jim Meyering
1ba4b1a996 *** empty log message *** 2000-06-30 13:25:04 +00:00
Jim Meyering
60cea0e8fe *** empty log message *** 2000-06-29 11:30:16 +00:00
Jim Meyering
d1e34222a8 Include <string.h> or <strings.h>, as appropriate, for declaration of strcmp. 2000-06-29 11:29:55 +00:00
Jim Meyering
13f4d23214 *** empty log message *** 2000-06-29 11:24:14 +00:00
Jim Meyering
2aab0b6a6c Include <stdlib.h>, for declaration of exit. 2000-06-29 11:24:09 +00:00
Jim Meyering
d0ffb1b198 *** empty log message *** 2000-06-29 11:16:29 +00:00
Jim Meyering
81d46d192a (find_bracketed_repeat): Add a cast to suppress a warning. 2000-06-29 11:15:52 +00:00
Jim Meyering
4c27ffdf05 *** empty log message *** 2000-06-29 10:39:57 +00:00
Jim Meyering
86956748b1 (enum): Remove comma from end of enumerator list.
From Gerhard Poul <gpoul@gnu.org
2000-06-29 10:39:41 +00:00
Jim Meyering
ded114511b *** empty log message *** 2000-06-29 10:39:00 +00:00
Jim Meyering
13225e0c76 *** empty log message *** 2000-06-29 08:37:00 +00:00
Jim Meyering
a1fd5e91ff (fsp_to_string) [HAVE_F_FSTYPENAME_IN_STATFS]:
Avoid warning by casting result to `char *' to remove `const'.
2000-06-29 08:30:03 +00:00
Jim Meyering
69b3d52b2a *** empty log message *** 2000-06-28 20:30:59 +00:00
Jim Meyering
27a839a3fa Use stdlib.h, not stdio.h. The latter is not included
by quotearg.c, for which we perform this test.  From Bruno Haible.
2000-06-28 20:29:27 +00:00
Jim Meyering
54b2c4933f *** empty log message *** 2000-06-28 14:06:34 +00:00
Jim Meyering
c93836544c Don't copy `out' into /tmp. 2000-06-28 14:06:30 +00:00
Jim Meyering
457fcbb2ca . 2000-06-27 13:23:13 +00:00
Jim Meyering
0865bd05b4 *** empty log message *** 2000-06-27 13:13:13 +00:00
Jim Meyering
b1b5fb67fc (count_entry): Don't set errno before
invoking savedir, and assume that errno is nonzero if savedir fails.
2000-06-27 13:12:12 +00:00
Jim Meyering
7e2d22e2a6 (copy_dir): Don't set errno before
invoking savedir, and assume that errno is nonzero if savedir fails.
2000-06-27 13:11:36 +00:00
Jim Meyering
e068bafb72 *** empty log message *** 2000-06-27 13:11:00 +00:00
Jim Meyering
53ec884edb (change_dir_mode): Don't set errno before
invoking savedir, and assume that errno is nonzero if savedir fails.
2000-06-27 13:10:50 +00:00
Jim Meyering
7aa50cfb3c (change_dir_owner): Don't set errno before
invoking savedir, and assume that errno is nonzero if savedir fails.
2000-06-27 13:10:24 +00:00
Jim Meyering
db0cd2f7e6 (change_dir_group): Don't set errno before
invoking savedir, and assume that errno is nonzero if savedir fails.
2000-06-27 13:09:57 +00:00
Jim Meyering
3dc875d9bd *** empty log message *** 2000-06-27 11:21:03 +00:00
Jim Meyering
f4e62844cb . 2000-06-27 10:10:13 +00:00
Jim Meyering
738611829c *** empty log message *** 2000-06-27 10:09:54 +00:00
Jim Meyering
4189da9d74 (libfetish_a_SOURCES): Remove readutmp.c. 2000-06-27 10:09:49 +00:00
Jim Meyering
26a158b619 *** empty log message *** 2000-06-27 10:08:15 +00:00
Jim Meyering
f8a79d9a8c (jm_PREREQ_READUTMP): Likewise. If either <utmp.h> or
<utmpx.h> exists, put readutmp.o into LIBOBJS.
2000-06-27 10:08:09 +00:00
Jim Meyering
ae641fdacf (_jm_DECL_HEADERS): Check for utmp.h as well. 2000-06-27 10:01:30 +00:00
Jim Meyering
0a43597bb8 *** empty log message *** 2000-06-27 07:08:52 +00:00
Jim Meyering
211b5731d7 savedir now sets errno on failure and invokes xmalloc to get memory.
Fix a couple of other minor bugs while we're at it.

(<unistd.h>): Do not include; there's no need.
(NAMLEN): Remove macro.
(malloc, realloc): Remove decls.
(stpcpy): Likewise.
("xalloc.h"): Include.
(NAME_SIZE_DEFAULT): New macro.
(savedir): Use xmalloc / xrealloc to allocate memory.
Use NAME_SIZE_DEFAULT if name_size is negative or overflows to zero.
Skip "" directory entries.
Use strlen to calculate directory entry length, since the old method
is rarely used these days and isn't worth supporting.
Don't use a pointer after freeing it.
Check for integer overflow when calculating allocation size.
Use memcpy to copy entries, instead of stpcpy.
Set errno properly when returning NULL.
Check for readdir error.
2000-06-27 07:08:48 +00:00
Jim Meyering
ae34e4466d *** empty log message *** 2000-06-27 06:33:35 +00:00
Jim Meyering
99c1d22a99 (show_dev): Round disk usage percentage up, not to nearest value.
Use integer arithmetic if it's easy.
Fix bug when converting twos-complement negative values to floating point.
2000-06-27 06:33:31 +00:00
Jim Meyering
b07eb28c60 *** empty log message *** 2000-06-26 13:48:40 +00:00
Jim Meyering
b4fd5c459e *** empty log message *** 2000-06-26 13:30:59 +00:00
Jim Meyering
dfaf03f037 *** empty log message *** 2000-06-26 10:55:57 +00:00
Jim Meyering
204a9ee115 [HAVE_STDLIB_H]: Include stdlib.h. 2000-06-26 10:55:18 +00:00
Jim Meyering
43c77218e4 *** empty log message *** 2000-06-26 06:33:22 +00:00
Jim Meyering
9abfcc500a `id -Gn' (invoked by groups) would fail without giving a diagnostic
on malconfigured systems.
(print_user): Give a diagnostic if number->name lookup fails.
(print_group): Likewise.
2000-06-26 06:32:58 +00:00
Jim Meyering
ac4e995ed3 *** empty log message *** 2000-06-25 21:19:41 +00:00
Jim Meyering
d705cb724b (xmalloc, xrealloc): Remove functions.
Include xalloc.h.
Don't include <stdlib.h>.  Don't declare malloc, realloc.
2000-06-25 21:17:32 +00:00
Jim Meyering
e195cd0425 *** empty log message *** 2000-06-25 21:03:05 +00:00
Jim Meyering
0adbb52608 *** empty log message *** 2000-06-25 20:20:28 +00:00
Jim Meyering
c72f18b2c3 (TESTS): Add fail-perm. 2000-06-25 20:20:23 +00:00
Jim Meyering
0a0e82382c *** empty log message *** 2000-06-25 20:19:52 +00:00
Jim Meyering
34591391d1 *** empty log message *** 2000-06-25 20:15:22 +00:00
Jim Meyering
ab50b6880f *** empty log message *** 2000-06-25 15:58:47 +00:00
Jim Meyering
92ead9886c (copy_internal): Don't return return immediately after a
failed copy_dir call -- otherwise, the failure to read a single file
in a source directory would cause the containing destination directory
not to have owner/perms set properly.  Reported by Piotr Kwapulinski.
2000-06-25 15:50:51 +00:00
Jim Meyering
8a900584f1 *** empty log message *** 2000-06-25 15:50:38 +00:00
Jim Meyering
18252dc7fc *** empty log message *** 2000-06-25 15:50:29 +00:00
Jim Meyering
046110aa3f *** empty log message *** 2000-06-25 15:49:21 +00:00
36 changed files with 391 additions and 200 deletions

3
THANKS
View File

@@ -86,6 +86,7 @@ Gary Anderson ganderson@clark.net
Gaël Quéri gqueri@mail.dotcom.fr
Geoff Kuenning geoff@cs.hmc.edu
Geoff Odhner geoff@franklin.com
Gerhard Poul gpoul@gnu.org
Germano Leichsenring germano@jedi.cs.kobe-u.ac.jp
GOTO Masanori gotom@debian.or.jp
Greg McGary gkm@gnu.org
@@ -208,6 +209,8 @@ Phil Richards phil.richards@vf.vodafone.co.uk
Philippe De Muyter phdm@macqel.be
Philippe Schnoebelen Philippe.Schnoebelen@imag.fr
Piergiorgio Sartor sartor@sony.de
Piotr Kwapulinski kwap@univ.gda.pl
Maciej Kwapulinski pikpok@univ.gda.pl
Rainer Orth ro@TechFak.Uni-Bielefeld.DE
Ralf W. Stephan stephan@tmt.de
Ralph Loader loader@maths.ox.ac.uk

View File

@@ -1,3 +1,55 @@
2000-06-17 Bruno Haible <haible@clisp.cons.org>
* mountlist.c: Use MOUNTED_FS_STAT_DEV instead of MOUNTED_NEXT_DEV,
per change in ../m4/ls-mntd-fs.m4.
(read_filesystem_list): Ignore symbolic links.
2000-06-29 Jim Meyering <meyering@lucent.com>
* same.c: Include <string.h> or <strings.h>, as appropriate,
for declaration of strcmp.
* long-options.c: Include <stdlib.h>, for declaration of exit.
* mountlist.c (fsp_to_string) [HAVE_F_FSTYPENAME_IN_STATFS]:
Avoid warning by casting result to `char *' to remove `const'.
2000-06-17 Bruno Haible <haible@clisp.cons.org>
* Makefile.am (libfetish_a_SOURCES): Remove readutmp.c.
2000-06-26 Paul Eggert <eggert@twinsun.com>
savedir now sets errno on failure and invokes xmalloc to get memory.
Fix a couple of other minor bugs while we're at it.
* savedir.c (<unistd.h>): Do not include; there's no need.
(NAMLEN): Remove macro.
(malloc, realloc): Remove decls.
(stpcpy): Likewise.
("xalloc.h"): Include.
(NAME_SIZE_DEFAULT): New macro.
(savedir): Use xmalloc / xrealloc to allocate memory.
Use NAME_SIZE_DEFAULT if name_size is negative or overflows to zero.
Skip "" directory entries.
Use strlen to calculate directory entry length, since the old method
is rarely used these days and isn't worth supporting.
Don't use a pointer after freeing it.
Check for integer overflow when calculating allocation size.
Use memcpy to copy entries, instead of stpcpy.
Set errno properly when returning NULL.
Check for readdir error.
2000-06-26 Jim Meyering <meyering@lucent.com>
* posixtm.c [HAVE_STDLIB_H]: Include stdlib.h, for decl of abort.
2000-06-17 Bruno Haible <haible@clisp.cons.org>
* getusershell.c (xmalloc, xrealloc): Remove functions.
Include xalloc.h.
Don't include <stdlib.h>. Don't declare malloc, realloc.
2000-06-23 Bruno Haible <haible@clisp.cons.org>
* unicodeio.c (print_unicode_char): Work around ansi2knr deficiency.

View File

@@ -13,7 +13,7 @@ libfetish_a_SOURCES = \
full-write.c getopt.c getopt1.c getstr.c getugroups.c hard-locale.c hash.c \
human.c idcache.c isdir.c linebuffer.c localcharset.c long-options.c \
makepath.c md5.c memcasecmp.c memcoll.c modechange.c path-concat.c \
quotearg.c readtokens.c readutmp.c safe-read.c same.c save-cwd.c \
quotearg.c readtokens.c safe-read.c same.c save-cwd.c \
savedir.c stripslash.c unicodeio.c userspec.c version-etc.c xgetcwd.c \
xgethostname.c xmalloc.c xstrdup.c xstrtod.c xstrtol.c xstrtoul.c \
xstrtoumax.c yesno.c

View File

@@ -127,7 +127,7 @@ libfetish_a_SOURCES = \
full-write.c getopt.c getopt1.c getstr.c getugroups.c hard-locale.c hash.c \
human.c idcache.c isdir.c linebuffer.c localcharset.c long-options.c \
makepath.c md5.c memcasecmp.c memcoll.c modechange.c path-concat.c \
quotearg.c readtokens.c readutmp.c safe-read.c same.c save-cwd.c \
quotearg.c readtokens.c safe-read.c same.c save-cwd.c \
savedir.c stripslash.c unicodeio.c userspec.c version-etc.c xgetcwd.c \
xgethostname.c xmalloc.c xstrdup.c xstrtod.c xstrtol.c xstrtoul.c \
xstrtoumax.c yesno.c
@@ -177,10 +177,10 @@ getopt$U.o getopt1$U.o getstr$U.o getugroups$U.o hard-locale$U.o \
hash$U.o human$U.o idcache$U.o isdir$U.o linebuffer$U.o \
localcharset$U.o long-options$U.o makepath$U.o md5$U.o memcasecmp$U.o \
memcoll$U.o modechange$U.o path-concat$U.o quotearg$U.o readtokens$U.o \
readutmp$U.o safe-read$U.o same$U.o save-cwd$U.o savedir$U.o \
stripslash$U.o unicodeio$U.o userspec$U.o version-etc$U.o xgetcwd$U.o \
xgethostname$U.o xmalloc$U.o xstrdup$U.o xstrtod$U.o xstrtol$U.o \
xstrtoul$U.o xstrtoumax$U.o yesno$U.o
safe-read$U.o same$U.o save-cwd$U.o savedir$U.o stripslash$U.o \
unicodeio$U.o userspec$U.o version-etc$U.o xgetcwd$U.o xgethostname$U.o \
xmalloc$U.o xstrdup$U.o xstrtod$U.o xstrtol$U.o xstrtoul$U.o \
xstrtoumax$U.o yesno$U.o
libfetish_a_OBJECTS = $(am_libfetish_a_OBJECTS)
AR = ar
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -213,7 +213,7 @@ $(DEPDIR)/memcpy.Po $(DEPDIR)/memmove.Po $(DEPDIR)/memset.Po \
$(DEPDIR)/mktime.Po $(DEPDIR)/modechange$U.Po $(DEPDIR)/mountlist.Po \
$(DEPDIR)/nanosleep.Po $(DEPDIR)/obstack.Po $(DEPDIR)/path-concat$U.Po \
$(DEPDIR)/posixtm$U.Po $(DEPDIR)/putenv.Po $(DEPDIR)/quotearg$U.Po \
$(DEPDIR)/readtokens$U.Po $(DEPDIR)/readutmp$U.Po $(DEPDIR)/realloc.Po \
$(DEPDIR)/readtokens$U.Po $(DEPDIR)/readutmp.Po $(DEPDIR)/realloc.Po \
$(DEPDIR)/regex.Po $(DEPDIR)/rmdir.Po $(DEPDIR)/rpmatch.Po \
$(DEPDIR)/safe-read$U.Po $(DEPDIR)/same$U.Po $(DEPDIR)/save-cwd$U.Po \
$(DEPDIR)/savedir$U.Po $(DEPDIR)/stat.Po $(DEPDIR)/stime.Po \
@@ -234,10 +234,10 @@ euidaccess.c fileblocks.c fnmatch.c fsusage.c ftruncate.c getdate.c \
getgroups.c gethostname.c getline.c getloadavg.c getpass.c \
getusershell.c group-member.c lchown.c malloc.c memchr.c memcmp.c \
memcpy.c memmove.c memset.c mktime.c mountlist.c nanosleep.c obstack.c \
obstack.h putenv.c realloc.c regex.c rmdir.c rpmatch.c stime.c stpcpy.c \
strcasecmp.c strcspn.c strdup.c strftime.c strncasecmp.c strndup.c \
strnlen.c strpbrk.c strstr.c strtod.c strtol.c strtoul.c strtoull.c \
strtoumax.c strverscmp.c utime.c
obstack.h putenv.c readutmp.c realloc.c regex.c rmdir.c rpmatch.c \
stime.c stpcpy.c strcasecmp.c strcspn.c strdup.c strftime.c \
strncasecmp.c strndup.c strnlen.c strpbrk.c strstr.c strtod.c strtol.c \
strtoul.c strtoull.c strtoumax.c strverscmp.c utime.c
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -625,7 +625,7 @@ maintainer-clean-tags:
@AMDEP@include $(DEPDIR)/putenv.Po
@AMDEP@include $(DEPDIR)/quotearg$U.Po
@AMDEP@include $(DEPDIR)/readtokens$U.Po
@AMDEP@include $(DEPDIR)/readutmp$U.Po
@AMDEP@include $(DEPDIR)/readutmp.Po
@AMDEP@include $(DEPDIR)/realloc.Po
@AMDEP@include $(DEPDIR)/regex.Po
@AMDEP@include $(DEPDIR)/rmdir.Po

View File

@@ -1,5 +1,5 @@
/* getusershell.c -- Return names of valid user shells.
Copyright (C) 1991, 1997 Free Software Foundation, Inc.
Copyright (C) 1991, 1997, 2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <ctype.h>
#include "xalloc.h"
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
# define IN_CTYPE_DOMAIN(c) 1
@@ -37,15 +38,6 @@
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
#ifdef STDC_HEADERS
# include <stdlib.h>
#else
char *malloc ();
char *realloc ();
#endif
char *xstrdup ();
static int readname ();
/* List of shells to use if the shells file is missing. */
@@ -126,39 +118,6 @@ endusershell ()
}
}
/* Allocate N bytes of memory dynamically, with error checking. */
static char *
xmalloc (n)
unsigned n;
{
char *p;
p = malloc (n);
if (p == 0)
{
fprintf (stderr, "virtual memory exhausted\n");
exit (1);
}
return p;
}
/* Reallocate space P to size N, with error checking. */
static char *
xrealloc (p, n)
char *p;
unsigned n;
{
p = realloc (p, n);
if (p == 0)
{
fprintf (stderr, "virtual memory exhausted\n");
exit (1);
}
return p;
}
/* Read a line from STREAM, removing any newline at the end.
Place the result in *NAME, which is malloc'd
and/or realloc'd as necessary and can start out NULL,

View File

@@ -23,6 +23,10 @@
#include <stdio.h>
#include <getopt.h>
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include "long-options.h"
#include "version-etc.h"

View File

@@ -84,7 +84,7 @@ extern int errno;
# include <sys/fs_types.h>
#endif
#ifdef MOUNTED_NEXT_DEV /* BeOS. */
#ifdef MOUNTED_FS_STAT_DEV /* BeOS. */
# include <fs_info.h>
# include <dirent.h>
#endif
@@ -260,7 +260,7 @@ static char *
fsp_to_string (const struct statfs *fsp)
{
# if defined HAVE_F_FSTYPENAME_IN_STATFS
return fsp->f_fstypename;
return (char *) (fsp->f_fstypename);
# else
return fstype_to_string (fsp->f_type);
# endif
@@ -417,7 +417,7 @@ read_filesystem_list (int need_fs_type)
}
#endif /* MOUNTED_GETMNT. */
#if defined (MOUNTED_NEXT_DEV) /* BeOS */
#if defined (MOUNTED_FS_STAT_DEV) /* BeOS */
{
/* The next_dev() and fs_stat_dev() system calls give the list of
all filesystems, including the information returned by statvfs()
@@ -468,7 +468,7 @@ read_filesystem_list (int need_fs_type)
strcpy (name + 1, d->d_name);
}
if (stat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode))
if (lstat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode))
{
struct rootdir_entry *re;
@@ -520,7 +520,7 @@ read_filesystem_list (int need_fs_type)
free (re);
}
}
#endif /* MOUNTED_NEXT_DEV */
#endif /* MOUNTED_FS_STAT_DEV */
#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */
{

View File

@@ -1,5 +1,5 @@
/* Parse dates for touch and date.
Copyright (C) 1989, 1990, 1991, 1998 Free Software Foundation Inc.
Copyright (C) 1989, 1990, 1991, 1998, 2000 Free Software Foundation Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,6 +23,9 @@
#endif
#include <stdio.h>
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include <sys/types.h>
#if HAVE_STRING_H
# include <string.h>

View File

@@ -36,6 +36,12 @@
extern int errno;
#endif
#if HAVE_STRING_H
# include <string.h>
#else
# include <strings.h>
#endif
#include "same.h"
#include "dirname.h"
#include "error.h"

View File

@@ -23,16 +23,15 @@
#include <sys/types.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#if HAVE_DIRENT_H
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
# define dirent direct
# define NAMLEN(dirent) (dirent)->d_namlen
# if HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif
@@ -54,26 +53,25 @@
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *malloc ();
char *realloc ();
#endif
#ifndef NULL
# define NULL 0
#endif
#ifndef stpcpy
char *stpcpy ();
#endif
#include "savedir.h"
#include "xalloc.h"
/* Return a freshly allocated string containing the filenames
in directory DIR, separated by '\0' characters;
the end is marked by two '\0' characters in a row.
NAME_SIZE is the number of bytes to initially allocate
for the string; it will be enlarged as needed.
Return NULL if DIR cannot be opened or if out of memory. */
Use NAME_SIZE == -1 if you do not know the size.
Return NULL (setting errno) if DIR cannot be opened, read, or closed. */
#ifndef NAME_SIZE_DEFAULT
# define NAME_SIZE_DEFAULT 512
#endif
char *
savedir (const char *dir, off_t name_size)
@@ -81,57 +79,58 @@ savedir (const char *dir, off_t name_size)
DIR *dirp;
struct dirent *dp;
char *name_space;
char *namep;
size_t allocated = name_size; /* Overflow is checked indirectly below. */
size_t used = 0;
int save_errno;
dirp = opendir (dir);
if (dirp == NULL)
return NULL;
/* Be sure name_size is at least `1' so there's room for
the final NUL byte. */
if (name_size <= 0)
name_size = 1;
/* Use the default if the size is not known. Be sure "allocated"
is at least `1' so there's room for the final NUL byte.
Do not simply test name_size <= 0, because the initialization
of "allocated" might have overflowed. */
if (name_size < 0 || allocated == 0)
allocated = NAME_SIZE_DEFAULT;
name_space = (char *) malloc (name_size);
if (name_space == NULL)
{
closedir (dirp);
return NULL;
}
namep = name_space;
name_space = xmalloc (allocated);
errno = 0;
while ((dp = readdir (dirp)) != NULL)
{
/* Skip "." and ".." (some NFS filesystems' directories lack them). */
if (dp->d_name[0] != '.'
|| (dp->d_name[1] != '\0'
&& (dp->d_name[1] != '.' || dp->d_name[2] != '\0')))
/* Skip "", ".", and "..". "" is returned by at least one buggy
implementation: Solaris 2.4 readdir on NFS filesystems. */
char const *entry = dp->d_name;
if (entry[entry[0] != '.' ? 0 : entry[1] != '.' ? 1 : 2] != '\0')
{
off_t size_needed = (namep - name_space) + NAMLEN (dp) + 2;
if (size_needed > name_size)
size_t entry_size = strlen (entry) + 1;
if (used + entry_size < used)
xalloc_die ();
if (allocated <= used + entry_size)
{
char *new_name_space;
while (size_needed > name_size)
name_size += 1024;
new_name_space = realloc (name_space, name_size);
if (new_name_space == NULL)
do
{
closedir (dirp);
return NULL;
if (2 * allocated < allocated)
xalloc_die ();
allocated *= 2;
}
namep += new_name_space - name_space;
name_space = new_name_space;
while (allocated <= used + entry_size);
name_space = xrealloc (name_space, allocated);
}
namep = stpcpy (namep, dp->d_name) + 1;
memcpy (name_space + used, entry, entry_size);
used += entry_size;
}
}
*namep = '\0';
if (CLOSEDIR (dirp))
name_space[used] = '\0';
save_errno = errno;
if (CLOSEDIR (dirp) != 0)
save_errno = errno;
if (save_errno != 0)
{
free (name_space);
errno = save_errno;
return NULL;
}
return name_space;

View File

@@ -1,3 +1,28 @@
2000-07-01 Jim Meyering <meyering@lucent.com>
* ls-mntd-fs.m4: Remove a `FIXME' comment and fix the associated
problem.
2000-06-17 Bruno Haible <haible@clisp.cons.org>
* ls-mntd-fs.m4 (jm_LIST_MOUNTED_FILESYSTEMS): Rename BeOS specific
macro from MOUNTED_NEXT_DEV to MOUNTED_FS_STAT_DEV.
2000-07-01 Jim Meyering <meyering@lucent.com>
* uptime.m4: Put double quotes around use of $cross_compiling.
2000-06-28 Jim Meyering <meyering@lucent.com>
* mbstate_t.m4: Use stdlib.h, not stdio.h. The latter is not included
by quotearg.c, for which we perform this test. From Bruno Haible.
2000-06-17 Bruno Haible <haible@clisp.cons.org>
* check-decl.m4 (_jm_DECL_HEADERS): Check for utmp.h as well.
* prereq.m4 (jm_PREREQ_READUTMP): Likewise. If either <utmp.h> or
<utmpx.h> exists, put readutmp.o into LIBOBJS.
2000-06-25 Jim Meyering <meyering@lucent.com>
* mbstate_t.m4: Include stdio.h before wchar.h to work around

View File

@@ -1,4 +1,4 @@
#serial 12
#serial 13
dnl This is just a wrapper function to encapsulate this kludge.
dnl Putting it in a separate file like this helps share it between
@@ -68,5 +68,5 @@ AC_DEFUN(_jm_DECL_HEADERS,
[
AC_REQUIRE([AC_HEADER_STDC])
AC_CHECK_HEADERS(memory.h string.h strings.h stdlib.h unistd.h sys/time.h \
utmpx.h)
utmp.h utmpx.h)
])

View File

@@ -1,21 +1,19 @@
#serial 4
#serial 5
dnl From Jim Meyering.
dnl
dnl This is not pretty. I've just taken the autoconf code and wrapped
dnl it in an AC_DEFUN.
dnl
dnl CAUTION: This is very fragile. It relies on several checks that
dnl are still in fileutils' configure.in:
dnl FIXME: add AC_REQUIRE uses to pull in all definitions required
dnl for all uses of $ac_cv_func_* and $ac_cv_header_* variables below.
dnl
AC_PREREQ(2.14a)
# jm_LIST_MOUNTED_FILESYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
AC_DEFUN(jm_LIST_MOUNTED_FILESYSTEMS,
[
AC_CHECK_FUNCS(listmntent getmntent getmntinfo)
AC_CHECK_HEADERS(mntent.h)
# Determine how to get the list of mounted filesystems.
ac_list_mounted_fs=
@@ -213,7 +211,7 @@ if test -z "$ac_list_mounted_fs"; then
AC_MSG_RESULT($fu_result)
if test $fu_result = yes; then
ac_list_mounted_fs=found
AC_DEFINE(MOUNTED_NEXT_DEV, 1,
AC_DEFINE(MOUNTED_FS_STAT_DEV, 1,
[Define if there are functions named next_dev and fs_stat_dev for
reading the list of mounted filesystems. (BeOS)])
fi

View File

@@ -1,4 +1,4 @@
# serial 2
# serial 3
# From Paul Eggert.
@@ -6,13 +6,16 @@
# so you can't declare an object of that type.
# Check for this incompatibility with Standard C.
# Include stdio.h first, because otherwise this test would fail on Linux
# (at least 2.2.16) because the `_XOPEN_SOURCE 500' definition elicits
# Include stdlib.h first, because otherwise this test would fail on Linux
# (at least glibc-2.1.3) because the `_XOPEN_SOURCE 500' definition elicits
# a syntax error in wchar.h due to the use of undefined __int32_t.
AC_DEFUN(AC_MBSTATE_T_OBJECT,
[AC_CACHE_CHECK([for mbstate_t object type], ac_cv_type_mbstate_t_object,
[AC_TRY_COMPILE([#include <stdio.h>
[AC_TRY_COMPILE([
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include <wchar.h>],
[mbstate_t x; return sizeof x;],
ac_cv_type_mbstate_t_object=yes,

View File

@@ -1,4 +1,4 @@
#serial 9
#serial 10
dnl These are the prerequisite macros for files in the lib/
dnl directories of the fileutils, sh-utils, and textutils packages.
@@ -67,12 +67,13 @@ AC_DEFUN(jm_PREREQ_QUOTEARG,
AC_DEFUN(jm_PREREQ_READUTMP,
[
AC_HEADER_STDC
AC_CHECK_HEADERS(string.h utmpx.h sys/param.h)
AC_CHECK_HEADERS(string.h utmp.h utmpx.h sys/param.h)
AC_CHECK_FUNCS(utmpname)
AC_CHECK_FUNCS(utmpxname)
AM_C_PROTOTYPES
utmp_includes="\
if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
utmp_includes="\
$ac_includes_default
#ifdef HAVE_UTMPX_H
# include <utmpx.h>
@@ -80,10 +81,12 @@ $ac_includes_default
# include <utmp.h>
#endif
"
AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
AC_LIBOBJ(readutmp)
fi
])
AC_DEFUN(jm_PREREQ_REGEX,

View File

@@ -1,4 +1,4 @@
#serial 3
#serial 4
AC_PREREQ(2.13)
@@ -8,7 +8,7 @@ AC_DEFUN(jm_SYS_PROC_UPTIME,
AC_CACHE_CHECK([for /proc/uptime], jm_cv_have_proc_uptime,
[jm_cv_have_proc_uptime=no
test -f /proc/uptime \
&& test $cross_compiling = no \
&& test "$cross_compiling" = no \
&& cat < /proc/uptime >/dev/null 2>/dev/null \
&& jm_cv_have_proc_uptime=yes])
if test $jm_cv_have_proc_uptime = yes; then

View File

@@ -1,5 +1,43 @@
2000-07-01 Jim Meyering <meyering@lucent.com>
* Version 4.0w.
* tests/touch/dangling-symlink: Warn about the problem rather
than failing, on some very recent (at least 2.3.99) versions of
the Linux kernel. Suggestion from Ulrich Drepper.
* tests/touch/Makefile.am (TESTS_ENVIRONMENT): Define host_triplet
for use in the dangling-symlink test.
2000-06-28 Jim Meyering <meyering@lucent.com>
* tests/mv/i-2: Don't copy `out' into /tmp.
2000-06-26 Paul Eggert <eggert@twinsun.com>
Now that savedir.c has been cleaned up...
* src/chgrp.c (change_dir_group): Don't set errno before
invoking savedir, and assume that errno is nonzero if savedir fails.
* src/chmod.c (change_dir_mode): Likewise.
* src/chown.c (change_dir_owner): Likewise.
* src/copy.c (copy_dir): Likewise.
* src/du.c (count_entry): Likewise.
2000-06-26 Paul Eggert <eggert@twinsun.com>
* src/df.c (show_dev): Round disk usage percentage up, not to
nearest value. Use integer arithmetic if it's easy. Fix bug
when converting twos-complement negative values to floating point.
2000-06-25 Jim Meyering <meyering@lucent.com>
* src/copy.c (copy_internal): Don't return immediately after a failed
copy_dir call -- otherwise, the failure to read a single file in a
source directory would cause the containing destination directory
not to have the owner and/or permissions set properly.
Reported by Piotr and Maciej Kwapulinski.
* tests/cp/fail-perm: Test for it.
* tests/cp/Makefile.am (TESTS): Add fail-perm.
* Version 4.0v.
2000-06-18 Jim Meyering <meyering@lucent.com>

View File

@@ -1,4 +1,7 @@
Changes in release 4.1:
[4.0w]
* When `cp -pR' fails to copy a file, it now preserves permissions, owner,
and group of the containing directory.
[4.0v]
* df, du, and ls now round disk usage up and disk free space down
* df, du, ls: --block-size=N now works for values of N that are e.g.,

View File

@@ -1,3 +1,28 @@
2000-07-01 Jim Meyering <meyering@lucent.com>
* configure.in (jm_DUMMY_1): Wrap a snippet in a macro definition
so we can use AC_REQUIRE.
(jm_BOOT_TIME): Likewise.
2000-06-17 Bruno Haible <haible@clisp.cons.org>
* configure.in: Add pinky, users, who to OPTIONAL_BIN_PROGS if either
<utmp.h> or <utmpx.h> exists. Add uptime only if either <utmp.h> or
<utmpx.h> exists.
* src/Makefile.am (bin_PROGRAMS): Remove pinky, users, who from here...
(EXTRA_PROGRAMS): ... and add them here.
2000-06-26 Jim Meyering <meyering@lucent.com>
`id -Gn' (invoked by groups) would fail without giving a diagnostic
on malconfigured systems.
* src/id.c (print_user): Give a diagnostic if number->name lookup fails.
(print_group): Likewise.
2000-06-25 Jim Meyering <meyering@lucent.com>
* configure.in (ALL_LINGUAS): Add Danish (da).
2000-06-21 Jim Meyering <meyering@lucent.com>
* tests/stty/basic-1: New test for that.

View File

@@ -1,5 +1,20 @@
2000-06-29 Jim Meyering <meyering@lucent.com>
* src/tr.c (find_bracketed_repeat): Add a cast to suppress a warning.
Reported by Gerhard Poul.
* src/tail.c (enum): Remove comma from end of enumerator list.
From Gerhard Poul.
2000-06-25 Jim Meyering <meyering@lucent.com>
* configure.in (ALL_LINGUAS): Add Danish (da).
2000-06-24 Jim Meyering <meyering@lucent.com>
* doc/textutils.texi: Lots of minor rewording and grammar correction.
From Brian Youmans.
* tests/sum/basic-1: New file.
* tests/sum/Makefile.am: New file.
* configure.in (AC_OUTPUT): Add tests/md5sum/Makefile.

View File

@@ -288,18 +288,12 @@ change_dir_group (const char *dir, gid_t group, const struct stat *statp)
unsigned pathlength; /* Bytes allocated for `path'. */
int errors = 0;
errno = 0;
name_space = savedir (dir, statp->st_size);
if (name_space == NULL)
{
if (errno)
{
if (force_silent == 0)
error (0, errno, "%s", dir);
return 1;
}
else
error (1, 0, _("virtual memory exhausted"));
if (force_silent == 0)
error (0, errno, "%s", dir);
return 1;
}
dirlength = strlen (dir) + 1; /* + 1 is for the trailing '/'. */

View File

@@ -197,18 +197,12 @@ change_dir_mode (const char *dir, const struct mode_change *changes,
unsigned pathlength; /* Bytes allocated for `path'. */
int errors = 0;
errno = 0;
name_space = savedir (dir, statp->st_size);
if (name_space == NULL)
{
if (errno)
{
if (force_silent == 0)
error (0, errno, "%s", dir);
return 1;
}
else
error (1, 0, _("virtual memory exhausted"));
if (force_silent == 0)
error (0, errno, "%s", dir);
return 1;
}
dirlength = strlen (dir) + 1; /* + 1 is for the trailing '/'. */

View File

@@ -262,18 +262,12 @@ change_dir_owner (const char *dir, uid_t user, gid_t group,
unsigned pathlength; /* Bytes allocated for `path'. */
int errors = 0;
errno = 0;
name_space = savedir (dir, statp->st_size);
if (name_space == NULL)
{
if (errno)
{
if (force_silent == 0)
error (0, errno, "%s", dir);
return 1;
}
else
error (1, 0, _("virtual memory exhausted"));
if (force_silent == 0)
error (0, errno, "%s", dir);
return 1;
}
dirlength = strlen (dir) + 1; /* + 1 is for the trailing '/'. */

View File

@@ -114,17 +114,11 @@ copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
char *namep;
int ret = 0;
errno = 0;
name_space = savedir (src_path_in, src_sb->st_size);
if (name_space == 0)
if (name_space == NULL)
{
if (errno)
{
error (0, errno, "%s", src_path_in);
return -1;
}
else
error (1, 0, _("virtual memory exhausted"));
error (0, errno, "%s", src_path_in);
return -1;
}
namep = name_space;
@@ -373,6 +367,7 @@ copy_internal (const char *src_path, const char *dst_path,
int backup_succeeded = 0;
int fix_mode = 0;
int rename_errno;
int delayed_fail;
if (move_mode && rename_succeeded)
*rename_succeeded = 0;
@@ -692,6 +687,7 @@ copy_internal (const char *src_path, const char *dst_path,
}
}
delayed_fail = 0;
if (S_ISDIR (src_type))
{
struct dir_list *dir;
@@ -744,7 +740,12 @@ copy_internal (const char *src_path, const char *dst_path,
if (copy_dir (src_path, dst_path, new_dst, &src_sb, dir, x,
copy_into_self))
return 1;
{
/* Don't just return here -- otherwise, the failure to read a
single file in a source directory would cause the containing
destination directory not to have owner/perms set properly. */
delayed_fail = 1;
}
}
#ifdef S_ISLNK
else if (x->symbolic_link)
@@ -975,7 +976,7 @@ copy_internal (const char *src_path, const char *dst_path,
}
}
return 0;
return delayed_fail;
un_backup:
if (dst_backup)

View File

@@ -210,7 +210,8 @@ excluded_fstype (const char *fstype)
}
/* Like human_readable_inexact, except return "-" if the argument is -1,
and return the negative of N if NEGATIVE is 1. */
and if NEGATIVE is 1 then N represents a negative number, expressed
in two's complement. */
static char const *
df_readable (int negative, uintmax_t n, char *buf,
int from_block_size, int t_output_block_size,
@@ -356,29 +357,37 @@ show_dev (const char *disk, const char *mount_point, const char *fstype,
buf[2], input_units, output_units,
posix_format ? human_ceiling : human_floor));
if (used != -1 && available != -1)
if (used == -1 || available == -1)
;
else if (!negate_used
&& used <= TYPE_MAXIMUM (uintmax_t) / 100
&& used + available != 0
&& (used + available < used) == negate_available)
{
/* The following floating-point calculations can suffer from
minor rounding errors, but making them precise requires
uintmax_t u100 = used * 100;
uintmax_t nonroot_total = used + available;
pct = u100 / nonroot_total + (u100 % nonroot_total != 0);
}
else
{
/* The calculation cannot be done easily with integer
arithmetic. Fall back on floating point. This can suffer
from minor rounding errors, but doing it exactly requires
multiple precision arithmetic, and it's not worth the
aggravation. */
double u = used;
double a = available;
double nonroot_total = ((negate_used ? - u : u)
+ (negate_available ? - a : a));
double u = negate_used ? - (double) - used : used;
double a = negate_available ? - (double) - available : available;
double nonroot_total = u + a;
if (nonroot_total)
{
double ipct;
pct = u * 100 / nonroot_total;
ipct = (long) pct;
if (posix_format)
{
/* Like `pct = ceil (pct);', but avoid ceil so that
the math library needn't be linked. */
double ipct = (long) pct;
if (ipct - 1 < pct && pct <= ipct + 1)
pct = ipct + (ipct < pct);
}
/* Like `pct = ceil (dpct);', but avoid ceil so that
the math library needn't be linked. */
if (ipct - 1 < pct && pct <= ipct + 1)
pct = ipct + (ipct < pct);
}
}

View File

@@ -550,19 +550,13 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
return 0;
}
errno = 0;
name_space = savedir (".", stat_buf.st_size);
if (name_space == NULL)
{
if (errno)
{
error (0, errno, "%s", path->text);
pop_dir (cwd, path->text);
exit_status = 1;
return 0;
}
else
error (1, 0, _("virtual memory exhausted"));
error (0, errno, "%s", path->text);
pop_dir (cwd, path->text);
exit_status = 1;
return 0;
}
/* Remember the current path. */

View File

@@ -208,7 +208,10 @@ print_user (uid_t uid)
{
pwd = getpwuid (uid);
if (pwd == NULL)
problems++;
{
error (0, 0, _("cannot find name for user ID %u"), uid);
problems++;
}
}
if (pwd == NULL)
@@ -228,7 +231,10 @@ print_group (gid_t gid)
{
grp = getgrgid (gid);
if (grp == NULL)
problems++;
{
error (0, 0, _("cannot find name for group ID %u"), gid);
problems++;
}
}
if (grp == NULL)

View File

@@ -208,7 +208,7 @@ enum
MAX_CONSECUTIVE_SIZE_CHANGES_OPTION,
PID_OPTION,
LONG_FOLLOW_OPTION,
LONG_FOLLOW_OPTION
};
static struct option const long_options[] =

View File

@@ -879,7 +879,7 @@ find_bracketed_repeat (const struct E_string *es, size_t start_idx,
/* Here, we have found [c*s] where s should be a string
of octal (if it starts with `0') or decimal digits. */
{
const char *digit_str = &es->s[start_idx + 2];
const char *digit_str = (const char *) &es->s[start_idx + 2];
unsigned long int tmp_ulong;
char *d_end;
int base = 10;

View File

@@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = \
backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
same-file cp-mv-backup symlink-slash slink-2-slink
same-file cp-mv-backup symlink-slash slink-2-slink fail-perm
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
PATH=`pwd`/../../src:$$PATH

View File

@@ -118,7 +118,7 @@ AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = \
backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
same-file cp-mv-backup symlink-slash slink-2-slink
same-file cp-mv-backup symlink-slash slink-2-slink fail-perm
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \

43
tests/cp/fail-perm Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/sh
pwd=`pwd`
tmp=fail-perm.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap 'exit $?' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
mkdir D || framework_failure=1
touch D/a || framework_failure=1
chmod 0 D/a || framework_failure=1
chmod 500 D || framework_failure=1
touch file || framework_failure=1
chmod u-w file || framework_failure=1
(echo foo >> file) >/dev/null 2>&1 && {
echo '********************************************'
echo "$0: NOTICE: This test case cannot be run as root."
echo '********************************************'
exit 77
}
if test $framework_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
fail=0
# This is expected to exit non-zero, because it can't read D/a.
cp -pR D DD > /dev/null 2>&1 && fail=1
# Permissions on DD must be `dr-x------'
set X `ls -ld DD`
shift
test "$1" = dr-x------ || fail=1
chmod 700 D
(exit $fail); exit

View File

@@ -59,7 +59,6 @@ mv -fi c d < y >/dev/null 2>&1 || fail=1
# Before 4.0s, this would not prompt.
cp -if e f < y > out 2>&1 || fail=1
cp out /tmp
# Make sure out contains the prompt.
case "`cat out`" in

View File

@@ -4,4 +4,5 @@ AUTOMAKE_OPTIONS = 1.3 gnits
TESTS = dir-1 dangling-symlink empty-file fifo no-rights
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
host_triplet=$(host_triplet) \
PATH=`pwd`/../../src:$$PATH

View File

@@ -119,6 +119,7 @@ AUTOMAKE_OPTIONS = 1.3 gnits
TESTS = dir-1 dangling-symlink empty-file fifo no-rights
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
host_triplet=$(host_triplet) \
PATH=`pwd`/../../src:$$PATH
subdir = tests/touch

View File

@@ -17,4 +17,23 @@ touch t-symlink || fail=1
test -f touch-target || fail=1
rm -f touch-target t-symlink
if test $fail = 1; then
case $host_triplet in
*linux-gnu*)
case "`uname -r`" in
2.3.9[0-9]*)
cat 1>&2 <<EOF
====================================================
$0: WARNING!!!
This version of the Linux kernel causes touch to fail
when operating on dangling symlinks.
====================================================
EOF
exit 77
;;
esac
;;
esac
fi
exit $fail