source: rtems/cpukit/libfs/src/imfs/imfs_fchmod.c @ 624867b

4.104.114.84.95
Last change on this file since 624867b was 624867b, checked in by Eric Norum <WENorum@…>, on 02/08/05 at 17:12:54

Add copy-on-write semantics to rtems_tarfs_load().

  • Property mode set to 100644
File size: 1.3 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.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <errno.h>
19
20#include <rtems/libio_.h>
21#include <rtems/seterr.h>
22#include "imfs.h"
23
24int IMFS_fchmod(
25  rtems_filesystem_location_info_t *loc,
26  mode_t                            mode
27)
28{
29  IMFS_jnode_t  *jnode;
30#if defined(RTEMS_POSIX_API)
31  uid_t          st_uid;
32#endif
33   int IMFS_memfile_write(
34      IMFS_jnode_t          *the_jnode,
35      off_t                  start,
36      const unsigned char   *source,
37      unsigned int           length
38   );
39
40
41  jnode = loc->node_access;
42
43  /*
44   *  Verify I am the owner of the node or the super user.
45   */
46#if defined(RTEMS_POSIX_API)
47  st_uid = geteuid();
48
49  if ( ( st_uid != jnode->st_uid ) && ( st_uid != 0 ) )
50    rtems_set_errno_and_return_minus_one( EPERM );
51#endif
52
53  /*
54   * Change only the RWX permissions on the jnode to mode.
55   */
56  if ( mode & (~ (S_IRWXU | S_IRWXG | S_IRWXO ) ) )
57    rtems_set_errno_and_return_minus_one( EPERM );
58
59  jnode->st_mode &= ~(S_IRWXU | S_IRWXG | S_IRWXO);
60  jnode->st_mode |= mode;
61
62  IMFS_update_ctime( jnode );
63
64  return 0;
65}
Note: See TracBrowser for help on using the repository browser.