[patch] netcfg get_all_ifs()

2009-07-06 Thread Luca Favatella
This patch substitutes Linux-specific code in get_all_ifs() using getifaddrs().


I tested this patch on (linux-)i386 trunk monolithic.
It builds and seems to work without regressions.
I only tested on default qemu, and the network seems to behave as
usual (I didn't complete the installation, but it seems to
download/unpack/configure downloaded packages).

I tested this patch in a draft hackish port of netcfg on kfreebsd-i386
(see d-i kfreebsd branch), and it builds.
netcfg is not working on kfreebsd-i386, but at least now it creates a
saner /etc/network/interfaces (i.e. with ed0, not eth0).


Cheers,
Luca Favatella


P.S.
At the moment I'm trying to port netcfg on GNU/kFreeBSD.
If reading the code of netcfg you find some Linux-specific code that
could be easily rewritten to be more portable (at least on GNU/k*BSD),
please try to get it in trunk or drop me a patch.
Index: debian/changelog
===
--- debian/changelog	(.../trunk/packages/netcfg)	(revisione 59247)
+++ debian/changelog	(.../branches/d-i/kfreebsd/packages/netcfg)	(revisione 59252)
@@ -8,6 +8,7 @@
   * If wireless is disabled, don't build and link wireless related stuff.
   * Disable by default wireless on non-linux architectures.
   * Inverse the logic about building without wireless support (WIRELESS=0).
+  * Substitute Linux-specific code in get_all_ifs() using getifaddrs().
 
   [ Colin Watson ]
   * check_kill_switch is Linux-specific; provide a stub implementation for
Index: netcfg-common.c
===
--- netcfg-common.c	(.../trunk/packages/netcfg)	(revisione 59247)
+++ netcfg-common.c	(.../branches/d-i/kfreebsd/packages/netcfg)	(revisione 59252)
@@ -45,6 +45,8 @@
 #include 
 #include 
 
+#include 
+
 /* Set if there is currently a progress bar displayed. */
 int netcfg_progress_displayed = 0;
 
@@ -227,53 +233,24 @@
 return ((ifr.ifr_flags & IFF_UP) ? 1 : 0);
 }
 
