11.2Schristos/* $NetBSD: compat_utime.c,v 1.2 2009/01/11 02:46:25 christos Exp $ */ 21.2Schristos 31.2Schristos/*- 41.2Schristos * Copyright (c) 1990, 1993 51.2Schristos * The Regents of the University of California. All rights reserved. 61.2Schristos * 71.2Schristos * Redistribution and use in source and binary forms, with or without 81.2Schristos * modification, are permitted provided that the following conditions 91.2Schristos * are met: 101.2Schristos * 1. Redistributions of source code must retain the above copyright 111.2Schristos * notice, this list of conditions and the following disclaimer. 121.2Schristos * 2. Redistributions in binary form must reproduce the above copyright 131.2Schristos * notice, this list of conditions and the following disclaimer in the 141.2Schristos * documentation and/or other materials provided with the distribution. 151.2Schristos * 3. Neither the name of the University nor the names of its contributors 161.2Schristos * may be used to endorse or promote products derived from this software 171.2Schristos * without specific prior written permission. 181.2Schristos * 191.2Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 201.2Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 211.2Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 221.2Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 231.2Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 241.2Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 251.2Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 261.2Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 271.2Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 281.2Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 291.2Schristos * SUCH DAMAGE. 301.2Schristos */ 311.2Schristos 321.2Schristos#include <sys/cdefs.h> 331.2Schristos#if defined(LIBC_SCCS) && !defined(lint) 341.2Schristos#if 0 351.2Schristosstatic char sccsid[] = "@(#)utime.c 8.1 (Berkeley) 6/4/93"; 361.2Schristos#else 371.2Schristos__RCSID("$NetBSD: compat_utime.c,v 1.2 2009/01/11 02:46:25 christos Exp $"); 381.2Schristos#endif 391.2Schristos#endif /* LIBC_SCCS and not lint */ 401.2Schristos 411.2Schristos 421.2Schristos#define __LIBC12_SOURCE__ 431.2Schristos 441.2Schristos#include "namespace.h" 451.2Schristos#include <assert.h> 461.2Schristos#include <errno.h> 471.2Schristos#include <stddef.h> 481.2Schristos#include <stdint.h> 491.2Schristos#include <utime.h> 501.2Schristos#include <compat/include/utime.h> 511.2Schristos#include <sys/time.h> 521.2Schristos#include <compat/sys/time.h> 531.2Schristos 541.2Schristos__warn_references(utime, 551.2Schristos "warning: reference to compatibility utime(); include <utime.h> to generate correct reference") 561.2Schristos 571.2Schristos#ifdef __weak_alias 581.2Schristos__weak_alias(utime, _utime) 591.2Schristos#endif 601.2Schristos 611.2Schristosint 621.2Schristosutime(const char *path, const struct utimbuf50 *times50) 631.2Schristos{ 641.2Schristos struct timeval tv[2], *tvp; 651.2Schristos 661.2Schristos _DIAGASSERT(path != NULL); 671.2Schristos 681.2Schristos if (times50 == NULL) 691.2Schristos tvp = NULL; 701.2Schristos else { 711.2Schristos tv[0].tv_sec = times50->actime; 721.2Schristos tv[1].tv_sec = times50->modtime; 731.2Schristos tv[0].tv_usec = tv[1].tv_usec = 0; 741.2Schristos tvp = tv; 751.2Schristos } 761.2Schristos return __utimes50(path, tvp); 771.2Schristos} 78