mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-20 20:31:04 +08:00
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.
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
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.
|
||||
|
||||
2010-07-01 Vinu Rajashekhar <vinutheraj@gmail.com>
|
||||
|
||||
PR 1529/cpukit
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
@@ -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 );
|
||||
}
|
||||
Reference in New Issue
Block a user