aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2002-07-04 22:51:08 +0000
committerJeff Johnston <jjohnstn@redhat.com>2002-07-04 22:51:08 +0000
commitae6c4c84212f196efc9e65f5f6de9beb226f78dc (patch)
tree7adce04cbbf71ef935ef490c551962a66c46473e /newlib/libc
parent3e35e424d7b9b0036d93fc7314288c94063b513f (diff)
downloadnewlib-ae6c4c84212f196efc9e65f5f6de9beb226f78dc.zip
newlib-ae6c4c84212f196efc9e65f5f6de9beb226f78dc.tar.gz
newlib-ae6c4c84212f196efc9e65f5f6de9beb226f78dc.tar.bz2
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.
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/include/utime.h2
-rw-r--r--newlib/libc/sys/linux/Makefile.am1
-rw-r--r--newlib/libc/sys/linux/Makefile.in8
-rw-r--r--newlib/libc/sys/linux/inode.c43
-rw-r--r--newlib/libc/sys/linux/sys/time.h2
-rw-r--r--newlib/libc/sys/linux/sys/utime.h14
-rw-r--r--newlib/libc/sys/linux/utimes.c44
7 files changed, 108 insertions, 6 deletions
diff --git a/newlib/libc/include/utime.h b/newlib/libc/include/utime.h
index c05e08e..652891a 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/<arch>/sys if it exists. */
#include <sys/utime.h>
diff --git a/newlib/libc/sys/linux/Makefile.am b/newlib/libc/sys/linux/Makefile.am
index 6f05fc8..6c06ff6 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 37b2bd2..d7de4d6 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 f6d8946..e2f4ab1 100644
--- a/newlib/libc/sys/linux/inode.c
+++ b/newlib/libc/sys/linux/inode.c
@@ -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;
+}
+
diff --git a/newlib/libc/sys/linux/sys/time.h b/newlib/libc/sys/linux/sys/time.h
index d180764..f2c656e 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 0000000..7499cfe
--- /dev/null
+++ b/newlib/libc/sys/linux/sys/utime.h
@@ -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
index 0000000..0bee551
--- /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 <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)