utils.c (100538) | utils.c (101093) |
---|---|
1/*- 2 * Copyright (c) 1991, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94"; 37#endif 38#endif /* not lint */ 39#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1991, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94"; 37#endif 38#endif /* not lint */ 39#include <sys/cdefs.h> |
40__FBSDID("$FreeBSD: head/bin/cp/utils.c 100538 2002-07-23 00:42:56Z johan $"); | 40__FBSDID("$FreeBSD: head/bin/cp/utils.c 101093 2002-07-31 16:52:16Z markm $"); |
41 42#include <sys/param.h> 43#include <sys/stat.h> 44#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED 45#include <sys/mman.h> 46#endif 47 48#include <err.h> --- 86 unchanged lines hidden (view full) --- 135 if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ, 136 MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) { 137 warn("%s", entp->fts_path); 138 rval = 1; 139 } else { 140 for (bufp = p, wresid = fs->st_size; ; 141 bufp += wcount, wresid -= (size_t)wcount) { 142 wcount = write(to_fd, bufp, wresid); | 41 42#include <sys/param.h> 43#include <sys/stat.h> 44#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED 45#include <sys/mman.h> 46#endif 47 48#include <err.h> --- 86 unchanged lines hidden (view full) --- 135 if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ, 136 MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) { 137 warn("%s", entp->fts_path); 138 rval = 1; 139 } else { 140 for (bufp = p, wresid = fs->st_size; ; 141 bufp += wcount, wresid -= (size_t)wcount) { 142 wcount = write(to_fd, bufp, wresid); |
143 if (wcount >= wresid || wcount <= 0) | 143 if (wcount >= (ssize_t)wresid || wcount <= 0) |
144 break; 145 } | 144 break; 145 } |
146 if (wcount != wresid) { | 146 if (wcount != (ssize_t)wresid) { |
147 warn("%s", to.p_path); 148 rval = 1; 149 } 150 /* Some systems don't unmap on close(2). */ 151 if (munmap(p, fs->st_size) < 0) { 152 warn("%s", entp->fts_path); 153 rval = 1; 154 } 155 } 156 } else 157#endif 158 { 159 while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) { 160 for (bufp = buf, wresid = rcount; ; 161 bufp += wcount, wresid -= wcount) { 162 wcount = write(to_fd, bufp, wresid); | 147 warn("%s", to.p_path); 148 rval = 1; 149 } 150 /* Some systems don't unmap on close(2). */ 151 if (munmap(p, fs->st_size) < 0) { 152 warn("%s", entp->fts_path); 153 rval = 1; 154 } 155 } 156 } else 157#endif 158 { 159 while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) { 160 for (bufp = buf, wresid = rcount; ; 161 bufp += wcount, wresid -= wcount) { 162 wcount = write(to_fd, bufp, wresid); |
163 if (wcount >= wresid || wcount <= 0) | 163 if (wcount >= (ssize_t)wresid || wcount <= 0) |
164 break; 165 } | 164 break; 165 } |
166 if (wcount != wresid) { | 166 if (wcount != (ssize_t)wresid) { |
167 warn("%s", to.p_path); 168 rval = 1; 169 break; 170 } 171 } 172 if (rcount < 0) { 173 warn("%s", entp->fts_path); 174 rval = 1; --- 136 unchanged lines hidden --- | 167 warn("%s", to.p_path); 168 rval = 1; 169 break; 170 } 171 } 172 if (rcount < 0) { 173 warn("%s", entp->fts_path); 174 rval = 1; --- 136 unchanged lines hidden --- |