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

TOMOYO Linux Cross Reference
Linux/sound/core/rawmidi_compat.c

Version: ~ [ linux-5.2 ] ~ [ linux-5.1.16 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.57 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.132 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.184 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.184 ] ~ [ 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.69 ] ~ [ 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-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ 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  *   32bit -> 64bit ioctl wrapper for raw MIDI API
  3  *   Copyright (c) by Takashi Iwai <tiwai@suse.de>
  4  *
  5  *   This program is free software; you can redistribute it and/or modify
  6  *   it under the terms of the GNU General Public License as published by
  7  *   the Free Software Foundation; either version 2 of the License, or
  8  *   (at your option) any later version.
  9  *
 10  *   This program is distributed in the hope that it will be useful,
 11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  *   GNU General Public License for more details.
 14  *
 15  *   You should have received a copy of the GNU General Public License
 16  *   along with this program; if not, write to the Free Software
 17  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 18  *
 19  */
 20 
 21 /* This file included from rawmidi.c */
 22 
 23 #include <linux/compat.h>
 24 
 25 struct snd_rawmidi_params32 {
 26         s32 stream;
 27         u32 buffer_size;
 28         u32 avail_min;
 29         unsigned int no_active_sensing; /* avoid bit-field */
 30         unsigned char reserved[16];
 31 } __attribute__((packed));
 32 
 33 static int snd_rawmidi_ioctl_params_compat(struct snd_rawmidi_file *rfile,
 34                                            struct snd_rawmidi_params32 __user *src)
 35 {
 36         struct snd_rawmidi_params params;
 37         unsigned int val;
 38 
 39         if (rfile->output == NULL)
 40                 return -EINVAL;
 41         if (get_user(params.stream, &src->stream) ||
 42             get_user(params.buffer_size, &src->buffer_size) ||
 43             get_user(params.avail_min, &src->avail_min) ||
 44             get_user(val, &src->no_active_sensing))
 45                 return -EFAULT;
 46         params.no_active_sensing = val;
 47         switch (params.stream) {
 48         case SNDRV_RAWMIDI_STREAM_OUTPUT:
 49                 return snd_rawmidi_output_params(rfile->output, &params);
 50         case SNDRV_RAWMIDI_STREAM_INPUT:
 51                 return snd_rawmidi_input_params(rfile->input, &params);
 52         }
 53         return -EINVAL;
 54 }
 55 
 56 struct snd_rawmidi_status32 {
 57         s32 stream;
 58         struct compat_timespec tstamp;
 59         u32 avail;
 60         u32 xruns;
 61         unsigned char reserved[16];
 62 } __attribute__((packed));
 63 
 64 static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile,
 65                                            struct snd_rawmidi_status32 __user *src)
 66 {
 67         int err;
 68         struct snd_rawmidi_status status;
 69 
 70         if (rfile->output == NULL)
 71                 return -EINVAL;
 72         if (get_user(status.stream, &src->stream))
 73                 return -EFAULT;
 74 
 75         switch (status.stream) {
 76         case SNDRV_RAWMIDI_STREAM_OUTPUT:
 77                 err = snd_rawmidi_output_status(rfile->output, &status);
 78                 break;
 79         case SNDRV_RAWMIDI_STREAM_INPUT:
 80                 err = snd_rawmidi_input_status(rfile->input, &status);
 81                 break;
 82         default:
 83                 return -EINVAL;
 84         }
 85         if (err < 0)
 86                 return err;
 87 
 88         if (put_user(status.tstamp.tv_sec, &src->tstamp.tv_sec) ||
 89             put_user(status.tstamp.tv_nsec, &src->tstamp.tv_nsec) ||
 90             put_user(status.avail, &src->avail) ||
 91             put_user(status.xruns, &src->xruns))
 92                 return -EFAULT;
 93 
 94         return 0;
 95 }
 96 
 97 enum {
 98         SNDRV_RAWMIDI_IOCTL_PARAMS32 = _IOWR('W', 0x10, struct snd_rawmidi_params32),
 99         SNDRV_RAWMIDI_IOCTL_STATUS32 = _IOWR('W', 0x20, struct snd_rawmidi_status32),
100 };
101 
102 static long snd_rawmidi_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
103 {
104         struct snd_rawmidi_file *rfile;
105         void __user *argp = compat_ptr(arg);
106 
107         rfile = file->private_data;
108         switch (cmd) {
109         case SNDRV_RAWMIDI_IOCTL_PVERSION:
110         case SNDRV_RAWMIDI_IOCTL_INFO:
111         case SNDRV_RAWMIDI_IOCTL_DROP:
112         case SNDRV_RAWMIDI_IOCTL_DRAIN:
113                 return snd_rawmidi_ioctl(file, cmd, (unsigned long)argp);
114         case SNDRV_RAWMIDI_IOCTL_PARAMS32:
115                 return snd_rawmidi_ioctl_params_compat(rfile, argp);
116         case SNDRV_RAWMIDI_IOCTL_STATUS32:
117                 return snd_rawmidi_ioctl_status_compat(rfile, argp);
118         }
119         return -ENOIOCTLCMD;
120 }
121 

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