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