chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vol_id: use long options
[elogind.git]
/
udev_node.c
diff --git
a/udev_node.c
b/udev_node.c
index 526d7135169d35f3b58af446eaf8c7648a398494..b1bbda8369c3e264e86b583015d122e1299f96fe 100644
(file)
--- a/
udev_node.c
+++ b/
udev_node.c
@@
-44,7
+44,7
@@
int udev_node_mknod(struct udevice *udev, const char *file, dev_t devt, mode_t m
else
mode |= S_IFCHR;
else
mode |= S_IFCHR;
- if (stat(file, &stats) != 0)
+ if (
l
stat(file, &stats) != 0)
goto create;
/* preserve node with already correct numbers, to prevent changing the inode number */
goto create;
/* preserve node with already correct numbers, to prevent changing the inode number */
@@
-153,7
+153,7
@@
static int update_link(struct udevice *udev, const char *name)
count = udev_db_get_devices_by_name(name, &name_list);
info("found %i devices with name '%s'", count, name);
count = udev_db_get_devices_by_name(name, &name_list);
info("found %i devices with name '%s'", count, name);
- /* if we don't have a
ny reference, we can delete the link
*/
+ /* if we don't have a
reference, delete it
*/
if (count <= 0) {
info("no reference left, remove '%s'", name);
if (!udev->test_run) {
if (count <= 0) {
info("no reference left, remove '%s'", name);
if (!udev->test_run) {
@@
-236,11
+236,10
@@
void udev_node_update_symlinks(struct udevice *udev, struct udevice *udev_old)
if (udev_old != NULL) {
struct name_entry *link_loop;
struct name_entry *link_old_loop;
if (udev_old != NULL) {
struct name_entry *link_loop;
struct name_entry *link_old_loop;
- struct name_entry *link_old_tmp_loop;
int found;
/* remove current symlinks from old list */
int found;
/* remove current symlinks from old list */
- list_for_each_entry
_safe(link_old_loop, link_old_tmp
_loop, &udev_old->symlink_list, node) {
+ list_for_each_entry
(link_old
_loop, &udev_old->symlink_list, node) {
found = 0;
list_for_each_entry(link_loop, &udev->symlink_list, node) {
if (strcmp(link_old_loop->name, link_loop->name) == 0) {
found = 0;
list_for_each_entry(link_loop, &udev->symlink_list, node) {
if (strcmp(link_old_loop->name, link_loop->name) == 0) {
@@
-255,6
+254,13
@@
void udev_node_update_symlinks(struct udevice *udev, struct udevice *udev_old)
update_link(udev, link_old_loop->name);
}
}
update_link(udev, link_old_loop->name);
}
}
+
+ /*
+ * if the node name has changed, delete the node,
+ * or possibly restore a symlink of another device
+ */
+ if (strcmp(udev->name, udev_old->name) != 0)
+ update_link(udev, udev_old->name);
}
}
}
}
@@
-342,7
+348,7
@@
int udev_node_remove(struct udevice *udev)
char filename[PATH_SIZE];
char partitionname[PATH_SIZE];
struct stat stats;
char filename[PATH_SIZE];
char partitionname[PATH_SIZE];
struct stat stats;
- int retval;
+ int retval
= 0
;
int num;
strlcpy(filename, udev_root, sizeof(filename));
int num;
strlcpy(filename, udev_root, sizeof(filename));
@@
-358,7
+364,8
@@
int udev_node_remove(struct udevice *udev)
}
info("removing device node '%s'", filename);
}
info("removing device node '%s'", filename);
- retval = unlink_secure(filename);
+ if (!udev->test_run)
+ retval = unlink_secure(filename);
if (retval)
return retval;
if (retval)
return retval;
@@
-373,7
+380,8
@@
int udev_node_remove(struct udevice *udev)
for (i = 1; i <= num; i++) {
snprintf(partitionname, sizeof(partitionname), "%s%d", filename, i);
partitionname[sizeof(partitionname)-1] = '\0';
for (i = 1; i <= num; i++) {
snprintf(partitionname, sizeof(partitionname), "%s%d", filename, i);
partitionname[sizeof(partitionname)-1] = '\0';
- unlink_secure(partitionname);
+ if (!udev->test_run)
+ unlink_secure(partitionname);
}
}
delete_path(filename);
}
}
delete_path(filename);