LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: viro@parcelfarce.linux.theplanet.co.uk
To: Joshua Kwan <joshk@triplehelix.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: consistent ioctl for getting all net interfaces?
Date: Sun, 23 May 2004 06:35:38 +0100	[thread overview]
Message-ID: <20040523053538.GW17014@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <pan.2004.05.23.04.28.28.143054@triplehelix.org>

On Sat, May 22, 2004 at 09:28:28PM -0700, Joshua Kwan wrote:
> Hi,
> 
> I'm interested in not having to parse /proc/net/dev to get a list of all
> available (not necessarily even up) interfaces on the system. I
> investigated the ioctl SIOCGIFCONF, but it seems to behave differently on
> 2.4 and 2.6 series kernels, e.g. sometimes it won't return all interfaces.
> 
> Is there some end-all ioctl that does what I want, or am I forever doomed
> to process /proc/net/dev (in C, no less..)?

ASCII is tough, let's go shopping?

	char name[17];
	FILE *in = fopen("/proc/net/dev", "r");
	if (!in)
		die("can't open");
	fscanf(in, "%*[^\n]\n%*[^\n]");		/* skip two lines */
	while (fscanf(in, " %16[^:]:%*[^\n]", name) == 1)
		do_whatever_you_want(name);

That you are calling "forever doomed"?  Wimp...

  reply	other threads:[~2004-05-23  5:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-23  4:28 Joshua Kwan
2004-05-23  5:35 ` viro [this message]
2004-05-23  5:57   ` Joshua Kwan
2004-05-23  6:05     ` viro
2004-05-23 15:20 ` Tigran Aivazian
2004-05-23 15:25   ` Tigran Aivazian
2004-05-23 15:29   ` Joshua Kwan
2004-05-30 20:25 ` Olaf Hering
2004-05-23 12:35 Albert Cahalan

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=20040523053538.GW17014@parcelfarce.linux.theplanet.co.uk \
    --to=viro@parcelfarce.linux.theplanet.co.uk \
    --cc=joshk@triplehelix.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: consistent ioctl for getting all net interfaces?' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).