summaryrefslogtreecommitdiff
path: root/packages/linux/linux-2.6.21/ramfs-mode-support.patch
blob: 423eab507f925d66485ce0284a06b0313022bc50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Index: linux-2.6.21gum/fs/ramfs/inode.c
===================================================================
--- linux-2.6.21gum.orig/fs/ramfs/inode.c
+++ linux-2.6.21gum/fs/ramfs/inode.c
@@ -33,6 +33,7 @@
 #include <linux/smp_lock.h>
 #include <linux/backing-dev.h>
 #include <linux/ramfs.h>
+#include <linux/ctype.h>
 
 #include <asm/uaccess.h>
 #include "internal.h"
@@ -160,10 +161,66 @@ static const struct super_operations ram
 	.drop_inode	= generic_delete_inode,
 };
 
+static int ramfs_parse_options(char *options, int *mode)
+{
+	char *this_char, *value, *rest;
+
+	while (options != NULL) {
+		this_char = options;
+		for (;;) {
+			/*
+			 * NUL-terminate this option: unfortunately,
+			 * mount options form a comma-separated list,
+			 * but mpol's nodelist may also contain commas.
+			 */
+			options = strchr(options, ',');
+			if (options == NULL)
+				break;
+			options++;
+			if (!isdigit(*options)) {
+				options[-1] = '\0';
+				break;
+			}
+		}
+		if (!*this_char)
+			continue;
+		if ((value = strchr(this_char,'=')) != NULL) {
+			*value++ = 0;
+		} else {
+			printk(KERN_ERR
+			    "ramfs: No value for mount option '%s'\n",
+			    this_char);
+			return 1;
+		}
+
+		if (!strcmp(this_char,"mode")) {
+			if (!mode)
+				continue;
+			*mode = simple_strtoul(value,&rest,8);
+			if (*rest)
+				goto bad_val;
+		} else {
+			printk(KERN_ERR "ramfs: Bad mount option %s\n",
+			       this_char);
+			return 1;
+		}
+	}
+	return 0;
+
+bad_val:
+	printk(KERN_ERR "ramfs: Bad value '%s' for mount option '%s'\n",
+	       value, this_char);
+	return 1;
+}
+
 static int ramfs_fill_super(struct super_block * sb, void * data, int silent)
 {
 	struct inode * inode;
 	struct dentry * root;
+	int mode = 0755;
+
+	if (ramfs_parse_options(data, &mode))
+        	return -EINVAL;
 
 	sb->s_maxbytes = MAX_LFS_FILESIZE;
 	sb->s_blocksize = PAGE_CACHE_SIZE;
@@ -171,7 +228,7 @@ static int ramfs_fill_super(struct super
 	sb->s_magic = RAMFS_MAGIC;
 	sb->s_op = &ramfs_ops;
 	sb->s_time_gran = 1;
-	inode = ramfs_get_inode(sb, S_IFDIR | 0755, 0);
+	inode = ramfs_get_inode(sb, S_IFDIR | mode, 0);
 	if (!inode)
 		return -ENOMEM;