ipmgmt_util.c revision 9b5bf10ab04b9be5564d70a57980cfb68b6372e7
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* Utility functions used by the ipmgmtd daemon.
*/
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <syslog.h>
#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
#include "ipmgmt_impl.h"
#define IPMGMT_BUFSIZ 1024
void
{
}
/*
* Copy a source file to a new destination. The source file will be
* removed if rdonly is false (i.e., used when the source file resides
* on a read-only file system).
*
* Returns 0 on success and errno on failure.
*/
int
{
char buf[IPMGMT_BUFSIZ];
int err = 0;
/*
* Attempt to open the destination file first since we
* want to optimize for the case where it is read-only
* and will return EROFS.
*/
return (errno);
/*
* Require that the source file exists.
*/
return (err);
}
return (err);
}
/*
* Copy the file.
*/
(errno == 0)) {
if (errno != 0)
break;
}
if (errno != 0)
/*
* If any error occurred, then remove the destination file.
*/
if (err != 0) {
return (err);
}
/*
* Make sure the file attributes are correct.
*/
return (err);
}
/*
* If the source file does not reside on a read-only file system
* then remove it.
*/
if (!rdonly)
return (0);
}