diff options
Diffstat (limited to 'fs/proc/proc_devtree.c')
-rw-r--r-- | fs/proc/proc_devtree.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c index 6fd57f154197..fb117b74809e 100644 --- a/fs/proc/proc_devtree.c +++ b/fs/proc/proc_devtree.c | |||
@@ -49,6 +49,39 @@ static int property_read_proc(char *page, char **start, off_t off, | |||
49 | */ | 49 | */ |
50 | 50 | ||
51 | /* | 51 | /* |
52 | * Add a property to a node | ||
53 | */ | ||
54 | static struct proc_dir_entry * | ||
55 | __proc_device_tree_add_prop(struct proc_dir_entry *de, struct property *pp) | ||
56 | { | ||
57 | struct proc_dir_entry *ent; | ||
58 | |||
59 | /* | ||
60 | * Unfortunately proc_register puts each new entry | ||
61 | * at the beginning of the list. So we rearrange them. | ||
62 | */ | ||
63 | ent = create_proc_read_entry(pp->name, | ||
64 | strncmp(pp->name, "security-", 9) | ||
65 | ? S_IRUGO : S_IRUSR, de, | ||
66 | property_read_proc, pp); | ||
67 | if (ent == NULL) | ||
68 | return NULL; | ||
69 | |||
70 | if (!strncmp(pp->name, "security-", 9)) | ||
71 | ent->size = 0; /* don't leak number of password chars */ | ||
72 | else | ||
73 | ent->size = pp->length; | ||
74 | |||
75 | return ent; | ||
76 | } | ||
77 | |||
78 | |||
79 | void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop) | ||
80 | { | ||
81 | __proc_device_tree_add_prop(pde, prop); | ||
82 | } | ||
83 | |||
84 | /* | ||
52 | * Process a node, adding entries for its children and its properties. | 85 | * Process a node, adding entries for its children and its properties. |
53 | */ | 86 | */ |
54 | void proc_device_tree_add_node(struct device_node *np, | 87 | void proc_device_tree_add_node(struct device_node *np, |
@@ -57,11 +90,9 @@ void proc_device_tree_add_node(struct device_node *np, | |||
57 | struct property *pp; | 90 | struct property *pp; |
58 | struct proc_dir_entry *ent; | 91 | struct proc_dir_entry *ent; |
59 | struct device_node *child; | 92 | struct device_node *child; |
60 | struct proc_dir_entry *list = NULL, **lastp; | ||
61 | const char *p; | 93 | const char *p; |
62 | 94 | ||
63 | set_node_proc_entry(np, de); | 95 | set_node_proc_entry(np, de); |
64 | lastp = &list; | ||
65 | for (child = NULL; (child = of_get_next_child(np, child));) { | 96 | for (child = NULL; (child = of_get_next_child(np, child));) { |
66 | p = strrchr(child->full_name, '/'); | 97 | p = strrchr(child->full_name, '/'); |
67 | if (!p) | 98 | if (!p) |
@@ -71,9 +102,6 @@ void proc_device_tree_add_node(struct device_node *np, | |||
71 | ent = proc_mkdir(p, de); | 102 | ent = proc_mkdir(p, de); |
72 | if (ent == 0) | 103 | if (ent == 0) |
73 | break; | 104 | break; |
74 | *lastp = ent; | ||
75 | ent->next = NULL; | ||
76 | lastp = &ent->next; | ||
77 | proc_device_tree_add_node(child, ent); | 105 | proc_device_tree_add_node(child, ent); |
78 | } | 106 | } |
79 | of_node_put(child); | 107 | of_node_put(child); |
@@ -84,7 +112,7 @@ void proc_device_tree_add_node(struct device_node *np, | |||
84 | * properties are quite unimportant for us though, thus we | 112 | * properties are quite unimportant for us though, thus we |
85 | * simply "skip" them here, but we do have to check. | 113 | * simply "skip" them here, but we do have to check. |
86 | */ | 114 | */ |
87 | for (ent = list; ent != NULL; ent = ent->next) | 115 | for (ent = de->subdir; ent != NULL; ent = ent->next) |
88 | if (!strcmp(ent->name, pp->name)) | 116 | if (!strcmp(ent->name, pp->name)) |
89 | break; | 117 | break; |
90 | if (ent != NULL) { | 118 | if (ent != NULL) { |
@@ -94,25 +122,10 @@ void proc_device_tree_add_node(struct device_node *np, | |||
94 | continue; | 122 | continue; |
95 | } | 123 | } |
96 | 124 | ||
97 | /* | 125 | ent = __proc_device_tree_add_prop(de, pp); |
98 | * Unfortunately proc_register puts each new entry | ||
99 | * at the beginning of the list. So we rearrange them. | ||
100 | */ | ||
101 | ent = create_proc_read_entry(pp->name, | ||
102 | strncmp(pp->name, "security-", 9) | ||
103 | ? S_IRUGO : S_IRUSR, de, | ||
104 | property_read_proc, pp); | ||
105 | if (ent == 0) | 126 | if (ent == 0) |
106 | break; | 127 | break; |
107 | if (!strncmp(pp->name, "security-", 9)) | ||
108 | ent->size = 0; /* don't leak number of password chars */ | ||
109 | else | ||
110 | ent->size = pp->length; | ||
111 | ent->next = NULL; | ||
112 | *lastp = ent; | ||
113 | lastp = &ent->next; | ||
114 | } | 128 | } |
115 | de->subdir = list; | ||
116 | } | 129 | } |
117 | 130 | ||
118 | /* | 131 | /* |