[klibc] bunch of small fixes

maximilian attems max at stro.at
Tue Mar 25 08:39:36 PDT 2008


hello hpa,

ok added to the bunch of debian fixes also patches of klibc ml,
previously forgot to cc Sam for the header install fix.
could test all but the nilfs2 one.

please pull
git pull git://git.debian.org/~maks/klibc.git maks

for the changes:
Aaron Griffin (1):
      [klibc] kinit: skip md assembly if mdX exists

Colin Watson (1):
      [klibc] mount/umount FUSE support

David Flynn (1):
      [klibc] nfsmount: added options support for [no]acl

Harald Jenny (1):
      [klibc] fstype: tuxonice swap signature

Michal Sojka (1):
      [klibc] ipconfig: fix indef loop with multiple interfaces

Stephane Chazelas (2):
      [klibc] fstype: fix size returned for jfs
      [klibc] fstype: nilfs2 support

maximilian attems (2):
      [klibc] Kbuild.install header install target cleanup
      [klibc] .gitingore: move havesyscall.h entry to top .gitignore

the diffstat is:
 .gitignore                   |    3 ++
 scripts/Kbuild.install       |    8 ++--
 usr/include/klibc/.gitignore |    1 -
 usr/kinit/do_mounts_md.c     |    4 ++
 usr/kinit/fstype/fstype.c    |   21 ++++++++++++-
 usr/kinit/fstype/nilfs_fs.h  |   64 ++++++++++++++++++++++++++++++++++++++++++
 usr/kinit/fstype/swap_fs.h   |    5 +++
 usr/kinit/ipconfig/main.c    |    1 +
 usr/kinit/nfsmount/main.c    |    2 +
 usr/utils/mount_main.c       |   10 +++++-
 usr/utils/umount.c           |    8 ++++-
 11 files changed, 116 insertions(+), 11 deletions(-)
 delete mode 100644 usr/include/klibc/.gitignore
 create mode 100644 usr/kinit/fstype/nilfs_fs.h

thanks
maks


ps below the actual patches

commit 1b43fb87b4f20c9a2a80b7fa9438722da037931d
Author: Michal Sojka <sojkam1 at fel.cvut.cz>
Date:   Tue Mar 25 16:09:44 2008 +0100

    [klibc] ipconfig: fix indef loop with multiple interfaces
    
    if ipconfig is run as ipconfig :::::: (i.e. long spec with all fields empty)
    and the computer has multiple network interfaces and only one of them is
    connected to dhcp managed network, ipconfig ends up in an infinite loop (see
    the log bellow).
    
    The following patch solved this for me. According to README, if the <device>
    in the long spec is empty, the first interface should be used, but the
    program busy wait for all interfaces.
    
    (easily testable on any laptop with 2 interfaces eth0 and wlan0,
     fixed ipconfig no longer loops indefinitely:
     ./src/klibc/usr/kinit/ipconfig/static/ipconfig -d ::::::
    IP-Config: eth0 hardware address 00:16:d3:3e:31:5c mtu 1500 DHCP RARP
    IP-Config: wlan0 hardware address 00:13:e8:70:59:fb mtu 1500 DHCP RARP
    IP-Config: eth0 guessed broadcast address 128.131.48.255
    IP-Config: eth0 complete (from 128.131.48.127):
     address: 128.131.48.177   broadcast: 128.131.48.255   netmask: 255.255.255.0
     gateway: 128.131.48.1     dns0     : 128.130.4.3      dns1   : 128.131.4.3
     domain : itp.tuwien.ac.at
     rootserver: 128.131.48.127 rootpath:
     filename  : /pxelinux.0
    )
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c
index 50141e5..72bfdaf 100644
--- a/usr/kinit/ipconfig/main.c
+++ b/usr/kinit/ipconfig/main.c
@@ -534,6 +534,7 @@ static int parse_device(struct netdev *dev, const char *ip)
 	if (dev->name == NULL ||
 	    dev->name[0] == '\0' || strcmp(dev->name, "all") == 0) {
 		add_all_devices(dev);
+		bringup_first = 1;
 		return 0;
 	}
 	return 1;

