chiark / gitweb /
[PATCH] klibc specific tweaks
authorgreg@kroah.com <greg@kroah.com>
Thu, 23 Oct 2003 06:48:55 +0000 (23:48 -0700)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:06:22 +0000 (21:06 -0700)
Makefile.klibc
klibc.c [new file with mode: 0644]
klibc/klibc/include/signal.h
libsysfs/sysfs_dir.c
libsysfs/sysfs_utils.c
namedev.c
udev-add.c

index d679ba900bd6030ec2dd97ddb2618ca201137dee..ccc862dd8bd7b306f34d3d1ba74e9b22059c128f 100644 (file)
@@ -106,7 +106,7 @@ endif
 # If we are using our version of klibc, then we need to build and link it.
 # Otherwise, use glibc and link statically.
 ifeq ($(strip $(KLIBC)),true)
-       KLIBC_DIR       = /home/greg/src/klibc/klibc/klibc
+       KLIBC_DIR       = klibc/klibc
        INCLUDE_DIR     := $(KLIBC_DIR)/include
        # arch specific objects
        LIBGCC          = $(shell $(CC) --print-libgcc)
@@ -120,7 +120,7 @@ ifeq ($(strip $(KLIBC)),true)
 #      LIB_OBJS =      $(GCC_LIB)
 
        LIBC =  $(ARCH_LIB_OBJS) $(LIB_OBJS)
-       CFLAGS += -nostdinc -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/bits32 -I/home/greg/linux/linux-2.5/include -I$(GCCINCDIR)
+       CFLAGS += -nostdinc -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/bits32 -I/home/greg/linux/linux-2.5/include -I$(GCCINCDIR) -D__KLIBC__
        LDFLAGS =
 #      LDFLAGS = --static --nostdlib -nostartfiles
 else
@@ -130,15 +130,21 @@ else
        LDFLAGS = --static 
 endif
 
-LIB=libsysfs
-
 all: $(LIBC) $(ROOT)
 
 $(ARCH_LIB_OBJS) :
        $(MAKE) -C klibc
 
-LIBSYSFS = libsysfs/libsysfs.a
-TDB = tdb/tdb.o tdb/spinlock.o
+TDB =  tdb/tdb.o       \
+       tdb/spinlock.o
+
+SYSFS =        libsysfs/sysfs_bus.o    \
+       libsysfs/sysfs_class.o  \
+       libsysfs/sysfs_device.o \
+       libsysfs/sysfs_dir.o    \
+       libsysfs/sysfs_driver.o \
+       libsysfs/sysfs_utils.o  \
+       libsysfs/dlist.o
 
 OBJS = udev.o          \
        udev-add.o      \
@@ -146,14 +152,10 @@ OBJS =    udev.o          \
        udevdb.o        \
        logging.o       \
        namedev.o       \
+       klibc.o         \
+       $(SYSFS)        \
        $(TDB)
 
-libsysfs/libsysfs.a:
-       $(MAKE) -C libsysfs
-
-tdb/tdb.o:
-       $(MAKE) -C tdb
-
 # header files automatically generated
 GEN_HEADERS =  udev_version.h
 
@@ -165,7 +167,7 @@ udev_version.h:
 
 
 $(ROOT): $(GEN_HEADERS) $(OBJS)
-#      $(CC) $(LDFLAGS) -o $(ROOT) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
+       $(CC) $(LDFLAGS) -o $(ROOT) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
        $(LD) $(LDFLAGS) -o $(ROOT) $(KLIBC_DIR)/crt0.o $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
        $(STRIPCMD) $(ROOT)
 
@@ -174,24 +176,4 @@ clean:
         | xargs rm -f 
        -rm -f core $(ROOT) $(GEN_HEADERS)
        $(MAKE) -C klibc clean
-       $(MAKE) -C libsysfs clean
-       $(MAKE) -C tdb clean
 
