1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>device_rename</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="ch02s02.html" title="Device Drivers Base"><link rel="prev" href="API-device-destroy.html" title="device_destroy"><link rel="next" href="API-device-move.html" title="device_move"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">device_rename</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-device-destroy.html">Prev</a> </td><th width="60%" align="center">Device Drivers Base</th><td width="20%" align="right"> <a accesskey="n" href="API-device-move.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-device-rename"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>device_rename — 2 renames a device 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">device_rename </b>(</code></td><td>struct device * <var class="pdparam">dev</var>, </td></tr><tr><td> </td><td>const char * <var class="pdparam">new_name</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1109468372"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>dev</code></em></span></dt><dd><p> 4 the pointer to the struct device to be renamed 5 </p></dd><dt><span class="term"><em class="parameter"><code>new_name</code></em></span></dt><dd><p> 6 the new name of the device 7 </p></dd></dl></div></div><div class="refsect1"><a name="idp1109471028"></a><h2>Description</h2><p> 8 It is the responsibility of the caller to provide mutual 9 exclusion between two different calls of device_rename 10 on the same device to ensure that new_name is valid and 11 won't conflict with other devices. 12</p></div><div class="refsect1"><a name="idp1109471844"></a><h2>Note</h2><p> 13 Don't call this function. Currently, the networking layer calls this 14 function, but that will change. The following text from Kay Sievers offers 15</p></div><div class="refsect1"><a name="idp1109472596"></a><h2>some insight</h2><p> 16 </p><p> 17 18 Renaming devices is racy at many levels, symlinks and other stuff are not 19 replaced atomically, and you get a <span class="quote">“<span class="quote">move</span>”</span> uevent, but it's not easy to 20 connect the event to the old and new device. Device nodes are not renamed at 21 all, there isn't even support for that in the kernel now. 22 </p><p> 23 24 In the meantime, during renaming, your target name might be taken by another 25 driver, creating conflicts. Or the old name is taken directly after you 26 renamed it -- then you get events for the same DEVPATH, before you even see 27 the <span class="quote">“<span class="quote">move</span>”</span> event. It's just a mess, and nothing new should ever rely on 28 kernel device renaming. Besides that, it's not even implemented now for 29 other things than (driver-core wise very simple) network devices. 30 </p><p> 31 32 We are currently about to change network renaming in udev to completely 33 disallow renaming of devices in the same namespace as the kernel uses, 34 because we can't solve the problems properly, that arise with swapping names 35 of multiple interfaces without races. Means, renaming of eth[0-9]* will only 36 be allowed to some other name than eth[0-9]*, for the aforementioned 37 reasons. 38 </p><p> 39 40 Make up a <span class="quote">“<span class="quote">real</span>”</span> name in the driver before you register anything, or add 41 some other attributes for userspace to find the device, or use udev to add 42 symlinks -- but never rename kernel devices later, it's a complete mess. We 43 don't even want to get into that and try to implement the missing pieces in 44 the core. We really have other pieces to fix in the driver core mess. :) 45</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-device-destroy.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch02s02.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-device-move.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">device_destroy</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">device_move</span></td></tr></table></div></body></html> 46