sendfile.c (256281) | sendfile.c (281974) |
---|---|
1/*- 2 * Copyright (c) 2006 Robert N. M. Watson 3 * 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2006 Robert N. M. Watson 3 * 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: stable/10/tools/regression/sockets/sendfile/sendfile.c 255451 2013-09-10 13:51:19Z emaste $ | 26 * $FreeBSD: stable/10/tools/regression/sockets/sendfile/sendfile.c 281974 2015-04-25 05:31:52Z ngie $ |
27 */ 28 29#include <sys/types.h> 30#include <sys/socket.h> 31#include <sys/stat.h> 32#include <sys/wait.h> 33 34#include <netinet/in.h> --- 412 unchanged lines hidden (view full) --- 447 printf("not ok %d\n", test_num); 448 } 449 } 450} 451 452static void 453cleanup(void) 454{ | 27 */ 28 29#include <sys/types.h> 30#include <sys/socket.h> 31#include <sys/stat.h> 32#include <sys/wait.h> 33 34#include <netinet/in.h> --- 412 unchanged lines hidden (view full) --- 447 printf("not ok %d\n", test_num); 448 } 449 } 450} 451 452static void 453cleanup(void) 454{ |
455 if (*path != '\0') 456 unlink(path); | 455 456 unlink(path); |
457} 458 459int 460main(int argc, char *argv[]) 461{ 462 int pagesize; 463 | 457} 458 459int 460main(int argc, char *argv[]) 461{ 462 int pagesize; 463 |
464 *path = '\0'; | 464 path[0] = '\0'; |
465 466 pagesize = getpagesize(); 467 468 if (argc == 1) { | 465 466 pagesize = getpagesize(); 467 468 if (argc == 1) { |
469 snprintf(path, PATH_MAX, "/tmp/sendfile.XXXXXXXXXXXX"); | 469 snprintf(path, sizeof(path), "sendfile.XXXXXXXXXXXX"); |
470 file_fd = mkstemp(path); 471 if (file_fd == -1) 472 FAIL_ERR("mkstemp"); 473 } else if (argc == 2) { 474 (void)strlcpy(path, argv[1], sizeof(path)); 475 file_fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0600); 476 if (file_fd == -1) 477 FAIL_ERR("open"); 478 } else { 479 FAIL("usage: sendfile [path]"); 480 } 481 482 atexit(cleanup); 483 484 run_parent(); 485 return (0); 486} | 470 file_fd = mkstemp(path); 471 if (file_fd == -1) 472 FAIL_ERR("mkstemp"); 473 } else if (argc == 2) { 474 (void)strlcpy(path, argv[1], sizeof(path)); 475 file_fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0600); 476 if (file_fd == -1) 477 FAIL_ERR("open"); 478 } else { 479 FAIL("usage: sendfile [path]"); 480 } 481 482 atexit(cleanup); 483 484 run_parent(); 485 return (0); 486} |