+static int add_perm_dev(struct perm_device *new_dev)
+{
+ struct perm_device *dev;
+ struct perm_device *tmp_dev;
+
+ /* if we already have that entry, just update the values */
+ list_for_each_entry(dev, &perm_device_list, node) {
+ if (strcmp(new_dev->name, dev->name) != 0)
+ continue;
+
+ /* don't overwrite values from earlier entries */
+ if (dev->mode == 0000)
+ dev->mode = new_dev->mode;
+ if (dev->owner[0] == '\0')
+ strfieldcpy(dev->owner, new_dev->owner);
+ if (dev->owner[0] == '\0')
+ strfieldcpy(dev->group, new_dev->group);
+
+ return 0;
+ }
+
+ /* not found, add new structure to the perm list */
+ tmp_dev = malloc(sizeof(*tmp_dev));
+ if (!tmp_dev)
+ return -ENOMEM;
+
+ memcpy(tmp_dev, new_dev, sizeof(*tmp_dev));
+ list_add_tail(&tmp_dev->node, &perm_device_list);
+ /* dump_perm_dev(tmp_dev); */
+
+ return 0;
+}
+