diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-01 17:22:03 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-01 17:22:03 +0000 |
commit | 98b785e66c762f0aa4b9001b26e7956bdccfb54a (patch) | |
tree | 6b3650a74e5e21bb45b1a34772f3d09bbfe2a6e3 /cpukit/libcsupport | |
parent | 2010-07-01 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-98b785e66c762f0aa4b9001b26e7956bdccfb54a.tar.bz2 |
2010-07-01 Vinu Rajashekhar <vinutheraj@gmail.com>
PR 1597/cpukit
* libcsupport/Makefile.am, libcsupport/src/chown.c: Add lchown() and
utimes().
* libcsupport/src/lchown.c, libcsupport/src/utimes.c: New files.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r-- | cpukit/libcsupport/Makefile.am | 2 | ||||
-rw-r--r-- | cpukit/libcsupport/src/chown.c | 16 | ||||
-rw-r--r-- | cpukit/libcsupport/src/lchown.c | 31 | ||||
-rw-r--r-- | cpukit/libcsupport/src/utimes.c | 33 |
4 files changed, 78 insertions, 4 deletions
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 <rtems/libio_.h> #include <rtems/seterr.h> -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 <vinutheraj@gmail.com> + * + * 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 <sys/stat.h> + +#include <rtems.h> + +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 <vinutheraj@gmail.com> + * + * 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 <sys/types.h> +#include <utime.h> +#include <sys/time.h> + +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 ); +} |