libsysfs.h   libsysfs.h 
/* /*
* libsysfs.h * libsysfs.h
* *
* Header Definitions for libsysfs * Header Definitions for libsysfs
* *
* Copyright (C) IBM Corp. 2003 * Copyright (C) IBM Corp. 2004-2005
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but 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
* Lesser General Public License for more details. * Lesser General Public License for more details.
skipping to change at line 30 skipping to change at line 30
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
#ifndef _LIBSYSFS_H_ #ifndef _LIBSYSFS_H_
#define _LIBSYSFS_H_ #define _LIBSYSFS_H_
#include <sys/types.h> #include <sys/types.h>
#include <string.h> #include <string.h>
#include "dlist.h" #include "dlist.h"
/*
* Defines to prevent buffer overruns
*/
#define safestrcpy(to, from) strncpy(to, from, sizeof(to)-1)
#define safestrcat(to, from) strncat(to, from, sizeof(to) - strlen(to)-1)
#define safestrcpymax(to, from, max) \
do { \
to[max-1] = '\0'; \
strncpy(to, from, max-1); \
} while (0)
#define safestrcatmax(to, from, max) \
do { \
to[max-1] = '\0'; \
strncat(to, from, max - strlen(to)-1); \
} while (0)
/*
* Generic #defines go here..
*/
#define SYSFS_FSTYPE_NAME "sysfs" #define SYSFS_FSTYPE_NAME "sysfs"
#define SYSFS_PROC_MNTS "/proc/mounts" #define SYSFS_PROC_MNTS "/proc/mounts"
#define SYSFS_BUS_NAME "bus" #define SYSFS_BUS_NAME "bus"
#define SYSFS_CLASS_NAME "class" #define SYSFS_CLASS_NAME "class"
#define SYSFS_BLOCK_NAME "block" #define SYSFS_BLOCK_NAME "block"
#define SYSFS_DEVICES_NAME "devices" #define SYSFS_DEVICES_NAME "devices"
#define SYSFS_DRIVERS_NAME "drivers" #define SYSFS_DRIVERS_NAME "drivers"
#define SYSFS_MODULE_NAME "module"
#define SYSFS_NAME_ATTRIBUTE "name" #define SYSFS_NAME_ATTRIBUTE "name"
#define SYSFS_UNKNOWN "unknown" #define SYSFS_UNKNOWN "unknown"
#define SYSFS_PATH_ENV "SYSFS_PATH" #define SYSFS_PATH_ENV "SYSFS_PATH"
#define SYSFS_PATH_MAX 255 #define SYSFS_PATH_MAX 256
#define SYSFS_NAME_LEN 50 #define SYSFS_NAME_LEN 64
#define SYSFS_BUS_ID_SIZE 20 #define SYSFS_BUS_ID_SIZE 32
#define SYSFS_METHOD_SHOW 0x01 /* attr can be read by user */ enum sysfs_attribute_method {
#define SYSFS_METHOD_STORE 0x02 /* attr can be changed by user */ SYSFS_METHOD_SHOW = 0x01, /* attr can be read by user */
SYSFS_METHOD_STORE = 0x02, /* attr can be changed by user */
};
/* NOTE: statically define mnt path for sysfs */
#define SYSFS_MNT_PATH "/sys"
/* /*
* NOTE: We have the statically allocated "name" as the first element of al * NOTE:
l * 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 * 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 { struct sysfs_attribute {
char name[SYSFS_NAME_LEN]; char name[SYSFS_NAME_LEN];
char path[SYSFS_PATH_MAX]; char path[SYSFS_PATH_MAX];
char *value; char *value;
unsigned short len; /* value length */ unsigned short len; /* value length */
unsigned short method; /* show and store */ enum sysfs_attribute_method method; /* show and store */
};
struct sysfs_link {
char name[SYSFS_NAME_LEN];
char path[SYSFS_PATH_MAX];
char target[SYSFS_PATH_MAX];
};
struct sysfs_directory {
char name[SYSFS_NAME_LEN];
char path[SYSFS_PATH_MAX];
/* Private: for internal use only */
struct dlist *subdirs;
struct dlist *links;
struct dlist *attributes;
}; };
struct sysfs_driver { struct sysfs_driver {
char name[SYSFS_NAME_LEN]; char name[SYSFS_NAME_LEN];
char path[SYSFS_PATH_MAX]; char path[SYSFS_PATH_MAX];
struct dlist *attrlist;
char bus[SYSFS_NAME_LEN];
/* Private: for internal use only */ /* Private: for internal use only */
struct dlist *devices; struct dlist *devices;
struct sysfs_directory *directory;
}; };
struct sysfs_device { struct sysfs_device {
char name[SYSFS_NAME_LEN]; char name[SYSFS_NAME_LEN];
char path[SYSFS_PATH_MAX];
struct dlist *attrlist;
char bus_id[SYSFS_NAME_LEN]; char bus_id[SYSFS_NAME_LEN];
char bus[SYSFS_NAME_LEN]; char bus[SYSFS_NAME_LEN];
char driver_name[SYSFS_NAME_LEN]; char driver_name[SYSFS_NAME_LEN];
char path[SYSFS_PATH_MAX];
/* Private: for internal use only */ /* Private: for internal use only */
struct sysfs_device *parent; struct sysfs_device *parent;
/* NOTE - we still don't populate this */
struct dlist *children; struct dlist *children;
struct sysfs_directory *directory;
};
struct sysfs_root_device {
char name[SYSFS_NAME_LEN];
char path[SYSFS_PATH_MAX];
/* Private: for internal use only */
struct dlist *devices;
struct sysfs_directory *directory;
}; };
/* NOTE: not used as of now */
struct sysfs_bus { struct sysfs_bus {
char name[SYSFS_NAME_LEN]; char name[SYSFS_NAME_LEN];
char path[SYSFS_PATH_MAX]; char path[SYSFS_PATH_MAX];
struct dlist *attrlist;
/* Private: for internal use only */ /* Private: for internal use only */
struct dlist *drivers; struct dlist *drivers;
struct dlist *devices; struct dlist *devices;
struct sysfs_directory *directory;
}; };
struct sysfs_class_device { struct sysfs_class_device {
char name[SYSFS_NAME_LEN]; char name[SYSFS_NAME_LEN];
char classname[SYSFS_NAME_LEN];
char path[SYSFS_PATH_MAX]; char path[SYSFS_PATH_MAX];
struct dlist *attrlist;
char classname[SYSFS_NAME_LEN];
/* Private: for internal use only */ /* Private: for internal use only */
struct sysfs_class_device *parent; struct sysfs_class_device *parent;
struct sysfs_device *sysdevice; /* NULL if virtual */ struct sysfs_device *sysdevice; /* NULL if virtual */
struct sysfs_driver *driver; /* NULL if not implemented *
/
struct sysfs_directory *directory;
}; };
/* NOTE: not used as of now */
struct sysfs_class { struct sysfs_class {
char name[SYSFS_NAME_LEN]; char name[SYSFS_NAME_LEN];
char path[SYSFS_PATH_MAX]; char path[SYSFS_PATH_MAX];
struct dlist *attrlist;
/* Private: for internal use only */ /* Private: for internal use only */
struct dlist *devices; struct dlist *devices;
struct sysfs_directory *directory;
}; };
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* /*
* Function Prototypes * Function Prototypes
*/ */
extern int sysfs_get_mnt_path(char *mnt_path, size_t len); extern int sysfs_get_mnt_path(char *mnt_path, size_t len);
extern int sysfs_remove_trailing_slash(char *path); extern int sysfs_remove_trailing_slash(char *path);
extern int sysfs_get_name_from_path(const char *path, char *name, size_t le n); extern int sysfs_get_name_from_path(const char *path, char *name, size_t le n);
extern int sysfs_path_is_dir(const char *path); extern int sysfs_path_is_dir(const char *path);
extern int sysfs_path_is_link(const char *path); extern int sysfs_path_is_link(const char *path);
extern int sysfs_path_is_file(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 int sysfs_get_link(const char *path, char *target, size_t len);
extern struct dlist *sysfs_open_subsystem_list(char *name); extern struct dlist *sysfs_open_directory_list(const char *path);
extern struct dlist *sysfs_open_bus_devices_list(char *name);
extern void sysfs_close_list(struct dlist *list); extern void sysfs_close_list(struct dlist *list);
/* sysfs directory and file access */ /* sysfs directory and file access */
extern void sysfs_close_attribute(struct sysfs_attribute *sysattr); extern void sysfs_close_attribute(struct sysfs_attribute *sysattr);
extern struct sysfs_attribute *sysfs_open_attribute(const char *path); extern struct sysfs_attribute *sysfs_open_attribute(const char *path);
extern int sysfs_read_attribute(struct sysfs_attribute *sysattr); extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
extern int sysfs_read_attribute_value(const char *attrpath,
char *value, size_t vsize);
extern int sysfs_write_attribute(struct sysfs_attribute *sysattr, extern int sysfs_write_attribute(struct sysfs_attribute *sysattr,
const char *new_value, size_t len); const char *new_value, size_t len);
extern char *sysfs_get_value_from_attributes(struct dlist *attr,
const char *name);
extern int sysfs_refresh_dir_attributes(struct sysfs_directory *sysdir);
extern int sysfs_refresh_dir_links(struct sysfs_directory *sysdir);
extern int sysfs_refresh_dir_subdirs(struct sysfs_directory *sysdir);
extern void sysfs_close_directory(struct sysfs_directory *sysdir);
extern struct sysfs_directory *sysfs_open_directory(const char *path);
extern int sysfs_read_dir_attributes(struct sysfs_directory *sysdir);
extern int sysfs_read_dir_links(struct sysfs_directory *sysdir);
extern int sysfs_read_dir_subdirs(struct sysfs_directory *sysdir);
extern int sysfs_read_directory(struct sysfs_directory *sysdir);
extern int sysfs_read_all_subdirs(struct sysfs_directory *sysdir);
extern struct sysfs_directory *sysfs_get_subdirectory
(struct sysfs_directory *dir, char *subname);
extern void sysfs_close_link(struct sysfs_link *ln);
extern struct sysfs_link *sysfs_open_link(const char *lnpath);
extern struct sysfs_link *sysfs_get_directory_link
(struct sysfs_directory *dir, char *linkname);
extern struct sysfs_link *sysfs_get_subdirectory_link
(struct sysfs_directory *dir, char *linkname);
extern struct sysfs_attribute *sysfs_get_directory_attribute
(struct sysfs_directory *dir, char *attrname);
extern struct dlist *sysfs_get_dir_attributes(struct sysfs_directory *dir);
extern struct dlist *sysfs_get_dir_links(struct sysfs_directory *dir);
extern struct dlist *sysfs_get_dir_subdirs(struct sysfs_directory *dir);
/* sysfs driver access */ /* sysfs driver access */
extern void sysfs_close_driver(struct sysfs_driver *driver); extern void sysfs_close_driver(struct sysfs_driver *driver);
extern struct sysfs_driver *sysfs_open_driver extern struct sysfs_driver *sysfs_open_driver
(const char *bus_name, const char *drv_name); (const char *bus_name, const char *drv_name);
extern struct sysfs_driver *sysfs_open_driver_path(const char *path); extern struct sysfs_driver *sysfs_open_driver_path(const char *path);
extern struct sysfs_attribute *sysfs_get_driver_attr extern struct sysfs_attribute *sysfs_get_driver_attr
(struct sysfs_driver *drv, const char *name); (struct sysfs_driver *drv, const char *name);
extern struct dlist *sysfs_get_driver_attributes(struct sysfs_driver *drive r); extern struct dlist *sysfs_get_driver_attributes(struct sysfs_driver *drive r);
extern struct dlist *sysfs_get_driver_devices(struct sysfs_driver *driver); extern struct dlist *sysfs_get_driver_devices(struct sysfs_driver *driver);
extern struct dlist *sysfs_refresh_driver_devices(struct sysfs_driver *driv
er);
extern struct dlist *sysfs_get_driver_links(struct sysfs_driver *driver);
extern struct sysfs_device *sysfs_get_driver_device
(struct sysfs_driver *driver, const char *name);
extern struct dlist *sysfs_refresh_driver_attributes
(struct sysfs_driver *driver);
extern struct sysfs_attribute *sysfs_open_driver_attr
(const char *bus, const char *drv, const char *attrib);
/* generic sysfs device access */ /* generic sysfs device access */
extern void sysfs_close_root_device(struct sysfs_root_device *root);
extern struct sysfs_root_device *sysfs_open_root_device(const char *name);
extern struct dlist *sysfs_get_root_devices(struct sysfs_root_device *root)
;
extern void sysfs_close_device_tree(struct sysfs_device *device); extern void sysfs_close_device_tree(struct sysfs_device *device);
extern struct sysfs_device *sysfs_open_device_tree(const char *path); extern struct sysfs_device *sysfs_open_device_tree(const char *path);
extern void sysfs_close_device(struct sysfs_device *dev); extern void sysfs_close_device(struct sysfs_device *dev);
extern struct sysfs_device *sysfs_open_device extern struct sysfs_device *sysfs_open_device
(const char *bus, const char *bus_id); (const char *bus, const char *bus_id);
extern struct sysfs_device *sysfs_get_device_parent(struct sysfs_device *de v); extern struct sysfs_device *sysfs_get_device_parent(struct sysfs_device *de v);
extern struct sysfs_device *sysfs_open_device_path(const char *path); extern struct sysfs_device *sysfs_open_device_path(const char *path);
extern int sysfs_get_device_bus(struct sysfs_device *dev); extern int sysfs_get_device_bus(struct sysfs_device *dev);
extern struct sysfs_attribute *sysfs_get_device_attr extern struct sysfs_attribute *sysfs_get_device_attr
(struct sysfs_device *dev, const char *name); (struct sysfs_device *dev, const char *name);
extern struct dlist *sysfs_get_device_attributes(struct sysfs_device *devic extern struct dlist *sysfs_get_device_attributes
e); (struct sysfs_device *dev);
extern struct dlist *sysfs_refresh_device_attributes
(struct sysfs_device *device);
extern struct sysfs_attribute *sysfs_open_device_attr(const char *bus,
const char *bus_id, const char *attrib);
/* 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 sysfs_device *sysfs_get_bus_device(struct sysfs_bus *bus,
char *id);
extern struct sysfs_driver *sysfs_get_bus_driver(struct sysfs_bus *bus,
char *drvname);
extern struct dlist *sysfs_get_bus_drivers(struct sysfs_bus *bus);
extern struct dlist *sysfs_get_bus_devices(struct sysfs_bus *bus);
extern struct dlist *sysfs_get_bus_attributes(struct sysfs_bus *bus);
extern struct dlist *sysfs_refresh_bus_attributes(struct sysfs_bus *bus);
extern struct sysfs_attribute *sysfs_get_bus_attribute
(struct sysfs_bus *bus, char *attrname);
extern int sysfs_find_driver_bus(const char *driver, char *busname,
size_t bsize);
/* generic sysfs class access */ /* generic sysfs class access */
extern void sysfs_close_class_device(struct sysfs_class_device *dev); extern void sysfs_close_class_device(struct sysfs_class_device *dev);
extern struct sysfs_class_device *sysfs_open_class_device_path extern struct sysfs_class_device *sysfs_open_class_device_path
(const char *path); (const char *path);
extern struct sysfs_class_device *sysfs_open_class_device extern struct sysfs_class_device *sysfs_open_class_device
(const char *classname, const char *name); (const char *classname, const char *name);
extern struct sysfs_device *sysfs_get_classdev_device
(struct sysfs_class_device *clsdev);
extern struct sysfs_driver *sysfs_get_classdev_driver
(struct sysfs_class_device *clsdev);
extern struct sysfs_class_device *sysfs_get_classdev_parent extern struct sysfs_class_device *sysfs_get_classdev_parent
(struct sysfs_class_device *clsdev); (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 dlist *sysfs_get_class_devices(struct sysfs_class *cls);
extern struct sysfs_class_device *sysfs_get_class_device
(struct sysfs_class *cls, char *name);
extern struct dlist *sysfs_get_classdev_attributes
(struct sysfs_class_device *cdev);
extern struct dlist *sysfs_refresh_classdev_attributes
(struct sysfs_class_device *cdev);
extern struct sysfs_attribute *sysfs_get_classdev_attr extern struct sysfs_attribute *sysfs_get_classdev_attr
(struct sysfs_class_device *clsdev, const char *name); (struct sysfs_class_device *clsdev, const char *name);
extern struct sysfs_attribute *sysfs_open_classdev_attr extern struct dlist *sysfs_get_classdev_attributes
(const char *classname, const char *dev, (struct sysfs_class_device *clsdev);
const char *attrib); extern struct sysfs_device *sysfs_get_classdev_device
(struct sysfs_class_device *clsdev);
/** /**
* sort_list: sorter function to keep list elements sorted in alphabetical * sort_list: sorter function to keep list elements sorted in alphabetical
* order. Just does a strncmp as you can see :) * order. Just does a strncmp as you can see :)
* *
* Returns 1 if less than 0 otherwise * Returns 1 if less than 0 otherwise
* *
* NOTE: We take care to have a statically allocated "name" as the first * NOTE: We take care to have a statically allocated "name" as the first
* lement of all libsysfs structures. Hence, this function will work * lement of all libsysfs structures. Hence, this function will work
* AS IS for _ALL_ the lists that have to be sorted. * AS IS for _ALL_ the lists that have to be sorted.
 End of changes. 33 change blocks. 
146 lines changed or deleted 36 lines changed or added


 namedev.h   namedev.h 
skipping to change at line 39 skipping to change at line 39
struct sysfs_class_device; struct sysfs_class_device;
#define BUS_SIZE 32 #define BUS_SIZE 32
#define FILE_SIZE 64 #define FILE_SIZE 64
#define VALUE_SIZE 128 #define VALUE_SIZE 128
#define ID_SIZE 64 #define ID_SIZE 64
#define PLACE_SIZE 64 #define PLACE_SIZE 64
#define DRIVER_SIZE 64 #define DRIVER_SIZE 64
#define PROGRAM_SIZE 128 #define PROGRAM_SIZE 128
#define FIELD_KERNEL "KERNEL"
#define FIELD_SUBSYSTEM "SUBSYSTEM"
#define FIELD_BUS "BUS" #define FIELD_BUS "BUS"
#define FIELD_SYSFS "SYSFS" #define FIELD_SYSFS "SYSFS"
#define FIELD_ID "ID" #define FIELD_ID "ID"
#define FIELD_PLACE "PLACE" #define FIELD_PLACE "PLACE"
#define FIELD_PROGRAM "PROGRAM" #define FIELD_PROGRAM "PROGRAM"
#define FIELD_RESULT "RESULT" #define FIELD_RESULT "RESULT"
#define FIELD_KERNEL "KERNEL"
#define FIELD_SUBSYSTEM "SUBSYSTEM"
#define FIELD_DRIVER "DRIVER" #define FIELD_DRIVER "DRIVER"
#define FIELD_NAME "NAME" #define FIELD_NAME "NAME"
#define FIELD_SYMLINK "SYMLINK" #define FIELD_SYMLINK "SYMLINK"
#define FIELD_OWNER "OWNER" #define FIELD_OWNER "OWNER"
#define FIELD_GROUP "GROUP" #define FIELD_GROUP "GROUP"
#define FIELD_MODE "MODE" #define FIELD_MODE "MODE"
#define FIELD_OPTIONS "OPTIONS"
#define ATTR_PARTITIONS "all_partitions" #define ATTR_IGNORE_DEVICE "ignore_device"
#define ATTR_IGNORE_REMOVE "ignore_remove" #define ATTR_IGNORE_REMOVE "ignore_remove"
#define ATTR_PARTITIONS "all_partitions"
#define MAX_SYSFS_PAIRS 5 #define MAX_SYSFS_PAIRS 5
#define RULEFILE_SUFFIX ".rules" #define RULEFILE_SUFFIX ".rules"
struct sysfs_pair { struct sysfs_pair {
char file[FILE_SIZE]; char file[FILE_SIZE];
char value[VALUE_SIZE]; char value[VALUE_SIZE];
}; };
struct config_device { struct config_device {
struct list_head node; struct list_head node;
char kernel[NAME_SIZE];
char subsystem[SUBSYSTEM_SIZE];
char bus[BUS_SIZE]; char bus[BUS_SIZE];
char id[ID_SIZE]; char id[ID_SIZE];
char place[PLACE_SIZE]; char place[PLACE_SIZE];
char kernel[NAME_SIZE]; struct sysfs_pair sysfs_pair[MAX_SYSFS_PAIRS];
char program[PROGRAM_SIZE]; char program[PROGRAM_SIZE];
char result[PROGRAM_SIZE]; char result[PROGRAM_SIZE];
char subsystem[SUBSYSTEM_SIZE];
char driver[DRIVER_SIZE]; char driver[DRIVER_SIZE];
char name[NAME_SIZE]; char name[NAME_SIZE];
char symlink[NAME_SIZE]; char symlink[NAME_SIZE];
struct sysfs_pair sysfs_pair[MAX_SYSFS_PAIRS];
char owner[USER_SIZE]; char owner[USER_SIZE];
char group[USER_SIZE]; char group[USER_SIZE];
mode_t mode; mode_t mode;
int partitions; int partitions;
int ignore_device;
int ignore_remove; int ignore_remove;
char config_file[NAME_SIZE]; char config_file[NAME_SIZE];
int config_line; int config_line;
}; };
extern struct list_head config_device_list; extern struct list_head config_device_list;
extern int namedev_init(void); extern int namedev_init(void);
extern int namedev_name_device(struct udevice *udev, struct sysfs_class_dev ice *class_dev); extern int namedev_name_device(struct udevice *udev, struct sysfs_class_dev ice *class_dev);
extern void namedev_close(void); extern void namedev_close(void);
 End of changes. 12 change blocks. 
6 lines changed or deleted 12 lines changed or added


 sysfs.h   sysfs.h 
skipping to change at line 30 skipping to change at line 30
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
#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 <mntent.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>
/* external library functions */ #define safestrcpy(to, from) strncpy(to, from, sizeof(to)-1)
extern int isascii(int c); #define safestrcat(to, from) strncat(to, from, sizeof(to) - strlen(to)-1)
#define safestrcpymax(to, from, max) \
do { \
to[max-1] = '\0'; \
strncpy(to, from, max-1); \
} while (0)
#define safestrcatmax(to, from, max) \
do { \
to[max-1] = '\0'; \
strncat(to, from, max - strlen(to)-1); \
} while (0)
extern struct sysfs_attribute *get_attribute(void *dev, const char *name);
extern struct dlist *read_dir_subdirs(const char *path);
extern struct dlist *read_dir_links(const char *path);
extern struct dlist *get_attributes_list(void *dev);
/* Debugging */ /* Debugging */
#ifdef DEBUG #ifdef DEBUG
#include "../logging.h" #include "../logging.h"
#define dprintf(format, arg...) dbg(format, ##arg) #define dprintf(format, arg...) dbg(format, ## arg)
#else #else
#define dprintf(format, arg...) do { } while (0) #define dprintf(format, arg...) do { } while (0)
#endif #endif
#endif /* _SYSFS_H_ */ #endif /* _SYSFS_H_ */
 End of changes. 3 change blocks. 
3 lines changed or deleted 21 lines changed or added


 udev.h   udev.h 
skipping to change at line 29 skipping to change at line 29
* 675 Mass Ave, Cambridge, MA 02139, USA. * 675 Mass Ave, Cambridge, MA 02139, USA.
* *
*/ */
#ifndef _UDEV_H_ #ifndef _UDEV_H_
#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"
#define ALARM_TIMEOUT 120 #define ALARM_TIMEOUT 120
#define COMMENT_CHARACTER '#' #define COMMENT_CHARACTER '#'
#define NAME_SIZE 256 #define NAME_SIZE 256
#define USER_SIZE 32 #define USER_SIZE 32
#define ACTION_SIZE 32 #define ACTION_SIZE 32
#define DEVPATH_SIZE 256 #define DEVPATH_SIZE 256
#define SUBSYSTEM_SIZE 32 #define SUBSYSTEM_SIZE 32
skipping to change at line 51 skipping to change at line 52
#define LINE_SIZE 512 #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 {
UNKNOWN,
CLASS,
BLOCK,
NET,
PHYSDEV,
};
struct udevice { struct udevice {
char devpath[DEVPATH_SIZE]; char devpath[DEVPATH_SIZE];
char subsystem[SUBSYSTEM_SIZE]; char subsystem[SUBSYSTEM_SIZE];
char name[NAME_SIZE]; char name[NAME_SIZE];
char symlink[NAME_SIZE]; char symlink[NAME_SIZE];
char owner[USER_SIZE]; char owner[USER_SIZE];
char group[USER_SIZE]; char group[USER_SIZE];
mode_t mode; mode_t mode;
char type; char type;
int major; dev_t devt;
int minor;
char devname[NAME_SIZE]; char devname[NAME_SIZE];
char tmp_node[NAME_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[NAME_SIZE];
char bus_id[SYSFS_NAME_LEN]; char bus_id[SYSFS_NAME_LEN];
char program_result[NAME_SIZE]; char program_result[NAME_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, int major , int minor, 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[SYSFS_PATH_MAX];
extern char udev_root[PATH_MAX]; extern char udev_root[PATH_MAX];
extern char udev_db_path[PATH_MAX+NAME_MAX]; extern char udev_db_path[PATH_MAX+NAME_MAX];
extern char udev_config_filename[PATH_MAX+NAME_MAX]; extern char udev_config_filename[PATH_MAX+NAME_MAX];
extern char udev_rules_filename[PATH_MAX+NAME_MAX]; extern char udev_rules_filename[PATH_MAX+NAME_MAX];
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;
 End of changes. 4 change blocks. 
3 lines changed or deleted 11 lines changed or added


 udev_db.h   udev_db.h 
skipping to change at line 28 skipping to change at line 28
* You should have received a copy of the GNU General Public License al ong * You should have received a copy of the GNU General Public License al ong
* 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_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_get_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_byname(struct udevice *udev, const char *name extern int udev_db_get_device_by_devpath(struct udevice *dev, const char *d
); evpath);
extern int udev_db_get_device_by_name(struct udevice *udev, const char *nam
e);
extern int udev_db_call_foreach(int (*handler_function)(struct udevice *ude
v));
#endif /* _UDEV_DB_H_ */ #endif /* _UDEV_DB_H_ */
 End of changes. 2 change blocks. 
3 lines changed or deleted 6 lines changed or added


 udev_sysfs.h   udev_sysfs.h 
skipping to change at line 30 skipping to change at line 30
*/ */
#ifndef _UDEV_SYSFS_H_ #ifndef _UDEV_SYSFS_H_
#define _UDEV_SYSFS_H_ #define _UDEV_SYSFS_H_
#include "libsysfs/sysfs/libsysfs.h" #include "libsysfs/sysfs/libsysfs.h"
#define WAIT_MAX_SECONDS 5 #define WAIT_MAX_SECONDS 5
#define WAIT_LOOP_PER_SECOND 20 #define WAIT_LOOP_PER_SECOND 20
extern dev_t get_devt(struct sysfs_class_device *class_dev);
extern int subsystem_expect_no_dev(const char *subsystem); extern int subsystem_expect_no_dev(const char *subsystem);
/* /sys/class /sys/block devices */ /* /sys/class /sys/block devices */
extern struct sysfs_class_device *wait_class_device_open(const char *path); extern struct sysfs_class_device *wait_class_device_open(const char *path);
extern int wait_for_class_device(struct sysfs_class_device *class_dev, cons t char **error); extern int wait_for_class_device(struct sysfs_class_device *class_dev, cons t char **error);
/* /sys/devices devices */ /* /sys/devices devices */
extern struct sysfs_device *wait_devices_device_open(const char *path); extern struct sysfs_device *wait_devices_device_open(const char *path);
extern int wait_for_devices_device(struct sysfs_device *devices_dev, const char **error); extern int wait_for_devices_device(struct sysfs_device *devices_dev, const char **error);
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 udev_utils.h   udev_utils.h 
skipping to change at line 79 skipping to change at line 79
#ifdef asmlinkage #ifdef asmlinkage
# undef asmlinkage # undef asmlinkage
#endif #endif
#ifdef __i386__ #ifdef __i386__
# define asmlinkage __attribute__((regparm(0))) # define asmlinkage __attribute__((regparm(0)))
#endif #endif
#ifndef asmlinkage #ifndef asmlinkage
# define asmlinkage /* nothing */ # define asmlinkage /* nothing */
#endif #endif
extern void udev_init_device(struct udevice *udev, const char* devpath, con st char *subsystem); extern int udev_init_device(struct udevice *udev, const char* devpath, cons t char *subsystem);
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); typedef int (*file_fnct_t)(const char *filename, void *data);
extern int call_foreach_file(file_fnct_t fnct, const char *dirname, extern int call_foreach_file(file_fnct_t fnct, const char *dirname,
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 udev_version.h   udev_version.h 
#define UDEV_VERSION "053" #define UDEV_VERSION "054"
#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


 udevd.h   udevd.h 
skipping to change at line 55 skipping to change at line 55
/* environment buffer, should match the kernel's size in lib/kobject_uevent .h */ /* environment buffer, should match the kernel's size in lib/kobject_uevent .h */
#define HOTPLUG_BUFFER_SIZE 1024 #define HOTPLUG_BUFFER_SIZE 1024
#define HOTPLUG_NUM_ENVP 32 #define HOTPLUG_NUM_ENVP 32
struct udevsend_msg { struct udevsend_msg {
char magic[20]; char magic[20];
char envbuf[HOTPLUG_BUFFER_SIZE+256]; char envbuf[HOTPLUG_BUFFER_SIZE+256];
}; };
struct hotplug_msg { struct hotplug_msg {
struct list_head list; struct list_head node;
pid_t pid; pid_t pid;
long queue_time; long queue_time;
char *action; char *action;
char *devpath; char *devpath;
char *subsystem; char *subsystem;
unsigned long long seqnum; unsigned long long seqnum;
char *physdevpath; char *physdevpath;
char *envp[HOTPLUG_NUM_ENVP+1]; char *envp[HOTPLUG_NUM_ENVP+1];
char envbuf[]; char envbuf[];
}; };
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/