From ae6c4c84212f196efc9e65f5f6de9beb226f78dc Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 4 Jul 2002 22:51:08 +0000 Subject: [PATCH] 2002-07-04 Jeff Johnston * libc/include/utime.h: Add include of <_ansi.h>. * libc/sys/linux/Makefile.am: Add utimes.c. * libc/sys/linux/Makefile.in: Regenerated. * libc/sys/linux/inode.c(__umask): New static routine. (umask): Written to use __umask and attempt to thread lock. (getumask): New function written to use __umask and thread lock. * libc/sys/linux/utimes.c: New file. * libc/sys/linux/sys/time.h: Fix utimes prototype. * libc/sys/linux/sys/utime.h: New file. --- newlib/ChangeLog | 12 +++++++++ newlib/libc/include/utime.h | 2 ++ newlib/libc/sys/linux/Makefile.am | 1 + newlib/libc/sys/linux/Makefile.in | 8 +++--- newlib/libc/sys/linux/inode.c | 43 +++++++++++++++++++++++++++++- newlib/libc/sys/linux/sys/time.h | 2 +- newlib/libc/sys/linux/sys/utime.h | 14 ++++++++++ newlib/libc/sys/linux/utimes.c | 44 +++++++++++++++++++++++++++++++ 8 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 newlib/libc/sys/linux/sys/utime.h create mode 100644 newlib/libc/sys/linux/utimes.c diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 597203a36..b6f822383 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,15 @@ +2002-07-04 Jeff Johnston + + * libc/include/utime.h: Add include of <_ansi.h>. + * libc/sys/linux/Makefile.am: Add utimes.c. + * libc/sys/linux/Makefile.in: Regenerated. + * libc/sys/linux/inode.c(__umask): New static routine. + (umask): Written to use __umask and attempt to thread lock. + (getumask): New function written to use __umask and thread lock. + * libc/sys/linux/utimes.c: New file. + * libc/sys/linux/sys/time.h: Fix utimes prototype. + * libc/sys/linux/sys/utime.h: New file. + 2002-07-04 Thomas Fitzsimmons * libtool.m4: New file. diff --git a/newlib/libc/include/utime.h b/newlib/libc/include/utime.h index c05e08e94..652891aab 100644 --- a/newlib/libc/include/utime.h +++ b/newlib/libc/include/utime.h @@ -2,6 +2,8 @@ extern "C" { #endif +#include <_ansi.h> + /* The utime function is defined in libc/sys//sys if it exists. */ #include diff --git a/newlib/libc/sys/linux/Makefile.am b/newlib/libc/sys/linux/Makefile.am index 6f05fc881..6c06ff621 100644 --- a/newlib/libc/sys/linux/Makefile.am +++ b/newlib/libc/sys/linux/Makefile.am @@ -76,6 +76,7 @@ LIB_SOURCES = \ termios.c \ time.c \ usleep.c \ + utimes.c \ wait.c # This will handle both /usr/src/linux-2.4/include/asm/signal.h (in Red Hat Linux 7.1) diff --git a/newlib/libc/sys/linux/Makefile.in b/newlib/libc/sys/linux/Makefile.in index 37b2bd2fd..d7de4d600 100644 --- a/newlib/libc/sys/linux/Makefile.in +++ b/newlib/libc/sys/linux/Makefile.in @@ -173,6 +173,7 @@ LIB_SOURCES = \ termios.c \ time.c \ usleep.c \ + utimes.c \ wait.c @@ -237,7 +238,7 @@ LIBS = @LIBS@ @USE_LIBTOOL_FALSE@sysconf.$(OBJEXT) sysctl.$(OBJEXT) systat.$(OBJEXT) \ @USE_LIBTOOL_FALSE@system.$(OBJEXT) tcdrain.$(OBJEXT) \ @USE_LIBTOOL_FALSE@tcsendbrk.$(OBJEXT) termios.$(OBJEXT) time.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@usleep.$(OBJEXT) wait.$(OBJEXT) +@USE_LIBTOOL_FALSE@usleep.$(OBJEXT) utimes.$(OBJEXT) wait.$(OBJEXT) LTLIBRARIES = $(noinst_LTLIBRARIES) @USE_LIBTOOL_TRUE@liblinux_la_OBJECTS = aio.lo brk.lo cfspeed.lo \ @@ -256,7 +257,7 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) @USE_LIBTOOL_TRUE@sigset.lo sigwait.lo socket.lo sleep.lo stack.lo \ @USE_LIBTOOL_TRUE@strsignal.lo sysconf.lo sysctl.lo systat.lo system.lo \ @USE_LIBTOOL_TRUE@tcdrain.lo tcsendbrk.lo termios.lo time.lo usleep.lo \ -@USE_LIBTOOL_TRUE@wait.lo +@USE_LIBTOOL_TRUE@utimes.lo wait.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -285,8 +286,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in \ - ../../../acinclude.m4 ../../../aclocal.m4 \ - ../../../libtool.m4 + ../../../acinclude.m4 ../../../aclocal.m4 cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) diff --git a/newlib/libc/sys/linux/inode.c b/newlib/libc/sys/linux/inode.c index f6d89469c..e2f4ab16e 100644 --- a/newlib/libc/sys/linux/inode.c +++ b/newlib/libc/sys/linux/inode.c @@ -9,8 +9,12 @@ #include #include #include +#include #include +__LOCK_INIT(static, umask_lock); + +#define __NR___umask __NR_umask _syscall2(int,link,const char *,oldpath,const char *,newpath) _syscall1(int,unlink,const char *,pathname) @@ -22,7 +26,6 @@ _syscall2(int,access,const char *,filename,int,mode) _syscall2(int,mkdir,const char *,pathname,mode_t,mode) _syscall1(int,rmdir,const char *,pathname) _syscall1(int,pipe,int *,filedes) -_syscall1(mode_t,umask,mode_t,mask) _syscall1(int,chroot,const char *,path) _syscall2(int,symlink,const char *,oldpath,const char *,newpath) _syscall3(int,readlink,const char *,path,char *,buf,size_t,bufsiz) @@ -30,3 +33,41 @@ _syscall2(int,stat,const char *,file_name,struct stat *,buf) _syscall2(int,lstat,const char *,file_name,struct stat *,buf) _syscall2(int,fstat,int,filedes,struct stat *,buf) _syscall3(int,getdents,int,fd,struct dirent *,dirp,unsigned int,count) +_syscall1(mode_t,__umask,mode_t,mask) + +static _syscall3(int,fchown32,int,fd,uid_t,owner,gid_t,group) + +int +fchown (int fd, uid_t owner, gid_t group) +{ + return __libc_fchown32 (fd, owner, group); +} + +mode_t +umask (mode_t mask) +{ + mode_t old_mask; + + /* we need to lock so as to not interfere with getumask */ + __lock_acquire(umask_lock); + old_mask = __umask (mask); + __lock_release(umask_lock); + + return old_mask; +} + +mode_t +getumask (void) +{ + mode_t mask; + + __lock_acquire(umask_lock); + + mask = __umask (0); + mask = __umask (mask); + + __lock_release(umask_lock); + + return mask; +} + diff --git a/newlib/libc/sys/linux/sys/time.h b/newlib/libc/sys/linux/sys/time.h index d18076477..f2c656e5a 100644 --- a/newlib/libc/sys/linux/sys/time.h +++ b/newlib/libc/sys/linux/sys/time.h @@ -87,7 +87,7 @@ int _EXFUN(gettimeofday, (struct timeval *__p, struct timezone *__z)); int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *)); -int _EXFUN(utimes, (const char *__path, struct timeval *__tvp)); +int _EXFUN(utimes, (const char *__path, const struct timeval __tvp[2])); int _EXFUN(getitimer, (int __which, struct itimerval *__value)); int _EXFUN(setitimer, (int __which, const struct itimerval *__value, struct itimerval *__ovalue)); diff --git a/newlib/libc/sys/linux/sys/utime.h b/newlib/libc/sys/linux/sys/utime.h new file mode 100644 index 000000000..7499cfe7e --- /dev/null +++ b/newlib/libc/sys/linux/sys/utime.h @@ -0,0 +1,14 @@ +#ifndef _SYS_UTIME_H +#define _SYS_UTIME_H 1 + +#include + +struct utimbuf + { + time_t actime; /* Access time. */ + time_t modtime; /* Modification time. */ + }; + +int _EXFUN(utime, (const char *__file, const struct utimbuf *__times)); + +#endif /* _SYS_UTIME_H */ diff --git a/newlib/libc/sys/linux/utimes.c b/newlib/libc/sys/linux/utimes.c new file mode 100644 index 000000000..0bee55152 --- /dev/null +++ b/newlib/libc/sys/linux/utimes.c @@ -0,0 +1,44 @@ +/* Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include + +/* Change the access time of FILE to TVP[0] and + the modification time of FILE to TVP[1]. */ +int +__utimes (const char *file, const struct timeval tvp[2]) +{ + struct utimbuf buf, *times; + + if (tvp) + { + times = &buf; + times->actime = tvp[0].tv_sec + tvp[0].tv_usec / 1000000; + times->modtime = tvp[1].tv_sec + tvp[1].tv_usec / 1000000; + } + else + times = NULL; + + return utime (file, times); +} + +weak_alias (__utimes, utimes) -- 2.43.5