+ /*
+ * don't waste tmpfs memory pages, if we don't have any data to store
+ * create fake db-file; store the node-name in a symlink target
+ */
+ if (list_empty(&udev->symlink_list) && list_empty(&udev->env_list) &&
+ !udev->partitions && !udev->ignore_remove) {
+ dbg("nothing interesting to store, create symlink");
+ if (symlink(udev->name, filename) != 0) {
+ err("unable to create db link '%s': %s", filename, strerror(errno));
+ return -1;
+ }
+ } else {
+ FILE *f;
+ struct name_entry *name_loop;
+
+ 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);
+ /* add symlink-name to index */
+ name_index(udev->dev->devpath, name_loop->name, 1);
+ }
+ fprintf(f, "M:%u:%u\n", major(udev->devt), minor(udev->devt));
+ if (udev->link_priority != 0)
+ fprintf(f, "L:%u\n", udev->link_priority);
+ if (udev->partitions != 0)
+ 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);