| 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 | |
|
| 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_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 | |
|