udev_device_event.c revision 44aff4cd6d74d230e4a97f8d59f780472b7cad6e
/*
* Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org>
*
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include "udev.h"
#include "udev_rules.h"
{
int klog;
FILE *f;
if (klog < 0)
return;
if (f == NULL) {
return;
}
fprintf(f, "<6>udev: renamed network interface %s to %s\n",
fclose(f);
}
{
int sk;
int retval;
return 0;
if (sk < 0) {
return -1;
}
if (retval == 0)
else {
int loop;
/* see if the destination interface name already exists */
goto exit;
}
/* free our own name, another process may wait for us */
if (retval != 0) {
goto exit;
}
/* wait 30 seconds for our target to become available */
while (loop--) {
if (retval == 0) {
break;
}
err("error changing net interface name %s to %s: %s\n",
break;
}
}
}
exit:
return retval;
}
{
int retval = 0;
/* add device node */
if (udev->ignore_device) {
info("device event will be ignored\n");
goto exit;
}
info("device node creation supressed\n");
goto exit;
}
/* read current database entry; cleanup, if it is known device */
udev_old = udev_device_init();
} else {
}
}
/* create node */
if (retval != 0)
goto exit;
/* store in database */
/* create, replace, delete symlinks according to priority */
goto exit;
}
/* add netif */
if (udev->ignore_device) {
info("device event will be ignored\n");
goto exit;
}
info("device renaming supressed\n");
goto exit;
}
/* look if we want to change the name of the netif */
char *pos;
if (retval != 0)
goto exit;
/* export old name */
/* now change the devpath, because the kernel device name has changed */
}
}
goto exit;
}
/* remove device node */
struct name_entry *name_loop;
/* import database entry, and delete it */
/* restore stored persistent data */
} else {
dbg("'%s' not found in database, using kernel name '%s'\n",
}
if (udev->ignore_device) {
info("device event will be ignored\n");
goto exit;
}
if (udev->ignore_remove) {
goto exit;
}
/* remove the node */
/* delete or restore symlinks according to priority */
goto exit;
}
/* default devices */
if (udev->ignore_device)
info("device event will be ignored\n");
exit:
return retval;
}