From: kay.sievers@vrfy.org Date: Wed, 20 Oct 2004 09:59:11 +0000 (+0200) Subject: [PATCH] improve klibc fixup integration X-Git-Tag: 042~4 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=f8c1ccde6aaf08c858616c9a8a83c06d609f52f5;ds=sidebyside [PATCH] improve klibc fixup integration --- diff --git a/Makefile b/Makefile index 4d25aee73..19dc72d95 100644 --- a/Makefile +++ b/Makefile @@ -137,6 +137,7 @@ endif # link udev against it statically. # Otherwise, use glibc and link dynamically. ifeq ($(strip $(USE_KLIBC)),true) + KLIBC_FIXUPS_DIR= $(PWD)/klibc_fixups KLIBC_BASE = $(PWD)/klibc KLIBC_DIR = $(KLIBC_BASE)/klibc INCLUDE_DIR := $(KLIBC_BASE)/include @@ -149,13 +150,15 @@ ifeq ($(strip $(USE_KLIBC)),true) CRT0 = $(KLIBC_DIR)/crt0.o LIBC = $(ARCH_LIB_OBJS) $(LIB_OBJS) $(CRT0) - CFLAGS += $(WARNINGS) -nostdinc \ - $(OPTFLAGS) \ - -D__KLIBC__ -fno-builtin-printf \ - -I$(INCLUDE_DIR) \ - -I$(INCLUDE_DIR)/arch/$(ARCH) \ - -I$(INCLUDE_DIR)/bits$(BITSIZE) \ - -I$(GCCINCDIR) \ + CFLAGS += $(WARNINGS) -nostdinc \ + $(OPTFLAGS) \ + -D__KLIBC__ -fno-builtin-printf \ + -I$(KLIBC_FIXUPS_DIR) \ + -include $(KLIBC_FIXUPS_DIR)/klibc_fixups.h \ + -I$(INCLUDE_DIR) \ + -I$(INCLUDE_DIR)/arch/$(ARCH) \ + -I$(INCLUDE_DIR)/bits$(BITSIZE) \ + -I$(GCCINCDIR) \ -I$(LINUX_INCLUDE_DIR) LIB_OBJS = LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs @@ -226,14 +229,14 @@ HEADERS = udev.h \ udev_version.h \ udevdb.h \ udev_sysfs.h \ - klibc_fixups.h \ logging.h \ selinux.h \ - list.h + list.h \ + klibc_fixups/klibc_fixups.h ifeq ($(strip $(USE_KLIBC)),true) - OBJS += klibc_fixups.o - KLIBC_FIXUP = klibc_fixups.o + OBJS += klibc_fixups/klibc_fixups.o + KLIBC_FIXUP = klibc_fixups/klibc_fixups.o endif ifeq ($(strip $(V)),false) diff --git a/klibc_fixups.h b/klibc_fixups.h deleted file mode 100644 index 082105eb8..000000000 --- a/klibc_fixups.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifdef __KLIBC__ - -#ifndef KLIBC_FIXUPS_H -#define KLIBC_FIXUPS_H - -struct passwd { - char *pw_name; /* user name */ - char *pw_passwd; /* user password */ - uid_t pw_uid; /* user id */ - gid_t pw_gid; /* group id */ - char *pw_gecos; /* real name */ - char *pw_dir; /* home directory */ - char *pw_shell; /* shell program */ -}; - -struct group { - char *gr_name; /* group name */ - char *gr_passwd; /* group password */ - gid_t gr_gid; /* group id */ - char **gr_mem; /* group members */ -}; - -struct passwd *getpwnam(const char *name); -struct group *getgrnam(const char *name); - - -#define UT_LINESIZE 32 -#define UT_NAMESIZE 32 -#define UT_HOSTSIZE 256 -#define USER_PROCESS 7 /* normal process */ -#define ut_time ut_tv.tv_sec - - -extern int ufd; - -struct exit_status { - short int e_termination; /* process termination status */ - short int e_exit; /* process exit status */ -}; - -struct utmp -{ - short int ut_type; /* type of login */ - pid_t ut_pid; /* pid of login process */ - char ut_line[UT_LINESIZE]; /* devicename */ - char ut_id[4]; /* Inittab id */ - char ut_user[UT_NAMESIZE]; /* username */ - char ut_host[UT_HOSTSIZE]; /* hostname for remote login */ - struct exit_status ut_exit; /* exit status of a process marked as DEAD_PROCESS */ - /* The ut_session and ut_tv fields must be the same size for 32 and 64-bit */ -#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32 - int32_t ut_session; /* sid used for windowing */ - struct { - int32_t tv_sec; /* seconds */ - int32_t tv_usec; /* microseconds */ - } ut_tv; -#else - long int ut_session; - struct timeval ut_tv; -#endif - int32_t ut_addr_v6[4]; /* internet address of remote host */ - char __unused[20]; /* reserved for future use */ -}; - -#endif /* KLIBC_FIXUPS_H */ -#endif /* __KLIBC__ */ diff --git a/klibc_fixups.c b/klibc_fixups/klibc_fixups.c similarity index 95% rename from klibc_fixups.c rename to klibc_fixups/klibc_fixups.c index e68ce22b5..2d673d8ca 100644 --- a/klibc_fixups.c +++ b/klibc_fixups/klibc_fixups.c @@ -28,14 +28,13 @@ #include #include -#include "udev.h" -#include "klibc_fixups.h" -#include "udev_lib.h" -#include "logging.h" +#include "pwd.h" +#include "../udev.h" +#include "../udev_lib.h" +#include "../logging.h" #define PW_FILE "/etc/passwd" #define GR_FILE "/etc/group" -#define UTMP_FILE "/var/run/utmp" /* return the id of a passwd style line, selected by the users name */ static unsigned long get_id_by_name(const char *uname, const char *dbfile) @@ -125,4 +124,4 @@ struct group *getgrnam(const char *name) return &gr; } -#endif +#endif /* __KLIBC__ */ diff --git a/klibc_fixups/klibc_fixups.h b/klibc_fixups/klibc_fixups.h new file mode 100644 index 000000000..8d2933b1b --- /dev/null +++ b/klibc_fixups/klibc_fixups.h @@ -0,0 +1,12 @@ +#ifdef __KLIBC__ + +#ifndef _KLIBC_FIXUPS_H +#define _KLIBC_FIXUPS_H + +struct exit_status { + short int e_termination; /* process termination status */ + short int e_exit; /* process exit status */ +}; + +#endif /* KLIBC_FIXUPS_H */ +#endif /* __KLIBC__ */ diff --git a/klibc_fixups/pwd.h b/klibc_fixups/pwd.h new file mode 100644 index 000000000..f5de6c50b --- /dev/null +++ b/klibc_fixups/pwd.h @@ -0,0 +1,27 @@ +#ifdef __KLIBC__ + +#ifndef _PWD_H +#define _PWD_H + +struct passwd { + char *pw_name; /* user name */ + char *pw_passwd; /* user password */ + uid_t pw_uid; /* user id */ + gid_t pw_gid; /* group id */ + char *pw_gecos; /* real name */ + char *pw_dir; /* home directory */ + char *pw_shell; /* shell program */ +}; + +struct group { + char *gr_name; /* group name */ + char *gr_passwd; /* group password */ + gid_t gr_gid; /* group id */ + char **gr_mem; /* group members */ +}; + +struct passwd *getpwnam(const char *name); +struct group *getgrnam(const char *name); + +#endif /* _PWD_H */ +#endif /* __KLIBC__ */ diff --git a/namedev.c b/namedev.c index 03fc41d23..80d5f1a49 100644 --- a/namedev.c +++ b/namedev.c @@ -40,7 +40,6 @@ #include "udev_version.h" #include "logging.h" #include "namedev.h" -#include "klibc_fixups.h" #include "udevdb.h" static struct sysfs_attribute *find_sysfs_attribute(struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device, char *attr); diff --git a/udev_add.c b/udev_add.c index 0e7d575d5..689c2dcee 100644 --- a/udev_add.c +++ b/udev_add.c @@ -34,10 +34,7 @@ #include #include #include -#ifndef __KLIBC__ #include -#include -#endif #include "libsysfs/sysfs/libsysfs.h" #include "udev.h" @@ -46,7 +43,6 @@ #include "logging.h" #include "namedev.h" #include "udevdb.h" -#include "klibc_fixups.h" #include "selinux.h" diff --git a/udevd.c b/udevd.c index c5267d6d9..015083714 100644 --- a/udevd.c +++ b/udevd.c @@ -33,7 +33,6 @@ #include #include #include -#include "klibc_fixups.h" #include #include