-p option should preserve file flags as well
[unix-history] / usr / src / bin / cp / utils.c
index 661c257..3aeea74 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)utils.c    5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)utils.c    5.5 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -77,8 +77,8 @@ copy_file(entp, dne)
         * wins some CPU back.
         */
        if (fs->st_size <= 8 * 1048576) {
         * wins some CPU back.
         */
        if (fs->st_size <= 8 * 1048576) {
-               if ((p = mmap(NULL, fs->st_size, PROT_READ,
-                   MAP_FILE, from_fd, (off_t)0)) == (char *)-1)
+               if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ,
+                   0, from_fd, (off_t)0)) == (char *)-1)
                        err("%s: %s", entp->fts_path, strerror(errno));
                if (write(to_fd, p, fs->st_size) != fs->st_size)
                        err("%s: %s", to.p_path, strerror(errno));
                        err("%s: %s", entp->fts_path, strerror(errno));
                if (write(to_fd, p, fs->st_size) != fs->st_size)
                        err("%s: %s", to.p_path, strerror(errno));
@@ -196,6 +196,9 @@ setfile(fs, fd)
        }
        if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode))
                err("chown: %s: %s", to.p_path, strerror(errno));
        }
        if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode))
                err("chown: %s: %s", to.p_path, strerror(errno));
+
+       if (fd ? fchflags(fd, fs->st_flags) : chflags(to.p_path, fs->st_flags))
+               err("chflags: %s: %s", to.p_path, strerror(errno));
 }
 
 void
 }
 
 void