diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-03-02 10:18:10 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-03-13 12:23:44 +0100 |
commit | 3ba4f828e45141e9428a2c06d3d7c4bec3d5b404 (patch) | |
tree | f790e1259ffa11da3f993e58d2ceeb152b4133f3 /cpukit/libcsupport/src/sup_fs_eval_path.c | |
parent | Filesystem: Reference counting for locations (diff) | |
download | rtems-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/sup_fs_eval_path.c')
-rw-r--r-- | cpukit/libcsupport/src/sup_fs_eval_path.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/cpukit/libcsupport/src/sup_fs_eval_path.c b/cpukit/libcsupport/src/sup_fs_eval_path.c index 1940cce745..c827ba72f8 100644 --- a/cpukit/libcsupport/src/sup_fs_eval_path.c +++ b/cpukit/libcsupport/src/sup_fs_eval_path.c @@ -68,26 +68,32 @@ static void check_access( ) { const rtems_filesystem_location_info_t *currentloc = &ctx->currentloc; - struct stat st; - int rv; - - st.st_mode = 0; - st.st_uid = 0; - st.st_gid = 0; - rv = (*currentloc->handlers->fstat_h)(currentloc, &st); - if (rv == 0) { - bool access_ok = rtems_filesystem_check_access( - eval_flags, - st.st_mode, - st.st_uid, - st.st_gid - ); - - if (!access_ok) { - rtems_filesystem_eval_path_error(ctx, EACCES); + const rtems_filesystem_mount_table_entry_t *mt_entry = currentloc->mt_entry; + + if ((eval_flags & RTEMS_LIBIO_PERMS_WRITE) == 0 || mt_entry->writeable) { + struct stat st; + int rv; + + st.st_mode = 0; + st.st_uid = 0; + st.st_gid = 0; + rv = (*currentloc->handlers->fstat_h)(currentloc, &st); + if (rv == 0) { + bool access_ok = rtems_filesystem_check_access( + eval_flags, + st.st_mode, + st.st_uid, + st.st_gid + ); + + if (!access_ok) { + rtems_filesystem_eval_path_error(ctx, EACCES); + } + } else { + rtems_filesystem_eval_path_error(ctx, 0); } } else { - rtems_filesystem_eval_path_error(ctx, 0); + rtems_filesystem_eval_path_error(ctx, EROFS); } } |