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

TOMOYO Linux Cross Reference
Linux/arch/s390/hypfs/hypfs_dbfs.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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 /*
  3  * Hypervisor filesystem for Linux on s390 - debugfs interface
  4  *
  5  * Copyright IBM Corp. 2010
  6  * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com>
  7  */
  8 
  9 #include <linux/slab.h>
 10 #include "hypfs.h"
 11 
 12 static struct dentry *dbfs_dir;
 13 
 14 static struct hypfs_dbfs_data *hypfs_dbfs_data_alloc(struct hypfs_dbfs_file *f)
 15 {
 16         struct hypfs_dbfs_data *data;
 17 
 18         data = kmalloc(sizeof(*data), GFP_KERNEL);
 19         if (!data)
 20                 return NULL;
 21         data->dbfs_file = f;
 22         return data;
 23 }
 24 
 25 static void hypfs_dbfs_data_free(struct hypfs_dbfs_data *data)
 26 {
 27         data->dbfs_file->data_free(data->buf_free_ptr);
 28         kfree(data);
 29 }
 30 
 31 static ssize_t dbfs_read(struct file *file, char __user *buf,
 32                          size_t size, loff_t *ppos)
 33 {
 34         struct hypfs_dbfs_data *data;
 35         struct hypfs_dbfs_file *df;
 36         ssize_t rc;
 37 
 38         if (*ppos != 0)
 39                 return 0;
 40 
 41         df = file_inode(file)->i_private;
 42         if (mutex_lock_interruptible(&df->lock))
 43                 return -ERESTARTSYS;
 44 
 45         data = hypfs_dbfs_data_alloc(df);
 46         if (!data) {
 47                 mutex_unlock(&df->lock);
 48                 return -ENOMEM;
 49         }
 50         rc = df->data_create(&data->buf, &data->buf_free_ptr, &data->size);
 51         if (rc) {
 52                 mutex_unlock(&df->lock);
 53                 kfree(data);
 54                 return rc;
 55         }
 56         mutex_unlock(&df->lock);
 57 
 58         rc = simple_read_from_buffer(buf, size, ppos, data->buf, data->size);
 59         hypfs_dbfs_data_free(data);
 60         return rc;
 61 }
 62 
 63 static long dbfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 64 {
 65         struct hypfs_dbfs_file *df = file_inode(file)->i_private;
 66         long rc;
 67 
 68         mutex_lock(&df->lock);
 69         if (df->unlocked_ioctl)
 70                 rc = df->unlocked_ioctl(file, cmd, arg);
 71         else
 72                 rc = -ENOTTY;
 73         mutex_unlock(&df->lock);
 74         return rc;
 75 }
 76 
 77 static const struct file_operations dbfs_ops = {
 78         .read           = dbfs_read,
 79         .llseek         = no_llseek,
 80         .unlocked_ioctl = dbfs_ioctl,
 81 };
 82 
 83 void hypfs_dbfs_create_file(struct hypfs_dbfs_file *df)
 84 {
 85         df->dentry = debugfs_create_file(df->name, 0400, dbfs_dir, df,
 86                                          &dbfs_ops);
 87         mutex_init(&df->lock);
 88 }
 89 
 90 void hypfs_dbfs_remove_file(struct hypfs_dbfs_file *df)
 91 {
 92         debugfs_remove(df->dentry);
 93 }
 94 
 95 static int __init hypfs_dbfs_init(void)
 96 {
 97         int rc = -ENODATA;
 98 
 99         dbfs_dir = debugfs_create_dir("s390_hypfs", NULL);
100         if (hypfs_diag_init())
101                 goto fail_dbfs_exit;
102         if (hypfs_vm_init())
103                 goto fail_hypfs_diag_exit;
104         hypfs_sprp_init();
105         if (hypfs_diag0c_init())
106                 goto fail_hypfs_sprp_exit;
107         rc = hypfs_fs_init();
108         if (rc)
109                 goto fail_hypfs_diag0c_exit;
110         return 0;
111 
112 fail_hypfs_diag0c_exit:
113         hypfs_diag0c_exit();
114 fail_hypfs_sprp_exit:
115         hypfs_sprp_exit();
116         hypfs_vm_exit();
117 fail_hypfs_diag_exit:
118         hypfs_diag_exit();
119         pr_err("Initialization of hypfs failed with rc=%i\n", rc);
120 fail_dbfs_exit:
121         debugfs_remove(dbfs_dir);
122         return rc;
123 }
124 device_initcall(hypfs_dbfs_init)
125 

~ [ 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