develooper Front page | perl.perl5.porters | Postings from September 2003

64bit pack + ioctl problem

Thread Next
From:
Armin Obersteiner
Date:
September 6, 2003 16:21
Subject:
64bit pack + ioctl problem
Message ID:
20030906232042.GA18932@elch.elche
hi!

I'm the author of CDDB_get. This module works for 32bit litte/big endien archs.
I got a bugreport for OpenBSD / sparc64, it does not work there:

The problem is to read the table of contents of a CD. The C structure is:

struct ioc_read_toc_entry {
        u_char  address_format;
        u_char  starting_track;
        u_short data_len;
        struct  cd_toc_entry *data;
};

u_short is 2 bytes on this machine. (on any so far ;-)

this is the code:

  my $BIG_ENDIAN = unpack("h*", pack("s", 1)) =~ /01/;

  my $tocentry;
  my $toc="";
  my $size=0;
  for(@tracks) {
    $toc.="        ";
    $size+=8;
  }

  if($os =~ /BSD/) {
    my $size_hi=int($size / 256);
    my $size_lo=$size & 255;

    if($BIG_ENDIAN) {
      $tocentry=pack "CCCCP8l", $CDROM_MSF,0,$size_hi,$size_lo,$toc;
    } else {
      $tocentry=pack "CCCCP8l", $CDROM_MSF,0,$size_lo,$size_hi,$toc;
    }
    ioctl(CD, $CDROMREADTOCENTRY, $tocentry) or die "cannot read track info [$!] [$device]";
  }

All I get is: fatal error: Bad address in the ioctl line

perl version: 5.8.0

Do you have an idea why this works on intel/sparc/32bit/(net|free|open)BSD and Linux, 
and why it does not work with sparc/64bit/openBSD.

Of course it could be the pointer size, but I tried "l!", "p", "P", ... none of it worked.
I get the same error.

Any ideas?

Thanks,
	Armin
--
armin@xos.net                        pgp public key on request        CU

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About