static int logging_init = 0;
static unsigned char udev_logname[42];
-static void init_logging (void)
+static void init_logging(void)
{
- snprintf(udev_logname,42,"udev[%d]", getpid());
+ snprintf(udev_logname, 42,"udev[%d]", getpid());
- openlog (udev_logname, 0, LOG_DAEMON);
+ openlog(udev_logname, 0, LOG_DAEMON);
logging_init = 1;
}
/**
* log_message - sends a message to the logging facility
*/
-int log_message (int level, const char *format, ...)
+int log_message(int level, const char *format, ...)
{
va_list args;
if (!logging_init)
init_logging();
- va_start (args, format);
- vsyslog (level, format, args);
- va_end (args);
+ va_start(args, format);
+ vsyslog(level, format, args);
+ va_end(args);
return 1;
}
int retval = 0;
struct config_device dev;
- dbg("opening %s to read as config", udev_config_filename);
+ dbg("opening '%s' to read as config", udev_config_filename);
fd = fopen(udev_config_filename, "r");
if (fd == NULL) {
- dbg("can't open %s", udev_config_filename);
+ dbg("can't open '%s'", udev_config_filename);
return -ENODEV;
}
goto exit;
lineno++;
- dbg_parse("read %s", temp);
+ dbg_parse("read '%s'", temp);
/* eat the whitespace at the beginning of the line */
while (isspace(*temp))
int retval = 0;
struct config_device dev;
- dbg("opening %s to read as permissions config", udev_config_permission_filename);
+ dbg("opening '%s' to read as permissions config", udev_config_permission_filename);
fd = fopen(udev_config_permission_filename, "r");
if (fd == NULL) {
- dbg("can't open %s", udev_config_permission_filename);
+ dbg("can't open '%s'", udev_config_permission_filename);
return -ENODEV;
}
if (temp == NULL)
break;
- dbg_parse("read %s", temp);
+ dbg_parse("read '%s'", temp);
/* eat the whitespace at the beginning of the line */
while (isspace(*temp))
/* parse the line */
temp2 = strsep(&temp, ":");
if (!temp2) {
- dbg("cannot parse line: %s", line);
+ dbg("cannot parse line '%s'", line);
continue;
}
strncpy(dev.name, temp2, sizeof(dev.name));
temp2 = strsep(&temp, ":");
if (!temp2) {
- dbg("cannot parse line: %s", line);
+ dbg("cannot parse line '%s'", line);
continue;
}
strncpy(dev.owner, temp2, sizeof(dev.owner));
temp2 = strsep(&temp, ":");
if (!temp2) {
- dbg("cannot parse line: %s", line);
+ dbg("cannot parse line '%s'", line);
continue;
}
strncpy(dev.group, temp2, sizeof(dev.owner));
while (isdigit(*(dig-1)))
dig--;
strfieldcpy(udev->kernel_number, dig);
- dbg("kernel_number = %s", udev->kernel_number);
+ dbg("kernel_number='%s'", udev->kernel_number);
}
static void apply_format(struct udevice *udev, unsigned char *string)
break;
buffer[res] = '\0';
if (res > len) {
- dbg("callout len %d too short\n", len);
+ dbg("callout len %d too short", len);
retval = -1;
}
if (value_set) {
strfieldcpy(udev->group, dev->group);
}
dbg_parse("callout returned matching value '%s', '%s' becomes '%s'"
- " - owner='%s', group='%s', mode =%#o",
+ " - owner='%s', group='%s', mode=%#o",
dev->id, class_dev->name, udev->name,
dev->owner, dev->group, dev->mode);
return 0;
* up in the kernel...
*/
if (strstr(class_dev->path, "block")) {
- dbg_parse("looking at block device...");
+ dbg_parse("looking at block device");
if (isdigit(class_dev->path[strlen(class_dev->path)-1])) {
char path[SYSFS_PATH_MAX];
- dbg_parse("really is a partition...");
+ dbg_parse("really is a partition");
strfieldcpy(path, class_dev->path);
temp = strrchr(path, '/');
*temp = 0x00;
if (class_dev_parent == NULL) {
dbg("sysfs_open_class_device at '%s' failed", path);
} else {
- dbg_parse("class_dev_parent->name=%s", class_dev_parent->name);
+ dbg_parse("class_dev_parent->name='%s'", class_dev_parent->name);
if (class_dev_parent->sysdevice)
sysfs_device = class_dev_parent->sysdevice;
}
struct list_head node;
enum config_type type;
-
char bus[BUS_SIZE];
char sysfs_file[FILE_SIZE];
char sysfs_value[VALUE_SIZE];
char place[PLACE_SIZE];
char kernel_name[NAME_SIZE];
char exec_program[FILE_SIZE];
-
+
/* what to set the device to */
char name[NAME_SIZE];
char owner[OWNER_SIZE];
if (dev == NULL)
goto exit;
- dbg("dev = %s", dev);
+ dbg("dev='%s'", dev);
if (sscanf(dev, "%u:%u", &udev->major, &udev->minor) != 2)
goto exit;
- dbg("found major = %d, minor = %d", udev->major, udev->minor);
+ dbg("found major=%d, minor=%d", udev->major, udev->minor);
retval = 0;
exit:
path, strerror(errno));
return retval;
}
- dbg("created %s", path);
+ dbg("created '%s'", path);
}
*pos = '/';
}
else {
struct passwd *pw = getpwnam(dev->owner);
if (!pw)
- dbg("user unknown: %s", dev->owner);
+ dbg("user unknown '%s'", dev->owner);
else
uid = pw->pw_uid;
}
else {
struct group *gr = getgrnam(dev->group);
if (!gr)
- dbg("group unknown: %s", dev->group);
+ dbg("group unknown '%s'", dev->group);
else
gid = gr->gr_gid;
}
strcpy(dev_path, sysfs_path);
strcat(dev_path, device_name);
- dbg("looking at %s", dev_path);
+ dbg("looking at '%s'", dev_path);
/* open up the sysfs class device for this thing... */
class_dev = sysfs_open_class_device(dev_path);
dbg ("sysfs_open_class_device failed");
goto exit;
}
- dbg("class_dev->name = %s", class_dev->name);
+ dbg("class_dev->name='%s'", class_dev->name);
exit:
return class_dev;
while (loop--) {
struct stat buf;
- dbg("looking for %s", filename);
+ dbg("looking for '%s'", filename);
retval = stat(filename, &buf);
if (!retval)
goto exit;
- /* sleep for a second or two to give the kernel a chance to
- * create the dev file */
+ /* sleep to give the kernel a chance to create the dev file */
sleep(1);
}
retval = -ENODEV;
dbg("udevdb_add_dev failed, but we are going to try to create the node anyway. "
"But remove might not work properly for this device.");
- dbg("name = %s", dev.name);
+ dbg("name='%s'", dev.name);
retval = create_node(&dev);
exit:
return retval;
}
-
goto exit;
}
- dbg("%s not found in database, falling back on default name", path);
+ dbg("'%s' not found in database, falling back on default name", path);
temp = strrchr(path, '/');
if (temp == NULL)
return NULL;
strncpy(name, &temp[1], sizeof(name));
exit:
- dbg("name is %s", name);
+ dbg("name is '%s'", name);
return &name[0];
}
strncpy(filename, udev_root, sizeof(filename));
strncat(filename, name, sizeof(filename));
- dbg("unlinking %s", filename);
+ dbg("unlinking '%s'", filename);
retval = unlink(filename);
if (retval) {
dbg("unlink(%s) failed with error '%s'",
filename, strerror(errno));
break;
}
- dbg("removed %s", filename);
+ dbg("removed '%s'", filename);
}
}
return retval;
if (temp)
udev_permission = temp;
}
- dbg("sysfs_path = %s", sysfs_path);
+ dbg("sysfs_path='%s'", sysfs_path);
strncpy(udev_db_filename, udev_config_dir, sizeof(udev_db_filename));
strncat(udev_db_filename, udev_db, sizeof(udev_db_filename));
dbg ("no devpath?");
goto exit;
}
- dbg("looking at %s", devpath);
+ dbg("looking at '%s'", devpath);
/* we only care about class devices and block stuff */
if (!strstr(devpath, "class") &&
!strstr(devpath, "block")) {
- dbg("not block or class");
+ dbg("not a block or class device");
goto exit;
}
get_dirs();
retval = udevdb_init(UDEVDB_DEFAULT);
if (retval != 0) {
- dbg("Unable to initialize database.");
+ dbg("unable to initialize database");
goto exit;
}
retval = udev_remove_device(devpath, subsystem);
else {
- dbg("Unknown action: %s", action);
+ dbg("unknown action '%s'", action);
retval = -EINVAL;
}
udevdb_exit();
exit:
return retval;
}
-
extern char udev_config_filename[PATH_MAX+NAME_MAX];
#endif
-
strcpy(keystr, path);
key.dptr = keystr;
key.dsize = strlen(keystr) + 1;
-
+
data.dptr = (void *)dev;
data.dsize = sizeof(*dev);
dev = malloc(sizeof(*dev));
if (dev == NULL)
goto exit;
-
+
memcpy(dev, data.dptr, sizeof(*dev));
exit:
free(data.dptr);
key.dptr = keystr;
key.dsize = strlen(keystr) + 1;
-
+
return tdb_delete(udevdb, key);
}
/**
* udevdb_init: initializes database
- * @init_flag: database can either be in memory - UDEVDB_INTERNAL - or
- * written to a file with UDEVDB_DEFAULT.
+ * @init_flag: UDEVDB_INTERNAL - database stays in memory
+ * UDEVDB_DEFAULT - database is written to a file
*/
int udevdb_init(int init_flag)
{
udevdb = tdb_open(udev_db_filename, 0, init_flag, O_RDWR | O_CREAT, 0644);
if (udevdb == NULL) {
if (init_flag == UDEVDB_INTERNAL)
- dbg("Unable to initialize in-memory database");
+ dbg("unable to initialize in-memory database");
else
- dbg("Unable to initialize database at %s", udev_db_filename);
+ dbg("unable to initialize database at '%s'", udev_db_filename);
return -EINVAL;
}
return 0;
#define _UDEVDB_H_
/* Udevdb initialization flags */
-#define UDEVDB_DEFAULT 0 /* Defaults database to use file */
-#define UDEVDB_INTERNAL 1 /* Don't store db on disk, use in memory */
+#define UDEVDB_DEFAULT 0 /* defaults database to use file */
+#define UDEVDB_INTERNAL 1 /* don't store db on disk, use in memory */
-/* Function Prototypes */
+/* function prototypes */
extern void udevdb_exit(void);
extern int udevdb_init(int init_flag);