summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/imfs/imfs_fchmod.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2001-01-12 13:44:12 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2001-01-12 13:44:12 +0000
commitd19415873fb6b6197d77916758593c9897a0cb69 (patch)
treefb1e3dd1eb1f4c8d47c262fae6e68500aef79087 /cpukit/libfs/src/imfs/imfs_fchmod.c
parent2001-01-12 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-d19415873fb6b6197d77916758593c9897a0cb69.tar.bz2
2001-01-12 Jake Janovetz <janovetz@uiuc.edu>
* src/imfs/imfs.h, src/imfs/imfs_creat.c, src/imfs/imfs_debug.c, src/imfs/imfs_eval.c, src/imfs/imfs_fchmod.c, src/imfs/imfs_handlers_memfile.c, src/imfs/imfs_init.c, src/imfs/imfs_initsupp.c, src/imfs/imfs_stat.c, src/imfs/memfile.c, src/imfs/miniimfs_init.c: Final developmental update to "tarfs". When rtems_tarfs_load() is called, it checks the permissions on each file. If there is write permission, it just creates a standard file using "creat()" and therefore, uses the IMFS MEMORY_FILE. If there is no write permission, it creates a LINEAR_FILE node with the appropriate properties. If the permission is ever changed to writeable, IMFS_fchmod converts it to a regular memory file.
Diffstat (limited to 'cpukit/libfs/src/imfs/imfs_fchmod.c')
-rw-r--r--cpukit/libfs/src/imfs/imfs_fchmod.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/cpukit/libfs/src/imfs/imfs_fchmod.c b/cpukit/libfs/src/imfs/imfs_fchmod.c
index 02ac934854..d360a1543a 100644
--- a/cpukit/libfs/src/imfs/imfs_fchmod.c
+++ b/cpukit/libfs/src/imfs/imfs_fchmod.c
@@ -44,6 +44,25 @@ int IMFS_fchmod(
if ( mode & (~ (S_IRWXU | S_IRWXG | S_IRWXO ) ) )
set_errno_and_return_minus_one( EPERM );
+ /*
+ * If we make a linear-file writeable, construct a block file
+ * from it first.
+ */
+ if ( (jnode->type == IMFS_LINEAR_FILE) &&
+ (mode & (S_IWUSR | S_IWGRP | S_IWOTH)) )
+ {
+ unsigned32 count = jnode->info.linearfile.size;
+ const unsigned char *buffer = jnode->info.linearfile.direct;
+
+ jnode->type = IMFS_MEMORY_FILE;
+ jnode->info.file.size = 0;
+ jnode->info.file.indirect = 0;
+ jnode->info.file.doubly_indirect = 0;
+ jnode->info.file.triply_indirect = 0;
+ if (IMFS_memfile_write(jnode, 0, buffer, count) == -1)
+ return(-1);
+ }
+
jnode->st_mode &= ~(S_IRWXU | S_IRWXG | S_IRWXO);
jnode->st_mode |= mode;