source: rtems/cpukit/libcsupport/src/fchmod.c @ 3ba4f828

4.115
Last change on this file since 3ba4f828 was 3ba4f828, checked in by Sebastian Huber <sebastian.huber@…>, on 03/02/12 at 09:18:10

Filesystem: Read-only file system checks

o Make sure EROFS is indicated for write operations on a read-only file

system.

o Add error indication for read-only file systems in fchmod() and

fchown() according to POSIX.

  • Property mode set to 100644
File size: 866 bytes
Line 
1/*
2 *  fchmod() - POSIX 1003.1b 5.6.4 - Change File Modes
3 *
4 *  COPYRIGHT (c) 1989-2011.
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 <sys/stat.h>
19
20#include <rtems/libio_.h>
21
22int fchmod( int fd, mode_t mode )
23{
24  int rv;
25  rtems_libio_t *iop;
26
27  rtems_libio_check_fd( fd );
28  iop = rtems_libio_iop( fd );
29  rtems_libio_check_is_open(iop);
30
31  if (iop->pathinfo.mt_entry->writeable) {
32    rtems_filesystem_instance_lock( &iop->pathinfo );
33    rv = (*iop->pathinfo.ops->fchmod_h)( &iop->pathinfo, mode );
34    rtems_filesystem_instance_unlock( &iop->pathinfo );
35  } else {
36    errno = EROFS;
37    rv = -1;
38  }
39
40  return rv;
41}
Note: See TracBrowser for help on using the repository browser.