1 diff -Nur coreutils-4.5.3.orig/doc/coreutils.texi coreutils-4.5.3/doc/coreutils.texi
2 --- coreutils-4.5.3.orig/doc/coreutils.texi Sun Oct 27 22:19:34 2002
3 +++ coreutils-4.5.3/doc/coreutils.texi Sun Oct 27 22:48:17 2002
6 Make a backup of each file that would otherwise be overwritten or removed.
10 +Install file, unless target already exists and is the same file, in which
11 +case the modification time is not changed.
15 Ignored; for compatibility with old Unix versions of @command{install}.
16 diff -Nur coreutils-4.5.3.orig/src/install.c coreutils-4.5.3/src/install.c
17 --- coreutils-4.5.3.orig/src/install.c Thu Sep 26 10:39:20 2002
18 +++ coreutils-4.5.3/src/install.c Sun Oct 27 22:48:17 2002
22 #include <sys/types.h>
23 +#include <sys/mman.h>
29 static mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
31 +/* Compare files before installing (-C) */
32 +static int docompare=0;
34 /* If nonzero, strip executable files after copying them. */
35 static int strip_files;
41 +int compare (const char *file, const char *to)
47 + struct stat file_s, to_s;
50 + stat(file, &file_s);
53 + if (file_s.st_size != to_s.st_size)
56 + file_fd = open(file, O_RDONLY);
60 + to_fd = open(to, O_RDONLY);
67 + size = (size_t) file_s.st_size;
68 + if (size <= 4194309) /* Don't try to mmap() files > 4 MB */
70 + p = mmap(NULL, size, PROT_READ, MAP_SHARED, file_fd, (off_t) 0);
71 + if (p != MAP_FAILED)
73 + q = mmap(NULL, size, PROT_READ, MAP_SHARED, to_fd, (off_t) 0);
74 + if (q == MAP_FAILED)
80 + ret = (memcmp(p, q, size)==0) ? 0 : 1;
89 + char buf1[65536], buf2[65536];
92 + lseek(file_fd, 0, SEEK_SET);
93 + lseek(to_fd, 0, SEEK_SET);
96 + n1 = read(file_fd, buf1, sizeof(buf1));
101 + n2 = read(to_fd, buf2, n1);
103 + ret = memcmp(buf1, buf2, n1);
105 + ret = 1; /* ouf of sync */
108 + ret = 1; /* read failure */
118 cp_option_init (struct cp_options *x)
121 we'll actually use backup_suffix_string. */
122 backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
124 - while ((optc = getopt_long (argc, argv, "bcsDdg:m:o:pvV:S:", long_options,
125 + while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pvV:S:", long_options,
145 + if(compare(from, to)==0) /* Files are identical */
149 fail = copy (from, to, nonexistent_dst, x, ©_into_self, NULL);
153 --backup[=CONTROL] make a backup of each existing destination file\n\
154 -b like --backup but does not accept an argument\n\
156 + -C Install file, unless the target already exists and is the same,\n\
157 + in which case the modification time won't be changed.\n\
158 + For compatibility with *BSD.\n\
159 -d, --directory treat all arguments as directory names; create all\n\
160 components of the specified directories\n\