LKML Archive on
help / color / mirror / Atom feed
To: Joshua Kwan <>
Subject: Re: consistent ioctl for getting all net interfaces?
Date: Sun, 23 May 2004 06:35:38 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

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)

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:

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

  git send-email \ \ \ \ \
    --subject='Re: consistent ioctl for getting all net interfaces?' \

* 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).