From: Phil Callihan Date: 2003-12-21T14:16:53+09:00 Subject: Ioctl problem I'm trying to use Ruby IO:ioctl on /dev/mixer. It work with c but not with ruby. I sure it a dumb mistake, but I can see it. Below is a ruby program that fails and the c program that work. Thanks ahead of time. pc _________ #! /usr/bin/env ruby SOUND_MIXER_READ_DEVMASK = 0x80044dfe mixer = File.open("/dev/mixer", "w+") notused = 0 devmask = mixer.ioctl(SOUND_MIXER_READ_DEVMASK, notused) printf "devmask[%08x]\n", devmask #~ Program results: #~ test.rb:8: #~ in `ioctl': Bad address - /dev/mixer (Errno::EFAULT) from test.rb:8 __________ #include #include #include #include #include #define SOUND_MIXER_READ_DEVMASK 0X80044dfe int main(int argc, char *argv[]) { int mixerfd, devmask; char* name = "/dev/mixer"; if ((mixerfd = open(name, O_RDWR)) < 0) { perror(name); exit(1); } if (ioctl(mixerfd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1) { perror("SOUND_MIXER_READ_DEVMASK"); exit(-1); } printf("Mixer Device mask [%08x]\n", devmask); return 0; } /* Program results: Mixer Device mask [005051d1] */