+ /*
+ * create only a symlink with the name as the target
+ * if we don't have any interesting data to remember
+ */
+ if (list_empty(&udev->symlink_list) && list_empty(&udev->env_list) &&
+ !udev->partitions && !udev->ignore_remove) {
+ dbg("nothing interesting to store, create symlink");
+ unlink(filename);
+ if (symlink(udev->name, filename) != 0) {
+ err("unable to create db link '%s': %s", filename, strerror(errno));
+ return -1;
+ }
+ } else {
+ struct name_entry *name_loop;
+ FILE *f;
+
+ unlink(filename);
+ f = fopen(filename, "w");
+ if (f == NULL) {
+ err("unable to create db file '%s': %s", filename, strerror(errno));
+ return -1;
+ }
+ dbg("storing data for device '%s' in '%s'", udev->dev->devpath, filename);
+
+ fprintf(f, "N:%s\n", udev->name);
+ list_for_each_entry(name_loop, &udev->symlink_list, node)
+ fprintf(f, "S:%s\n", name_loop->name);
+ fprintf(f, "M:%u:%u\n", major(udev->devt), minor(udev->devt));
+ if (udev->partitions)
+ fprintf(f, "A:%u\n", udev->partitions);
+ if (udev->ignore_remove)
+ fprintf(f, "R:%u\n", udev->ignore_remove);
+ list_for_each_entry(name_loop, &udev->env_list, node)
+ fprintf(f, "E:%s\n", name_loop->name);
+ fclose(f);