Changeset 3192 for trunk/src/kmk/kmkbuiltin/cp_utils.c
- Timestamp:
- Mar 26, 2018, 10:25:56 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/cp_utils.c
r3148 r3192 87 87 88 88 int 89 copy_file( const FTSENT *entp, int dne, int changed_only, int *pcopied)89 copy_file(PKMKBUILTINCTX pCtx, const FTSENT *entp, int dne, int changed_only, int *pcopied) 90 90 { 91 91 static char buf[MAXBSIZE]; … … 103 103 104 104 if ((from_fd = open(entp->fts_path, O_RDONLY | O_BINARY, 0)) == -1) { 105 warn( "open: %s", entp->fts_path);105 warn(pCtx, "open: %s", entp->fts_path); 106 106 return (1); 107 107 } … … 120 120 /* compare the files first if requested */ 121 121 if (changed_only) { 122 if (cmp_fd_and_file( from_fd, entp->fts_path, to.p_path,122 if (cmp_fd_and_file(pCtx, from_fd, entp->fts_path, to.p_path, 123 123 1 /* silent */, 0 /* lflag */, 124 124 0 /* special */) == OK_EXIT) { … … 129 129 close(from_fd); 130 130 if ((from_fd = open(entp->fts_path, O_RDONLY | O_BINARY, 0)) == -1) { 131 warn( "open: %s", entp->fts_path);131 warn(pCtx, "open: %s", entp->fts_path); 132 132 return (1); 133 133 } … … 138 138 if (nflag) { 139 139 if (vflag) 140 printf("%s not overwritten\n", to.p_path);140 kmk_builtin_ctx_printf(pCtx, 0, "%s not overwritten\n", to.p_path); 141 141 return (0); 142 142 } else if (iflag) { … … 148 148 if (checkch != 'y' && checkch != 'Y') { 149 149 (void)close(from_fd); 150 (void)fprintf(stderr, "not overwritten\n");150 kmk_builtin_ctx_printf(pCtx, 1, "not overwritten\n"); 151 151 return (1); 152 152 } … … 167 167 168 168 if (to_fd == -1) { 169 warn( "open: %s", to.p_path);169 warn(pCtx, "open: %s", to.p_path); 170 170 (void)close(from_fd); 171 171 return (1); … … 185 185 if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ, 186 186 MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) { 187 warn( "mmap: %s", entp->fts_path);187 warn(pCtx, "mmap: %s", entp->fts_path); 188 188 rval = 1; 189 189 } else { … … 195 195 if (info) { 196 196 info = 0; 197 (void)fprintf(stderr,197 kmk_builtin_ctx_printf(pCtx, 1, 198 198 "%s -> %s %3d%%\n", 199 199 entp->fts_path, to.p_path, … … 205 205 } 206 206 if (wcount != (ssize_t)wresid) { 207 warn( "write[%zd != %zu]: %s", wcount, wresid, to.p_path);207 warn(pCtx, "write[%zd != %zu]: %s", wcount, wresid, to.p_path); 208 208 rval = 1; 209 209 } 210 210 /* Some systems don't unmap on close(2). */ 211 211 if (munmap(p, fs->st_size) < 0) { 212 warn( "munmap: %s", entp->fts_path);212 warn(pCtx, "munmap: %s", entp->fts_path); 213 213 rval = 1; 214 214 } … … 225 225 if (info) { 226 226 info = 0; 227 (void)fprintf(stderr,227 kmk_builtin_ctx_printf(pCtx, 1, 228 228 "%s -> %s %3d%%\n", 229 229 entp->fts_path, to.p_path, … … 235 235 } 236 236 if (wcount != (ssize_t)wresid) { 237 warn( "write[%zd != %zu]: %s", wcount, wresid, to.p_path);237 warn(pCtx, "write[%zd != %zu]: %s", wcount, wresid, to.p_path); 238 238 rval = 1; 239 239 break; … … 241 241 } 242 242 if (rcount < 0) { 243 warn( "read: %s", entp->fts_path);243 warn(pCtx, "read: %s", entp->fts_path); 244 244 rval = 1; 245 245 } … … 253 253 */ 254 254 255 if (pflag && setfile( fs, to_fd))255 if (pflag && setfile(pCtx, fs, to_fd)) 256 256 rval = 1; 257 257 (void)close(from_fd); 258 258 if (close(to_fd)) { 259 warn( "close: %s", to.p_path);259 warn(pCtx, "close: %s", to.p_path); 260 260 rval = 1; 261 261 } … … 264 264 265 265 int 266 copy_link( const FTSENT *p, int exists)266 copy_link(PKMKBUILTINCTX pCtx, const FTSENT *p, int exists) 267 267 { 268 268 int len; … … 270 270 271 271 if ((len = readlink(p->fts_path, llink, sizeof(llink) - 1)) == -1) { 272 warn( "readlink: %s", p->fts_path);272 warn(pCtx, "readlink: %s", p->fts_path); 273 273 return (1); 274 274 } 275 275 llink[len] = '\0'; 276 276 if (exists && unlink(to.p_path)) { 277 warn( "unlink: %s", to.p_path);277 warn(pCtx, "unlink: %s", to.p_path); 278 278 return (1); 279 279 } 280 280 if (symlink(llink, to.p_path)) { 281 warn( "symlink: %s", llink);282 return (1); 283 } 284 return (pflag ? setfile(p ->fts_statp, -1) : 0);285 } 286 287 int 288 copy_fifo( struct stat *from_stat, int exists)281 warn(pCtx, "symlink: %s", llink); 282 return (1); 283 } 284 return (pflag ? setfile(pCtx, p->fts_statp, -1) : 0); 285 } 286 287 int 288 copy_fifo(PKMKBUILTINCTX pCtx, struct stat *from_stat, int exists) 289 289 { 290 290 if (exists && unlink(to.p_path)) { 291 warn( "unlink: %s", to.p_path);291 warn(pCtx, "unlink: %s", to.p_path); 292 292 return (1); 293 293 } 294 294 if (mkfifo(to.p_path, from_stat->st_mode)) { 295 warn( "mkfifo: %s", to.p_path);296 return (1); 297 } 298 return (pflag ? setfile( from_stat, -1) : 0);299 } 300 301 int 302 copy_special( struct stat *from_stat, int exists)295 warn(pCtx, "mkfifo: %s", to.p_path); 296 return (1); 297 } 298 return (pflag ? setfile(pCtx, from_stat, -1) : 0); 299 } 300 301 int 302 copy_special(PKMKBUILTINCTX pCtx, struct stat *from_stat, int exists) 303 303 { 304 304 if (exists && unlink(to.p_path)) { 305 warn( "unlink: %s", to.p_path);305 warn(pCtx, "unlink: %s", to.p_path); 306 306 return (1); 307 307 } 308 308 if (mknod(to.p_path, from_stat->st_mode, from_stat->st_rdev)) { 309 warn( "mknod: %s", to.p_path);310 return (1); 311 } 312 return (pflag ? setfile( from_stat, -1) : 0);313 } 314 315 int 316 setfile( struct stat *fs, int fd)309 warn(pCtx, "mknod: %s", to.p_path); 310 return (1); 311 } 312 return (pflag ? setfile(pCtx, from_stat, -1) : 0); 313 } 314 315 int 316 setfile(PKMKBUILTINCTX pCtx, struct stat *fs, int fd) 317 317 { 318 318 static struct timeval tv[2]; … … 335 335 #endif 336 336 if (islink ? lutimes(to.p_path, tv) : utimes(to.p_path, tv)) { 337 warn( "%sutimes: %s", islink ? "l" : "", to.p_path);337 warn(pCtx, "%sutimes: %s", islink ? "l" : "", to.p_path); 338 338 rval = 1; 339 339 } … … 357 357 chown(to.p_path, fs->st_uid, fs->st_gid))) { 358 358 if (errno != EPERM) { 359 warn( "chown: %s", to.p_path);359 warn(pCtx, "chown: %s", to.p_path); 360 360 rval = 1; 361 361 } … … 367 367 (islink ? lchmod(to.p_path, fs->st_mode) : 368 368 chmod(to.p_path, fs->st_mode))) { 369 warn( "chmod: %s", to.p_path);369 warn(pCtx, "chmod: %s", to.p_path); 370 370 rval = 1; 371 371 } … … 377 377 (islink ? (errno = ENOSYS) : 378 378 chflags(to.p_path, fs->st_flags))) { 379 warn( "chflags: %s", to.p_path);379 warn(pCtx, "chflags: %s", to.p_path); 380 380 rval = 1; 381 381 }
Note:
See TracChangeset
for help on using the changeset viewer.