X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=namedev.c;h=7fd69f7778954332ab2075232fa98b7297b58001;hb=be9b51f6638d66025ebde1ca154ae9180383409c;hp=fdda039f5993f41a42cdd8502ea24334fa447410;hpb=616a7078071362b32a4db73fe3314feb46438258;p=elogind.git diff --git a/namedev.c b/namedev.c index fdda039f5..7fd69f777 100644 --- a/namedev.c +++ b/namedev.c @@ -36,6 +36,7 @@ #include "list.h" #include "udev.h" #include "udev_version.h" +#include "logging.h" #include "namedev.h" #include "libsysfs/libsysfs.h" #include "klibc_fixups.h" @@ -140,7 +141,7 @@ static struct perm_device *find_perm(char *name) return NULL; } -static mode_t get_default_mode(struct sysfs_class_device *class_dev) +static mode_t get_default_mode(void) { mode_t mode = 0600; /* default to owner rw only */ @@ -150,6 +151,22 @@ static mode_t get_default_mode(struct sysfs_class_device *class_dev) return mode; } +static char * get_default_owner(void) +{ + if (strlen(default_owner_str) == 0) { + strncpy(default_owner_str, "root", OWNER_SIZE); + } + return default_owner_str; +} + +static char * get_default_group(void) +{ + if (strlen(default_group_str) == 0) { + strncpy(default_group_str, "root", GROUP_SIZE); + } + return default_group_str; +} + static void apply_format(struct udevice *udev, unsigned char *string) { char temp[NAME_SIZE]; @@ -196,16 +213,6 @@ static void apply_format(struct udevice *udev, unsigned char *string) strcat(pos, udev->kernel_number); dbg("substitute kernel number '%s'", udev->kernel_number); break; - case 'D': - if (strlen(udev->kernel_number) == 0) { - strcat(pos, "disc"); - dbg("substitute devfs disc"); - break; - } - strcat(pos, "part"); - strcat(pos, udev->kernel_number); - dbg("substitute devfs part '%s'", udev->kernel_number); - break; case 'm': sprintf(pos, "%u", udev->minor); dbg("substitute minor number '%u'", udev->minor); @@ -295,12 +302,12 @@ static void wait_for_device_to_initialize(struct sysfs_device *sysfs_device) /* sleep to give the kernel a chance to create the file */ sleep(1); } - dbg("Timed out waiting for '%s' file, continuing on anyway...", b->file); + dbg("timed out waiting for '%s' file, continuing on anyway...", b->file); goto exit; } b++; } - dbg("Did not find bus type '%s' on list of bus_id_files, contact greg@kroah.com", sysfs_device->bus); + dbg("did not find bus type '%s' on list of bus_id_files, contact greg@kroah.com", sysfs_device->bus); exit: return; /* here to prevent compiler warning... */ } @@ -544,7 +551,7 @@ static struct sysfs_device *get_sysfs_device(struct sysfs_class_device *class_de if (sysfs_device != NULL) goto device_found; } - dbg("Timed out waiting for device symlink, continuing on anyway..."); + dbg("timed out waiting for device symlink, continuing on anyway..."); device_found: /* We have another issue with just the wait above - the sysfs part of @@ -569,10 +576,10 @@ device_found: if (sysfs_device->bus[0] != '\0') goto bus_found; } - dbg("Timed out waiting to find the device bus, continuing on anyway\n"); + dbg("timed out waiting to find the device bus, continuing on anyway"); goto exit; bus_found: - dbg("Device %s is registered with bus %s\n", + dbg("device %s is registered with bus '%s'", sysfs_device->name, sysfs_device->bus); } exit: @@ -704,7 +711,8 @@ int namedev_name_device(struct sysfs_class_device *class_dev, struct udevice *ud } /* Yup, this rule belongs to us! */ - dbg("found matching rule, '%s' becomes '%s'", dev->kernel, dev->name); + info("configured rule in '%s' at line %i applied, '%s' becomes '%s'", + udev_rules_filename, dev->config_line, udev->kernel_name, dev->name); strfieldcpy(udev->name, dev->name); strfieldcpy(udev->symlink, dev->symlink); goto found; @@ -727,9 +735,9 @@ done: strfieldcpy(udev->group, perm->group); } else { /* no matching perms found :( */ - udev->mode = get_default_mode(class_dev); - udev->owner[0] = 0x00; - udev->group[0] = 0x00; + udev->mode = get_default_mode(); + strncpy(udev->owner, get_default_owner(), OWNER_SIZE); + strncpy(udev->group, get_default_group(), GROUP_SIZE); } dbg("name, '%s' is going to have owner='%s', group='%s', mode = %#o", udev->name, udev->owner, udev->group, udev->mode);