Bug #6427
closedruby ioctl: Error integer 2148012656 too big to convert to `int'
Description
Hi,
the upgrade to ubuntu 12.04 came with an upgrade to ruby 1.9.3.
Unfortunately, in recent 1.9.3 versions of ruby there's a bug in the
ioctl function. E.g. if you want to do getbsz() on a block device and do
a
f.ioctl(0x80081270,a)
you'll get the error message
Error integer 2148012656 too big to convert to `int'
RangeError
(2148012656 = 0x80081270)
So ruby can't do ioctl's anymore if the highest bit is set in the ioctl code.
This was working code in ruby 1.9.2 / ubuntu 11.10.
regards
        
           Updated by shyouhei (Shyouhei Urabe) over 13 years ago
          Updated by shyouhei (Shyouhei Urabe) over 13 years ago
          
          
        
        
      
      - Status changed from Open to Rejected
Both ruby and glibc header file (and Ubuntu's manpage of ioctl(2)) agree that
ioctl takes int, and 2148012656 is greater than INT_MAX.  Hence the exception.
You have to use -2146954640 instead.
        
           Updated by naruse (Yui NARUSE) over 13 years ago
          Updated by naruse (Yui NARUSE) over 13 years ago
          
          
        
        
      
      shyouhei (Shyouhei Urabe) wrote:
Both ruby and glibc header file (and Ubuntu's manpage of ioctl(2)) agree that
ioctl takes int, and 2148012656 is greater than INT_MAX. Hence the exception.You have to use -2146954640 instead.
The manpage of ioctl(2) says that the type of its 2nd argument is int, but it is a lie.
The prototype of ioctl(2) in /usr/include/sys/ioctl.h says it is unsigned int.
extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
Bug #5429 is the issue and it says:
- Free Unix uses unsigned int
- Commercial Unix uses int
This issue is fixed in trunk but not backported to 1.9.3 yet.
        
           Updated by shyouhei (Shyouhei Urabe) over 13 years ago
          Updated by shyouhei (Shyouhei Urabe) over 13 years ago
          
          
        
        
      
      Oh, I didn't know that. Thank you to point that out.
        
           Updated by kosaki (Motohiro KOSAKI) over 13 years ago
          Updated by kosaki (Motohiro KOSAKI) over 13 years ago
          
          
        
        
      
      On Sat, May 12, 2012 at 11:23 AM, naruse (Yui NARUSE) naruse@airemix.jp wrote:
Issue #6427 has been updated by naruse (Yui NARUSE).
shyouhei (Shyouhei Urabe) wrote:
Both ruby and glibc header file (and Ubuntu's manpage of ioctl(2)) agree that
ioctl takes int, and 2148012656 is greater than INT_MAX. Hence the exception.You have to use -2146954640 instead.
The manpage of ioctl(2) says that the type of its 2nd argument is int, but it is a lie.
The prototype of ioctl(2) in /usr/include/sys/ioctl.h says it is unsigned int.
extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;Bug #5429 is the issue and it says:
- Free Unix uses unsigned int
- Commercial Unix uses int
This issue is fixed in trunk but not backported to 1.9.3 yet.
btw, Linux community plan to fix man pages too.