public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: "Tseng-hui Lin" <tsenglin@us.ibm.com>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] x86 compatability problem: ioctl() SIOCGIFCONF
Date: Wed, 20 Feb 2002 17:03:51 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590701905147@msgid-missing> (raw)

    I need to keep some x86 code alive in IA64 land. It looks like ioctl()
SIOCGIFCONF function doesn't work. I compiled the attached test program on
an x86 machine and ran it on an RedHat 7.2 Linux/IA64. It gave me "ioctl
SIOCGIFCONF: Bad address". The program works if it is compiled and run on
an IA64 machine. I know that the sizes of struct ifreq are different on x86
and IA64. However, it hasn't reached that part yet. I thought it might be
memory alignment problem since ioctl() returns "Bad address". I put some
paddings to make the variables allocated on 8-byte boundary but the problem
is still there. Has any one seen this problem before?

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>

#define MAX_NUM_IFREQ (512)

main() {
    struct ifconf       Ifc;
    struct ifreq        IfcBuf[MAX_NUM_IFREQ];
    struct ifreq        *pIfr;
    int num_ifreq;
    int i;
    int fd;

    Ifc.ifc_len = sizeof(IfcBuf);
    Ifc.ifc_buf = (char *) IfcBuf;

    if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
        perror("socket()");
        exit(1);
    }
    if ( ioctl(fd, SIOCGIFCONF, &Ifc) < 0) {
        perror("ioctl SIOCGIFCONF");
        exit(1);
    }
    num_ifreq = Ifc.ifc_len / sizeof(struct ifreq);
    for ( pIfr = Ifc.ifc_req, i = 0 ; i < num_ifreq; pIfr++, i++ ) {
        printf("%d: %s<=\n", i, pIfr->ifr_name);
    }
}

Tseng-Hui (Frank) Lin  tsenglin@us.ibm.com
Phone:(512)838-8312  T/L 678-8312
FAX: (512)838-3484 T/L 678-3484
IBM Poughkeepsie Unix Development Lab, Dept XXWA
Building 905-2H018, 11501 Burnet Road, Austin, TX 78758



             reply	other threads:[~2002-02-20 17:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-20 17:03 Tseng-hui Lin [this message]
2002-02-20 17:21 ` [Linux-ia64] x86 compatability problem: ioctl() SIOCGIFCONF n0ano
2002-02-21  6:59 ` Don Dugger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-ia64-105590701905147@msgid-missing \
    --to=tsenglin@us.ibm.com \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox