[PATCH] specify ramfs root inode permissions at mount time

From: Mathias Froehlich (frohlich@na.uni-tuebingen.de)
Date: Thu Jul 20 2000 - 03:23:49 EST


Hi,

Since ramfs is very fast I tried to use ramfs for /tmp. This would
have the important side effect, that all those open files in /tmp will
no longer corrupt my root fs in case of a crash.

I tried to use ramfs for /tmp which failed because the default
permissions of the root inode of ramfs is set to 0755. So I thought,
that having this permission as a mount option will solve this problem.

Here is a small patch which implements the mount option rootperm=1777.
Maybe this is usefull for others too.

    Thanks

      Mathias

--- linux-2.4.0-test5-pre3/fs/ramfs/inode.c.orig Thu Jul 20 08:48:21 2000
+++ linux-2.4.0-test5-pre3/fs/ramfs/inode.c Thu Jul 20 09:09:14 2000
@@ -309,6 +309,37 @@
         put_inode: force_delete,
 };
 
+static int get_root_mode(char * options)
+{
+ const int defaultmode = 0755;
+ int mode = defaultmode;
+ char * this_char;
+
+ if (!options)
+ return defaultmode;
+ for (this_char = strtok (options, ",");
+ this_char != NULL;
+ this_char = strtok (NULL, ",")) {
+ char * value;
+ if ((value = strchr (this_char, '=')) != NULL)
+ *value++ = 0;
+ if (!strcmp (this_char, "rootperm")) {
+ if (!value || !*value) {
+ printk("RAMFS: no value given to the rootperm option\n");
+ break;
+ }
+ mode = simple_strtoul(value,&value,8) & 07777;
+ if (*value) {
+ printk("RAMFS: invalid value given to the rootperm option\n");
+ mode = defaultmode;
+ break;
+ }
+ }
+ }
+
+ return mode;
+}
+
 static struct super_block *ramfs_read_super(struct super_block * sb, void * data, int silent)
 {
         struct inode * inode;
@@ -318,7 +349,7 @@
         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
         sb->s_magic = RAMFS_MAGIC;
         sb->s_op = &ramfs_ops;
- inode = ramfs_get_inode(sb, S_IFDIR | 0755, 0);
+ inode = ramfs_get_inode(sb, S_IFDIR | get_root_mode((char*)data), 0);
         if (!inode)
                 return NULL;
 

-- 
Mathias Fr"ohlich              e-mail: frohlich@na.uni-tuebingen.de
Institut f"ur Mathematik, Universit"at T"ubingen, D-72076 T"ubingen

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Jul 23 2000 - 21:00:13 EST