ipmgmt_util.c revision 9b5bf10ab04b9be5564d70a57980cfb68b6372e7
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * CDDL HEADER START
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * The contents of this file are subject to the terms of the
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Common Development and Distribution License (the "License").
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * You may not use this file except in compliance with the License.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * See the License for the specific language governing permissions
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * and limitations under the License.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * When distributing Covered Code, include this CDDL HEADER in each
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * If applicable, add the following below this CDDL HEADER, with the
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * fields enclosed by brackets "[]" replaced with your own identifying
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * information: Portions Copyright [yyyy] [name of copyright owner]
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * CDDL HEADER END
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Utility functions used by the ipmgmtd daemon.
4201a95e0468170d576f82c3aa63afecf718497aRic Aleshire * Copy a source file to a new destination. The source file will be
4201a95e0468170d576f82c3aa63afecf718497aRic Aleshire * removed if rdonly is false (i.e., used when the source file resides
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * on a read-only file system).
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Returns 0 on success and errno on failure.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpkipmgmt_cpfile(const char *src, const char *dst, boolean_t rdonly)
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Attempt to open the destination file first since we
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * want to optimize for the case where it is read-only
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * and will return EROFS.
return (err);
return (err);
(errno == 0)) {
if (errno != 0)
if (errno != 0)
if (err != 0) {
return (err);
return (err);
if (!rdonly)