7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/string.h>
12 #include <linux/slab.h>
14 #include <linux/magic.h>
16 #include <asm/openprom.h>
17 #include <asm/oplib.h>
19 #include <asm/uaccess.h>
23 #define OPENPROM_ROOT_INO 0
48 static int is_string(
unsigned char *
p,
int len)
52 for (i = 0; i < len; i++) {
53 unsigned char val = p[
i];
56 (val >=
' ' && val <=
'~'))
65 static int property_show(
struct seq_file *
f,
void *
v)
74 if (is_string(pval, len)) {
93 *(
unsigned char *) pval);
96 *(
unsigned char *) pval);
105 *(
unsigned int *) pval);
108 *(
unsigned int *) pval);
118 static void *property_start(
struct seq_file *f, loff_t *
pos)
125 static void *property_next(
struct seq_file *f,
void *v, loff_t *pos)
131 static void property_stop(
struct seq_file *f,
void *v)
137 .start = property_start,
138 .next = property_next,
139 .stop = property_stop,
140 .show = property_show
159 .open = property_open,
165 static int openpromfs_readdir(
struct file *,
void *,
filldir_t);
169 .readdir = openpromfs_readdir,
173 static struct dentry *openpromfs_lookup(
struct inode *,
struct dentry *,
unsigned int);
176 .lookup = openpromfs_lookup,
195 name = dentry->
d_name.name;
202 int n =
strlen(child->path_component_name);
205 !
strncmp(child->path_component_name, name, len)) {
207 ent_data.node = child;
208 ino = child->unique_id;
220 ent_data.prop = prop;
232 inode = openprom_iget(dir->
i_sb, ino);
235 return ERR_CAST(inode);
236 ent_oi = OP_I(inode);
237 ent_oi->
type = ent_type;
238 ent_oi->
u = ent_data;
243 inode->
i_op = &openprom_inode_operations;
244 inode->
i_fop = &openprom_operations;
248 if (!
strcmp(dp->
name,
"options") && (len == 17) &&
249 !
strncmp (name,
"security-password", 17))
253 inode->
i_fop = &openpromfs_prop_ops;
259 d_add(dentry, inode);
263 static int openpromfs_readdir(
struct file * filp,
void *
dirent,
filldir_t filldir)
265 struct inode *inode = filp->
f_path.dentry->d_inode;
279 if (filldir(dirent,
".", 1, i, ino,
DT_DIR) < 0)
285 if (filldir(dirent,
"..", 2, i,
304 child->path_component_name,
305 strlen(child->path_component_name),
335 static struct inode *openprom_alloc_inode(
struct super_block *
sb)
352 static void openprom_destroy_inode(
struct inode *inode)
366 if (inode->
i_ino == OPENPROM_ROOT_INO) {
367 inode->
i_op = &openprom_inode_operations;
368 inode->
i_fop = &openprom_operations;
376 static int openprom_remount(
struct super_block *sb,
int *flags,
char *
data)
383 .alloc_inode = openprom_alloc_inode,
384 .destroy_inode = openprom_destroy_inode,
386 .remount_fs = openprom_remount,
389 static int openprom_fill_super(
struct super_block *
s,
void *
data,
int silent)
391 struct inode *root_inode;
399 s->
s_op = &openprom_sops;
401 root_inode = openprom_iget(s, OPENPROM_ROOT_INO);
402 if (IS_ERR(root_inode)) {
403 ret = PTR_ERR(root_inode);
407 oi = OP_I(root_inode);
413 goto out_no_root_dentry;
419 printk(
"openprom_fill_super: get root inode failed\n");
424 int flags,
const char *dev_name,
void *data)
426 return mount_single(fs_type, flags, data, openprom_fill_super);
431 .name =
"openpromfs",
432 .mount = openprom_mount,
436 static void op_inode_init_once(
void *data)
443 static int __init init_openprom_fs(
void)
453 if (!op_inode_cachep)
463 static void __exit exit_openprom_fs(
void)