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

TOMOYO Linux Cross Reference
Linux/arch/um/kernel/exitcode.c

Version: ~ [ linux-5.10-rc1 ] ~ [ linux-5.9.1 ] ~ [ linux-5.8.16 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.72 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.152 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.202 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.240 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.240 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3  * Licensed under the GPL
  4  */
  5 
  6 #include <linux/ctype.h>
  7 #include <linux/init.h>
  8 #include <linux/kernel.h>
  9 #include <linux/module.h>
 10 #include <linux/proc_fs.h>
 11 #include <linux/seq_file.h>
 12 #include <linux/types.h>
 13 #include <asm/uaccess.h>
 14 
 15 /*
 16  * If read and write race, the read will still atomically read a valid
 17  * value.
 18  */
 19 int uml_exitcode = 0;
 20 
 21 static int exitcode_proc_show(struct seq_file *m, void *v)
 22 {
 23         int val;
 24 
 25         /*
 26          * Save uml_exitcode in a local so that we don't need to guarantee
 27          * that sprintf accesses it atomically.
 28          */
 29         val = uml_exitcode;
 30         seq_printf(m, "%d\n", val);
 31         return 0;
 32 }
 33 
 34 static int exitcode_proc_open(struct inode *inode, struct file *file)
 35 {
 36         return single_open(file, exitcode_proc_show, NULL);
 37 }
 38 
 39 static ssize_t exitcode_proc_write(struct file *file,
 40                 const char __user *buffer, size_t count, loff_t *pos)
 41 {
 42         char *end, buf[sizeof("nnnnn\0")];
 43         size_t size;
 44         int tmp;
 45 
 46         size = min(count, sizeof(buf));
 47         if (copy_from_user(buf, buffer, size))
 48                 return -EFAULT;
 49 
 50         tmp = simple_strtol(buf, &end, 0);
 51         if ((*end != '\0') && !isspace(*end))
 52                 return -EINVAL;
 53 
 54         uml_exitcode = tmp;
 55         return count;
 56 }
 57 
 58 static const struct file_operations exitcode_proc_fops = {
 59         .owner          = THIS_MODULE,
 60         .open           = exitcode_proc_open,
 61         .read           = seq_read,
 62         .llseek         = seq_lseek,
 63         .release        = single_release,
 64         .write          = exitcode_proc_write,
 65 };
 66 
 67 static int make_proc_exitcode(void)
 68 {
 69         struct proc_dir_entry *ent;
 70 
 71         ent = proc_create("exitcode", 0600, NULL, &exitcode_proc_fops);
 72         if (ent == NULL) {
 73                 printk(KERN_WARNING "make_proc_exitcode : Failed to register "
 74                        "/proc/exitcode\n");
 75                 return 0;
 76         }
 77         return 0;
 78 }
 79 
 80 __initcall(make_proc_exitcode);
 81 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp