1DEVICE_RENAME(9) Device drivers infrastructure DEVICE_RENAME(9)
2
3
4
6 device_rename - renames a device
7
9 int device_rename(struct device * dev, const char * new_name);
10
12 dev
13 the pointer to the struct device to be renamed
14
15 new_name
16 the new name of the device
17
19 It is the responsibility of the caller to provide mutual exclusion
20 between two different calls of device_rename on the same device to
21 ensure that new_name is valid and won't conflict with other devices.
22
24 Don't call this function. Currently, the networking layer calls this
25 function, but that will change. The following text from Kay Sievers
26 offers
27
29 Renaming devices is racy at many levels, symlinks and other stuff are
30 not replaced atomically, and you get a “move” uevent, but it's not easy
31 to connect the event to the old and new device. Device nodes are not
32 renamed at all, there isn't even support for that in the kernel now.
33
34 In the meantime, during renaming, your target name might be taken by
35 another driver, creating conflicts. Or the old name is taken directly
36 after you renamed it -- then you get events for the same DEVPATH,
37 before you even see the “move” event. It's just a mess, and nothing new
38 should ever rely on kernel device renaming. Besides that, it's not even
39 implemented now for other things than (driver-core wise very simple)
40 network devices.
41
42 We are currently about to change network renaming in udev to completely
43 disallow renaming of devices in the same namespace as the kernel uses,
44 because we can't solve the problems properly, that arise with swapping
45 names of multiple interfaces without races. Means, renaming of
46 eth[0-9]* will only be allowed to some other name than eth[0-9]*, for
47 the aforementioned reasons.
48
49 Make up a “real” name in the driver before you register anything, or
50 add some other attributes for userspace to find the device, or use udev
51 to add symlinks -- but never rename kernel devices later, it's a
52 complete mess. We don't even want to get into that and try to implement
53 the missing pieces in the core. We really have other pieces to fix in
54 the driver core mess. :)
55
57Kernel Hackers Manual 3.10 June 2019 DEVICE_RENAME(9)