From 98b785e66c762f0aa4b9001b26e7956bdccfb54a Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 1 Jul 2010 17:22:03 +0000 Subject: 2010-07-01 Vinu Rajashekhar PR 1597/cpukit * libcsupport/Makefile.am, libcsupport/src/chown.c: Add lchown() and utimes(). * libcsupport/src/lchown.c, libcsupport/src/utimes.c: New files. --- cpukit/ChangeLog | 7 +++++++ cpukit/libcsupport/Makefile.am | 2 +- cpukit/libcsupport/src/chown.c | 16 +++++++++++++--- cpukit/libcsupport/src/lchown.c | 31 +++++++++++++++++++++++++++++++ cpukit/libcsupport/src/utimes.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 cpukit/libcsupport/src/lchown.c create mode 100644 cpukit/libcsupport/src/utimes.c diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index ade6f77599..c13a31efee 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,10 @@ +2010-07-01 Vinu Rajashekhar + + PR 1597/cpukit + * libcsupport/Makefile.am, libcsupport/src/chown.c: Add lchown() and + utimes(). + * libcsupport/src/lchown.c, libcsupport/src/utimes.c: New files. + 2010-07-01 Vinu Rajashekhar PR 1529/cpukit diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index aa7416ed24..8cdf7973d1 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -62,7 +62,7 @@ SYSTEM_CALL_C_FILES = src/open.c src/close.c src/read.c src/write.c \ src/link.c src/unlink.c src/umask.c src/ftruncate.c src/utime.c src/fstat.c \ src/fcntl.c src/fpathconf.c src/getdents.c src/fsync.c src/fdatasync.c \ src/pipe.c src/dup.c src/dup2.c src/symlink.c src/readlink.c src/creat.c \ - src/chroot.c src/sync.c src/_rename_r.c src/statvfs.c + src/chroot.c src/sync.c src/_rename_r.c src/statvfs.c src/utimes.c src/lchown.c ## Until sys/uio.h is moved to libcsupport, we have to have networking ## enabled to compile these. Hopefully this is a temporary situation. diff --git a/cpukit/libcsupport/src/chown.c b/cpukit/libcsupport/src/chown.c index 157c59e997..3cab985cad 100644 --- a/cpukit/libcsupport/src/chown.c +++ b/cpukit/libcsupport/src/chown.c @@ -24,16 +24,17 @@ #include #include -int chown( +int _chown_helper( const char *path, uid_t owner, - gid_t group + gid_t group, + int follow_link ) { rtems_filesystem_location_info_t loc; int result; - if ( rtems_filesystem_evaluate_path( path, strlen( path ), 0x00, &loc, true ) ) + if ( rtems_filesystem_evaluate_path( path, strlen( path ), 0x00, &loc, follow_link ) ) return -1; result = (*loc.ops->chown_h)( &loc, owner, group ); @@ -42,3 +43,12 @@ int chown( return result; } + +int chown( + const char *path, + uid_t owner, + gid_t group +) +{ + return _chown_helper( path, owner, group, true ); +} diff --git a/cpukit/libcsupport/src/lchown.c b/cpukit/libcsupport/src/lchown.c new file mode 100644 index 0000000000..c244e08879 --- /dev/null +++ b/cpukit/libcsupport/src/lchown.c @@ -0,0 +1,31 @@ +/* + * lchown() - POSIX 1003.1b 5.6.5 - Change Owner and Group of a File + * But Do Not Follow a Symlink + * + * Written by: Vinu Rajashekhar + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include + +int _chown_helper( const char *path, uid_t owner, gid_t group, int follow_link); + +int lchown( + const char *path, + uid_t owner, + gid_t group +) +{ + return _chown_helper( path, owner, group, false ); +} diff --git a/cpukit/libcsupport/src/utimes.c b/cpukit/libcsupport/src/utimes.c new file mode 100644 index 0000000000..b2070a9431 --- /dev/null +++ b/cpukit/libcsupport/src/utimes.c @@ -0,0 +1,33 @@ +/* + * Written by: Vinu Rajashekhar + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +int utimes( + const char *path, + const struct timeval times[2] +) +{ + struct utimbuf timeinsecs; + + if ( times == NULL ) + return utime( path, NULL ); + + timeinsecs.actime = (time_t) times[0].tv_sec; + timeinsecs.modtime = (time_t) times[1].tv_sec; + + return utime( path, &timeinsecs ); +} -- cgit v1.2.3