From: Tobias Klauser <tklauser@access.unizh.ch>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] Fix libsyfs include paths
Date: Sun, 31 Jul 2005 19:56:20 +0000 [thread overview]
Message-ID: <20050731195620.GC1155@neon.tklauser.home> (raw)
In the libsysfs/sysfs_*.c files inside the udev distribtiuon the
includes for libsysfs.h just state
#include "libsysfs.h"
while the udev files use
#include "libsysfs/sysfs/libsysfs.h"
where in fact the header files are. This causes gcc to complain when
building udev (and especially the libsysfs part) with -Wall. The
attached patch moves dlist.h and libsysfs.h from libsysfs/sysfs/ to
libsysfs/ and adjusts the include paths in the udev header files. All
includes of libsysfs.h in the *.c files of udev are not needed (and thus
deleted by this patch) as they are already included by the udev header
files.
As a consequence the libsysfs/sysfs/ direectory can be deleted.
This patch is compile-tested.
diff -urpN udev-064/libsysfs/dlist.h udev-064~tk/libsysfs/dlist.h
--- udev-064/libsysfs/dlist.h 1970-01-01 01:00:00.000000000 +0100
+++ udev-064~tk/libsysfs/dlist.h 2005-07-31 19:10:31.000000000 +0200
@@ -0,0 +1,207 @@
+/*
+ * dlist.h
+ *
+ * Copyright (C) 2003 Eric J Bohm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef _DLIST_H_
+#define _DLIST_H_
+
+/* Double linked list header.
+
+* navigate your list with DLIST_PREV and DLIST_NEXT. These are macros
+* so function call overhead is minimized.
+
+* Supports perl style push, pop, shift, unshift list semantics.
+
+* You allocate the data and give dlist the pointer. If your data is
+* complex set the dlist->del_func to a an appropriate delete using
+* dlist_new_with_delete. Your delete function must match
+(void * )(del(void *)
+*Otherwise dlist will just use free.
+
+* NOTE: The small amount of pain involved in doing that allows us to
+* avoid copy in copy out semantics.
+
+* Dlist uses an internal mark pointer to keep track of where you are
+* in the list.
+
+* insert and delete take a directional parameter. Where direction
+* corresponds to the direction in which you want the list to go.
+* true direction corresponded to progressing forward in the last
+* false to regressing in the list.
+* so a dlist_insert(yourlist,item,1) will insert it after the mark
+* so a dlist_insert(yourlist,item,0) will insert it before the mark
+* any insert will move the mark to the new node regardless of the direction.
+
+* Just use the dlist_(insert|delete)_(before|after) macros if you do not want
+* to think about it.
+
+*/
+
+#include <stddef.h>
+
+typedef struct dl_node {
+ struct dl_node *prev;
+ struct dl_node *next;
+ void *data;
+} DL_node;
+
+typedef struct dlist {
+ DL_node *marker;
+ unsigned long count;
+ size_t data_size;
+ void (*del_func)(void *);
+ DL_node headnode;
+ DL_node *head;
+} Dlist;
+
+Dlist *dlist_new(size_t datasize);
+Dlist *dlist_new_with_delete(size_t datasize,void (*del_func)(void*));
+void *_dlist_mark_move(Dlist *list,int direction);
+void *dlist_mark(Dlist *);
+void dlist_start(Dlist *);
+void dlist_end(Dlist *);
+void dlist_move(struct dlist *source, struct dlist *dest, struct dl_node *target,int direction);
+void *dlist_insert(Dlist *,void *,int) ;
+
+void *dlist_insert_sorted(struct dlist *list, void *new_elem, int (*sorter)(void *, void *));
+
+void dlist_delete(Dlist *,int);
+
+void dlist_push(Dlist *,void *);
+
+void dlist_unshift(Dlist *,void *);
+void dlist_unshift_sorted(Dlist *,void *,int (*sorter)(void *, void *));
+
+void *dlist_pop(Dlist *);
+
+void *dlist_shift(Dlist *);
+
+void dlist_destroy(Dlist *);
+
+int _dlist_merge(struct dlist *listsource, struct dlist *listdest, unsigned int passcount, int (*compare)(void *, void *));
+
+void *dlist_find_custom(struct dlist *list, void *target, int (*comp)(void *, void *));
+
+void dlist_sort_custom(struct dlist *list, int (*compare)(void *, void *));
+
+
+void _dlist_swap(struct dlist *list, struct dl_node *a, struct dl_node *b);
+
+void dlist_transform(struct dlist *list, void (*node_operation)(void *));
+
+
+/*
+ * _dlist_remove is for internal use only
+ * _dlist_mark_move is for internal use only
+ */
+void *_dlist_remove(struct dlist *,struct dl_node *,int );
+void *_dlist_insert_dlnode(struct dlist *list,struct dl_node *new_node,int direction);
+
+#define dlist_prev(A) _dlist_mark_move((A),0)
+#define dlist_next(A) _dlist_mark_move((A),1)
+
+#define dlist_insert_before(A,B) dlist_insert((A),(B),0)
+#define dlist_insert_after(A,B) dlist_insert((A),(B),1)
+
+#define dlist_delete_before(A) dlist_delete((A),0)
+#define dlist_delete_after(A) dlist_delete((A),1)
+
+/**
+ * provide for loop header which iterates the mark from start to end
+ * list: the dlist pointer, use dlist_mark(list) to get iterator
+ */
+#define dlist_for_each(list) \
+ for(dlist_start(list),dlist_next(list); \
+ (list)->marker!=(list)->head;dlist_next(list))
+
+/**
+ * provide for loop header which iterates the mark from end to start
+ * list: the dlist pointer, use dlist_mark(list) to get iterator
+ */
+#define dlist_for_each_rev(list) \
+ for(dlist_end(list),dlist_prev(list); \
+ (list)->marker!=(list)->head;dlist_prev(list))
+
+/**
+ * provide for loop header which iterates through the list without moving mark
+ * list: the dlist_pointer
+ * iterator: dl_node pointer to iterate
+ */
+#define dlist_for_each_nomark(list,iterator) \
+ for((iterator)=(list)->head->next; (iterator)!=(list)->head; \
+ (iterator)=(iterator)->next)
+
+/**
+ * provide for loop header which iterates through the list without moving mark
+ * in reverse
+ * list: the dlist_pointer
+ * iterator: dl_node pointer to iterate
+ */
+#define dlist_for_each_nomark_rev(list,iterator) \
+ for((iterator)=(list)->head->prev; (iterator)!=(list)->head; \
+ (iterator)=(iterator)->prev)
+/**
+ * provide for loop header which iterates through the list providing a
+ * data iterator
+ * list: the dlist pointer
+ * data_iterator: the pointer of type datatype to iterate
+ * datatype: actual type of the contents in the dl_node->data
+ */
+
+#define dlist_for_each_data(list,data_iterator,datatype) \
+ for(dlist_start(list), (data_iterator)=(datatype *) dlist_next(list); \
+ (list)->marker!=(list)->head;(data_iterator)=(datatype *) dlist_next(list))
+
+/**
+ * provide for loop header which iterates through the list providing a
+ * data iterator in reverse
+ * list: the dlist pointer
+ * data_iterator: the pointer of type datatype to iterate
+ * datatype: actual type of the contents in the dl_node->data
+ */
+#define dlist_for_each_data_rev(list,data_iterator,datatype) \
+ for(dlist_end(list), (data_iterator)=(datatype *) dlist_prev(list); \
+ (list)->marker!=(list)->head;(data_iterator)=(datatype *) dlist_prev(list))
+
+/**
+ * provide for loop header which iterates through the list providing a
+ * data iterator without moving the mark
+ * list: the dlist pointer
+ * iterator: the dl_node pointer to iterate
+ * data_iterator: the pointer of type datatype to iterate
+ * datatype: actual type of the contents in the dl_node->data
+ */
+
+#define dlist_for_each_data_nomark(list,iterator,data_iterator,datatype) \
+ for((iterator)=(list)->head->next, (data_iterator)=(datatype *) (iterator)->data; \
+ (iterator)!=(list)->head;(iterator)=(iterator)->next,(data_iterator)=(datatype *) (iterator))
+
+/**
+ * provide for loop header which iterates through the list providing a
+ * data iterator in reverse without moving the mark
+ * list: the dlist pointer
+ * iterator: the dl_node pointer to iterate
+ * data_iterator: the pointer of type datatype to iterate
+ * datatype: actual type of the contents in the dl_node->data
+ */
+#define dlist_for_each_data_nomark_rev(list,iterator, data_iterator,datatype) \
+ for((iterator)=(list)->head->prev, (data_iterator)=(datatype *) (iterator)->data; \
+ (iterator)!=(list)->head;(iterator)=(iterator)->prev,(data_iterator)=(datatype *) (iterator))
+
+#endif /* _DLIST_H_ */
diff -urpN udev-064/libsysfs/libsysfs.h udev-064~tk/libsysfs/libsysfs.h
--- udev-064/libsysfs/libsysfs.h 1970-01-01 01:00:00.000000000 +0100
+++ udev-064~tk/libsysfs/libsysfs.h 2005-07-31 19:09:57.000000000 +0200
@@ -0,0 +1,225 @@
+/*
+ * libsysfs.h
+ *
+ * Header Definitions for libsysfs
+ *
+ * Copyright (C) IBM Corp. 2004-2005
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef _LIBSYSFS_H_
+#define _LIBSYSFS_H_
+
+#include <sys/types.h>
+#include <string.h>
+#include "dlist.h"
+
+#define SYSFS_FSTYPE_NAME "sysfs"
+#define SYSFS_PROC_MNTS "/proc/mounts"
+#define SYSFS_BUS_NAME "bus"
+#define SYSFS_CLASS_NAME "class"
+#define SYSFS_BLOCK_NAME "block"
+#define SYSFS_DEVICES_NAME "devices"
+#define SYSFS_DRIVERS_NAME "drivers"
+#define SYSFS_MODULE_NAME "module"
+#define SYSFS_NAME_ATTRIBUTE "name"
+#define SYSFS_UNKNOWN "unknown"
+#define SYSFS_PATH_ENV "SYSFS_PATH"
+
+#define SYSFS_PATH_MAX 256
+#define SYSFS_NAME_LEN 64
+#define SYSFS_BUS_ID_SIZE 32
+
+/* mount path for sysfs, can be overridden by exporting SYSFS_PATH */
+#define SYSFS_MNT_PATH "/sys"
+
+enum sysfs_attribute_method {
+ SYSFS_METHOD_SHOW = 0x01, /* attr can be read by user */
+ SYSFS_METHOD_STORE = 0x02, /* attr can be changed by user */
+};
+
+/*
+ * NOTE:
+ * 1. We have the statically allocated "name" as the first element of all
+ * the structures. This feature is used in the "sorter" function for dlists
+ * 2. As is the case with attrlist
+ * 3. As is the case with path
+ */
+struct sysfs_attribute {
+ char name[SYSFS_NAME_LEN];
+ char path[SYSFS_PATH_MAX];
+ char *value;
+ unsigned short len; /* value length */
+ enum sysfs_attribute_method method; /* show and store */
+};
+
+struct sysfs_driver {
+ char name[SYSFS_NAME_LEN];
+ char path[SYSFS_PATH_MAX];
+ struct dlist *attrlist;
+ char bus[SYSFS_NAME_LEN];
+
+ /* Private: for internal use only */
+ struct dlist *devices;
+};
+
+struct sysfs_device {
+ char name[SYSFS_NAME_LEN];
+ char path[SYSFS_PATH_MAX];
+ struct dlist *attrlist;
+ char bus_id[SYSFS_NAME_LEN];
+ char bus[SYSFS_NAME_LEN];
+ char driver_name[SYSFS_NAME_LEN];
+
+ /* Private: for internal use only */
+ struct sysfs_device *parent;
+ /* NOTE - we still don't populate this */
+ struct dlist *children;
+};
+
+/* NOTE: not used as of now */
+struct sysfs_bus {
+ char name[SYSFS_NAME_LEN];
+ char path[SYSFS_PATH_MAX];
+ struct dlist *attrlist;
+
+ /* Private: for internal use only */
+ struct dlist *drivers;
+ struct dlist *devices;
+};
+
+struct sysfs_class_device {
+ char name[SYSFS_NAME_LEN];
+ char path[SYSFS_PATH_MAX];
+ struct dlist *attrlist;
+ char classname[SYSFS_NAME_LEN];
+
+ /* Private: for internal use only */
+ struct sysfs_class_device *parent;
+ struct sysfs_device *sysdevice; /* NULL if virtual */
+};
+
+/* NOTE: not used as of now */
+struct sysfs_class {
+ char name[SYSFS_NAME_LEN];
+ char path[SYSFS_PATH_MAX];
+ struct dlist *attrlist;
+
+ /* Private: for internal use only */
+ struct dlist *devices;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Function Prototypes
+ */
+extern int sysfs_get_mnt_path(char *mnt_path, size_t len);
+extern int sysfs_remove_trailing_slash(char *path);
+extern int sysfs_get_name_from_path(const char *path, char *name, size_t len);
+extern int sysfs_path_is_dir(const char *path);
+extern int sysfs_path_is_link(const char *path);
+extern int sysfs_path_is_file(const char *path);
+extern int sysfs_get_link(const char *path, char *target, size_t len);
+extern struct dlist *sysfs_open_directory_list(const char *path);
+extern void sysfs_close_list(struct dlist *list);
+
+/* sysfs directory and file access */
+extern void sysfs_close_attribute(struct sysfs_attribute *sysattr);
+extern struct sysfs_attribute *sysfs_open_attribute(const char *path);
+extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
+extern int sysfs_write_attribute(struct sysfs_attribute *sysattr,
+ const char *new_value, size_t len);
+
+/* sysfs driver access */
+extern void sysfs_close_driver(struct sysfs_driver *driver);
+extern struct sysfs_driver *sysfs_open_driver
+ (const char *bus_name, const char *drv_name);
+extern struct sysfs_driver *sysfs_open_driver_path(const char *path);
+extern struct sysfs_attribute *sysfs_get_driver_attr
+ (struct sysfs_driver *drv, const char *name);
+extern struct dlist *sysfs_get_driver_attributes(struct sysfs_driver *driver);
+extern struct dlist *sysfs_get_driver_devices(struct sysfs_driver *driver);
+
+/* generic sysfs device access */
+extern void sysfs_close_device_tree(struct sysfs_device *device);
+extern struct sysfs_device *sysfs_open_device_tree(const char *path);
+extern void sysfs_close_device(struct sysfs_device *dev);
+extern struct sysfs_device *sysfs_open_device
+ (const char *bus, const char *bus_id);
+extern struct sysfs_device *sysfs_get_device_parent(struct sysfs_device *dev);
+extern struct sysfs_device *sysfs_open_device_path(const char *path);
+extern int sysfs_get_device_bus(struct sysfs_device *dev);
+extern struct sysfs_attribute *sysfs_get_device_attr
+ (struct sysfs_device *dev, const char *name);
+extern struct dlist *sysfs_get_device_attributes
+ (struct sysfs_device *dev);
+
+/* generic sysfs class access */
+extern void sysfs_close_class_device(struct sysfs_class_device *dev);
+extern struct sysfs_class_device *sysfs_open_class_device_path
+ (const char *path);
+extern struct sysfs_class_device *sysfs_open_class_device
+ (const char *classname, const char *name);
+extern struct sysfs_class_device *sysfs_get_classdev_parent
+ (struct sysfs_class_device *clsdev);
+extern struct sysfs_attribute *sysfs_get_classdev_attr
+ (struct sysfs_class_device *clsdev, const char *name);
+extern struct dlist *sysfs_get_classdev_attributes
+ (struct sysfs_class_device *clsdev);
+extern struct sysfs_device *sysfs_get_classdev_device
+ (struct sysfs_class_device *clsdev);
+extern void sysfs_close_class(struct sysfs_class *cls);
+extern struct sysfs_class *sysfs_open_class(const char *name);
+extern struct sysfs_class_device *sysfs_get_class_device
+ (struct sysfs_class *cls, const char *name);
+extern struct dlist *sysfs_get_class_devices(struct sysfs_class *cls);
+
+/* generic sysfs bus access */
+extern void sysfs_close_bus(struct sysfs_bus *bus);
+extern struct sysfs_bus *sysfs_open_bus(const char *name);
+extern struct dlist *sysfs_get_bus_devices(struct sysfs_bus *bus);
+extern struct dlist *sysfs_get_bus_drivers(struct sysfs_bus *bus);
+extern struct sysfs_device *sysfs_get_bus_device
+ (struct sysfs_bus *bus, const char *id);
+extern struct sysfs_driver *sysfs_get_bus_driver
+ (struct sysfs_bus *bus, const char *drvname);
+
+/**
+ * sort_list: sorter function to keep list elements sorted in alphabetical
+ * order. Just does a strncmp as you can see :)
+ *
+ * Returns 1 if less than 0 otherwise
+ *
+ * NOTE: We take care to have a statically allocated "name" as the first
+ * lement of all libsysfs structures. Hence, this function will work
+ * AS IS for _ALL_ the lists that have to be sorted.
+ */
+static inline int sort_list(void *new_elem, void *old_elem)
+{
+ return ((strncmp(((struct sysfs_attribute *)new_elem)->name,
+ ((struct sysfs_attribute *)old_elem)->name,
+ strlen(((struct sysfs_attribute *)new_elem)->name))) < 0 ? 1 : 0);
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBSYSFS_H_ */
diff -urpN udev-064/libsysfs/sysfs/dlist.h udev-064~tk/libsysfs/sysfs/dlist.h
--- udev-064/libsysfs/sysfs/dlist.h 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/libsysfs/sysfs/dlist.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,207 +0,0 @@
-/*
- * dlist.h
- *
- * Copyright (C) 2003 Eric J Bohm
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-#ifndef _DLIST_H_
-#define _DLIST_H_
-
-/* Double linked list header.
-
-* navigate your list with DLIST_PREV and DLIST_NEXT. These are macros
-* so function call overhead is minimized.
-
-* Supports perl style push, pop, shift, unshift list semantics.
-
-* You allocate the data and give dlist the pointer. If your data is
-* complex set the dlist->del_func to a an appropriate delete using
-* dlist_new_with_delete. Your delete function must match
-(void * )(del(void *)
-*Otherwise dlist will just use free.
-
-* NOTE: The small amount of pain involved in doing that allows us to
-* avoid copy in copy out semantics.
-
-* Dlist uses an internal mark pointer to keep track of where you are
-* in the list.
-
-* insert and delete take a directional parameter. Where direction
-* corresponds to the direction in which you want the list to go.
-* true direction corresponded to progressing forward in the last
-* false to regressing in the list.
-* so a dlist_insert(yourlist,item,1) will insert it after the mark
-* so a dlist_insert(yourlist,item,0) will insert it before the mark
-* any insert will move the mark to the new node regardless of the direction.
-
-* Just use the dlist_(insert|delete)_(before|after) macros if you do not want
-* to think about it.
-
-*/
-
-#include <stddef.h>
-
-typedef struct dl_node {
- struct dl_node *prev;
- struct dl_node *next;
- void *data;
-} DL_node;
-
-typedef struct dlist {
- DL_node *marker;
- unsigned long count;
- size_t data_size;
- void (*del_func)(void *);
- DL_node headnode;
- DL_node *head;
-} Dlist;
-
-Dlist *dlist_new(size_t datasize);
-Dlist *dlist_new_with_delete(size_t datasize,void (*del_func)(void*));
-void *_dlist_mark_move(Dlist *list,int direction);
-void *dlist_mark(Dlist *);
-void dlist_start(Dlist *);
-void dlist_end(Dlist *);
-void dlist_move(struct dlist *source, struct dlist *dest, struct dl_node *target,int direction);
-void *dlist_insert(Dlist *,void *,int) ;
-
-void *dlist_insert_sorted(struct dlist *list, void *new_elem, int (*sorter)(void *, void *));
-
-void dlist_delete(Dlist *,int);
-
-void dlist_push(Dlist *,void *);
-
-void dlist_unshift(Dlist *,void *);
-void dlist_unshift_sorted(Dlist *,void *,int (*sorter)(void *, void *));
-
-void *dlist_pop(Dlist *);
-
-void *dlist_shift(Dlist *);
-
-void dlist_destroy(Dlist *);
-
-int _dlist_merge(struct dlist *listsource, struct dlist *listdest, unsigned int passcount, int (*compare)(void *, void *));
-
-void *dlist_find_custom(struct dlist *list, void *target, int (*comp)(void *, void *));
-
-void dlist_sort_custom(struct dlist *list, int (*compare)(void *, void *));
-
-
-void _dlist_swap(struct dlist *list, struct dl_node *a, struct dl_node *b);
-
-void dlist_transform(struct dlist *list, void (*node_operation)(void *));
-
-
-/*
- * _dlist_remove is for internal use only
- * _dlist_mark_move is for internal use only
- */
-void *_dlist_remove(struct dlist *,struct dl_node *,int );
-void *_dlist_insert_dlnode(struct dlist *list,struct dl_node *new_node,int direction);
-
-#define dlist_prev(A) _dlist_mark_move((A),0)
-#define dlist_next(A) _dlist_mark_move((A),1)
-
-#define dlist_insert_before(A,B) dlist_insert((A),(B),0)
-#define dlist_insert_after(A,B) dlist_insert((A),(B),1)
-
-#define dlist_delete_before(A) dlist_delete((A),0)
-#define dlist_delete_after(A) dlist_delete((A),1)
-
-/**
- * provide for loop header which iterates the mark from start to end
- * list: the dlist pointer, use dlist_mark(list) to get iterator
- */
-#define dlist_for_each(list) \
- for(dlist_start(list),dlist_next(list); \
- (list)->marker!=(list)->head;dlist_next(list))
-
-/**
- * provide for loop header which iterates the mark from end to start
- * list: the dlist pointer, use dlist_mark(list) to get iterator
- */
-#define dlist_for_each_rev(list) \
- for(dlist_end(list),dlist_prev(list); \
- (list)->marker!=(list)->head;dlist_prev(list))
-
-/**
- * provide for loop header which iterates through the list without moving mark
- * list: the dlist_pointer
- * iterator: dl_node pointer to iterate
- */
-#define dlist_for_each_nomark(list,iterator) \
- for((iterator)=(list)->head->next; (iterator)!=(list)->head; \
- (iterator)=(iterator)->next)
-
-/**
- * provide for loop header which iterates through the list without moving mark
- * in reverse
- * list: the dlist_pointer
- * iterator: dl_node pointer to iterate
- */
-#define dlist_for_each_nomark_rev(list,iterator) \
- for((iterator)=(list)->head->prev; (iterator)!=(list)->head; \
- (iterator)=(iterator)->prev)
-/**
- * provide for loop header which iterates through the list providing a
- * data iterator
- * list: the dlist pointer
- * data_iterator: the pointer of type datatype to iterate
- * datatype: actual type of the contents in the dl_node->data
- */
-
-#define dlist_for_each_data(list,data_iterator,datatype) \
- for(dlist_start(list), (data_iterator)=(datatype *) dlist_next(list); \
- (list)->marker!=(list)->head;(data_iterator)=(datatype *) dlist_next(list))
-
-/**
- * provide for loop header which iterates through the list providing a
- * data iterator in reverse
- * list: the dlist pointer
- * data_iterator: the pointer of type datatype to iterate
- * datatype: actual type of the contents in the dl_node->data
- */
-#define dlist_for_each_data_rev(list,data_iterator,datatype) \
- for(dlist_end(list), (data_iterator)=(datatype *) dlist_prev(list); \
- (list)->marker!=(list)->head;(data_iterator)=(datatype *) dlist_prev(list))
-
-/**
- * provide for loop header which iterates through the list providing a
- * data iterator without moving the mark
- * list: the dlist pointer
- * iterator: the dl_node pointer to iterate
- * data_iterator: the pointer of type datatype to iterate
- * datatype: actual type of the contents in the dl_node->data
- */
-
-#define dlist_for_each_data_nomark(list,iterator,data_iterator,datatype) \
- for((iterator)=(list)->head->next, (data_iterator)=(datatype *) (iterator)->data; \
- (iterator)!=(list)->head;(iterator)=(iterator)->next,(data_iterator)=(datatype *) (iterator))
-
-/**
- * provide for loop header which iterates through the list providing a
- * data iterator in reverse without moving the mark
- * list: the dlist pointer
- * iterator: the dl_node pointer to iterate
- * data_iterator: the pointer of type datatype to iterate
- * datatype: actual type of the contents in the dl_node->data
- */
-#define dlist_for_each_data_nomark_rev(list,iterator, data_iterator,datatype) \
- for((iterator)=(list)->head->prev, (data_iterator)=(datatype *) (iterator)->data; \
- (iterator)!=(list)->head;(iterator)=(iterator)->prev,(data_iterator)=(datatype *) (iterator))
-
-#endif /* _DLIST_H_ */
diff -urpN udev-064/libsysfs/sysfs/libsysfs.h udev-064~tk/libsysfs/sysfs/libsysfs.h
--- udev-064/libsysfs/sysfs/libsysfs.h 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/libsysfs/sysfs/libsysfs.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,225 +0,0 @@
-/*
- * libsysfs.h
- *
- * Header Definitions for libsysfs
- *
- * Copyright (C) IBM Corp. 2004-2005
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-#ifndef _LIBSYSFS_H_
-#define _LIBSYSFS_H_
-
-#include <sys/types.h>
-#include <string.h>
-#include "dlist.h"
-
-#define SYSFS_FSTYPE_NAME "sysfs"
-#define SYSFS_PROC_MNTS "/proc/mounts"
-#define SYSFS_BUS_NAME "bus"
-#define SYSFS_CLASS_NAME "class"
-#define SYSFS_BLOCK_NAME "block"
-#define SYSFS_DEVICES_NAME "devices"
-#define SYSFS_DRIVERS_NAME "drivers"
-#define SYSFS_MODULE_NAME "module"
-#define SYSFS_NAME_ATTRIBUTE "name"
-#define SYSFS_UNKNOWN "unknown"
-#define SYSFS_PATH_ENV "SYSFS_PATH"
-
-#define SYSFS_PATH_MAX 256
-#define SYSFS_NAME_LEN 64
-#define SYSFS_BUS_ID_SIZE 32
-
-/* mount path for sysfs, can be overridden by exporting SYSFS_PATH */
-#define SYSFS_MNT_PATH "/sys"
-
-enum sysfs_attribute_method {
- SYSFS_METHOD_SHOW = 0x01, /* attr can be read by user */
- SYSFS_METHOD_STORE = 0x02, /* attr can be changed by user */
-};
-
-/*
- * NOTE:
- * 1. We have the statically allocated "name" as the first element of all
- * the structures. This feature is used in the "sorter" function for dlists
- * 2. As is the case with attrlist
- * 3. As is the case with path
- */
-struct sysfs_attribute {
- char name[SYSFS_NAME_LEN];
- char path[SYSFS_PATH_MAX];
- char *value;
- unsigned short len; /* value length */
- enum sysfs_attribute_method method; /* show and store */
-};
-
-struct sysfs_driver {
- char name[SYSFS_NAME_LEN];
- char path[SYSFS_PATH_MAX];
- struct dlist *attrlist;
- char bus[SYSFS_NAME_LEN];
-
- /* Private: for internal use only */
- struct dlist *devices;
-};
-
-struct sysfs_device {
- char name[SYSFS_NAME_LEN];
- char path[SYSFS_PATH_MAX];
- struct dlist *attrlist;
- char bus_id[SYSFS_NAME_LEN];
- char bus[SYSFS_NAME_LEN];
- char driver_name[SYSFS_NAME_LEN];
-
- /* Private: for internal use only */
- struct sysfs_device *parent;
- /* NOTE - we still don't populate this */
- struct dlist *children;
-};
-
-/* NOTE: not used as of now */
-struct sysfs_bus {
- char name[SYSFS_NAME_LEN];
- char path[SYSFS_PATH_MAX];
- struct dlist *attrlist;
-
- /* Private: for internal use only */
- struct dlist *drivers;
- struct dlist *devices;
-};
-
-struct sysfs_class_device {
- char name[SYSFS_NAME_LEN];
- char path[SYSFS_PATH_MAX];
- struct dlist *attrlist;
- char classname[SYSFS_NAME_LEN];
-
- /* Private: for internal use only */
- struct sysfs_class_device *parent;
- struct sysfs_device *sysdevice; /* NULL if virtual */
-};
-
-/* NOTE: not used as of now */
-struct sysfs_class {
- char name[SYSFS_NAME_LEN];
- char path[SYSFS_PATH_MAX];
- struct dlist *attrlist;
-
- /* Private: for internal use only */
- struct dlist *devices;
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Function Prototypes
- */
-extern int sysfs_get_mnt_path(char *mnt_path, size_t len);
-extern int sysfs_remove_trailing_slash(char *path);
-extern int sysfs_get_name_from_path(const char *path, char *name, size_t len);
-extern int sysfs_path_is_dir(const char *path);
-extern int sysfs_path_is_link(const char *path);
-extern int sysfs_path_is_file(const char *path);
-extern int sysfs_get_link(const char *path, char *target, size_t len);
-extern struct dlist *sysfs_open_directory_list(const char *path);
-extern void sysfs_close_list(struct dlist *list);
-
-/* sysfs directory and file access */
-extern void sysfs_close_attribute(struct sysfs_attribute *sysattr);
-extern struct sysfs_attribute *sysfs_open_attribute(const char *path);
-extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
-extern int sysfs_write_attribute(struct sysfs_attribute *sysattr,
- const char *new_value, size_t len);
-
-/* sysfs driver access */
-extern void sysfs_close_driver(struct sysfs_driver *driver);
-extern struct sysfs_driver *sysfs_open_driver
- (const char *bus_name, const char *drv_name);
-extern struct sysfs_driver *sysfs_open_driver_path(const char *path);
-extern struct sysfs_attribute *sysfs_get_driver_attr
- (struct sysfs_driver *drv, const char *name);
-extern struct dlist *sysfs_get_driver_attributes(struct sysfs_driver *driver);
-extern struct dlist *sysfs_get_driver_devices(struct sysfs_driver *driver);
-
-/* generic sysfs device access */
-extern void sysfs_close_device_tree(struct sysfs_device *device);
-extern struct sysfs_device *sysfs_open_device_tree(const char *path);
-extern void sysfs_close_device(struct sysfs_device *dev);
-extern struct sysfs_device *sysfs_open_device
- (const char *bus, const char *bus_id);
-extern struct sysfs_device *sysfs_get_device_parent(struct sysfs_device *dev);
-extern struct sysfs_device *sysfs_open_device_path(const char *path);
-extern int sysfs_get_device_bus(struct sysfs_device *dev);
-extern struct sysfs_attribute *sysfs_get_device_attr
- (struct sysfs_device *dev, const char *name);
-extern struct dlist *sysfs_get_device_attributes
- (struct sysfs_device *dev);
-
-/* generic sysfs class access */
-extern void sysfs_close_class_device(struct sysfs_class_device *dev);
-extern struct sysfs_class_device *sysfs_open_class_device_path
- (const char *path);
-extern struct sysfs_class_device *sysfs_open_class_device
- (const char *classname, const char *name);
-extern struct sysfs_class_device *sysfs_get_classdev_parent
- (struct sysfs_class_device *clsdev);
-extern struct sysfs_attribute *sysfs_get_classdev_attr
- (struct sysfs_class_device *clsdev, const char *name);
-extern struct dlist *sysfs_get_classdev_attributes
- (struct sysfs_class_device *clsdev);
-extern struct sysfs_device *sysfs_get_classdev_device
- (struct sysfs_class_device *clsdev);
-extern void sysfs_close_class(struct sysfs_class *cls);
-extern struct sysfs_class *sysfs_open_class(const char *name);
-extern struct sysfs_class_device *sysfs_get_class_device
- (struct sysfs_class *cls, const char *name);
-extern struct dlist *sysfs_get_class_devices(struct sysfs_class *cls);
-
-/* generic sysfs bus access */
-extern void sysfs_close_bus(struct sysfs_bus *bus);
-extern struct sysfs_bus *sysfs_open_bus(const char *name);
-extern struct dlist *sysfs_get_bus_devices(struct sysfs_bus *bus);
-extern struct dlist *sysfs_get_bus_drivers(struct sysfs_bus *bus);
-extern struct sysfs_device *sysfs_get_bus_device
- (struct sysfs_bus *bus, const char *id);
-extern struct sysfs_driver *sysfs_get_bus_driver
- (struct sysfs_bus *bus, const char *drvname);
-
-/**
- * sort_list: sorter function to keep list elements sorted in alphabetical
- * order. Just does a strncmp as you can see :)
- *
- * Returns 1 if less than 0 otherwise
- *
- * NOTE: We take care to have a statically allocated "name" as the first
- * lement of all libsysfs structures. Hence, this function will work
- * AS IS for _ALL_ the lists that have to be sorted.
- */
-static inline int sort_list(void *new_elem, void *old_elem)
-{
- return ((strncmp(((struct sysfs_attribute *)new_elem)->name,
- ((struct sysfs_attribute *)old_elem)->name,
- strlen(((struct sysfs_attribute *)new_elem)->name))) < 0 ? 1 : 0);
-}
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LIBSYSFS_H_ */
diff -urpN udev-064/udev_add.c udev-064~tk/udev_add.c
--- udev-064/udev_add.c 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udev_add.c 2005-07-31 19:16:19.000000000 +0200
@@ -33,7 +33,6 @@
#include <sys/ioctl.h>
#include <linux/sockios.h>
-#include "libsysfs/sysfs/libsysfs.h"
#include "udev_libc_wrapper.h"
#include "udev.h"
#include "udev_utils.h"
diff -urpN udev-064/udev.c udev-064~tk/udev.c
--- udev-064/udev.c 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udev.c 2005-07-31 19:15:13.000000000 +0200
@@ -29,7 +29,6 @@
#include <signal.h>
#include <unistd.h>
-#include "libsysfs/sysfs/libsysfs.h"
#include "udev_libc_wrapper.h"
#include "udev.h"
#include "udev_utils.h"
diff -urpN udev-064/udev_config.c udev-064~tk/udev_config.c
--- udev-064/udev_config.c 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udev_config.c 2005-07-31 19:16:26.000000000 +0200
@@ -28,7 +28,6 @@
#include <ctype.h>
#include <syslog.h>
-#include "libsysfs/sysfs/libsysfs.h"
#include "udev_libc_wrapper.h"
#include "udev.h"
#include "udev_utils.h"
diff -urpN udev-064/udev_db.c udev-064~tk/udev_db.c
--- udev-064/udev_db.c 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udev_db.c 2005-07-31 19:17:30.000000000 +0200
@@ -30,7 +30,6 @@
#include <errno.h>
#include <dirent.h>
-#include "libsysfs/sysfs/libsysfs.h"
#include "udev_libc_wrapper.h"
#include "udev.h"
#include "udev_utils.h"
diff -urpN udev-064/udev.h udev-064~tk/udev.h
--- udev-064/udev.h 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udev.h 2005-07-31 19:11:47.000000000 +0200
@@ -24,7 +24,7 @@
#include <sys/types.h>
#include <sys/param.h>
-#include "libsysfs/sysfs/libsysfs.h"
+#include "libsysfs/libsysfs.h"
#include "list.h"
#define COMMENT_CHARACTER '#'
diff -urpN udev-064/udevinfo.c udev-064~tk/udevinfo.c
--- udev-064/udevinfo.c 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udevinfo.c 2005-07-31 19:17:37.000000000 +0200
@@ -26,7 +26,6 @@
#include <unistd.h>
#include <errno.h>
-#include "libsysfs/sysfs/libsysfs.h"
#include "udev_libc_wrapper.h"
#include "udev.h"
#include "udev_utils.h"
diff -urpN udev-064/udev_rules.c udev-064~tk/udev_rules.c
--- udev-064/udev_rules.c 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udev_rules.c 2005-07-31 19:17:45.000000000 +0200
@@ -30,7 +30,6 @@
#include <sys/wait.h>
#include <sys/stat.h>
-#include "libsysfs/sysfs/libsysfs.h"
#include "list.h"
#include "udev_libc_wrapper.h"
#include "udev.h"
diff -urpN udev-064/udev_rules.h udev-064~tk/udev_rules.h
--- udev-064/udev_rules.h 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udev_rules.h 2005-07-31 19:12:16.000000000 +0200
@@ -22,7 +22,7 @@
#ifndef UDEV_RULES_H
#define UDEV_RULES_H
-#include "libsysfs/sysfs/libsysfs.h"
+#include "libsysfs/libsysfs.h"
#include "udev.h"
#include "list.h"
diff -urpN udev-064/udevstart.c udev-064~tk/udevstart.c
--- udev-064/udevstart.c 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udevstart.c 2005-07-31 19:17:53.000000000 +0200
@@ -37,7 +37,6 @@
#include <sys/stat.h>
#include <sys/types.h>
-#include "libsysfs/sysfs/libsysfs.h"
#include "udev_libc_wrapper.h"
#include "udev_sysfs.h"
#include "udev.h"
diff -urpN udev-064/udev_sysfs.c udev-064~tk/udev_sysfs.c
--- udev-064/udev_sysfs.c 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udev_sysfs.c 2005-07-31 19:17:02.000000000 +0200
@@ -28,7 +28,6 @@
#include <errno.h>
#include <sys/stat.h>
-#include "libsysfs/sysfs/libsysfs.h"
#include "udev_version.h"
#include "udev_sysfs.h"
#include "udev_utils.h"
diff -urpN udev-064/udev_sysfs.h udev-064~tk/udev_sysfs.h
--- udev-064/udev_sysfs.h 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udev_sysfs.h 2005-07-31 19:15:21.000000000 +0200
@@ -22,7 +22,7 @@
#ifndef _UDEV_SYSFS_H_
#define _UDEV_SYSFS_H_
-#include "libsysfs/sysfs/libsysfs.h"
+#include "libsysfs/libsysfs.h"
#define WAIT_MAX_SECONDS 3
#define WAIT_LOOP_PER_SECOND 20
diff -urpN udev-064/udevtest.c udev-064~tk/udevtest.c
--- udev-064/udevtest.c 2005-07-23 18:27:02.000000000 +0200
+++ udev-064~tk/udevtest.c 2005-07-31 19:16:54.000000000 +0200
@@ -26,7 +26,6 @@
#include <signal.h>
#include <syslog.h>
-#include "libsysfs/sysfs/libsysfs.h"
#include "udev.h"
#include "udev_sysfs.h"
#include "udev_utils.h"
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id\x16492&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
next reply other threads:[~2005-07-31 19:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-31 19:56 Tobias Klauser [this message]
2005-07-31 20:17 ` [PATCH] Fix libsyfs include paths Kay Sievers
2005-07-31 21:51 ` Tobias Klauser
2005-07-31 22:52 ` Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050731195620.GC1155@neon.tklauser.home \
--to=tklauser@access.unizh.ch \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).