summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/fchown.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-03-02 10:18:10 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-03-13 12:23:44 +0100
commit3ba4f828e45141e9428a2c06d3d7c4bec3d5b404 (patch)
treef790e1259ffa11da3f993e58d2ceeb152b4133f3 /cpukit/libcsupport/src/fchown.c
parentFilesystem: Reference counting for locations (diff)
downloadrtems-3ba4f828e45141e9428a2c06d3d7c4bec3d5b404.tar.bz2
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.
Diffstat (limited to 'cpukit/libcsupport/src/fchown.c')
-rw-r--r--cpukit/libcsupport/src/fchown.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/cpukit/libcsupport/src/fchown.c b/cpukit/libcsupport/src/fchown.c
index b5891bf36d..d0d04005d8 100644
--- a/cpukit/libcsupport/src/fchown.c
+++ b/cpukit/libcsupport/src/fchown.c
@@ -28,11 +28,14 @@ int fchown( int fd, uid_t owner, gid_t group )
iop = rtems_libio_iop( fd );
rtems_libio_check_is_open(iop);
- rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE );
-
- rtems_filesystem_instance_lock( &iop->pathinfo );
- rv = (*iop->pathinfo.ops->chown_h)( &iop->pathinfo, owner, group );
- rtems_filesystem_instance_unlock( &iop->pathinfo );
+ if (iop->pathinfo.mt_entry->writeable) {
+ rtems_filesystem_instance_lock( &iop->pathinfo );
+ rv = (*iop->pathinfo.ops->chown_h)( &iop->pathinfo, owner, group );
+ rtems_filesystem_instance_unlock( &iop->pathinfo );
+ } else {
+ errno = EROFS;
+ rv = -1;
+ }
return rv;
}