-/* Reset permissions on the device node, before unlinking it to make sure,
- * that permisions of possible hard links will be removed too.
- */
-int unlink_secure(const char *filename)
-{
- int retval;
-
- retval = chown(filename, 0, 0);
- if (retval)
- dbg("chown(%s, 0, 0) failed with error '%s'", filename, strerror(errno));
-
- retval = chmod(filename, 0000);
- if (retval)
- dbg("chmod(%s, 0000) failed with error '%s'", filename, strerror(errno));
-
- retval = unlink(filename);
- if (errno == ENOENT)
- retval = 0;
-
- if (retval)
- dbg("unlink(%s) failed with error '%s'", filename, strerror(errno));
-
- return retval;
-}
-
-int file_map(const char *filename, char **buf, size_t *bufsize)
-{
- struct stat stats;
- int fd;
-
- fd = open(filename, O_RDONLY);
- if (fd < 0) {
- return -1;
- }
-
- if (fstat(fd, &stats) < 0) {
- close(fd);
- return -1;
- }
-
- *buf = mmap(NULL, stats.st_size, PROT_READ, MAP_SHARED, fd, 0);
- if (*buf == MAP_FAILED) {
- close(fd);
- return -1;
+ /* avoid duplicate entries */
+ list_for_each_entry(name_loop, name_list, node) {
+ if (strcmp(name_loop->name, name) == 0) {
+ dbg("'%s' is already in the list", name);
+ return name_loop;
+ }