chiark / gitweb /
fdda039f5993f41a42cdd8502ea24334fa447410
[elogind.git] / namedev.c
1 /*
2  * namedev.c
3  *
4  * Userspace devfs
5  *
6  * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
7  *
8  *
9  *      This program is free software; you can redistribute it and/or modify it
10  *      under the terms of the GNU General Public License as published by the
11  *      Free Software Foundation version 2 of the License.
12  * 
13  *      This program is distributed in the hope that it will be useful, but
14  *      WITHOUT ANY WARRANTY; without even the implied warranty of
15  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  *      General Public License for more details.
17  * 
18  *      You should have received a copy of the GNU General Public License along
19  *      with this program; if not, write to the Free Software Foundation, Inc.,
20  *      675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */
23
24 #include <stddef.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <stdio.h>
28 #include <fcntl.h>
29 #include <ctype.h>
30 #include <unistd.h>
31 #include <errno.h>
32 #include <time.h>
33 #include <sys/wait.h>
34 #include <sys/stat.h>
35
36 #include "list.h"
37 #include "udev.h"
38 #include "udev_version.h"
39 #include "namedev.h"
40 #include "libsysfs/libsysfs.h"
41 #include "klibc_fixups.h"
42
43 LIST_HEAD(config_device_list);
44 LIST_HEAD(perm_device_list);
45
46 /* compare string with pattern (supports * ? [0-9] [!A-Z]) */
47 static int strcmp_pattern(const char *p, const char *s)
48 {
49         if (*s == '\0') {
50                 while (*p == '*')
51                         p++;
52                 return (*p != '\0');
53         }
54         switch (*p) {
55         case '[':
56                 {
57                         int not = 0;
58                         p++;
59                         if (*p == '!') {
60                                 not = 1;
61                                 p++;
62                         }
63                         while (*p && (*p != ']')) {
64                                 int match = 0;
65                                 if (p[1] == '-') {
66                                         if ((*s >= *p) && (*s <= p[2]))
67                                                 match = 1;
68                                         p += 3;
69                                 } else {
70                                         match = (*p == *s);
71                                         p++;
72                                 }
73                                 if (match ^ not) {
74                                         while (*p && (*p != ']'))
75                                                 p++;
76                                         return strcmp_pattern(p+1, s+1);
77                                 }
78                         }
79                 }
80                 break;
81         case '*':
82                 if (strcmp_pattern(p, s+1))
83                         return strcmp_pattern(p+1, s);
84                 return 0;
85         case '\0':
86                 if (*s == '\0') {
87                         return 0;
88                 }
89                 break;
90         default:
91                 if ((*p == *s) || (*p == '?'))
92                         return strcmp_pattern(p+1, s+1);
93                 break;
94         }
95         return 1;
96 }
97
98 #define copy_var(a, b, var)             \
99         if (b->var)                     \
100                 a->var = b->var;
101
102 #define copy_string(a, b, var)          \
103         if (strlen(b->var))             \
104                 strcpy(a->var, b->var);
105
106 int add_perm_dev(struct perm_device *new_dev)
107 {
108         struct perm_device *dev;
109         struct perm_device *tmp_dev;
110
111         /* update the values if we already have the device */
112         list_for_each_entry(dev, &perm_device_list, node) {
113                 if (strcmp_pattern(new_dev->name, dev->name))
114                         continue;
115                 copy_var(dev, new_dev, mode);
116                 copy_string(dev, new_dev, owner);
117                 copy_string(dev, new_dev, group);
118                 return 0;
119         }
120
121         /* not found, add new structure to the perm list */
122         tmp_dev = malloc(sizeof(*tmp_dev));
123         if (!tmp_dev)
124                 return -ENOMEM;
125         memcpy(tmp_dev, new_dev, sizeof(*tmp_dev));
126         list_add_tail(&tmp_dev->node, &perm_device_list);
127         //dump_perm_dev(tmp_dev);
128         return 0;
129 }
130
131 static struct perm_device *find_perm(char *name)
132 {
133         struct perm_device *perm;
134
135         list_for_each_entry(perm, &perm_device_list, node) {
136                 if (strcmp_pattern(perm->name, name))
137                         continue;
138                 return perm;
139         }
140         return NULL;
141 }
142
143 static mode_t get_default_mode(struct sysfs_class_device *class_dev)
144 {
145         mode_t mode = 0600;     /* default to owner rw only */
146
147         if (strlen(default_mode_str) != 0) {
148                 mode = strtol(default_mode_str, NULL, 8);
149         }
150         return mode;
151 }
152
153 static void apply_format(struct udevice *udev, unsigned char *string)
154 {
155         char temp[NAME_SIZE];
156         char temp1[NAME_SIZE];
157         char *tail;
158         char *pos;
159         char *pos2;
160         char *pos3;
161         int num;
162
163         pos = string;
164         while (1) {
165                 num = 0;
166                 pos = strchr(pos, '%');
167
168                 if (pos) {
169                         pos[0] = '\0';
170                         tail = pos+1;
171                         if (isdigit(tail[0])) {
172                                 num = (int) strtoul(&pos[1], &tail, 10);
173                                 if (tail == NULL) {
174                                         dbg("format parsing error '%s'", pos+1);
175                                         break;
176                                 }
177                         }
178                         strfieldcpy(temp, tail+1);
179
180                         switch (tail[0]) {
181                         case 'b':
182                                 if (strlen(udev->bus_id) == 0)
183                                         break;
184                                 strcat(pos, udev->bus_id);
185                                 dbg("substitute bus_id '%s'", udev->bus_id);
186                                 break;
187                         case 'k':
188                                 if (strlen(udev->kernel_name) == 0)
189                                         break;
190                                 strcat(pos, udev->kernel_name);
191                                 dbg("substitute kernel name '%s'", udev->kernel_name);
192                                 break;
193                         case 'n':
194                                 if (strlen(udev->kernel_number) == 0)
195                                         break;
196                                 strcat(pos, udev->kernel_number);
197                                 dbg("substitute kernel number '%s'", udev->kernel_number);
198                                 break;
199                         case 'D':
200                                 if (strlen(udev->kernel_number) == 0) {
201                                         strcat(pos, "disc");
202                                         dbg("substitute devfs disc");
203                                         break;
204                                 }
205                                 strcat(pos, "part");
206                                 strcat(pos, udev->kernel_number);
207                                 dbg("substitute devfs part '%s'", udev->kernel_number);
208                                 break;
209                         case 'm':
210                                 sprintf(pos, "%u", udev->minor);
211                                 dbg("substitute minor number '%u'", udev->minor);
212                                 break;
213                         case 'M':
214                                 sprintf(pos, "%u", udev->major);
215                                 dbg("substitute major number '%u'", udev->major);
216                                 break;
217                         case 'c':
218                                 if (strlen(udev->program_result) == 0)
219                                         break;
220                                 if (num) {
221                                         /* get part of return string */
222                                         strncpy(temp1, udev->program_result, sizeof(temp1));
223                                         pos2 = temp1;
224                                         while (num) {
225                                                 num--;
226                                                 pos3 = strsep(&pos2, " ");
227                                                 if (pos3 == NULL) {
228                                                         dbg("requested part of result string not found");
229                                                         break;
230                                                 }
231                                         }
232                                         if (pos3) {
233                                                 strcat(pos, pos3);
234                                                 dbg("substitute part of result string '%s'", pos3);
235                                         }
236                                 } else {
237                                         strcat(pos, udev->program_result);
238                                         dbg("substitute result string '%s'", udev->program_result);
239                                 }
240                                 break;
241                         case '%':
242                                 strcat(pos, "%");
243                                 pos++;
244                                 break;
245                         default:
246                                 dbg("unknown substitution type '%%%c'", pos[1]);
247                                 break;
248                         }
249                         strcat(string, temp);
250                 } else
251                         break;
252         }
253 }
254
255 static struct bus_file {
256         char *bus;
257         char *file;
258 } bus_files[] = {
259         { .bus = "scsi",        .file = "vendor" },
260         { .bus = "usb",         .file = "idVendor" },
261         { .bus = "usb-serial",  .file = "detach_state" },
262         { .bus = "ide",         .file = "detach_state" },
263         { .bus = "pci",         .file = "vendor" },
264         {}
265 };
266
267 #define SECONDS_TO_WAIT_FOR_FILE        10
268 static void wait_for_device_to_initialize(struct sysfs_device *sysfs_device)
269 {
270         /* sleep until we see the file for this specific bus type show up this
271          * is needed because we can easily out-run the kernel in looking for
272          * these files before the paticular subsystem has created them in the
273          * sysfs tree properly.
274          *
275          * And people thought that the /sbin/hotplug event system was going to
276          * be slow, poo on you for arguing that before even testing it...
277          */
278         struct bus_file *b = &bus_files[0];
279         struct sysfs_attribute *tmpattr;
280         int loop;
281
282         while (1) {
283                 if (b->bus == NULL)
284                         break;
285                 if (strcmp(sysfs_device->bus, b->bus) == 0) {
286                         tmpattr = NULL;
287                         loop = SECONDS_TO_WAIT_FOR_FILE;
288                         while (loop--) {
289                                 dbg("looking for file '%s' on bus '%s'", b->file, b->bus);
290                                 tmpattr = sysfs_get_device_attr(sysfs_device, b->file);
291                                 if (tmpattr) {
292                                         /* found it! */
293                                         goto exit;
294                                 }
295                                 /* sleep to give the kernel a chance to create the file */
296                                 sleep(1);
297                         }
298                         dbg("Timed out waiting for '%s' file, continuing on anyway...", b->file);
299                         goto exit;
300                 }
301                 b++;
302         }
303         dbg("Did not find bus type '%s' on list of bus_id_files, contact greg@kroah.com", sysfs_device->bus);
304 exit:
305         return; /* here to prevent compiler warning... */
306 }
307
308 static int execute_program(char *path, char *value, int len)
309 {
310         int retval;
311         int res;
312         int status;
313         int fds[2];
314         pid_t pid;
315         int value_set = 0;
316         char buffer[256];
317         char *pos;
318         char *args[PROGRAM_MAXARG];
319         int i;
320
321         dbg("executing '%s'", path);
322         retval = pipe(fds);
323         if (retval != 0) {
324                 dbg("pipe failed");
325                 return -1;
326         }
327         pid = fork();
328         if (pid == -1) {
329                 dbg("fork failed");
330                 return -1;
331         }
332
333         if (pid == 0) {
334                 /* child */
335                 close(STDOUT_FILENO);
336                 dup(fds[1]);    /* dup write side of pipe to STDOUT */
337                 if (strchr(path, ' ')) {
338                         /* exec with arguments */
339                         pos = path;
340                         for (i=0; i < PROGRAM_MAXARG-1; i++) {
341                                 args[i] = strsep(&pos, " ");
342                                 if (args[i] == NULL)
343                                         break;
344                         }
345                         if (args[i]) {
346                                 dbg("too many args - %d", i);
347                                 args[i] = NULL;
348                         }
349                         retval = execve(args[0], args, main_envp);
350                 } else {
351                         retval = execve(path, main_argv, main_envp);
352                 }
353                 if (retval != 0) {
354                         dbg("child execve failed");
355                         exit(1);
356                 }
357                 return -1; /* avoid compiler warning */
358         } else {
359                 /* parent reads from fds[0] */
360                 close(fds[1]);
361                 retval = 0;
362                 while (1) {
363                         res = read(fds[0], buffer, sizeof(buffer) - 1);
364                         if (res <= 0)
365                                 break;
366                         buffer[res] = '\0';
367                         if (res > len) {
368                                 dbg("result len %d too short", len);
369                                 retval = -1;
370                         }
371                         if (value_set) {
372                                 dbg("result value already set");
373                                 retval = -1;
374                         } else {
375                                 value_set = 1;
376                                 strncpy(value, buffer, len);
377                                 pos = value + strlen(value)-1;
378                                 if (pos[0] == '\n')
379                                 pos[0] = '\0';
380                                 dbg("result is '%s'", value);
381                         }
382                 }
383                 close(fds[0]);
384                 res = wait(&status);
385                 if (res < 0) {
386                         dbg("wait failed result %d", res);
387                         retval = -1;
388                 }
389
390                 if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) {
391                         dbg("exec program status 0x%x", status);
392                         retval = -1;
393                 }
394         }
395         return retval;
396 }
397
398 static int compare_sysfs_attribute(struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device, struct sysfs_pair *pair)
399 {
400         struct sysfs_attribute *tmpattr = NULL;
401         char *c;
402
403         if ((pair == NULL) || (pair->file[0] == '\0') || (pair->value == '\0'))
404                 return -ENODEV;
405
406         dbg("look for device attribute '%s'", pair->file);
407         /* try to find the attribute in the class device directory */
408         tmpattr = sysfs_get_classdev_attr(class_dev, pair->file);
409         if (tmpattr)
410                 goto label_found;
411
412         /* look in the class device directory if present */
413         if (sysfs_device) {
414                 tmpattr = sysfs_get_device_attr(sysfs_device, pair->file);
415                 if (tmpattr)
416                         goto label_found;
417         }
418         return -ENODEV;
419
420 label_found:
421         c = tmpattr->value + strlen(tmpattr->value)-1;
422         if (*c == '\n')
423                 *c = 0x00;
424         dbg("compare attribute '%s' value '%s' with '%s'",
425                   pair->file, tmpattr->value, pair->value);
426         if (strcmp_pattern(pair->value, tmpattr->value) != 0)
427                 return -ENODEV;
428
429         dbg("found matching attribute '%s' with value '%s'",
430             pair->file, pair->value);
431         return 0;
432 }
433
434 static int match_sysfs_pairs(struct config_device *dev, struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device)
435 {
436         struct sysfs_pair *pair;
437         int i;
438
439         for (i = 0; i < MAX_SYSFS_PAIRS; ++i) {
440                 pair = &dev->sysfs_pair[i];
441                 if ((pair->file[0] == '\0') || (pair->value[0] == '\0'))
442                         break;
443                 if (compare_sysfs_attribute(class_dev, sysfs_device, pair) != 0) {
444                         dbg("sysfs attribute doesn't match");
445                         return -ENODEV;
446                 }
447         }
448
449         return 0;
450 }
451
452 static int match_id(struct config_device *dev, struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device)
453 {
454         char path[SYSFS_PATH_MAX];
455         int found;
456         char *temp = NULL;
457
458         /* we have to have a sysfs device for ID to work */
459         if (!sysfs_device)
460                 return -ENODEV;
461
462         found = 0;
463         strfieldcpy(path, sysfs_device->path);
464         temp = strrchr(path, '/');
465         dbg("search '%s' in '%s', path='%s'", dev->id, temp, path);
466         if (strstr(temp, dev->id) != NULL) {
467                 found = 1;
468         } else {
469                 *temp = 0x00;
470                 temp = strrchr(path, '/');
471                 dbg("search '%s' in '%s', path='%s'", dev->id, temp, path);
472                 if (strstr(temp, dev->id) != NULL)
473                         found = 1;
474         }
475         if (!found) {
476                 dbg("id doesn't match");
477                 return -ENODEV;
478         }
479
480         return 0;
481 }
482
483 static int match_place(struct config_device *dev, struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device)
484 {
485         char path[SYSFS_PATH_MAX];
486         int found;
487         char *temp = NULL;
488
489         /* we have to have a sysfs device for PLACE to work */
490         if (!sysfs_device)
491                 return -ENODEV;
492
493         found = 0;
494         strfieldcpy(path, sysfs_device->path);
495         temp = strrchr(path, '/');
496         dbg("search '%s' in '%s', path='%s'", dev->place, temp, path);
497         if (strstr(temp, dev->place) != NULL) {
498                 found = 1;
499         } else {
500                 *temp = 0x00;
501                 temp = strrchr(path, '/');
502                 dbg("search '%s' in '%s', path='%s'", dev->place, temp, path);
503                 if (strstr(temp, dev->place) != NULL)
504                         found = 1;
505         }
506         if (!found) {
507                 dbg("place doesn't match");
508                 return -ENODEV;
509         }
510
511         return 0;
512 }
513
514 static struct sysfs_device *get_sysfs_device(struct sysfs_class_device *class_dev)
515 {
516         struct sysfs_device *sysfs_device;
517         struct sysfs_class_device *class_dev_parent;
518         struct timespec tspec;
519         int loop;
520
521         /* Figure out where the device symlink is at.  For char devices this will
522          * always be in the class_dev->path.  But for block devices, it's different.
523          * The main block device will have the device symlink in it's path, but
524          * all partitions have the symlink in its parent directory.
525          * But we need to watch out for block devices that do not have parents, yet
526          * look like a partition (fd0, loop0, etc.)  They all do not have a device
527          * symlink yet.  We do sit and spin on waiting for them right now, we should
528          * possibly have a whitelist for these devices here...
529          */
530         class_dev_parent = sysfs_get_classdev_parent(class_dev);
531         if (class_dev_parent) 
532                 dbg("Really a partition");
533
534         tspec.tv_sec = 0;
535         tspec.tv_nsec = 10000000;  /* sleep 10 millisec */
536         loop = 10;
537         while (loop--) {
538                 nanosleep(&tspec, NULL);
539                 if (class_dev_parent)
540                         sysfs_device = sysfs_get_classdev_device(class_dev_parent);
541                 else
542                         sysfs_device = sysfs_get_classdev_device(class_dev);
543
544                 if (sysfs_device != NULL)
545                         goto device_found;
546         }
547         dbg("Timed out waiting for device symlink, continuing on anyway...");
548         
549 device_found:
550         /* We have another issue with just the wait above - the sysfs part of
551          * the kernel may not be quick enough to have created the link to the
552          * device under the "bus" subsystem. Due to this, the sysfs_device->bus
553          * will not contain the actual bus name :(
554          *
555          * Libsysfs now provides a new API sysfs_get_device_bus(), so use it
556          * if needed
557          */
558         if (sysfs_device) {
559                 
560                 if (sysfs_device->bus[0] != '\0')
561                         goto bus_found;
562                 
563                 loop = 10;
564                 tspec.tv_nsec = 10000000;
565                 while (loop--) {
566                         nanosleep(&tspec, NULL);
567                         sysfs_get_device_bus(sysfs_device);
568                         
569                         if (sysfs_device->bus[0] != '\0')
570                                 goto bus_found;
571                 }
572                 dbg("Timed out waiting to find the device bus, continuing on anyway\n");
573                 goto exit;
574 bus_found:
575                 dbg("Device %s is registered with bus %s\n",
576                                 sysfs_device->name, sysfs_device->bus);
577         }
578 exit:
579         return sysfs_device;
580 }
581
582 int namedev_name_device(struct sysfs_class_device *class_dev, struct udevice *udev)
583 {
584         struct sysfs_device *sysfs_device = NULL;
585         struct config_device *dev;
586         struct perm_device *perm;
587         char *pos;
588
589         udev->mode = 0;
590
591         /* find the sysfs_device associated with this class device */
592         sysfs_device = get_sysfs_device(class_dev);
593         if (sysfs_device) {
594                 dbg("sysfs_device->path='%s'", sysfs_device->path);
595                 dbg("sysfs_device->bus_id='%s'", sysfs_device->bus_id);
596                 dbg("sysfs_device->bus='%s'", sysfs_device->bus);
597                 strfieldcpy(udev->bus_id, sysfs_device->bus_id);
598                 wait_for_device_to_initialize(sysfs_device);
599         } else {
600                 dbg("class_dev->name = '%s'", class_dev->name);
601         }
602
603         strfieldcpy(udev->kernel_name, class_dev->name);
604
605         /* get kernel number */
606         pos = class_dev->name + strlen(class_dev->name);
607         while (isdigit(*(pos-1)))
608                 pos--;
609         strfieldcpy(udev->kernel_number, pos);
610         dbg("kernel_number='%s'", udev->kernel_number);
611
612         /* look for a matching rule to apply */
613         list_for_each_entry(dev, &config_device_list, node) {
614                 dbg("process rule");
615
616                 /* check for matching bus value */
617                 if (dev->bus[0] != '\0') {
618                         if (sysfs_device == NULL) {
619                                 dbg("device has no bus");
620                                 continue;
621                         }
622                         dbg("check for " FIELD_BUS " dev->bus='%s' sysfs_device->bus='%s'", dev->bus, sysfs_device->bus);
623                         if (strcmp_pattern(dev->bus, sysfs_device->bus) != 0) {
624                                 dbg(FIELD_BUS " is not matching");
625                                 continue;
626                         } else {
627                                 dbg(FIELD_BUS " matches");
628                         }
629                 }
630
631                 /* check for matching kernel name*/
632                 if (dev->kernel[0] != '\0') {
633                         dbg("check for " FIELD_KERNEL " dev->kernel='%s' class_dev->name='%s'", dev->kernel, class_dev->name);
634                         if (strcmp_pattern(dev->kernel, class_dev->name) != 0) {
635                                 dbg(FIELD_KERNEL " is not matching");
636                                 continue;
637                         } else {
638                                 dbg(FIELD_KERNEL " matches");
639                         }
640                 }
641
642                 /* check for matching bus id */
643                 if (dev->id[0] != '\0') {
644                         dbg("check " FIELD_ID);
645                         if (match_id(dev, class_dev, sysfs_device) != 0) {
646                                 dbg(FIELD_ID " is not matching");
647                                 continue;
648                         } else {
649                                 dbg(FIELD_ID " matches");
650                         }
651                 }
652
653                 /* check for matching place of device */
654                 if (dev->place[0] != '\0') {
655                         dbg("check " FIELD_PLACE);
656                         if (match_place(dev, class_dev, sysfs_device) != 0) {
657                                 dbg(FIELD_PLACE " is not matching");
658                                 continue;
659                         } else {
660                                 dbg(FIELD_PLACE " matches");
661                         }
662                 }
663
664                 /* check for matching sysfs pairs */
665                 if (dev->sysfs_pair[0].file[0] != '\0') {
666                         dbg("check " FIELD_SYSFS " pairs");
667                         if (match_sysfs_pairs(dev, class_dev, sysfs_device) != 0) {
668                                 dbg(FIELD_SYSFS " is not matching");
669                                 continue;
670                         } else {
671                                 dbg(FIELD_SYSFS " matches");
672                         }
673                 }
674
675                 /* execute external program */
676                 if (dev->program[0] != '\0') {
677                         dbg("check " FIELD_PROGRAM);
678                         apply_format(udev, dev->program);
679                         if (execute_program(dev->program, udev->program_result, NAME_SIZE) != 0) {
680                                 dbg(FIELD_PROGRAM " returned nozero");
681                                 continue;
682                         } else {
683                                 dbg(FIELD_PROGRAM " returned successful");
684                         }
685                 }
686
687                 /* check for matching result of external program */
688                 if (dev->result[0] != '\0') {
689                         dbg("check for " FIELD_RESULT
690                             " dev->result='%s', udev->program_result='%s'",
691                             dev->result, udev->program_result);
692                         if (strcmp_pattern(dev->result, udev->program_result) != 0) {
693                                 dbg(FIELD_RESULT " is not matching");
694                                 continue;
695                         } else {
696                                 dbg(FIELD_RESULT " matches");
697                         }
698                 }
699
700                 /* check if we are instructed to ignore this device */
701                 if (dev->name[0] == '\0') {
702                         dbg("instructed to ignore this device");
703                         return -1;
704                 }
705
706                 /* Yup, this rule belongs to us! */
707                 dbg("found matching rule, '%s' becomes '%s'", dev->kernel, dev->name);
708                 strfieldcpy(udev->name, dev->name);
709                 strfieldcpy(udev->symlink, dev->symlink);
710                 goto found;
711         }
712
713         /* no rule was found so we use the kernel name */
714         strfieldcpy(udev->name, class_dev->name);
715         goto done;
716
717 found:
718         /* substitute placeholder */
719         apply_format(udev, udev->name);
720         apply_format(udev, udev->symlink);
721
722 done:
723         perm = find_perm(udev->name);
724         if (perm) {
725                 udev->mode = perm->mode;
726                 strfieldcpy(udev->owner, perm->owner);
727                 strfieldcpy(udev->group, perm->group);
728         } else {
729                 /* no matching perms found :( */
730                 udev->mode = get_default_mode(class_dev);
731                 udev->owner[0] = 0x00;
732                 udev->group[0] = 0x00;
733         }
734         dbg("name, '%s' is going to have owner='%s', group='%s', mode = %#o",
735             udev->name, udev->owner, udev->group, udev->mode);
736
737         return 0;
738 }
739
740 int namedev_init(void)
741 {
742         int retval;
743
744         retval = namedev_init_rules();
745         if (retval)
746                 return retval;
747
748         retval = namedev_init_permissions();
749         if (retval)
750                 return retval;
751
752         dump_config_dev_list();
753         dump_perm_dev_list();
754         return retval;
755 }