chiark / gitweb /
get rid of udev_sysdeps.c
[elogind.git] / udev / udev_device_event.c
index 6b40623390e67dfd4c218d430374ecc7ee47acea..aacd1d2bc1007fbb9d24dc59bc46e2d54b1fd5ec 100644 (file)
@@ -1,22 +1,20 @@
 /*
- * Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2004-2008 Kay Sievers <kay.sievers@vrfy.org>
  *
- *     This program is free software; you can redistribute it and/or modify it
- *     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.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
  *
+ * 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, see <http://www.gnu.org/licenses/>.
  */
 
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <stddef.h>
@@ -33,7 +31,6 @@
 #include "udev.h"
 #include "udev_rules.h"
 
-
 static void kernel_log(struct ifreq ifr)
 {
        int klog;
@@ -71,8 +68,8 @@ static int rename_netif(struct udevice *udevice)
        }
 
        memset(&ifr, 0x00, sizeof(struct ifreq));
-       strlcpy(ifr.ifr_name, udevice->dev->kernel, IFNAMSIZ);
-       strlcpy(ifr.ifr_newname, udevice->name, IFNAMSIZ);
+       util_strlcpy(ifr.ifr_name, udevice->dev->kernel, IFNAMSIZ);
+       util_strlcpy(ifr.ifr_newname, udevice->name, IFNAMSIZ);
        retval = ioctl(sk, SIOCSIFNAME, &ifr);
        if (retval == 0)
                kernel_log(ifr);
@@ -81,22 +78,24 @@ static int rename_netif(struct udevice *udevice)
 
                /* see if the destination interface name already exists */
                if (errno != EEXIST) {
-                       err(udevice->udev, "error changing netif name %s to %s: %s\n", ifr.ifr_name, ifr.ifr_newname, strerror(errno));
+                       err(udevice->udev, "error changing netif name %s to %s: %s\n",
+                           ifr.ifr_name, ifr.ifr_newname, strerror(errno));
                        goto exit;
                }
 
                /* free our own name, another process may wait for us */
-               strlcpy(ifr.ifr_newname, udevice->dev->kernel, IFNAMSIZ);
-               strlcat(ifr.ifr_newname, "_rename", IFNAMSIZ);
+               util_strlcpy(ifr.ifr_newname, udevice->dev->kernel, IFNAMSIZ);
+               util_strlcat(ifr.ifr_newname, "_rename", IFNAMSIZ);
                retval = ioctl(sk, SIOCSIFNAME, &ifr);
                if (retval != 0) {
-                       err(udevice->udev, "error changing netif name %s to %s: %s\n", ifr.ifr_name, ifr.ifr_newname, strerror(errno));
+                       err(udevice->udev, "error changing netif name %s to %s: %s\n",
+                           ifr.ifr_name, ifr.ifr_newname, strerror(errno));
                        goto exit;
                }
 
                /* wait 30 seconds for our target to become available */
-               strlcpy(ifr.ifr_name, ifr.ifr_newname, IFNAMSIZ);
-               strlcpy(ifr.ifr_newname, udevice->name, IFNAMSIZ);
+               util_strlcpy(ifr.ifr_name, ifr.ifr_newname, IFNAMSIZ);
+               util_strlcpy(ifr.ifr_newname, udevice->name, IFNAMSIZ);
                loop = 30 * 20;
                while (loop--) {
                        retval = ioctl(sk, SIOCSIFNAME, &ifr);
@@ -110,7 +109,8 @@ static int rename_netif(struct udevice *udevice)
                                    ifr.ifr_name, ifr.ifr_newname, strerror(errno));
                                break;
                        }
-                       dbg(udevice->udev, "wait for netif '%s' to become free, loop=%i\n", udevice->name, (30 * 20) - loop);
+                       dbg(udevice->udev, "wait for netif '%s' to become free, loop=%i\n",
+                           udevice->name, (30 * 20) - loop);
                        usleep(1000 * 1000 / 20);
                }
        }
@@ -201,11 +201,11 @@ int udev_device_event(struct udev_rules *rules, struct udevice *udevice)
                        setenv("INTERFACE_OLD", udevice->dev->kernel, 1);
 
                        /* now change the devpath, because the kernel device name has changed */
-                       strlcpy(devpath, udevice->dev->devpath, sizeof(devpath));
+                       util_strlcpy(devpath, udevice->dev->devpath, sizeof(devpath));
                        pos = strrchr(devpath, '/');
                        if (pos != NULL) {
                                pos[1] = '\0';
-                               strlcat(devpath, udevice->name, sizeof(devpath));
+                               util_strlcat(devpath, udevice->name, sizeof(devpath));
                                sysfs_device_set_values(udevice->udev, udevice->dev, devpath, NULL, NULL);
                                setenv("DEVPATH", udevice->dev->devpath, 1);
                                setenv("INTERFACE", udevice->name, 1);
@@ -228,7 +228,7 @@ int udev_device_event(struct udev_rules *rules, struct udevice *udevice)
                } else {
                        dbg(udevice->udev, "'%s' not found in database, using kernel name '%s'\n",
                            udevice->dev->devpath, udevice->dev->kernel);
-                       strlcpy(udevice->name, udevice->dev->kernel, sizeof(udevice->name));
+                       util_strlcpy(udevice->name, udevice->dev->kernel, sizeof(udevice->name));
                }
 
                udev_rules_get_run(rules, udevice);