~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/kernel/atags_proc.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 #include <linux/slab.h>
  3 #include <linux/proc_fs.h>
  4 #include <asm/setup.h>
  5 #include <asm/types.h>
  6 #include <asm/page.h>
  7 
  8 struct buffer {
  9         size_t size;
 10         char data[] __counted_by(size);
 11 };
 12 
 13 static ssize_t atags_read(struct file *file, char __user *buf,
 14                           size_t count, loff_t *ppos)
 15 {
 16         struct buffer *b = pde_data(file_inode(file));
 17         return simple_read_from_buffer(buf, count, ppos, b->data, b->size);
 18 }
 19 
 20 static const struct proc_ops atags_proc_ops = {
 21         .proc_read      = atags_read,
 22         .proc_lseek     = default_llseek,
 23 };
 24 
 25 #define BOOT_PARAMS_SIZE 1536
 26 static char __initdata atags_copy[BOOT_PARAMS_SIZE];
 27 
 28 void __init save_atags(const struct tag *tags)
 29 {
 30         memcpy(atags_copy, tags, sizeof(atags_copy));
 31 }
 32 
 33 static int __init init_atags_procfs(void)
 34 {
 35         /*
 36          * This cannot go into save_atags() because kmalloc and proc don't work
 37          * yet when it is called.
 38          */
 39         struct proc_dir_entry *tags_entry;
 40         struct tag *tag = (struct tag *)atags_copy;
 41         struct buffer *b;
 42         size_t size;
 43 
 44         if (tag->hdr.tag != ATAG_CORE) {
 45                 pr_info("No ATAGs?\n");
 46                 return -EINVAL;
 47         }
 48 
 49         for (; tag->hdr.size; tag = tag_next(tag))
 50                 ;
 51 
 52         /* include the terminating ATAG_NONE */
 53         size = (char *)tag - atags_copy + sizeof(struct tag_header);
 54 
 55         WARN_ON(tag->hdr.tag != ATAG_NONE);
 56 
 57         b = kmalloc(struct_size(b, data, size), GFP_KERNEL);
 58         if (!b)
 59                 goto nomem;
 60 
 61         b->size = size;
 62         memcpy(b->data, atags_copy, size);
 63 
 64         tags_entry = proc_create_data("atags", 0400, NULL, &atags_proc_ops, b);
 65         if (!tags_entry)
 66                 goto nomem;
 67 
 68         return 0;
 69 
 70 nomem:
 71         kfree(b);
 72         pr_err("Exporting ATAGs: not enough memory\n");
 73 
 74         return -ENOMEM;
 75 }
 76 arch_initcall(init_atags_procfs);
 77 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php