source: rtems/c/src/lib/libc/imfs_fchmod.c @ df49c60

4.104.114.84.95
Last change on this file since df49c60 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
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$
12 */
13
14#include <errno.h>
15
16#include "libio_.h"
17#include "imfs.h"
18
19int 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
Note: See TracBrowser for help on using the repository browser.