summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-12-20 01:31:56 +0100
committerGreg KH <gregkh@suse.de>2005-04-26 23:19:09 -0700
commit65ab1334122b6ed427ce39f48fb40757d44f8d71 (patch)
tree331c69c08e98ca2f88c154f531549c79b458dfa8
parent2a270316e4c0afa1efe98d665e2e329b7bae6c0a (diff)
[PATCH] simplify permission application
We have only one source of permissions now, so apply the default permissions at udev init.
-rw-r--r--namedev.c37
-rw-r--r--udev_add.c2
-rw-r--r--udev_utils.c4
3 files changed, 20 insertions, 23 deletions
diff --git a/namedev.c b/namedev.c
index be7ae12cd5..3da783b55d 100644
--- a/namedev.c
+++ b/namedev.c
@@ -680,7 +680,6 @@ int namedev_name_device(struct udevice *udev, struct sysfs_class_device *class_d
struct config_device *dev;
char *pos;
- udev->mode = 0;
dbg("class_dev->name='%s'", class_dev->name);
/* Figure out where the "device"-symlink is at. For char devices this will
@@ -757,34 +756,28 @@ int namedev_name_device(struct udevice *udev, struct sysfs_class_device *class_d
goto exit;
udev->partitions = dev->partitions;
- udev->mode = dev->mode;
- strfieldcpy(udev->owner, dev->owner);
- apply_format(udev, udev->owner, sizeof(udev->owner), class_dev, sysfs_device);
- strfieldcpy(udev->group, dev->group);
- apply_format(udev, udev->group, sizeof(udev->group), class_dev, sysfs_device);
+ if (dev->mode != 0000)
+ udev->mode = dev->mode;
+ if (dev->owner[0] != '\0') {
+ strfieldcpy(udev->owner, dev->owner);
+ apply_format(udev, udev->owner, sizeof(udev->owner), class_dev, sysfs_device);
+ }
+ if (dev->group[0] != '\0') {
+ strfieldcpy(udev->group, dev->group);
+ apply_format(udev, udev->group, sizeof(udev->group), class_dev, sysfs_device);
+ }
+
+ dbg("name, '%s' is going to have owner='%s', group='%s', mode = %#o",
+ udev->name, udev->owner, udev->group, udev->mode);
- goto perms;
+ goto exit;
}
}
}
/* no rule matched, so we use the kernel name */
strfieldcpy(udev->name, udev->kernel_name);
-
- if (udev->type == 'n')
- goto exit;
-
-perms:
- /* apply default permissions to empty fields */
- if (udev->mode == 0000)
- udev->mode = default_mode;
- if (udev->owner[0] == '\0')
- strfieldcpy(udev->owner, default_owner);
- if (udev->group[0] == '\0')
- strfieldcpy(udev->group, default_group);
-
- dbg("name, '%s' is going to have owner='%s', group='%s', mode = %#o",
- udev->name, udev->owner, udev->group, udev->mode);
+ dbg("no rule found, use kernel name '%s'", udev->name);
exit:
return 0;
diff --git a/udev_add.c b/udev_add.c
index f537f567cc..c9b30bad90 100644
--- a/udev_add.c
+++ b/udev_add.c
@@ -189,7 +189,7 @@ static int create_node(struct udevice *udev)
} else {
info("creating device node '%s', major = '%d', minor = '%d', "
"mode = '%#o', uid = '%d', gid = '%d'", filename,
- udev->major, udev->minor, (mode_t)udev->mode, uid, gid);
+ udev->major, udev->minor, udev->mode, uid, gid);
}
/* create all_partitions if requested */
diff --git a/udev_utils.c b/udev_utils.c
index aa5c75f74d..0b730d565b 100644
--- a/udev_utils.c
+++ b/udev_utils.c
@@ -55,6 +55,10 @@ void udev_init_device(struct udevice *udev, const char* devpath, const char *sub
udev->type = 'n';
else if (strncmp(udev->devpath, "/class/", 7) == 0)
udev->type = 'c';
+
+ udev->mode = default_mode;
+ strfieldcpy(udev->owner, default_owner);
+ strfieldcpy(udev->group, default_group);
}
int kernel_release_satisfactory(int version, int patchlevel, int sublevel)