chiark / gitweb /
libudev: do not use any udev source file
authorKay Sievers <kay.sievers@vrfy.org>
Wed, 10 Sep 2008 16:00:31 +0000 (18:00 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Wed, 10 Sep 2008 16:00:31 +0000 (18:00 +0200)
13 files changed:
extras/collect/collect.c
udev/Makefile.am
udev/lib/Makefile.am
udev/lib/libudev-ctrl.c
udev/lib/libudev-device.c
udev/lib/libudev-enumerate.c
udev/lib/libudev-monitor.c
udev/lib/libudev-private.h
udev/lib/libudev-util.c
udev/lib/libudev.c
udev/list.h [deleted file]
udev/udev.h
udev/udev_rules.h

index 14184a5e058977361d9927afce60005e8517d806..8c141d2a5a6e818ec65aeca52eec3190b4469529 100644 (file)
@@ -31,7 +31,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include "../../udev/list.h"
+#include "../../udev/lib/list.h"
 
 #define TMPFILE                        UDEV_PREFIX "/dev/.udev/collect"
 #define BUFSIZE                        16
index 47b4237efc515dab224d58ea6609f6dabf3d1c6c..df0370842101e685b8ed3698df9aeb75ace32788 100644 (file)
@@ -16,8 +16,6 @@ AM_CPPFLAGS = \
 common_ldadd =
 
 common_files = \
-       list.h \
-       logging.h \
        udev.h \
        udev_rules.h \
        udev_sysdeps.h \
@@ -32,6 +30,7 @@ common_files = \
        udev_utils.c \
        udev_utils_file.c \
        udev_utils_string.c \
+       lib/list.h \
        lib/libudev.h \
        lib/libudev-private.h \
        lib/libudev.c \
index 5d6438eb8e41946628256f54a05ae60ed3928aaf..000b3f73ca8bfe1ac4ee491b0955a75903b2f79e 100644 (file)
@@ -28,9 +28,7 @@ libudev_la_SOURCES =\
        libudev-enumerate.c \
        libudev-ctrl.c \
        libudev-monitor.c \
-       ../list.h \
-       ../udev.h \
-       ../udev_sysdeps.c
+       list.h
 
 libudev_la_LDFLAGS = \
        -version-info $(LIBUDEV_LT_CURRENT):$(LIBUDEV_LT_REVISION):$(LIBUDEV_LT_AGE) \
index 6d91ea4dbcca048a442f0d29547a2ab19e75f1a0..e42f631571712ce5652738727b4452cb2608d71e 100644 (file)
@@ -29,7 +29,6 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 
-#include "../udev.h"
 #include "libudev.h"
 #include "libudev-private.h"
 
@@ -155,7 +154,7 @@ static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int
        ctrl_msg.type = type;
 
        if (buf != NULL)
-               strlcpy(ctrl_msg.buf, buf, sizeof(ctrl_msg.buf));
+               util_strlcpy(ctrl_msg.buf, buf, sizeof(ctrl_msg.buf));
        else
                ctrl_msg.intval = intval;
 
index 78b644b01d8252a638a64a8690e4d191cbd1d9c5..a182750e612fc04a80d48428338d1c2ddb4b204e 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "libudev.h"
 #include "libudev-private.h"
-#include "../udev.h"
 
 struct udev_device {
        int refcount;
@@ -58,17 +57,17 @@ static size_t devpath_to_db_path(struct udev *udev, const char *devpath, char *f
        size_t start;
 
        /* translate to location of db file */
-       strlcpy(filename, udev_get_dev_path(udev), len);
-       start = strlcat(filename, "/.udev/db/", len);
-       strlcat(filename, devpath, len);
+       util_strlcpy(filename, udev_get_dev_path(udev), len);
+       start = util_strlcat(filename, "/.udev/db/", len);
+       util_strlcat(filename, devpath, len);
        return util_path_encode(&filename[start], len - start);
 }
 
 static int device_read_db(struct udev_device *udev_device)
 {
        struct stat stats;
-       char filename[PATH_SIZE];
-       char line[PATH_SIZE];
+       char filename[UTIL_PATH_SIZE];
+       char line[UTIL_LINE_SIZE];
        FILE *f;
        int rc = 0;
 
@@ -79,7 +78,7 @@ static int device_read_db(struct udev_device *udev_device)
                return -1;
        }
        if ((stats.st_mode & S_IFMT) == S_IFLNK) {
-               char target[NAME_SIZE];
+               char target[UTIL_PATH_SIZE];
                int target_len;
 
                info(udev_device->udev, "found a symlink as db file\n");
@@ -121,9 +120,9 @@ static int device_read_db(struct udev_device *udev_device)
                        device_set_devnum(udev_device, makedev(maj, min));
                        break;
                case 'S':
-                       strlcpy(filename, udev_get_dev_path(udev_device->udev), sizeof(filename));
-                       strlcat(filename, "/", sizeof(filename));
-                       strlcat(filename, val, sizeof(filename));
+                       util_strlcpy(filename, udev_get_dev_path(udev_device->udev), sizeof(filename));
+                       util_strlcat(filename, "/", sizeof(filename));
+                       util_strlcat(filename, val, sizeof(filename));
                        device_add_devlink(udev_device, filename);
                        break;
                case 'L':
@@ -183,7 +182,7 @@ struct udev_device *device_init(struct udev *udev)
  **/
 struct udev_device *udev_device_new_from_devpath(struct udev *udev, const char *devpath)
 {
-       char path[PATH_SIZE];
+       char path[UTIL_PATH_SIZE];
        struct stat statbuf;
        struct udev_device *udev_device;
 
@@ -192,8 +191,8 @@ struct udev_device *udev_device_new_from_devpath(struct udev *udev, const char *
        if (devpath == NULL)
                return NULL;
 
-       strlcpy(path, udev_get_sys_path(udev), sizeof(path));
-       strlcat(path, devpath, sizeof(path));
+       util_strlcpy(path, udev_get_sys_path(udev), sizeof(path));
+       util_strlcat(path, devpath, sizeof(path));
        if (stat(path, &statbuf) != 0)
                return NULL;
        if (!S_ISDIR(statbuf.st_mode))
@@ -204,7 +203,7 @@ struct udev_device *udev_device_new_from_devpath(struct udev *udev, const char *
                return NULL;
 
        /* resolve possible symlink to real path */
-       strlcpy(path, devpath, sizeof(path));
+       util_strlcpy(path, devpath, sizeof(path));
        util_resolve_sys_link(udev, path, sizeof(path));
        device_set_devpath(udev_device, path);
        info(udev, "device %p has devpath '%s'\n", udev_device, udev_device_get_devpath(udev_device));
@@ -333,7 +332,7 @@ const char *udev_device_get_devname(struct udev_device *udev_device)
  **/
 const char *udev_device_get_subsystem(struct udev_device *udev_device)
 {
-       char subsystem[NAME_SIZE];
+       char subsystem[UTIL_PATH_SIZE];
 
        if (udev_device == NULL)
                return NULL;
@@ -363,7 +362,7 @@ int udev_device_get_devlinks(struct udev_device *udev_device,
                              int (*cb)(struct udev_device *udev_device, const char *value, void *data),
                              void *data)
 {
-       struct name_entry *name_loop;
+       struct util_name_entry *name_loop;
        int count = 0;
 
        if (udev_device == NULL)
@@ -393,17 +392,16 @@ int udev_device_get_properties(struct udev_device *udev_device,
                                int (*cb)(struct udev_device *udev_device, const char *key, const char *value, void *data),
                                void *data)
 {
-       struct name_entry *name_loop;
+       struct util_name_entry *name_loop;
        int count = 0;
 
        if (udev_device == NULL)
                return -1;
        list_for_each_entry(name_loop, &udev_device->env_list, node) {
-               char name[PATH_SIZE];
+               char name[UTIL_PATH_SIZE];
                char *val;
 
-               strncpy(name, name_loop->name, PATH_SIZE);
-               name[PATH_SIZE-1] = '\0';
+               strncpy(name, name_loop->name, sizeof(name));
                val = strchr(name, '=');
                if (val == NULL)
                        continue;
@@ -418,7 +416,7 @@ int udev_device_get_properties(struct udev_device *udev_device,
 
 const char *udev_device_get_driver(struct udev_device *udev_device)
 {
-       char driver[NAME_SIZE];
+       char driver[UTIL_PATH_SIZE];
 
        if (udev_device == NULL)
                return NULL;
index 72b97cebd7b5784010bbe271579625d4fab64336..9bd910105260dc900b6bad87891e4975971f7c76 100644 (file)
 
 #include "libudev.h"
 #include "libudev-private.h"
-#include "../udev.h"
 
 static int devices_scan_subsystem(struct udev *udev,
                                  const char *basedir, const char *subsystem, const char *subdir,
                                  struct list_head *device_list)
 {
-       char path[PATH_SIZE];
+       char path[UTIL_PATH_SIZE];
        DIR *dir;
        struct dirent *dent;
        size_t len;
 
-       len = strlcpy(path, udev_get_sys_path(udev), sizeof(path));
-       strlcat(path, basedir, sizeof(path));
-       strlcat(path, "/", sizeof(path));
-       strlcat(path, subsystem, sizeof(path));
+       len = util_strlcpy(path, udev_get_sys_path(udev), sizeof(path));
+       util_strlcat(path, basedir, sizeof(path));
+       util_strlcat(path, "/", sizeof(path));
+       util_strlcat(path, subsystem, sizeof(path));
        if (subdir != NULL)
-               strlcat(path, subdir, sizeof(path));
+               util_strlcat(path, subdir, sizeof(path));
        dir = opendir(path);
        if (dir == NULL)
                return -1;
        for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
-               char devpath[PATH_SIZE];
+               char devpath[UTIL_PATH_SIZE];
 
                if (dent->d_name[0] == '.')
                        continue;
-               strlcpy(devpath, &path[len], sizeof(devpath));
-               strlcat(devpath, "/", sizeof(devpath));
-               strlcat(devpath, dent->d_name, sizeof(devpath));
+               util_strlcpy(devpath, &path[len], sizeof(devpath));
+               util_strlcat(devpath, "/", sizeof(devpath));
+               util_strlcat(devpath, dent->d_name, sizeof(devpath));
                util_resolve_sys_link(udev, devpath, sizeof(devpath));
                util_name_list_add(udev, device_list, devpath, 1);
        }
@@ -69,15 +68,15 @@ static int devices_scan_subsystems(struct udev *udev,
                                   const char *basedir, const char *subsystem, const char *subdir,
                                   struct list_head *device_list)
 {
-       char path[PATH_SIZE];
+       char path[UTIL_PATH_SIZE];
        DIR *dir;
        struct dirent *dent;
 
        if (subsystem != NULL)
                return devices_scan_subsystem(udev, basedir, subsystem, subdir, device_list);
 
-       strlcpy(path, udev_get_sys_path(udev), sizeof(path));
-       strlcat(path, basedir, sizeof(path));
+       util_strlcpy(path, udev_get_sys_path(udev), sizeof(path));
+       util_strlcat(path, basedir, sizeof(path));
        dir = opendir(path);
        if (dir == NULL)
                return -1;
@@ -115,7 +114,7 @@ static int devices_call(struct udev *udev, const char *devpath,
                        void *data,
                        int *cb_rc)
 {
-       char subsystem[NAME_SIZE];
+       char subsystem[UTIL_PATH_SIZE];
        const char *name;
 
        name = strrchr(devpath, '/');
@@ -147,19 +146,19 @@ int udev_enumerate_devices(struct udev *udev, const char *subsystem,
                                     const char *devpath, const char *subsystem, const char *name, void *data),
                           void *data)
 {
-       char base[PATH_SIZE];
+       char base[UTIL_PATH_SIZE];
        struct stat statbuf;
        struct list_head device_list;
-       struct name_entry *loop_device;
-       struct name_entry *tmp_device;
+       struct util_name_entry *loop_device;
+       struct util_name_entry *tmp_device;
        int cb_rc = 0;
        int count = 0;
 
        INIT_LIST_HEAD(&device_list);
 
        /* if we have /sys/subsystem/, forget all the old stuff */
-       strlcpy(base, udev_get_sys_path(udev), sizeof(base));
-       strlcat(base, "/subsystem", sizeof(base));
+       util_strlcpy(base, udev_get_sys_path(udev), sizeof(base));
+       util_strlcat(base, "/subsystem", sizeof(base));
        if (stat(base, &statbuf) == 0) {
                devices_scan_subsystems(udev, "/subsystem", subsystem, "/devices", &device_list);
        } else {
@@ -174,6 +173,7 @@ int udev_enumerate_devices(struct udev *udev, const char *subsystem,
                        if (devices_call(udev, loop_device->name, cb, data, &cb_rc) == 0)
                                count++;
                list_del(&loop_device->node);
+               free(loop_device->name);
                free(loop_device);
        }
 
@@ -183,6 +183,7 @@ int udev_enumerate_devices(struct udev *udev, const char *subsystem,
                        if (devices_call(udev, loop_device->name, cb, data, &cb_rc) == 0)
                                count++;
                list_del(&loop_device->node);
+               free(loop_device->name);
                free(loop_device);
        }
 
index 3e1731e38223948b9f99503ee65f99f3ba54227b..60f7bc29e504fa041a58223d29aa71ee6803ac3c 100644 (file)
@@ -33,7 +33,6 @@
 
 #include "libudev.h"
 #include "libudev-private.h"
-#include "../udev.h"
 
 struct udev_monitor {
        struct udev *udev;
index a715067ebb7b03a28847ba717abba294a3f6331c..32837e368d278b11f01bd97859af0fbe6563a75f 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <syslog.h>
 #include "libudev.h"
-#include "../udev.h"
+#include "list.h"
 
 #ifdef USE_LOG
 #ifdef USE_DEBUG
@@ -104,6 +104,13 @@ extern const char *udev_ctrl_get_set_env(struct udev_ctrl_msg *ctrl_msg);
 extern int udev_ctrl_get_set_max_childs(struct udev_ctrl_msg *ctrl_msg);
 
 /* libudev-utils */
+#define UTIL_PATH_SIZE         1024
+#define UTIL_LINE_SIZE         1024
+struct util_name_entry {
+       struct list_head node;
+       char *name;
+       int *i;
+};
 extern ssize_t util_get_sys_subsystem(struct udev *udev, const char *devpath, char *subsystem, size_t size);
 extern ssize_t util_get_sys_driver(struct udev *udev, const char *devpath, char *driver, size_t size);
 extern int util_resolve_sys_link(struct udev *udev, char *devpath, size_t size);
@@ -114,4 +121,6 @@ extern int util_log_priority(const char *priority);
 extern size_t util_path_encode(char *s, size_t len);
 extern size_t util_path_decode(char *s);
 extern void util_remove_trailing_chars(char *path, char c);
+extern size_t util_strlcpy(char *dst, const char *src, size_t size);
+extern size_t util_strlcat(char *dst, const char *src, size_t size);
 #endif
index dfd5f3c3fb0af26d1f6c5cc046e1eb3ecf1365a5..ae0adf4b88cbb8b26df2dbbbcce9ed6a57826876 100644 (file)
 
 #include "libudev.h"
 #include "libudev-private.h"
-#include "../udev.h"
 
 static ssize_t get_sys_link(struct udev *udev, const char *slink, const char *devpath, char *subsystem, size_t size)
 {
-       char path[PATH_SIZE];
+       char path[UTIL_PATH_SIZE];
        ssize_t len;
        const char *pos;
 
-       strlcpy(path, udev_get_sys_path(udev), sizeof(path));
-       strlcat(path, devpath, sizeof(path));
-       strlcat(path, "/", sizeof(path));
-       strlcat(path, slink, sizeof(path));
+       util_strlcpy(path, udev_get_sys_path(udev), sizeof(path));
+       util_strlcat(path, devpath, sizeof(path));
+       util_strlcat(path, "/", sizeof(path));
+       util_strlcat(path, slink, sizeof(path));
        len = readlink(path, path, sizeof(path));
        if (len < 0 || len >= (ssize_t) sizeof(path))
                return -1;
@@ -50,7 +49,7 @@ static ssize_t get_sys_link(struct udev *udev, const char *slink, const char *de
        if (pos == NULL)
                return -1;
        pos = &pos[1];
-       return strlcpy(subsystem, pos, size);
+       return util_strlcpy(subsystem, pos, size);
 }
 
 ssize_t util_get_sys_subsystem(struct udev *udev, const char *devpath, char *subsystem, size_t size)
@@ -65,14 +64,15 @@ ssize_t util_get_sys_driver(struct udev *udev, const char *devpath, char *driver
 
 int util_resolve_sys_link(struct udev *udev, char *devpath, size_t size)
 {
-       char link_path[PATH_SIZE];
-       char link_target[PATH_SIZE];
+       char link_path[UTIL_PATH_SIZE];
+       char link_target[UTIL_PATH_SIZE];
+
        int len;
        int i;
        int back;
 
-       strlcpy(link_path, udev_get_sys_path(udev), sizeof(link_path));
-       strlcat(link_path, devpath, sizeof(link_path));
+       util_strlcpy(link_path, udev_get_sys_path(udev), sizeof(link_path));
+       util_strlcat(link_path, devpath, sizeof(link_path));
        len = readlink(link_path, link_target, sizeof(link_target));
        if (len <= 0)
                return -1;
@@ -90,17 +90,11 @@ int util_resolve_sys_link(struct udev *udev, char *devpath, size_t size)
                pos[0] = '\0';
        }
        dbg(udev, "after moving back '%s'\n", devpath);
-       strlcat(devpath, "/", size);
-       strlcat(devpath, &link_target[back * 3], size);
+       util_strlcat(devpath, "/", size);
+       util_strlcat(devpath, &link_target[back * 3], size);
        return 0;
 }
 
-struct util_name_entry {
-       struct list_head node;
-       char *name;
-       int *i;
-};
-
 struct util_name_entry *util_name_list_add(struct udev *udev, struct list_head *name_list,
                                           const char *name, int sort)
 {
@@ -122,9 +116,15 @@ struct util_name_entry *util_name_list_add(struct udev *udev, struct list_head *
                }
        }
 
+       name_new = malloc(sizeof(struct util_name_entry));
+       if (name_new == NULL)
+               return NULL;
+       memset(name_new, 0x00, sizeof(struct util_name_entry));
        name_new->name = strdup(name);
-       if (name_new->name == NULL)
+       if (name_new->name == NULL) {
+               free(name_new);
                return NULL;
+       }
        dbg(udev, "adding '%s'\n", name_new->name);
        list_add_tail(&name_new->node, &name_loop->node);
        return name_new;
@@ -212,3 +212,46 @@ void util_remove_trailing_chars(char *path, char c)
        while (len > 0 && path[len-1] == c)
                path[--len] = '\0';
 }
+
+size_t util_strlcpy(char *dst, const char *src, size_t size)
+{
+       size_t bytes = 0;
+       char *q = dst;
+       const char *p = src;
+       char ch;
+
+       while ((ch = *p++)) {
+               if (bytes+1 < size)
+                       *q++ = ch;
+               bytes++;
+       }
+
+       /* If size == 0 there is no space for a final null... */
+       if (size)
+               *q = '\0';
+       return bytes;
+}
+
+size_t util_strlcat(char *dst, const char *src, size_t size)
+{
+       size_t bytes = 0;
+       char *q = dst;
+       const char *p = src;
+       char ch;
+
+       while (bytes < size && *q) {
+               q++;
+               bytes++;
+       }
+       if (bytes == size)
+               return (bytes + strlen(src));
+
+       while ((ch = *p++)) {
+               if (bytes+1 < size)
+               *q++ = ch;
+               bytes++;
+       }
+
+       *q = '\0';
+       return bytes;
+}
index d1dd9e4838251bca244f82c3a6eea722a5417a3e..04ad26c6fbc5ec076eb77ea16ee35bc7758d9823 100644 (file)
@@ -33,7 +33,6 @@
 
 #include "libudev.h"
 #include "libudev-private.h"
-#include "../udev.h"
 
 struct udev {
        int refcount;
@@ -201,7 +200,7 @@ struct udev *udev_new(void)
                goto err;
        f = fopen(config_file, "r");
        if (f != NULL) {
-               char line[LINE_SIZE];
+               char line[UTIL_LINE_SIZE];
                int line_nr = 0;
 
                while (fgets(line, sizeof(line), f)) {
diff --git a/udev/list.h b/udev/list.h
deleted file mode 100644 (file)
index 3266e1b..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Based on list.h in the Linux kernel source tree.
- */
-
-#ifndef _LIST_H
-#define _LIST_H
-
-/**
- * container_of - cast a member of a structure out to the containing structure
- *
- * @ptr:       the pointer to the member.
- * @type:      the type of the container struct this is embedded in.
- * @member:    the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({                     \
-       const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
-       (type *)( (char *)__mptr - offsetof(type,member) );})
-
-/*
- * These are non-NULL pointers that will result in page faults
- * under normal circumstances, used to verify that nobody uses
- * non-initialized list entries.
- */
-#define LIST_POISON1  ((void *) 0x00100100)
-#define LIST_POISON2  ((void *) 0x00200200)
-
-/*
- * Simple doubly linked list implementation.
- *
- * Some of the internal functions ("__xxx") are useful when
- * manipulating whole lists rather than single entries, as
- * sometimes we already know the next/prev entries and we can
- * generate better code by using them directly rather than
- * using the generic single-entry routines.
- */
-
-struct list_head {
-       struct list_head *next, *prev;
-};
-
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
-
-#define LIST_HEAD(name) \
-       struct list_head name = LIST_HEAD_INIT(name)
-
-#define INIT_LIST_HEAD(ptr) do { \
-       (ptr)->next = (ptr); (ptr)->prev = (ptr); \
-} while (0)
-
-/*
- * Insert a new entry between two known consecutive entries. 
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_add(struct list_head *new,
-                             struct list_head *prev,
-                             struct list_head *next)
-{
-       next->prev = new;
-       new->next = next;
-       new->prev = prev;
-       prev->next = new;
-}
-
-/**
- * list_add - add a new entry
- * @new: new entry to be added
- * @head: list head to add it after
- *
- * Insert a new entry after the specified head.
- * This is good for implementing stacks.
- */
-static inline void list_add(struct list_head *new, struct list_head *head)
-{
-       __list_add(new, head, head->next);
-}
-
-/**
- * list_add_tail - add a new entry
- * @new: new entry to be added
- * @head: list head to add it before
- *
- * Insert a new entry before the specified head.
- * This is useful for implementing queues.
- */
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
-{
-       __list_add(new, head->prev, head);
-}
-
-/*
- * Delete a list entry by making the prev/next entries
- * point to each other.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_del(struct list_head * prev, struct list_head * next)
-{
-       next->prev = prev;
-       prev->next = next;
-}
-
-/**
- * list_del - deletes entry from list.
- * @entry: the element to delete from the list.
- * Note: list_empty on entry does not return true after this, the entry is
- * in an undefined state.
- */
-static inline void list_del(struct list_head *entry)
-{
-       __list_del(entry->prev, entry->next);
-       entry->next = LIST_POISON1;
-       entry->prev = LIST_POISON2;
-}
-
-/**
- * list_del_init - deletes entry from list and reinitialize it.
- * @entry: the element to delete from the list.
- */
-static inline void list_del_init(struct list_head *entry)
-{
-       __list_del(entry->prev, entry->next);
-       INIT_LIST_HEAD(entry); 
-}
-
-/**
- * list_move - delete from one list and add as another's head
- * @list: the entry to move
- * @head: the head that will precede our entry
- */
-static inline void list_move(struct list_head *list, struct list_head *head)
-{
-       __list_del(list->prev, list->next);
-       list_add(list, head);
-}
-
-/**
- * list_move_tail - delete from one list and add as another's tail
- * @list: the entry to move
- * @head: the head that will follow our entry
- */
-static inline void list_move_tail(struct list_head *list,
-                                 struct list_head *head)
-{
-       __list_del(list->prev, list->next);
-       list_add_tail(list, head);
-}
-
-/**
- * list_empty - tests whether a list is empty
- * @head: the list to test.
- */
-static inline int list_empty(struct list_head *head)
-{
-       return head->next == head;
-}
-
-static inline void __list_splice(struct list_head *list,
-                                struct list_head *head)
-{
-       struct list_head *first = list->next;
-       struct list_head *last = list->prev;
-       struct list_head *at = head->next;
-
-       first->prev = head;
-       head->next = first;
-
-       last->next = at;
-       at->prev = last;
-}
-
-/**
- * list_splice - join two lists
- * @list: the new list to add.
- * @head: the place to add it in the first list.
- */
-static inline void list_splice(struct list_head *list, struct list_head *head)
-{
-       if (!list_empty(list))
-               __list_splice(list, head);
-}
-
-/**
- * list_splice_init - join two lists and reinitialise the emptied list.
- * @list: the new list to add.
- * @head: the place to add it in the first list.
- *
- * The list at @list is reinitialised
- */
-static inline void list_splice_init(struct list_head *list,
-                                   struct list_head *head)
-{
-       if (!list_empty(list)) {
-               __list_splice(list, head);
-               INIT_LIST_HEAD(list);
-       }
-}
-
-/**
- * list_entry - get the struct for this entry
- * @ptr:       the &struct list_head pointer.
- * @type:      the type of the struct this is embedded in.
- * @member:    the name of the list_struct within the struct.
- */
-#define list_entry(ptr, type, member) \
-       container_of(ptr, type, member)
-
-/**
- * list_for_each       -       iterate over a list
- * @pos:       the &struct list_head to use as a loop counter.
- * @head:      the head for your list.
- */
-#define list_for_each(pos, head) \
-       for (pos = (head)->next; pos != (head); \
-               pos = pos->next)
-
-/**
- * __list_for_each     -       iterate over a list
- * @pos:       the &struct list_head to use as a loop counter.
- * @head:      the head for your list.
- *
- * This variant differs from list_for_each() in that it's the
- * simplest possible list iteration code.
- * Use this for code that knows the list to be very short (empty
- * or 1 entry) most of the time.
- */
-#define __list_for_each(pos, head) \
-       for (pos = (head)->next; pos != (head); pos = pos->next)
-
-/**
- * list_for_each_prev  -       iterate over a list backwards
- * @pos:       the &struct list_head to use as a loop counter.
- * @head:      the head for your list.
- */
-#define list_for_each_prev(pos, head) \
-       for (pos = (head)->prev; pos != (head); pos = pos->prev)
-
-/**
- * list_for_each_safe  -       iterate over a list safe against removal of list entry
- * @pos:       the &struct list_head to use as a loop counter.
- * @n:         another &struct list_head to use as temporary storage
- * @head:      the head for your list.
- */
-#define list_for_each_safe(pos, n, head) \
-       for (pos = (head)->next, n = pos->next; pos != (head); \
-               pos = n, n = pos->next)
-
-/**
- * list_for_each_entry -       iterate over list of given type
- * @pos:       the type * to use as a loop counter.
- * @head:      the head for your list.
- * @member:    the name of the list_struct within the struct.
- */
-#define list_for_each_entry(pos, head, member)                         \
-       for (pos = list_entry((head)->next, typeof(*pos), member);      \
-            &pos->member != (head);                                    \
-            pos = list_entry(pos->member.next, typeof(*pos), member))
-
-/**
- * list_for_each_entry_reverse - iterate backwards over list of given type.
- * @pos:       the type * to use as a loop counter.
- * @head:      the head for your list.
- * @member:    the name of the list_struct within the struct.
- */
-#define list_for_each_entry_reverse(pos, head, member)                 \
-       for (pos = list_entry((head)->prev, typeof(*pos), member);      \
-            &pos->member != (head);                                    \
-            pos = list_entry(pos->member.prev, typeof(*pos), member))
-
-/**
- * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
- * @pos:       the type * to use as a loop counter.
- * @n:         another type * to use as temporary storage
- * @head:      the head for your list.
- * @member:    the name of the list_struct within the struct.
- */
-#define list_for_each_entry_safe(pos, n, head, member)                 \
-       for (pos = list_entry((head)->next, typeof(*pos), member),      \
-               n = list_entry(pos->member.next, typeof(*pos), member); \
-            &pos->member != (head);                                    \
-            pos = n, n = list_entry(n->member.next, typeof(*n), member))
-
-#endif /* _LIST_H */
index 429b79b15fbe6a69cfdf8697a85b502d4321ee8f..24646ece594cb1835c6b69fe7c79d917b07132ac 100644 (file)
 #include <sys/types.h>
 #include <sys/param.h>
 
-#include "list.h"
 #include "udev_sysdeps.h"
 #define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE 1
 #include "lib/libudev.h"
 #include "lib/libudev-private.h"
+#include "lib/list.h"
 
 #define COMMENT_CHARACTER                      '#'
 #define LINE_SIZE                              512
index ac7388e8a18891be1f4fe84396803234ad80d93c..02685e18342ec80d9071a8fb496f5c3c6f371138 100644 (file)
@@ -20,7 +20,6 @@
 #define UDEV_RULES_H
 
 #include "udev.h"
-#include "list.h"
 
 #define PAIRS_MAX              5