From owner-svn-src-head@FreeBSD.ORG Tue Dec 3 03:40:47 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BE713AD8; Tue, 3 Dec 2013 03:40:47 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9078B11A4; Tue, 3 Dec 2013 03:40:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rB33elE0032963; Tue, 3 Dec 2013 03:40:47 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rB33elU2032962; Tue, 3 Dec 2013 03:40:47 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201312030340.rB33elU2032962@svn.freebsd.org> From: Mark Johnston Date: Tue, 3 Dec 2013 03:40:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r258861 - head/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Dec 2013 03:40:47 -0000 Author: markj Date: Tue Dec 3 03:40:47 2013 New Revision: 258861 URL: http://svnweb.freebsd.org/changeset/base/258861 Log: Use mkstemp(3) to create the temporary file used in the FreeBSD-specific portions of dtrace_program_link(). Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Tue Dec 3 01:21:21 2013 (r258860) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Tue Dec 3 03:40:47 2013 (r258861) @@ -1709,8 +1709,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, d */ return (0); } - /* XXX Should get a temp file name here. */ - snprintf(tfile, sizeof(tfile), "%s.tmp", file); #endif /* @@ -1785,9 +1783,11 @@ dtrace_program_link(dtrace_hdl_t *dtp, d "failed to open %s: %s", file, strerror(errno))); } #else - if ((fd = open(tfile, O_RDWR | O_CREAT | O_TRUNC, 0666)) == -1) + snprintf(tfile, sizeof(tfile), "%s.XXXXXX", file); + if ((fd = mkstemp(tfile)) == -1) return (dt_link_error(dtp, NULL, -1, NULL, - "failed to open %s: %s", tfile, strerror(errno))); + "failed to create temporary file %s: %s", + tfile, strerror(errno))); #endif /* @@ -1830,13 +1830,15 @@ dtrace_program_link(dtrace_hdl_t *dtp, d status = dump_elf32(dtp, dof, fd); if (status != 0 || lseek(fd, 0, SEEK_SET) != 0) { -#else - /* We don't write the ELF header, just the DOF section */ - if (dt_write(dtp, fd, dof, dof->dofh_filesz) < dof->dofh_filesz) { -#endif return (dt_link_error(dtp, NULL, -1, NULL, "failed to write %s: %s", file, strerror(errno))); } +#else + /* We don't write the ELF header, just the DOF section */ + if (dt_write(dtp, fd, dof, dof->dofh_filesz) < dof->dofh_filesz) + return (dt_link_error(dtp, NULL, -1, NULL, + "failed to write %s: %s", tfile, strerror(errno))); +#endif if (!dtp->dt_lazyload) { #if defined(sun)