home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.protocols.tcp-ip      TCP and IP network protocols.      14,669 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 13,498 of 14,669   
   Jorgen Grahn to Prakash   
   Re: ioctl() behaving different on Linux   
   03 May 10 08:46:31   
   
   3963b3f4   
   From: grahn+nntp@snipabacken.se   
      
   On Sun, 2010-05-02, Prakash wrote:   
   > On May 2, 1:03 am, Jorgen Grahn  wrote:   
   >> On Sat, 2010-05-01, Prakash wrote:   
   >> > Hello,   
   >>   
   >> > I am migrating the c application from Solaris 9 SPARC to RHEL 5.x   
   >> > x86_64 platform.   
      
   ...   
      
   >> >         /* Create unnamed socket pairs */   
   >> >         if ( socketpair(AF_UNIX, SOCK_STREAM,0,fd) == -1 ){   
   >> >                 fprintf(stdout, "socketpair call failed with errno: %d   
   >> > \n", errno);   
   >> >                 exit(1);   
   >> >         }   
   >>   
   >> >         fd_read = fd[0];   
   >> >         fd_write = fd[1];   
   >>   
   >> >         /* fcntl code comes here  to set non blocking read */   
   >>   
   >> >         if ( ioctl(fd_read, I_SRDOPT, RMSGN  ) == -1 ){  /* set read mode   
   to message -nondiscard mode */   
   >> >                 fprintf(stdout, "ioctl call failed with below error:\n" );   
      
   ...   
      
   >> I_SRDOPT seems to be related to STREAMS. I cannot find it documented   
   >> in Stevens' "Unixnetwork programming" books, and I have never used   
   >> STREAMS myself.  But I know the Linux people generally dislike it, and   
   >> last time I heard it was /not/ part of Linux except as a kernel patch.   
   >> It is most likely /not/ in RedHat's kernel.   
   >>   
   >> But the question is: if this is indeed STREAMS, and you don't have   
   >> that, then why are the ioctls defined in theheader files?  Perhaps   
   >> there are good reasons, but it's better when code that cannot possibly   
   >> work doesn't compile ...   
   >>   
   >> Also, normally I expect 'gcc -std=c89 -Wall -W -pedantic ...' not to   
   >> compile unless I say "I want BSD APIs" or "I want POSIX this and   
   >> that". See features.h. But for these things, there was *no*   
   >> protection. That's surely a bug in the headers.   
   >>   
   >> Someone else has to answer, but it seems to me you have a problem   
   >> here. The program you try to port uses Solaris-specific APIs. (OK,   
   >> some other Unices in the past may have had STREAMS too, but neither of   
   >> the healthy Unices -- Linux and the BSDs -- have it).   
      
   > Here is the output of strace:   
      
   ...   
   > socketpair(PF_FILE, SOCK_STREAM, 0, [3, 4]) = 0   
   > ioctl(3, CDROMREADTOCENTRY, 0x2)        = -1 EFAULT (Bad address)   
      
   ...   
      
   > I hope this extra details help you and others to understand the   
   > problem.   
      
   I already understand enough to be happy. You try to use STREAMS, and   
   Linux doesn't have STREAMS. And some glibc quirk makes this invisible   
   until you run the program.   
      
   > Let me know if you have any suggestions to replace ioctl()   
   > functionality (set the read to message-nondiscard mode) with other   
   > APIs.   
      
   As I wrote, I know nothing about STREAMS, so I cannot even understand   
   what "message-nondiscard mode" means, and cannot suggest alternatives.   
      
   If noone else here answers, and Google doesn't help, perhaps you can   
   ask on a Solaris newsgroup. comp.unix.solaris seems fairly active.   
      
   /Jorgen   
      
   --   
     // Jorgen Grahn    O  o   .   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca