OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libc/] [imfs_fchmod.c] - Blame information for rev 228

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  IMFS file change mode routine.
3
 *
4
 *  COPYRIGHT (c) 1989-1999.
5
 *  On-Line Applications Research Corporation (OAR).
6
 *
7
 *  The license and distribution terms for this file may be
8
 *  found in the file LICENSE in this distribution or at
9
 *  http://www.OARcorp.com/rtems/license.html.
10
 *
11
 *  $Id: imfs_fchmod.c,v 1.2 2001-09-27 12:01:15 chris Exp $
12
 */
13
 
14
#include <errno.h>
15
 
16
#include "libio_.h"
17
#include "imfs.h"
18
 
19
int IMFS_fchmod(
20
  rtems_filesystem_location_info_t *loc,
21
  mode_t                            mode
22
)
23
{
24
  IMFS_jnode_t  *jnode;
25
#if defined(RTEMS_POSIX_API)
26
  uid_t          st_uid;
27
#endif
28
 
29
  jnode = loc->node_access;
30
 
31
  /*
32
   *  Verify I am the owner of the node or the super user.
33
   */
34
#if defined(RTEMS_POSIX_API)
35
  st_uid = geteuid();
36
 
37
  if ( ( st_uid != jnode->st_uid ) && ( st_uid != 0 ) )
38
    set_errno_and_return_minus_one( EPERM );
39
#endif
40
 
41
  /*
42
   * Change only the RWX permissions on the jnode to mode.
43
   */
44
  if ( mode & (~ (S_IRWXU | S_IRWXG | S_IRWXO ) ) )
45
    set_errno_and_return_minus_one( EPERM );
46
 
47
  jnode->st_mode &= ~(S_IRWXU | S_IRWXG | S_IRWXO);
48
  jnode->st_mode |= mode;
49
 
50
  IMFS_update_ctime( jnode );
51
 
52
  return 0;
53
}
54
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.