OSDN Git Service

2002-07-04 Jeff Johnston <jjohnstn@redhat.com>
authorjjohnstn <jjohnstn>
Thu, 4 Jul 2002 22:51:07 +0000 (22:51 +0000)
committerjjohnstn <jjohnstn>
Thu, 4 Jul 2002 22:51:07 +0000 (22:51 +0000)
        * 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
newlib/libc/include/utime.h
newlib/libc/sys/linux/Makefile.am
newlib/libc/sys/linux/Makefile.in
newlib/libc/sys/linux/inode.c
newlib/libc/sys/linux/sys/time.h
newlib/libc/sys/linux/sys/utime.h [new file with mode: 0644]
newlib/libc/sys/linux/utimes.c [new file with mode: 0644]

index 597203a..b6f8223 100644 (file)
@@ -1,3 +1,15 @@
+2002-07-04  Jeff Johnston  <jjohnstn@redhat.com>
+
+       * 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  <fitzsim@redhat.com>
 
        * libtool.m4: New file.
index c05e08e..652891a 100644 (file)
@@ -2,6 +2,8 @@
 extern "C" {
 #endif
 
+#include <_ansi.h>
+
 /* The utime function is defined in libc/sys/<arch>/sys if it exists. */
 #include <sys/utime.h>
 
index 6f05fc8..6c06ff6 100644 (file)
@@ -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)
index 37b2bd2..d7de4d6 100644 (file)
@@ -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)
index f6d8946..e2f4ab1 100644 (file)
@@ -9,8 +9,12 @@
 #include <sys/stat.h>
 #include <sys/utime.h>
 #include <linux/dirent.h>
+#include <sys/lock.h>
 #include <machine/syscall.h>
 
+__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;
+}
+
index d180764..f2c656e 100644 (file)
@@ -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 (file)
index 0000000..7499cfe
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef        _SYS_UTIME_H
+#define        _SYS_UTIME_H    1
+
+#include <sys/types.h>
+
+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 (file)
index 0000000..0bee551
--- /dev/null
@@ -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 <utime.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <stddef.h>
+#include <machine/weakalias.h>
+
+/* 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)