commit 3a66c53df5b628bd035cee2f026c52a3d7355fc9
Author: Stephane Chazelas <Stephane_Chazelas at yahoo.fr>
Date:   Mon Mar 3 17:24:18 2008 +0000

    [klibc] fstype: nilfs2 support
    
    this patch adds support for the NILFS2 (http://www.nilfs.org/)
    filesystem to fstype (on top of 1.5.7 from the debian package).
    Please let me know what you think.
    
    (note debian sid has no mkfs.nilfs2, compile tested. -maks)
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index 69b6ec9..10d2a61 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -33,6 +33,7 @@
 #include "squashfs_fs.h"
 #include "gfs2_fs.h"
 #include "ocfs2_fs.h"
+#include "nilfs_fs.h"
 
 /*
  * Slightly cleaned up version of jfs_superblock to
@@ -330,6 +331,19 @@ static int ocfs2_image(const void *buf, unsigned long long *bytes)
 	return 0;
 }
 
+static int nilfs2_image(const void *buf, unsigned long long *bytes)
+{
+	const struct nilfs_super_block *sb =
+	    (const struct nilfs_super_block *)buf;
+
+	if (sb->s_magic == __cpu_to_le16(NILFS_SUPER_MAGIC) &&
+	    sb->s_rev_level == __cpu_to_le32(2)) {
+		*bytes = (unsigned long long)__le64_to_cpu(sb->s_dev_size);
+		return 1;
+	}
+	return 0;
+}
+
 struct imagetype {
 	off_t block;
 	const char name[12];
@@ -358,6 +372,7 @@ static struct imagetype images[] = {
 	{1, "ext3", ext3_image},
 	{1, "ext2", ext2_image},
 	{1, "minix", minix_image},
+	{1, "nilfs2", nilfs2_image},
 	{2, "ocfs2", ocfs2_image},
 	{8, "reiserfs", reiserfs_image},
 	{64, "reiserfs", reiserfs_image},
diff --git a/usr/kinit/fstype/nilfs_fs.h b/usr/kinit/fstype/nilfs_fs.h
new file mode 100644
index 0000000..0845edf
--- /dev/null
+++ b/usr/kinit/fstype/nilfs_fs.h
@@ -0,0 +1,64 @@
+#ifndef __NILFS_FS_H
+#define __NILFS_FS_H
+
+#define NILFS_SUPER_MAGIC       0x3434  /* NILFS filesystem  magic number */
+
+/*
+ * struct nilfs_super_block - structure of super block on disk
+ */
+struct nilfs_super_block {
+	__le32	s_rev_level;		/* Revision level */
+	__le16	s_minor_rev_level;	/* minor revision level */
+	__le16	s_magic;		/* Magic signature */
+
+	__le16  s_bytes;		/* Bytes count of CRC calculation
+					   for this structure. s_reserved
+					   is excluded. */
+	__le16  s_flags;		/* flags */
+	__le32  s_crc_seed;		/* Seed value of CRC calculation */
+	__le32	s_sum;			/* Check sum of super block */
+
+	__le32	s_log_block_size;	/* Block size represented as follows
+					   blocksize = 1 << (s_log_block_size + 10) */
+	__le64  s_nsegments;		/* Number of segments in filesystem */
+	__le64  s_dev_size;		/* block device size in bytes */
+	__le64	s_first_data_block;	/* 1st seg disk block number */
+	__le32  s_blocks_per_segment;   /* number of blocks per full segment */
+	__le32	s_r_segments_percentage;/* Reserved segments percentage */ /* or __le16 */
+
+	__le64  s_last_cno;		/* Last checkpoint number */
+	__le64  s_last_pseg;		/* disk block addr pseg written last */
+	__le64  s_last_seq;             /* seq. number of seg written last */
+	__le64	s_free_blocks_count;	/* Free blocks count */
+
+	__le64	s_ctime;		/* Creation time (execution time of newfs) */
+	__le64	s_mtime;		/* Mount time */
+	__le64	s_wtime;		/* Write time */
+	__le16	s_mnt_count;		/* Mount count */
+	__le16	s_max_mnt_count;	/* Maximal mount count */
+	__le16	s_state;		/* File system state */
+	__le16	s_errors;		/* Behaviour when detecting errors */
+	__le64	s_lastcheck;		/* time of last check */
+
+	__le32	s_checkinterval;	/* max. time between checks */
+	__le32	s_creator_os;		/* OS */
+	__le16	s_def_resuid;		/* Default uid for reserved blocks */
+	__le16	s_def_resgid;		/* Default gid for reserved blocks */
+	__le32	s_first_ino; 		/* First non-reserved inode */ /* or __le16 */
+
+	__le16  s_inode_size; 		/* Size of an inode */
+	__le16  s_dat_entry_size;       /* Size of a dat entry */
+	__le16  s_checkpoint_size;      /* Size of a checkpoint */
+	__le16	s_segment_usage_size;	/* Size of a segment usage */
+
+	__u8	s_uuid[16];		/* 128-bit uuid for volume */
+	char	s_volume_name[16]; 	/* volume name */
+	char	s_last_mounted[64]; 	/* directory where last mounted */
+
+	__le32  s_c_interval;           /* Commit interval of segment */
+	__le32  s_c_block_max;          /* Threshold of data amount for
+					   the segment construction */
+	__u32	s_reserved[192];	/* padding to the end of the block */
+};
+
+#endif /* __NILFS_FS_H */

commit da1cd4384f211aca92bfb928620af08de3dec6dc
Author: David Flynn <davidf at rd.bbc.co.uk>
Date:   Tue Feb 26 17:21:11 2008 +0000

    [klibc] nfsmount: added options support for [no]acl
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/kinit/nfsmount/main.c b/usr/kinit/nfsmount/main.c
index 2e2eec7..e9f8a0e 100644
--- a/usr/kinit/nfsmount/main.c
+++ b/usr/kinit/nfsmount/main.c
@@ -70,6 +70,8 @@ static struct bool_opts {
 	{"noac", ~NFS_MOUNT_NOAC, NFS_MOUNT_NOAC},
 	{"lock", ~NFS_MOUNT_NONLM, 0},
 	{"nolock", ~NFS_MOUNT_NONLM, NFS_MOUNT_NONLM},
+	{"acl", ~NFS_MOUNT_NOACL, 0},
+	{"noacl", ~NFS_MOUNT_NOACL, NFS_MOUNT_NOACL},
 	{"v2", ~NFS_MOUNT_VER3, 0},
 	{"v3", ~NFS_MOUNT_VER3, NFS_MOUNT_VER3},
 	{"udp", ~NFS_MOUNT_TCP, 0},

commit fe22acb5289b05c1af50bda2c5d249b5d2f0eb5b
Author: Stephane Chazelas <Stephane_Chazelas at yahoo.fr>
Date:   Mon Mar 3 17:15:05 2008 +0000

    [klibc] fstype: fix size returned for jfs
    
    I've noticed that the size returned by the fstype utility was
    not correct for JFS filesystems (it returns the size in number
    of HW blocks instead of bytes).
    
    Here is a simple patch that addresses it (based on 1.5.7 from
    the debian package).
    
    (easily testable:
    
    lvcreate -L 1G -n jfstest dualvg0
      Logical volume "jfstest" created
    
    mkfs.jfs -q /dev/dualvg0/jfstest > /dev/null
    
    /usr/lib/klibc/bin/fstype  /dev/dualvg0/jfstest
     FSTYPE=jfs
     FSSIZE=2088488
    
    fstype with aboves patch applied gives:
     ./usr/kinit/fstype/static/fstype /dev/mapper/dualvg0-jfstest
     FSTYPE=jfs
     FSSIZE=1069305856
    )
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index c8fa94c..69b6ec9 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -205,7 +205,7 @@ static int jfs_image(const void *buf, unsigned long long *bytes)
 	const struct jfs_superblock *sb = (const struct jfs_superblock *)buf;
 
 	if (!memcmp(sb->s_magic, JFS_MAGIC, 4)) {
-		*bytes = __le32_to_cpu(sb->s_size);
+		*bytes = __le64_to_cpu(sb->s_size) << __le16_to_cpu(sb->s_l2pbsize);
 		return 1;
 	}
 	return 0;

commit 16196c58c8d78b3cb286c6a407a3cc802025e58e
Author: Colin Watson <cjwatson at ubuntu.com>
Date:   Tue Mar 25 10:38:07 2008 +0100

    [klibc] mount/umount FUSE support
    
    add -i and -f options as fuse does:
    	execl("/bin/mount", "/bin/mount", "-i", "-f", "-t", type, "-o", opts,
    		fsname, mnt, NULL);
    
    it is relevant if someone tries to put ntfs-3g in the initramfs.
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/utils/mount_main.c b/usr/utils/mount_main.c
index fd62000..2fea3e3 100644
--- a/usr/utils/mount_main.c
+++ b/usr/utils/mount_main.c
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
 	rwflag = MS_VERBOSE;
 
 	do {
-		c = getopt(argc, argv, "no:rt:w");
+		c = getopt(argc, argv, "no:rt:wfi");
 		if (c == EOF)
 			break;
 		switch (c) {
@@ -83,6 +83,12 @@ int main(int argc, char *argv[])
 		case 'w':
 			rwflag &= ~MS_RDONLY;
 			break;
+		case 'f':
+			/* we can't edit /etc/mtab yet anyway; exit */
+			exit(0);
+		case 'i':
+			/* ignore for now; no support for mount helpers */
+			break;
 		case '?':
 			fprintf(stderr, "%s: invalid option -%c\n",
 				progname, optopt);
@@ -98,7 +104,7 @@ int main(int argc, char *argv[])
 		type = "none";
 
 	if (optind + 2 != argc || type == NULL) {
-		fprintf(stderr, "Usage: %s [-r] [-w] [-o options] [-t type] "
+		fprintf(stderr, "Usage: %s [-r] [-w] [-o options] [-t type] [-f] [-i] "
 			"[-n] device directory\n", progname);
 		exit(1);
 	}
diff --git a/usr/utils/umount.c b/usr/utils/umount.c
index 85497a7..4469297 100644
--- a/usr/utils/umount.c
+++ b/usr/utils/umount.c
@@ -17,7 +17,7 @@ int main(int argc, char *argv[])
 	progname = argv[0];
 
 	do {
-		c = getopt(argc, argv, "fl");
+		c = getopt(argc, argv, "fli");
 		if (c == EOF)
 			break;
 		switch (c) {
@@ -27,6 +27,9 @@ int main(int argc, char *argv[])
 		case 'l':
 			flag |= MNT_DETACH;
 			break;
+		case 'i':
+			/* ignore for now; no support for umount helpers */
+			break;
 		case '?':
 			fprintf(stderr, "%s: invalid option -%c\n",
 				progname, optopt);
@@ -35,7 +38,8 @@ int main(int argc, char *argv[])
 	} while (1);
 
 	if (optind + 1 != argc) {
-		fprintf(stderr, "Usage: %s [-f] [-l] mntpoint\n", progname);
+		fprintf(stderr, "Usage: %s [-f] [-l] [-i] mntpoint\n",
+			progname);
 		return 1;
 	}
 

commit eb3edc45fd0c5849331ff1b0ccaa4da348b97609
Author: Harald Jenny <harald at a-little-linux-box.at>
Date:   Mon Mar 24 20:03:20 2008 +0100

    [klibc] fstype: tuxonice swap signature
    
    please find attached a patch which adds support for tuxonice (formerly
    suspend2) swap partition recognition to klibc-utils 1.5.8-1. It adds two
    new signatures to swap space detection which are used by tuxonice in
    version 3.0-rc5 (don't know when they were put in use, but fstype
    stopped working for me some time ago).
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index ea7171b..c8fa94c 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -244,7 +244,9 @@ static int suspend_image(const void *buf, unsigned long long *blocks)
 
 	if (!memcmp(ssb->magic, SUSP_MAGIC_1, SUSP_MAGIC_L) ||
 	    !memcmp(ssb->magic, SUSP_MAGIC_2, SUSP_MAGIC_L) ||
-	    !memcmp(ssb->magic, SUSP_MAGIC_U, SUSP_MAGIC_L)) {
+	    !memcmp(ssb->magic, SUSP_MAGIC_U, SUSP_MAGIC_L) ||
+	    !memcmp(ssb->magic, TOI_MAGIC_1, TOI_MAGIC_L) ||
+	    !memcmp(ssb->magic, TOI_MAGIC_2, TOI_MAGIC_L)) {
 		*blocks = 0;
 		return 1;
 	}
diff --git a/usr/kinit/fstype/swap_fs.h b/usr/kinit/fstype/swap_fs.h
index 7b7fddb..f76bf02 100644
--- a/usr/kinit/fstype/swap_fs.h
+++ b/usr/kinit/fstype/swap_fs.h
@@ -13,6 +13,11 @@
 #define SUSP_MAGIC_2		"S2SUSPEND"
 #define SUSP_MAGIC_U		"ULSUSPEND"
 
+/* TuxOnIce signatures, located at same addr as swap magic */
+#define TOI_MAGIC_L		1
+#define TOI_MAGIC_1		"z"
+#define TOI_MAGIC_2		"Z"
+
 /* The superblock is the last block in the first page */
 #define SWAP_OFFSET()		((getpagesize() - 1024) >> 10)
 

commit 6752cb2fe4134b9daaf6121cf3413f571d2c979d
Author: maximilian attems <max at stro.at>
Date:   Tue Mar 25 10:25:30 2008 +0100

    [klibc] .gitingore: move havesyscall.h entry to top .gitignore
    
    it seems that .gitignore honours pathes, thus move
    the include/klibc/.gitignore line to top.
    otherwise we end up shipping this file in the header target.
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/.gitignore b/.gitignore
index d67ae65..efc15f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,6 @@
 *.o.cmd
 .*.cmd
 *.g
+
+# generated header
+usr/include/klibc/havesyscall.h
diff --git a/usr/include/klibc/.gitignore b/usr/include/klibc/.gitignore
deleted file mode 100644
index 8246d7f..0000000
--- a/usr/include/klibc/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-havesyscall.h

commit d33c99c558a7cf8ab3dad63fd89a634dcaebb469
Author: maximilian attems <max at stro.at>
Date:   Wed Dec 12 00:42:10 2007 +0100

    [klibc] Kbuild.install header install target cleanup
    
    - only create a dir if we really copy stuff to it.
    - add dual arch asm target (seen missing due to latest x86 arch merge)
    - headers_install in linux-2.6 exports no scsi headers anymore
    
    Cc: Sam Ravnborg <sam at ravnborg.org>
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/scripts/Kbuild.install b/scripts/Kbuild.install
index 1575169..44c8f76 100644
--- a/scripts/Kbuild.install
+++ b/scripts/Kbuild.install
@@ -95,12 +95,12 @@ header:
 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)lib
 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)bin
-	$(Q)set -e ; for d in linux scsi asm-$(KLIBCARCH) asm-generic $(ASMKLIBCARCH); do \
-	  mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)include/$$d ; \
+	$(Q)set -e ; for d in linux asm asm-$(KLIBCARCH) asm-generic $(ASMKLIBCARCH); do \
 	  for r in $(KLIBCKERNELSRC)/include $(KLIBCKERNELOBJ)/include \
 	           $(KLIBCKERNELOBJ)/include2 ; do \
-	    [ ! -d $$r/$$d ] || \
-	      cp -rfL $$r/$$d/. \
+	    [ ! -d $$r/$$d ] && continue; \
+	    mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)include/$$d ; \
+	    cp -rfL $$r/$$d/. \
 	          $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/$$d/. ; \
 	  done ; \
 	done

commit 9a6c1084bf4296840c0ed3877839af91c4ac2de3
Author: Aaron Griffin <aaronmgriffin at gmail.com>
Date:   Tue Sep 4 12:22:43 2007 +0200

    [klibc] kinit: skip md assembly if mdX exists
    
    mkinitcpio initramfs(?) tries to start root MD device twice
    http://bugs.archlinux.org/task/4938
    
    Belows patch shipped for one year in Archlinux,
    which seems to be an heavy kinit user.  -maks
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/kinit/do_mounts_md.c b/usr/kinit/do_mounts_md.c
index e5bbe21..c1c8b01 100644
--- a/usr/kinit/do_mounts_md.c
+++ b/usr/kinit/do_mounts_md.c
@@ -227,6 +227,7 @@ static void md_setup_drive(void)
 		char *devname;
 		mdu_disk_info_t dinfo;
 		char name[16];
+		struct stat st_chk;
 
 		dev_minor = md_setup_args[ent].minor;
 		partitioned = md_setup_args[ent].partitioned;
@@ -235,6 +236,9 @@ static void md_setup_drive(void)
 		snprintf(name, sizeof name,
 			 "/dev/md%s%d", partitioned ? "_d" : "", dev_minor);
 
+		if (stat(name, &st_chk) == 0)
+			continue;
+
 		if (partitioned)
 			dev = makedev(mdp_major(), dev_minor << MdpMinorShift);
 		else



More information about the klibc mailing list