-void get_name(char *name, char *p)
-{
-while (isspace(*p))
-p++;
-while (*p) {
-if (isspace(*p))
-break;
-if (*p == ':') {	/* could be an alias */
-char *dot = p, *dotname = name;
-*name++ = *p++;
-while (isdigit(*p))
-*name++ = *p++;
-if (*p != ':') {	/* it wasn't, backup */
-p = dot;
-name = dotname;
-}
-if (*p == '\0')
-return;
-p++;
-break;
-}
-*name++ = *p++;
-}
-*name++ = '\0';
-return;
-}
-
 int get_all_ifs (int all, char*** ptr)
 {
-FILE *ifs = NULL;
-char ibuf[512], rbuf[512];
+struct ifaddrs *ifap, *ifa;
+char ibuf[512];
 char** list = NULL;
 size_t len = 0;
 
-if ((ifs = fopen("/proc/net/dev", "r")) != NULL) {
-fgets(ibuf, sizeof(ibuf), ifs); /* eat header */
-fgets(ibuf, sizeof(ibuf), ifs); /* ditto */
-}
-else
+if (getifaddrs(&ifap) == -1)
 return 0;
 
-while (fgets(rbuf, sizeof(rbuf), ifs) != NULL) {
-get_name(ibuf, rbuf);
-if (!strcmp(ibuf, "lo"))/* ignore the loopback */
+for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
+strncpy(ibuf, ifa->ifa_name, sizeof(ibuf));
+if (!strncmp(ibuf, "lo", 2))/* ignore the loopback */
 continue;
+#if defined(__linux__)
 if (!strncmp(ibuf, "sit", 3))/* ignore tunnel devices */
 continue;
+#endif
 #if defined(WIRELESS)
 if (is_raw_80211(ibuf))
 continue;
@@ -290,7 +267,7 @@
 list = realloc(list, sizeof(char*) * (len + 1));
 list[len] = NULL;
 }
-fclose (ifs);
+freeifaddrs(ifap);
 
 *ptr = list;
 


[patch] libdebian-installer poll()

2009-07-06 Thread Luca Favatella
This patch solves a poll() portability issue on kfreebsd-i386, and
shouldn't affect other archs.

I tested this on kfreebsd-i386, solving an infinite loop.


Cheers,
Luca Favatella
Index: debian/changelog
===
--- debian/changelog	(.../trunk/packages/libdebian-installer)	(revision 59247)
+++ debian/changelog	(.../branches/d-i/kfreebsd/packages/libdebian-installer)	(revision 59254)
@@ -2,6 +2,10 @@
 
   * Remove a duplicated line from debian/copyright.
 
+  [ Luca Favatella ]
+  * The poll() system call has EOF-related portability issues. Solve them on
+kfreebsd-i386. Thanks to Colin Watson for the "poll() and EOF" URL.
+
  -- Colin Watson   Thu, 18 Jun 2009 12:40:52 +0100
 
 libdebian-installer (0.63) unstable; urgency=low
Index: src/exec.c
===
--- src/exec.c	(.../trunk/packages/libdebian-installer)	(revision 59247)
+++ src/exec.c	(.../branches/d-i/kfreebsd/packages/libdebian-installer)	(revision 59254)
@@ -164,7 +164,12 @@
 
 for (i = 0; i < pipes; i++)
 {
+// References: http://www.greenend.org.uk/rjk/2001/06/poll.html
+#if defined(__FreeBSD_kernel__)
+  if ((pollfds[i].revents & POLLIN) && (! (pollfds[i].revents & POLLHUP)))
+#else
   if (pollfds[i].revents & POLLIN)
+#endif
   {
 while (fgets (line, sizeof (line), files[i].file) != NULL)
 {


[patch] installer ufs initrd support (how to create a ufs filesystem as a normal user?)

2009-07-06 Thread Luca Favatella
This patch adds ufs initrd support.
It was in the previous d-i kfreebsd branch, so thanks to Robert Millan.

This code has the bad thing that mkfs.ufs must be executed as root,
and I don't know how to create a ufs filesystem on kfreebsd without
being root.
Comments on how to create a ufs filesystem as a normal user?


I use this on kfreebsd-i386.


Cheers,
Luca Favatella
Index: build/Makefile
===
--- build/Makefile	(.../trunk/installer)	(revision 59247)
+++ build/Makefile	(.../branches/d-i/kfreebsd/installer)	(revision 59256)
@@ -119,6 +119,18 @@
   (cd $(TREE) && find . | cpio --quiet -o -H newc) > 
 endef
 
+define mkfs.ufs
+  fs=`mktemp` ; \
+  dd if=/dev/zero of=$${fs} bs=1M count=16 ; \
+  md=`mdconfig -a -t vnode -f $${fs}` ; \
+  mkfs.ufs /dev/$${md} ; \
+  mnt=`mktemp -d` ; mount /dev/$${md} $${mnt} ; \
+  cp -a $(TREE)/* $${mnt}/ ; \
+  umount $${mnt} ; rmdir $${mnt} ; \
+  mdconfig -d -u $${md} ; \
+  mv $${fs}
+endef
+
 define e2fsck
   e2fsck -fy
 endef
@@ -610,6 +622,10 @@
 	jffs2) \
 		$(mkjffs2) $(TEMP_INITRD); \
 	;; \
+	ufs) \
+		$(mkfs.ufs) $(TEMP)/initrd; \
+		gzip -v9f $(TEMP)/initrd; \
+	;; \
 	*) \
 		echo "Unsupported filesystem type"; \
 		exit 1 ;; \
Index: debian/changelog
===
--- debian/changelog	(.../trunk/installer)	(revision 59247)
+++ debian/changelog	(.../branches/d-i/kfreebsd/installer)	(revision 59256)
@@ -76,6 +76,7 @@
 
   [ Luca Favatella ]
   * Handle libc0.1 (GNU/kFreeBSD) and libc0.3 (GNU/Hurd) as libc6/libc6.1.
+  * Add ufs initrd support. Thanks to Robert Millan.
 
  -- Frans Pop   Sat, 13 Jun 2009 16:35:46 +0200
 


hal: almost ready (was: Plans for libvolume-id?)

2009-07-06 Thread Cyril Brulebois
Cyril Brulebois  (01/07/2009):
> As agreed during a quick conversation on IRC (also with the
> maintainer), I'm going to work on getting that library in a reasonable
> shape, so that we are ready when 0.5.12 gets uploaded (which is
> blocked by util-linux, e2fsprogs, udev, etc. see #528830). Which means
> I'm cheating with the locally-hacked libvolume-id library for now, and
> that we'll only have to do some bits of porting for libblkid by then.

“almost” for the above-mentioned reason.

Just posted an updated patch against the sid version, which makes it
buildable if one has the locally-hacked libvolume-id library, in a way
that should be suitable for the maintainer.

If anyone's interested in getting the patch:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=528383#25

Mraw,
KiBi.


-- 
To UNSUBSCRIBE, email to debian-bsd-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org