-DISTFILES = $(shell find . \( -not -name '.' \) -print | grep -v CVS | grep -v "\.tar\.gz" | grep -v "\/\." | grep -v releases | grep -v BitKeeper | grep -v SCCS | grep -v "\.tdb" | grep -v "test\/sys" | sort )
-DISTDIR := $(RELEASE_NAME)
-srcdir = .
-release: $(DISTFILES) clean
-#      @echo $(DISTFILES)
-       @-rm -rf $(DISTDIR)
-       @mkdir $(DISTDIR)
-       @-chmod 777 $(DISTDIR)
-       @for file in $(DISTFILES); do                   \
-               if test -d $$file; then                 \
-                       mkdir $(DISTDIR)/$$file;        \
-               else                                    \
-                       cp -p $$file $(DISTDIR)/$$file; \
-               fi;                                     \
-       done
-       @tar -c $(DISTDIR) | gzip -9 > $(RELEASE_NAME).tar.gz
-       @rm -rf $(DISTDIR)
-       @echo "Built $(RELEASE_NAME).tar.gz"
diff --git a/klibc.c b/klibc.c
new file mode 100644 (file)
index 0000000..a5d5d59
--- /dev/null
+++ b/klibc.c
@@ -0,0 +1,33 @@
+
+#ifdef __KLIBC__
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+char *strerror(int errnum)
+{
+       return "some error";
+}
+
+int strcasecmp(const char *s1, const char *s2)
+{
+       char *n1;
+       char *n2;
+       int retval;
+       int i;
+
+       n1 = strdup(s1);
+       n2 = strdup(s2);
+       
+       for (i = 0; i < strlen(n1); ++i)
+               n1[i] = toupper(n1[i]);
+       for (i = 0; i < strlen(n2); ++i)
+               n2[i] = toupper(n2[i]);
+       retval = strcmp(n1, n2);
+       free(n1);
+       free(n2);
+       return retval;
+}
+       
+#endif
index ffd2beba439fdfb9e268b68a7f793075862e4107..e383755b2066e6f6ef35b92190f90f16abcf4f93 100644 (file)
@@ -22,6 +22,8 @@
 # define NSIG _NSIG
 #endif
 
+typedef int sig_atomic_t;
+
 __extern const char * const sys_siglist[];
 
 /* This assumes sigset_t is either an unsigned long or an array of such,
index ff2edf461588458b68201051b5a709059b80b4fc..e983d0eff4e88af4ab82516e038d393c96f1585c 100644 (file)
@@ -266,7 +266,11 @@ int sysfs_read_attribute(struct sysfs_attribute *sysattr)
                        sysattr->path);
                return -1;
        }
+#ifdef __KLIBC__
+       pgsize = 0x4000;
+#else
        pgsize = getpagesize();
+#endif
        fbuf = (unsigned char *)calloc(1, pgsize+1);
        if (fbuf == NULL) {
                dprintf("calloc failed\n");
index 4475342433d2151262e20ea57c58e0f1005f9a0c..f1303cacb302e2a011cdd45cf6f18f1139e4ec44 100644 (file)
@@ -22,6 +22,9 @@
  */
 #include "libsysfs.h"
 #include "sysfs.h"
+#ifndef __KLIBC__
+#include <mntent.h>
+#endif
 
 /**
  * sysfs_get_mnt_path: Gets the mount point for specified filesystem.
 static int sysfs_get_fs_mnt_path(const unsigned char *fs_type, 
                                unsigned char *mnt_path, size_t len)
 {
+#ifdef __KLIBC__
+       strcpy(mnt_path, "/sys");
+       return 0;
+#else
        FILE *mnt;
        struct mntent *mntent;
        int ret = 0;
@@ -66,6 +73,7 @@ static int sysfs_get_fs_mnt_path(const unsigned char *fs_type,
                ret = -1;
        }
        return ret;
+#endif
 }
 
 /*
index 22ec6ace244c67c56af4f0ecd5c7e7fdec5b37ce..6d88b5d47a263bf56f71266de84d22de6eafadf9 100644 (file)
--- a/namedev.c
+++ b/namedev.c
@@ -527,10 +527,12 @@ static int exec_callout(struct config_device *dev, char *value, int len)
                        retval = -1;
                }
 
+#ifndef __KLIBC__
                if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) {
                        dbg("callout program status 0x%x", status);
                        retval = -1;
                }
+#endif
        }
        return retval;
 }
index 8c63214a46794ebb233ed1e8cffc8c8875865697..7a89076add32891c287d878a738d2c62803ab1e3 100644 (file)
@@ -73,10 +73,17 @@ static int create_node(struct udevice *dev)
 {
        char filename[255];
        int retval = 0;
+       dev_t res;
 
        strncpy(filename, udev_root, sizeof(filename));
        strncat(filename, dev->name, sizeof(filename));
 
+#ifdef __KLIBC__
+       res = (dev->major << 8) | (dev->minor);
+#else
+       res = makedev(dev->major, dev->minor);
+#endif
+
        switch (dev->type) {
        case 'b':
                dev->mode |= S_IFBLK;
@@ -94,7 +101,7 @@ static int create_node(struct udevice *dev)
        }
 
        dbg("mknod(%s, %#o, %u, %u)", filename, dev->mode, dev->major, dev->minor);
-       retval = mknod(filename, dev->mode, makedev(dev->major, dev->minor));
+       retval = mknod(filename, dev->mode, res);
        if (retval)
                dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
                    filename, dev->mode, dev->major, dev->minor, strerror(errno));