Deleted Added
full compact
xinstall.c (21673) xinstall.c (21786)
1/*
2 * Copyright (c) 1987, 1993
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

--- 26 unchanged lines hidden (view full) ---

35static const char copyright[] =
36"@(#) Copyright (c) 1987, 1993\n\
37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41/*static char sccsid[] = "From: @(#)xinstall.c 8.1 (Berkeley) 7/21/93";*/
42static const char rcsid[] =
1/*
2 * Copyright (c) 1987, 1993
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

--- 26 unchanged lines hidden (view full) ---

35static const char copyright[] =
36"@(#) Copyright (c) 1987, 1993\n\
37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41/*static char sccsid[] = "From: @(#)xinstall.c 8.1 (Berkeley) 7/21/93";*/
42static const char rcsid[] =
43 "$FreeBSD: head/usr.bin/xinstall/xinstall.c 21673 1997-01-14 07:20:47Z jkh $";
43 "$FreeBSD: head/usr.bin/xinstall/xinstall.c 21786 1997-01-16 21:58:40Z alex $";
44#endif /* not lint */
45
46/*-
47 * Todo:
48 * o for -C, compare original files except in -s case.
49 * o for -C, don't change anything if nothing needs be changed. In
50 * particular, don't toggle the immutable flags just to allow null
51 * attribute changes and don't clear the dump flag. (I think inode

--- 456 unchanged lines hidden (view full) ---

508 if (from_sb->st_size != to_sb->st_size)
509 return 1;
510
511 tsize = (size_t)from_sb->st_size;
512
513 if (tsize <= 8 * 1024 * 1024) {
514 done_compare = 0;
515 if (trymmap(from_fd) && trymmap(to_fd)) {
44#endif /* not lint */
45
46/*-
47 * Todo:
48 * o for -C, compare original files except in -s case.
49 * o for -C, don't change anything if nothing needs be changed. In
50 * particular, don't toggle the immutable flags just to allow null
51 * attribute changes and don't clear the dump flag. (I think inode

--- 456 unchanged lines hidden (view full) ---

508 if (from_sb->st_size != to_sb->st_size)
509 return 1;
510
511 tsize = (size_t)from_sb->st_size;
512
513 if (tsize <= 8 * 1024 * 1024) {
514 done_compare = 0;
515 if (trymmap(from_fd) && trymmap(to_fd)) {
516 p = mmap(NULL, tsize, PROT_READ, 0, from_fd, (off_t)0);
517 if ((long)p == -1)
516 p = mmap(NULL, tsize, PROT_READ, MAP_SHARED, from_fd, (off_t)0);
517 if (p == (char *)MAP_FAILED)
518 goto out;
518 goto out;
519 q = mmap(NULL, tsize, PROT_READ, 0, to_fd, (off_t)0);
520 if ((long)q == -1) {
519 q = mmap(NULL, tsize, PROT_READ, MAP_SHARED, to_fd, (off_t)0);
520 if (q == (char *)MAP_FAILED) {
521 munmap(p, tsize);
522 goto out;
523 }
524
525 rv = memcmp(p, q, tsize);
526 munmap(p, tsize);
527 munmap(q, tsize);
528 done_compare = 1;

--- 47 unchanged lines hidden (view full) ---

576 /*
577 * Mmap and write if less than 8M (the limit is so we don't totally
578 * trash memory on big files. This is really a minor hack, but it
579 * wins some CPU back.
580 */
581 done_copy = 0;
582 if (size <= 8 * 1048576 && trymmap(from_fd)) {
583 if ((p = mmap(NULL, (size_t)size, PROT_READ,
521 munmap(p, tsize);
522 goto out;
523 }
524
525 rv = memcmp(p, q, tsize);
526 munmap(p, tsize);
527 munmap(q, tsize);
528 done_compare = 1;

--- 47 unchanged lines hidden (view full) ---

576 /*
577 * Mmap and write if less than 8M (the limit is so we don't totally
578 * trash memory on big files. This is really a minor hack, but it
579 * wins some CPU back.
580 */
581 done_copy = 0;
582 if (size <= 8 * 1048576 && trymmap(from_fd)) {
583 if ((p = mmap(NULL, (size_t)size, PROT_READ,
584 0, from_fd, (off_t)0)) == (char *)-1)
584 MAP_SHARED, from_fd, (off_t)0)) == (char *)MAP_FAILED)
585 goto out;
586 if ((nw = write(to_fd, p, size)) != size) {
587 serrno = errno;
588 (void)unlink(to_name);
589 errno = nw > 0 ? EIO : serrno;
590 err(EX_OSERR, "%s", to_name);
591 }
592 done_copy = 1;

--- 114 unchanged lines hidden ---
585 goto out;
586 if ((nw = write(to_fd, p, size)) != size) {
587 serrno = errno;
588 (void)unlink(to_name);
589 errno = nw > 0 ? EIO : serrno;
590 err(EX_OSERR, "%s", to_name);
591 }
592 done_copy = 1;

--- 114 unchanged lines hidden ---