1 #include <linux/slab.h>
2 #include <linux/proc_fs.h>
12 static ssize_t
atags_read(struct file
*file
, char __user
*buf
,
13 size_t count
, loff_t
*ppos
)
15 struct buffer
*b
= PDE_DATA(file_inode(file
));
16 return simple_read_from_buffer(buf
, count
, ppos
, b
->data
, b
->size
);
19 static const struct file_operations atags_fops
= {
21 .llseek
= default_llseek
,
24 #define BOOT_PARAMS_SIZE 1536
25 static char __initdata atags_copy
[BOOT_PARAMS_SIZE
];
27 void __init
save_atags(const struct tag
*tags
)
29 memcpy(atags_copy
, tags
, sizeof(atags_copy
));
32 static int __init
init_atags_procfs(void)
35 * This cannot go into save_atags() because kmalloc and proc don't work
36 * yet when it is called.
38 struct proc_dir_entry
*tags_entry
;
39 struct tag
*tag
= (struct tag
*)atags_copy
;
43 if (tag
->hdr
.tag
!= ATAG_CORE
) {
44 printk(KERN_INFO
"No ATAGs?");
48 for (; tag
->hdr
.size
; tag
= tag_next(tag
))
51 /* include the terminating ATAG_NONE */
52 size
= (char *)tag
- atags_copy
+ sizeof(struct tag_header
);
54 WARN_ON(tag
->hdr
.tag
!= ATAG_NONE
);
56 b
= kmalloc(sizeof(*b
) + size
, GFP_KERNEL
);
61 memcpy(b
->data
, atags_copy
, size
);
63 tags_entry
= proc_create_data("atags", 0400, NULL
, &atags_fops
, b
);
71 printk(KERN_ERR
"Exporting ATAGs: not enough memory\n");
75 arch_initcall(init_atags_procfs
);