dlist.h | dlist.h | |||
---|---|---|---|---|
skipping to change at line 53 | skipping to change at line 53 | |||
* insert and delete take a directional parameter. Where direction | * insert and delete take a directional parameter. Where direction | |||
* corresponds to the direction in which you want the list to go. | * corresponds to the direction in which you want the list to go. | |||
* true direction corresponded to progressing forward in the last | * true direction corresponded to progressing forward in the last | |||
* false to regressing in the list. | * 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,1) will insert it after the mark | |||
* so a dlist_insert(yourlist,item,0) will insert it before 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 . | * 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 wa nt | * Just use the dlist_(insert|delete)_(before|after) macros if you do not wa nt | |||
* to think about it. | * to think about it. | |||
*/ | */ | |||
#include <malloc.h> | ||||
#include <stddef.h> | ||||
typedef struct dl_node { | typedef struct dl_node { | |||
struct dl_node *prev; | struct dl_node *prev; | |||
struct dl_node *next; | struct dl_node *next; | |||
void *data; | void *data; | |||
} DL_node; | } DL_node; | |||
typedef struct dlist { | typedef struct dlist { | |||
DL_node *marker; | DL_node *marker; | |||
unsigned long count; | unsigned long count; | |||
size_t data_size; | size_t data_size; | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 3 lines changed or added | |||
list.h | list.h | |||
---|---|---|---|---|
/* | /* | |||
* Copied from the Linux kernel source tree, version 2.6.0-test1. | * Copied from the Linux kernel source tree, version 2.6.0-test1. | |||
* | * | |||
* Licensed under the GPL v2 as per the whole kernel source tree. | * Licensed under the GPL v2 as per the whole kernel source tree. | |||
* | * | |||
* Ripped out the rcu stuff, as it's not needed. | ||||
*/ | */ | |||
#ifndef _LINUX_LIST_H | #ifndef _LIST_H | |||
#define _LINUX_LIST_H | #define _LIST_H | |||
//#include <linux/stddef.h> | ||||
/** | /** | |||
* container_of - cast a member of a structure out to the containing struct ure | * container_of - cast a member of a structure out to the containing struct ure | |||
* | * | |||
* @ptr: the pointer to the member. | * @ptr: the pointer to the member. | |||
* @type: the type of the container struct this is embedded in. | * @type: the type of the container struct this is embedded in. | |||
* @member: the name of the member within the struct. | * @member: the name of the member within the struct. | |||
* | * | |||
*/ | */ | |||
#define container_of(ptr, type, member) ({ \ | #define container_of(ptr, type, member) ({ \ | |||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | |||
(type *)( (char *)__mptr - offsetof(type,member) );}) | (type *)( (char *)__mptr - offsetof(type,member) );}) | |||
//#include <linux/prefetch.h> | ||||
static inline void prefetch(const void *x) {;} | ||||
//#include <asm/system.h> | ||||
/* | /* | |||
* These are non-NULL pointers that will result in page faults | * These are non-NULL pointers that will result in page faults | |||
* under normal circumstances, used to verify that nobody uses | * under normal circumstances, used to verify that nobody uses | |||
* non-initialized list entries. | * non-initialized list entries. | |||
*/ | */ | |||
#define LIST_POISON1 ((void *) 0x00100100) | #define LIST_POISON1 ((void *) 0x00100100) | |||
#define LIST_POISON2 ((void *) 0x00200200) | #define LIST_POISON2 ((void *) 0x00200200) | |||
/* | /* | |||
* Simple doubly linked list implementation. | * Simple doubly linked list implementation. | |||
skipping to change at line 146 | skipping to change at line 139 | |||
INIT_LIST_HEAD(entry); | INIT_LIST_HEAD(entry); | |||
} | } | |||
/** | /** | |||
* list_move - delete from one list and add as another's head | * list_move - delete from one list and add as another's head | |||
* @list: the entry to move | * @list: the entry to move | |||
* @head: the head that will precede our entry | * @head: the head that will precede our entry | |||
*/ | */ | |||
static inline void list_move(struct list_head *list, struct list_head *head ) | static inline void list_move(struct list_head *list, struct list_head *head ) | |||
{ | { | |||
__list_del(list->prev, list->next); | __list_del(list->prev, list->next); | |||
list_add(list, head); | list_add(list, head); | |||
} | } | |||
/** | /** | |||
* list_move_tail - delete from one list and add as another's tail | * list_move_tail - delete from one list and add as another's tail | |||
* @list: the entry to move | * @list: the entry to move | |||
* @head: the head that will follow our entry | * @head: the head that will follow our entry | |||
*/ | */ | |||
static inline void list_move_tail(struct list_head *list, | static inline void list_move_tail(struct list_head *list, | |||
struct list_head *head) | struct list_head *head) | |||
{ | { | |||
__list_del(list->prev, list->next); | __list_del(list->prev, list->next); | |||
list_add_tail(list, head); | list_add_tail(list, head); | |||
} | } | |||
/** | /** | |||
* list_empty - tests whether a list is empty | * list_empty - tests whether a list is empty | |||
* @head: the list to test. | * @head: the list to test. | |||
*/ | */ | |||
static inline int list_empty(struct list_head *head) | static inline int list_empty(struct list_head *head) | |||
{ | { | |||
return head->next == head; | return head->next == head; | |||
} | } | |||
skipping to change at line 227 | skipping to change at line 220 | |||
*/ | */ | |||
#define list_entry(ptr, type, member) \ | #define list_entry(ptr, type, member) \ | |||
container_of(ptr, type, member) | container_of(ptr, type, member) | |||
/** | /** | |||
* list_for_each - iterate over a list | * list_for_each - iterate over a list | |||
* @pos: the &struct list_head to use as a loop counter. | * @pos: the &struct list_head to use as a loop counter. | |||
* @head: the head for your list. | * @head: the head for your list. | |||
*/ | */ | |||
#define list_for_each(pos, head) \ | #define list_for_each(pos, head) \ | |||
for (pos = (head)->next, prefetch(pos->next); pos != (head); \ | for (pos = (head)->next; pos != (head); \ | |||
pos = pos->next, prefetch(pos->next)) | pos = pos->next) | |||
/** | /** | |||
* __list_for_each - iterate over a list | * __list_for_each - iterate over a list | |||
* @pos: the &struct list_head to use as a loop counter. | * @pos: the &struct list_head to use as a loop counter. | |||
* @head: the head for your list. | * @head: the head for your list. | |||
* | * | |||
* This variant differs from list_for_each() in that it's the | * This variant differs from list_for_each() in that it's the | |||
* simplest possible list iteration code, no prefetching is done. | * simplest possible list iteration code. | |||
* Use this for code that knows the list to be very short (empty | * Use this for code that knows the list to be very short (empty | |||
* or 1 entry) most of the time. | * or 1 entry) most of the time. | |||
*/ | */ | |||
#define __list_for_each(pos, head) \ | #define __list_for_each(pos, head) \ | |||
for (pos = (head)->next; pos != (head); pos = pos->next) | for (pos = (head)->next; pos != (head); pos = pos->next) | |||
/** | /** | |||
* list_for_each_prev - iterate over a list backwards | * list_for_each_prev - iterate over a list backwards | |||
* @pos: the &struct list_head to use as a loop counter. | * @pos: the &struct list_head to use as a loop counter. | |||
* @head: the head for your list. | * @head: the head for your list. | |||
*/ | */ | |||
#define list_for_each_prev(pos, head) \ | #define list_for_each_prev(pos, head) \ | |||
for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \ | for (pos = (head)->prev; pos != (head); pos = pos->prev) | |||
pos = pos->prev, prefetch(pos->prev)) | ||||
/** | /** | |||
* list_for_each_safe - iterate over a list safe against removal of list entry | * 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. | * @pos: the &struct list_head to use as a loop counter. | |||
* @n: another &struct list_head to use as temporary storage | * @n: another &struct list_head to use as temporary storage | |||
* @head: the head for your list. | * @head: the head for your list. | |||
*/ | */ | |||
#define list_for_each_safe(pos, n, head) \ | #define list_for_each_safe(pos, n, head) \ | |||
for (pos = (head)->next, n = pos->next; pos != (head); \ | for (pos = (head)->next, n = pos->next; pos != (head); \ | |||
pos = n, n = pos->next) | pos = n, n = pos->next) | |||
/** | /** | |||
* list_for_each_entry - iterate over list of given type | * list_for_each_entry - iterate over list of given type | |||
* @pos: the type * to use as a loop counter. | * @pos: the type * to use as a loop counter. | |||
* @head: the head for your list. | * @head: the head for your list. | |||
* @member: the name of the list_struct within the struct. | * @member: the name of the list_struct within the struct. | |||
*/ | */ | |||
#define list_for_each_entry(pos, head, member) \ | #define list_for_each_entry(pos, head, member) \ | |||
for (pos = list_entry((head)->next, typeof(*pos), member), \ | for (pos = list_entry((head)->next, typeof(*pos), member); \ | |||
prefetch(pos->member.next); \ | ||||
&pos->member != (head); \ | &pos->member != (head); \ | |||
pos = list_entry(pos->member.next, typeof(*pos), member), \ | pos = list_entry(pos->member.next, typeof(*pos), member)) | |||
prefetch(pos->member.next)) | ||||
/** | /** | |||
* list_for_each_entry_reverse - iterate backwards over list of given type. | * list_for_each_entry_reverse - iterate backwards over list of given type. | |||
* @pos: the type * to use as a loop counter. | * @pos: the type * to use as a loop counter. | |||
* @head: the head for your list. | * @head: the head for your list. | |||
* @member: the name of the list_struct within the struct. | * @member: the name of the list_struct within the struct. | |||
*/ | */ | |||
#define list_for_each_entry_reverse(pos, head, member) \ | #define list_for_each_entry_reverse(pos, head, member) \ | |||
for (pos = list_entry((head)->prev, typeof(*pos), member), \ | for (pos = list_entry((head)->prev, typeof(*pos), member); \ | |||
prefetch(pos->member.prev); \ | ||||
&pos->member != (head); \ | &pos->member != (head); \ | |||
pos = list_entry(pos->member.prev, typeof(*pos), member), \ | pos = list_entry(pos->member.prev, typeof(*pos), member)) | |||
prefetch(pos->member.prev)) | ||||
/** | /** | |||
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry | * 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. | * @pos: the type * to use as a loop counter. | |||
* @n: another type * to use as temporary storage | * @n: another type * to use as temporary storage | |||
* @head: the head for your list. | * @head: the head for your list. | |||
* @member: the name of the list_struct within the struct. | * @member: the name of the list_struct within the struct. | |||
*/ | */ | |||
#define list_for_each_entry_safe(pos, n, head, member) \ | #define list_for_each_entry_safe(pos, n, head, member) \ | |||
for (pos = list_entry((head)->next, typeof(*pos), member), \ | for (pos = list_entry((head)->next, typeof(*pos), member), \ | |||
n = list_entry(pos->member.next, typeof(*pos), member); \ | n = list_entry(pos->member.next, typeof(*pos), member); \ | |||
&pos->member != (head); \ | &pos->member != (head); \ | |||
pos = n, n = list_entry(n->member.next, typeof(*n), member)) | pos = n, n = list_entry(n->member.next, typeof(*n), member)) | |||
/* | #endif /* _LIST_H */ | |||
* Double linked lists with a single pointer list head. | ||||
* Mostly useful for hash tables where the two pointer list head is | ||||
* too wasteful. | ||||
* You lose the ability to access the tail in O(1). | ||||
*/ | ||||
struct hlist_head { | ||||
struct hlist_node *first; | ||||
}; | ||||
struct hlist_node { | ||||
struct hlist_node *next, **pprev; | ||||
}; | ||||
#define HLIST_HEAD_INIT { .first = NULL } | ||||
#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } | ||||
#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL) | ||||
#define INIT_HLIST_NODE(ptr) ((ptr)->next = NULL, (ptr)->pprev = NULL) | ||||
static __inline__ int hlist_unhashed(struct hlist_node *h) | ||||
{ | ||||
return !h->pprev; | ||||
} | ||||
static __inline__ int hlist_empty(struct hlist_head *h) | ||||
{ | ||||
return !h->first; | ||||
} | ||||
static __inline__ void __hlist_del(struct hlist_node *n) | ||||
{ | ||||
struct hlist_node *next = n->next; | ||||
struct hlist_node **pprev = n->pprev; | ||||
*pprev = next; | ||||
if (next) | ||||
next->pprev = pprev; | ||||
} | ||||
static __inline__ void hlist_del(struct hlist_node *n) | ||||
{ | ||||
__hlist_del(n); | ||||
n->next = LIST_POISON1; | ||||
n->pprev = LIST_POISON2; | ||||
} | ||||
static __inline__ void hlist_del_init(struct hlist_node *n) | ||||
{ | ||||
if (n->pprev) { | ||||
__hlist_del(n); | ||||
INIT_HLIST_NODE(n); | ||||
} | ||||
} | ||||
static __inline__ void hlist_add_head(struct hlist_node *n, struct hlist_he | ||||
ad *h) | ||||
{ | ||||
struct hlist_node *first = h->first; | ||||
n->next = first; | ||||
if (first) | ||||
first->pprev = &n->next; | ||||
h->first = n; | ||||
n->pprev = &h->first; | ||||
} | ||||
/* next must be != NULL */ | ||||
static __inline__ void hlist_add_before(struct hlist_node *n, struct hlist_ | ||||
node *next) | ||||
{ | ||||
n->pprev = next->pprev; | ||||
n->next = next; | ||||
next->pprev = &n->next; | ||||
*(n->pprev) = n; | ||||
} | ||||
static __inline__ void hlist_add_after(struct hlist_node *n, | ||||
struct hlist_node *next) | ||||
{ | ||||
next->next = n->next; | ||||
*(next->pprev) = n; | ||||
n->next = next; | ||||
} | ||||
#define hlist_entry(ptr, type, member) container_of(ptr,type,member) | ||||
/* Cannot easily do prefetch unfortunately */ | ||||
#define hlist_for_each(pos, head) \ | ||||
for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \ | ||||
pos = pos->next) | ||||
#define hlist_for_each_safe(pos, n, head) \ | ||||
for (pos = (head)->first; n = pos ? pos->next : 0, pos; \ | ||||
pos = n) | ||||
/** | ||||
* hlist_for_each_entry - iterate over list of given type | ||||
* @tpos: the type * to use as a loop counter. | ||||
* @pos: the &struct hlist_node to use as a loop counter. | ||||
* @head: the head for your list. | ||||
* @member: the name of the hlist_node within the struct. | ||||
*/ | ||||
#define hlist_for_each_entry(tpos, pos, head, member) \ | ||||
for (pos = (head)->first; \ | ||||
pos && ({ prefetch(pos->next); 1;}) && \ | ||||
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ | ||||
pos = pos->next) | ||||
/** | ||||
* hlist_for_each_entry_continue - iterate over a hlist continuing after ex | ||||
isting point | ||||
* @tpos: the type * to use as a loop counter. | ||||
* @pos: the &struct hlist_node to use as a loop counter. | ||||
* @member: the name of the hlist_node within the struct. | ||||
*/ | ||||
#define hlist_for_each_entry_continue(tpos, pos, member) \ | ||||
for (pos = (pos)->next; \ | ||||
pos && ({ prefetch(pos->next); 1;}) && \ | ||||
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ | ||||
pos = pos->next) | ||||
/** | ||||
* hlist_for_each_entry_from - iterate over a hlist continuing from existin | ||||
g point | ||||
* @tpos: the type * to use as a loop counter. | ||||
* @pos: the &struct hlist_node to use as a loop counter. | ||||
* @member: the name of the hlist_node within the struct. | ||||
*/ | ||||
#define hlist_for_each_entry_from(tpos, pos, member) \ | ||||
for (; pos && ({ prefetch(pos->next); 1;}) && \ | ||||
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ | ||||
pos = pos->next) | ||||
/** | ||||
* hlist_for_each_entry_safe - iterate over list of given type safe against | ||||
removal of list entry | ||||
* @tpos: the type * to use as a loop counter. | ||||
* @pos: the &struct hlist_node to use as a loop counter. | ||||
* @n: another &struct hlist_node to use as temporary storage | ||||
* @head: the head for your list. | ||||
* @member: the name of the hlist_node within the struct. | ||||
*/ | ||||
#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \ | ||||
for (pos = (head)->first; \ | ||||
pos && ({ n = pos->next; 1; }) && \ | ||||
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ | ||||
pos = n) | ||||
#endif | ||||
End of changes. 15 change blocks. | ||||
29 lines changed or deleted | 17 lines changed or added | |||
logging.h | logging.h | |||
---|---|---|---|---|
skipping to change at line 29 | skipping to change at line 29 | |||
* with this program; if not, write to the Free Software Foundation, In c., | * with this program; if not, write to the Free Software Foundation, In c., | |||
* 675 Mass Ave, Cambridge, MA 02139, USA. | * 675 Mass Ave, Cambridge, MA 02139, USA. | |||
* | * | |||
*/ | */ | |||
#ifndef LOGGING_H | #ifndef LOGGING_H | |||
#define LOGGING_H | #define LOGGING_H | |||
#define info(format, arg...) do { } while (0) | #define info(format, arg...) do { } while (0) | |||
#define dbg(format, arg...) do { } while (0) | #define dbg(format, arg...) do { } while (0) | |||
#define dbg_parse(format, arg...) do { } while (0) | ||||
#define logging_init(foo) do { } while (0) | #define logging_init(foo) do { } while (0) | |||
#define logging_close(foo) do { } while (0) | #define logging_close(foo) do { } while (0) | |||
#ifdef LOG | #ifdef USE_LOG | |||
#include <stdarg.h> | #include <stdarg.h> | |||
#include <unistd.h> | #include <unistd.h> | |||
#include <syslog.h> | #include <syslog.h> | |||
#undef info | #undef info | |||
#define info(format, arg...) \ | #define info(format, arg...) \ | |||
do { \ | do { \ | |||
log_message(LOG_INFO , format , ## arg); \ | log_message(LOG_INFO , format , ## arg); \ | |||
} while (0) | } while (0) | |||
#ifdef DEBUG | #ifdef DEBUG | |||
#undef dbg | #undef dbg | |||
#define dbg(format, arg...) \ | #define dbg(format, arg...) \ | |||
do { \ | do { \ | |||
log_message(LOG_DEBUG , "%s: " format , __FUNCTION__ , ## ar g); \ | log_message(LOG_DEBUG , "%s: " format , __FUNCTION__ , ## ar g); \ | |||
} while (0) | } while (0) | |||
#endif | #endif | |||
/* Parser needs it's own debugging statement, we usually don't care about t | ||||
his at all */ | ||||
#ifdef DEBUG_PARSER | ||||
#undef dbg_parse | ||||
#define dbg_parse(format, arg...) | ||||
\ | ||||
do { | ||||
\ | ||||
log_message(LOG_DEBUG , "%s: " format , __FUNCTION__ , ## ar | ||||
g); \ | ||||
} while (0) | ||||
#endif | ||||
extern void log_message(int level, const char *format, ...) | extern void log_message(int level, const char *format, ...) | |||
__attribute__ ((format (printf, 2, 3))); | __attribute__ ((format (printf, 2, 3))); | |||
#undef logging_init | #undef logging_init | |||
static inline void logging_init(const char *program_name) | static inline void logging_init(const char *program_name) | |||
{ | { | |||
openlog(program_name, LOG_PID, LOG_DAEMON); | openlog(program_name, LOG_PID, LOG_DAEMON); | |||
} | } | |||
#undef logging_close | #undef logging_close | |||
static inline void logging_close(void) | static inline void logging_close(void) | |||
{ | { | |||
closelog(); | closelog(); | |||
} | } | |||
#endif /* LOG */ | #endif /* USE_LOG */ | |||
#endif | #endif | |||
End of changes. 4 change blocks. | ||||
16 lines changed or deleted | 2 lines changed or added | |||
sysfs.h | sysfs.h | |||
---|---|---|---|---|
skipping to change at line 31 | skipping to change at line 31 | |||
* | * | |||
*/ | */ | |||
#ifndef _SYSFS_H_ | #ifndef _SYSFS_H_ | |||
#define _SYSFS_H_ | #define _SYSFS_H_ | |||
#include <stdio.h> | #include <stdio.h> | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <unistd.h> | #include <unistd.h> | |||
#include <string.h> | #include <string.h> | |||
#include <ctype.h> | #include <ctype.h> | |||
#include <mntent.h> | ||||
#include <dirent.h> | #include <dirent.h> | |||
#include <sys/stat.h> | #include <sys/stat.h> | |||
#include <fcntl.h> | #include <fcntl.h> | |||
#include <errno.h> | #include <errno.h> | |||
#define safestrcpy(to, from) strncpy(to, from, sizeof(to)-1) | #define safestrcpy(to, from) strncpy(to, from, sizeof(to)-1) | |||
#define safestrcat(to, from) strncat(to, from, sizeof(to) - strlen(to)-1) | #define safestrcat(to, from) strncat(to, from, sizeof(to) - strlen(to)-1) | |||
#define safestrcpymax(to, from, max) \ | #define safestrcpymax(to, from, max) \ | |||
do { \ | do { \ | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 0 lines changed or added | |||
udev.h | udev.h | |||
---|---|---|---|---|
/* | /* | |||
* udev.h | * udev.h | |||
* | * | |||
* Userspace devfs | * Userspace devfs | |||
* | * | |||
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com> | * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com> | |||
* Copyright (C) 2003-2005 Kay Sievers <kay.sievers@vrfy.org> | ||||
* | * | |||
* This program is free software; you can redistribute it and/or modify it | * This program is free software; you can redistribute it and/or modify it | |||
* under the terms of the GNU General Public License as published by th e | * under the terms of the GNU General Public License as published by th e | |||
* Free Software Foundation version 2 of the License. | * Free Software Foundation version 2 of the License. | |||
* | * | |||
* This program is distributed in the hope that it will be useful, but | * This program is distributed in the hope that it will be useful, but | |||
* WITHOUT ANY WARRANTY; without even the implied warranty of | * WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* General Public License for more details. | * General Public License for more details. | |||
* | * | |||
skipping to change at line 34 | skipping to change at line 35 | |||
#define _UDEV_H_ | #define _UDEV_H_ | |||
#include <sys/types.h> | #include <sys/types.h> | |||
#include <sys/param.h> | #include <sys/param.h> | |||
#include "libsysfs/sysfs/libsysfs.h" | #include "libsysfs/sysfs/libsysfs.h" | |||
#include "list.h" | #include "list.h" | |||
#define ALARM_TIMEOUT 120 | #define ALARM_TIMEOUT 120 | |||
#define COMMENT_CHARACTER '#' | #define COMMENT_CHARACTER '#' | |||
#define NAME_SIZE 256 | #define LINE_SIZE 512 | |||
#define NAME_SIZE 128 | ||||
#define PATH_SIZE 256 | ||||
#define USER_SIZE 32 | #define USER_SIZE 32 | |||
#define ACTION_SIZE 32 | ||||
#define DEVPATH_SIZE 256 | ||||
#define SUBSYSTEM_SIZE 32 | ||||
#define SEQNUM_SIZE 32 | #define SEQNUM_SIZE 32 | |||
#define VALUE_SIZE 128 | ||||
#define LINE_SIZE 512 | ||||
#define DEVD_DIR "/etc/dev.d" | #define DEVD_DIR "/etc/dev.d" | |||
#define DEVD_SUFFIX ".dev" | #define DEVD_SUFFIX ".dev" | |||
#define HOTPLUGD_DIR "/etc/hotplug.d" | #define HOTPLUGD_DIR "/etc/hotplug.d" | |||
#define HOTPLUG_SUFFIX ".hotplug" | #define HOTPLUG_SUFFIX ".hotplug" | |||
#define DEFAULT_PARTITIONS_COUNT 15 | #define DEFAULT_PARTITIONS_COUNT 15 | |||
enum device_type { | enum device_type { | |||
UNKNOWN, | DEV_UNKNOWN, | |||
CLASS, | DEV_CLASS, | |||
BLOCK, | DEV_BLOCK, | |||
NET, | DEV_NET, | |||
PHYSDEV, | DEV_DEVICE, | |||
}; | }; | |||
struct udevice { | struct udevice { | |||
char devpath[DEVPATH_SIZE]; | char devpath[PATH_SIZE]; | |||
char subsystem[SUBSYSTEM_SIZE]; | char subsystem[NAME_SIZE]; | |||
char name[NAME_SIZE]; | enum device_type type; | |||
char symlink[NAME_SIZE]; | char name[PATH_SIZE]; | |||
char devname[PATH_SIZE]; | ||||
struct list_head symlink_list; | ||||
char owner[USER_SIZE]; | char owner[USER_SIZE]; | |||
char group[USER_SIZE]; | char group[USER_SIZE]; | |||
mode_t mode; | mode_t mode; | |||
char type; | ||||
dev_t devt; | dev_t devt; | |||
char devname[NAME_SIZE]; | char tmp_node[PATH_SIZE]; | |||
char tmp_node[NAME_SIZE]; | ||||
int partitions; | int partitions; | |||
int ignore_remove; | int ignore_remove; | |||
int config_line; | int config_line; | |||
char config_file[NAME_SIZE]; | char config_file[PATH_SIZE]; | |||
char bus_id[SYSFS_NAME_LEN]; | char bus_id[NAME_SIZE]; | |||
char program_result[NAME_SIZE]; | char program_result[PATH_SIZE]; | |||
char kernel_number[NAME_SIZE]; | char kernel_number[NAME_SIZE]; | |||
char kernel_name[NAME_SIZE]; | char kernel_name[NAME_SIZE]; | |||
int test_run; | int test_run; | |||
}; | }; | |||
extern int udev_add_device(struct udevice *udev, struct sysfs_class_device *class_dev); | extern int udev_add_device(struct udevice *udev, struct sysfs_class_device *class_dev); | |||
extern int udev_remove_device(struct udevice *udev); | extern int udev_remove_device(struct udevice *udev); | |||
extern void udev_init_config(void); | extern void udev_init_config(void); | |||
extern int udev_start(void); | extern int udev_start(void); | |||
extern void udev_multiplex_directory(struct udevice *udev, const char *base dir, const char *suffix); | extern void udev_multiplex_directory(struct udevice *udev, const char *base dir, const char *suffix); | |||
extern int udev_make_node(struct udevice *udev, const char *file, dev_t dev t, mode_t mode, uid_t uid, gid_t gid); | extern int udev_make_node(struct udevice *udev, const char *file, dev_t dev t, mode_t mode, uid_t uid, gid_t gid); | |||
extern char sysfs_path[SYSFS_PATH_MAX]; | extern char sysfs_path[PATH_SIZE]; | |||
extern char udev_root[PATH_MAX]; | extern char udev_root[PATH_SIZE]; | |||
extern char udev_db_path[PATH_MAX+NAME_MAX]; | extern char udev_db_path[PATH_SIZE]; | |||
extern char udev_config_filename[PATH_MAX+NAME_MAX]; | extern char udev_config_filename[PATH_SIZE]; | |||
extern char udev_rules_filename[PATH_MAX+NAME_MAX]; | extern char udev_rules_filename[PATH_SIZE]; | |||
extern int udev_log; | extern int udev_log; | |||
extern int udev_dev_d; | extern int udev_dev_d; | |||
extern int udev_hotplug_d; | extern int udev_hotplug_d; | |||
#endif | #endif | |||
End of changes. 11 change blocks. | ||||
27 lines changed or deleted | 25 lines changed or added | |||
udev_db.h | udev_db.h | |||
---|---|---|---|---|
skipping to change at line 30 | skipping to change at line 30 | |||
* 675 Mass Ave, Cambridge, MA 02139, USA. | * 675 Mass Ave, Cambridge, MA 02139, USA. | |||
* | * | |||
*/ | */ | |||
#ifndef _UDEV_DB_H_ | #ifndef _UDEV_DB_H_ | |||
#define _UDEV_DB_H_ | #define _UDEV_DB_H_ | |||
extern int udev_db_add_device(struct udevice *dev); | extern int udev_db_add_device(struct udevice *dev); | |||
extern int udev_db_delete_device(struct udevice *dev); | extern int udev_db_delete_device(struct udevice *dev); | |||
extern int udev_db_get_device_by_devpath(struct udevice *dev, const char *d | extern int udev_db_get_device(struct udevice *udev, const char *devpath); | |||
evpath); | extern int udev_db_search_name(char *devpath, size_t len, const char *name) | |||
extern int udev_db_get_device_by_name(struct udevice *udev, const char *nam | ; | |||
e); | extern int udev_db_dump_names(int (*handler_function)(const char *path, con | |||
extern int udev_db_call_foreach(int (*handler_function)(struct udevice *ude | st char *name)); | |||
v)); | ||||
#endif /* _UDEV_DB_H_ */ | #endif /* _UDEV_DB_H_ */ | |||
End of changes. 1 change blocks. | ||||
6 lines changed or deleted | 5 lines changed or added | |||
udev_selinux.h | udev_selinux.h | |||
---|---|---|---|---|
skipping to change at line 27 | skipping to change at line 27 | |||
* 675 Mass Ave, Cambridge, MA 02139, USA. | * 675 Mass Ave, Cambridge, MA 02139, USA. | |||
* | * | |||
*/ | */ | |||
#ifndef _UDEV_SELINUX_H | #ifndef _UDEV_SELINUX_H | |||
#define _UDEV_SELINUX_H | #define _UDEV_SELINUX_H | |||
#ifdef USE_SELINUX | #ifdef USE_SELINUX | |||
extern void selinux_setfilecon(const char *file, const char *devname, unsig ned int mode); | extern void selinux_setfilecon(const char *file, const char *devname, unsig ned int mode); | |||
extern void selinux_setfscreatecon(const char *file, const char *devname, u nsigned int mode); | extern void selinux_setfscreatecon(const char *file, const char *devname, u nsigned int mode); | |||
extern void selinux_resetfscreatecon(void); | ||||
extern void selinux_init(void); | extern void selinux_init(void); | |||
extern void selinux_restore(void); | extern void selinux_exit(void); | |||
#else | #else | |||
static inline void selinux_setfilecon(const char *file, const char *devname , unsigned int mode) {} | static inline void selinux_setfilecon(const char *file, const char *devname , unsigned int mode) {} | |||
static inline void selinux_setfscreatecon(const char *file, const char *dev name, unsigned int mode) {} | static inline void selinux_setfscreatecon(const char *file, const char *dev name, unsigned int mode) {} | |||
static inline void selinux_resetfscreatecon(void) {} | ||||
static inline void selinux_init(void) {} | static inline void selinux_init(void) {} | |||
static inline void selinux_restore(void) {} | static inline void selinux_exit(void) {} | |||
#endif /* USE_SELINUX */ | #endif /* USE_SELINUX */ | |||
#endif /* _UDEV_USE_SELINUX */ | #endif /* _UDEV_USE_SELINUX */ | |||
End of changes. 4 change blocks. | ||||
2 lines changed or deleted | 4 lines changed or added | |||
udev_utils.h | udev_utils.h | |||
---|---|---|---|---|
skipping to change at line 27 | skipping to change at line 27 | |||
* with this program; if not, write to the Free Software Foundation, In c., | * with this program; if not, write to the Free Software Foundation, In c., | |||
* 675 Mass Ave, Cambridge, MA 02139, USA. | * 675 Mass Ave, Cambridge, MA 02139, USA. | |||
* | * | |||
*/ | */ | |||
#ifndef _UDEV_LIB_H_ | #ifndef _UDEV_LIB_H_ | |||
#define _UDEV_LIB_H_ | #define _UDEV_LIB_H_ | |||
#include "udev.h" | #include "udev.h" | |||
#define strfieldcpy(to, from) \ | struct name_entry { | |||
do { \ | struct list_head node; | |||
to[sizeof(to)-1] = '\0'; \ | char name[PATH_SIZE]; | |||
strncpy(to, from, sizeof(to)-1); \ | }; | |||
} while (0) | ||||
#define strfieldcat(to, from) \ | ||||
do { \ | ||||
to[sizeof(to)-1] = '\0'; \ | ||||
strncat(to, from, sizeof(to) - strlen(to)-1); \ | ||||
} while (0) | ||||
#define strfieldcpymax(to, from, maxsize) \ | ||||
do { \ | ||||
to[maxsize-1] = '\0'; \ | ||||
strncpy(to, from, maxsize-1); \ | ||||
} while (0) | ||||
#define strfieldcatmax(to, from, maxsize) \ | ||||
do { \ | ||||
to[maxsize-1] = '\0'; \ | ||||
strncat(to, from, maxsize - strlen(to)-1); \ | ||||
} while (0) | ||||
#define strintcat(to, i) \ | ||||
do { \ | ||||
to[sizeof(to)-1] = '\0'; \ | ||||
snprintf((to) + strlen(to), sizeof(to) - strlen(to)-1, "%u", i); \ | ||||
} while (0) | ||||
#define strintcatmax(to, i, maxsize) \ | ||||
do { \ | ||||
to[maxsize-1] = '\0'; \ | ||||
snprintf((to) + strlen(to), maxsize - strlen(to)-1, "%u", i); \ | ||||
} while (0) | ||||
#define foreach_strpart(str, separator, pos, len) \ | ||||
for(pos = str, len = 0; \ | ||||
(pos) < ((str) + strlen(str)); \ | ||||
pos = pos + len + strspn(pos, separator), len = strcspn(pos, sep | ||||
arator)) \ | ||||
if (len > 0) | ||||
#ifdef asmlinkage | ||||
# undef asmlinkage | ||||
#endif | ||||
#ifdef __i386__ | ||||
# define asmlinkage __attribute__((regparm(0))) | ||||
#endif | ||||
#ifndef asmlinkage | ||||
# define asmlinkage /* nothing */ | ||||
#endif | ||||
extern int udev_init_device(struct udevice *udev, const char* devpath, cons t char *subsystem); | extern int udev_init_device(struct udevice *udev, const char* devpath, cons t char *subsystem); | |||
extern void udev_cleanup_device(struct udevice *udev); | ||||
extern int kernel_release_satisfactory(unsigned int version, unsigned int p atchlevel, unsigned int sublevel); | extern int kernel_release_satisfactory(unsigned int version, unsigned int p atchlevel, unsigned int sublevel); | |||
extern int create_path(const char *path); | extern int create_path(const char *path); | |||
extern int parse_get_pair(char **orig_string, char **left, char **right); | extern int parse_get_pair(char **orig_string, char **left, char **right); | |||
extern int unlink_secure(const char *filename); | extern int unlink_secure(const char *filename); | |||
extern int file_map(const char *filename, char **buf, size_t *bufsize); | extern int file_map(const char *filename, char **buf, size_t *bufsize); | |||
extern void file_unmap(char *buf, size_t bufsize); | extern void file_unmap(char *buf, size_t bufsize); | |||
extern size_t buf_get_line(const char *buf, size_t buflen, size_t cur); | extern size_t buf_get_line(const char *buf, size_t buflen, size_t cur); | |||
extern void no_trailing_slash(char *path); | extern void no_trailing_slash(char *path); | |||
typedef int (*file_fnct_t)(const char *filename, void *data); | extern int name_list_add(struct list_head *name_list, const char *name, int | |||
extern int call_foreach_file(file_fnct_t fnct, const char *dirname, | sort); | |||
const char *suffix, void *data); | extern int call_foreach_file(int (*handler_function)(struct udevice *udev, | |||
const char *string), | ||||
struct udevice *udev, const char *dirname, cons | ||||
t char *suffix); | ||||
#endif | #endif | |||
End of changes. 3 change blocks. | ||||
56 lines changed or deleted | 12 lines changed or added | |||
udev_version.h | udev_version.h | |||
---|---|---|---|---|
#define UDEV_VERSION "054" | #define UDEV_VERSION "055" | |||
#define UDEV_ROOT "/udev" | #define UDEV_ROOT "/udev" | |||
#define UDEV_DB "/udev/.udevdb" | #define UDEV_DB "/udev/.udevdb" | |||
#define UDEV_CONFIG_DIR "/etc/udev" | #define UDEV_CONFIG_DIR "/etc/udev" | |||
#define UDEV_CONFIG_FILE "/etc/udev/udev.conf" | #define UDEV_CONFIG_FILE "/etc/udev/udev.conf" | |||
#define UDEV_RULES_FILE "/etc/udev/rules.d" | #define UDEV_RULES_FILE "/etc/udev/rules.d" | |||
#define UDEV_LOG_DEFAULT "yes" | #define UDEV_LOG_DEFAULT "yes" | |||
#define UDEV_BIN "/sbin/udev" | #define UDEV_BIN "/sbin/udev" | |||
#define UDEVD_BIN "/sbin/udevd" | #define UDEVD_BIN "/sbin/udevd" | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||