]> err.no Git - systemd/commitdiff
libudev: get rid of udev_sysfs.c
authorKay Sievers <kay.sievers@vrfy.org>
Wed, 10 Sep 2008 12:29:07 +0000 (14:29 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Wed, 10 Sep 2008 12:29:07 +0000 (14:29 +0200)
14 files changed:
extras/ata_id/Makefile.am
extras/cdrom_id/Makefile.am
extras/edd_id/Makefile.am
extras/floppy/Makefile.am
extras/fstab_import/Makefile.am
extras/scsi_id/Makefile.am
extras/usb_id/Makefile.am
extras/volume_id/Makefile.am
udev/lib/Makefile.am
udev/lib/libudev-device.c
udev/lib/libudev-enumerate.c
udev/lib/libudev-private.h
udev/lib/libudev-utils.c
udev/lib/libudev.c

index db5f87f8c3372b75a62df20d068e768ab6295ada..f74964875b166e1ca62c19898399515b12fd0998 100644 (file)
@@ -12,7 +12,6 @@ ata_id_SOURCES = \
        ata_id.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
-       ../../udev/udev_sysfs.c \
        ../../udev/udev_sysdeps.c \
        ../../udev/udev_utils.c \
        ../../udev/udev_utils_string.c
index 0514a2ea51318c11467eed88eb1e20848d92145c..9a39ee503a2ab446f18e6a7701d51a5ca000fce2 100644 (file)
@@ -15,7 +15,6 @@ cdrom_id_SOURCES = \
        cdrom_id.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
-       ../../udev/udev_sysfs.c \
        ../../udev/udev_sysdeps.c \
        ../../udev/udev_utils.c \
        ../../udev/udev_utils_string.c
index 22af7e952877234cf91f904eb29642eef3c5a6c7..575de8514d710adc63dbdd82e10d28fe03c59cfa 100644 (file)
@@ -15,7 +15,6 @@ edd_id_SOURCES = \
        edd_id.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
-       ../../udev/udev_sysfs.c \
        ../../udev/udev_sysdeps.c \
        ../../udev/udev_utils.c \
        ../../udev/udev_utils_string.c
index a5e9c1080078b94166a5bf3251e5c3ff163b25d2..44e9b2fbc070fdcd137c226a0437750b51aa9370 100644 (file)
@@ -11,11 +11,9 @@ create_floppy_devices_SOURCES = \
        create_floppy_devices.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
-       ../../udev/udev_sysfs.c \
        ../../udev/udev_sysdeps.c \
        ../../udev/udev_utils.c \
-       ../../udev/udev_utils_string.c \
-       ../../udev/udev_utils_file.c
+       ../../udev/udev_utils_string.c
 
 if USE_SELINUX
 create_floppy_devices_LDADD = \
index c4fbdce2485978d0284fc350dbbe26c6b85e8f9c..92be9a439b84993c192459f100678bdba9185705 100644 (file)
@@ -15,7 +15,6 @@ fstab_import_SOURCES = \
        fstab_import.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
-       ../../udev/udev_sysfs.c \
        ../../udev/udev_sysdeps.c \
        ../../udev/udev_utils.c \
        ../../udev/udev_utils_string.c
index f42563f498a723e94974ed1c5218d95e0f61e025..ffa9bf31433137cbed110a77a0d10b54d68e8602 100644 (file)
@@ -15,7 +15,6 @@ scsi_id_SOURCES = \
        bsg.h \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
-       ../../udev/udev_sysfs.c \
        ../../udev/udev_sysdeps.c \
        ../../udev/udev_utils.c \
        ../../udev/udev_utils_string.c
index aa1c4f82b6ff0f39252b9223ca7f8533e7fb93b8..9eb6f16b57c5abdddbdbccb40694beb933c85a4a 100644 (file)
@@ -11,8 +11,8 @@ usb_id_SOURCES = \
        usb_id.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
-       ../../udev/udev_sysfs.c \
        ../../udev/udev_sysdeps.c \
+       ../../udev/udev_sysfs.c \
        ../../udev/udev_utils.c \
        ../../udev/udev_utils_string.c
 
index 9fb2cba646594d35402d82fc675a32e04d14ce74..85607634152eaf377bf3d3280dda3e572c381476 100644 (file)
@@ -14,7 +14,6 @@ vol_id_SOURCES = \
        vol_id.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
-       ../../udev/udev_sysfs.c \
        ../../udev/udev_sysdeps.c \
        ../../udev/udev_utils.c \
        ../../udev/udev_utils_string.c
index 33d0f633ab0f5454d67632e7cb28ec09717ca452..a768daa8179987b05a5eafb7dfea3dca7a54bf7a 100644 (file)
@@ -32,7 +32,6 @@ libudev_la_SOURCES =\
        ../udev.h \
        ../udev_utils.c \
        ../udev_utils_string.c \
-       ../udev_sysfs.c \
        ../udev_sysdeps.c
 
 libudev_la_LDFLAGS = \
index e13146599cbe1354bd1b9c75e7bae90c210ae5d0..416cae450d99053997a79d46a1f44e45f0f936d9 100644 (file)
@@ -205,7 +205,7 @@ struct udev_device *udev_device_new_from_devpath(struct udev *udev, const char *
 
        /* resolve possible symlink to real path */
        strlcpy(path, devpath, sizeof(path));
-       sysfs_resolve_link(udev, path, sizeof(path));
+       util_resolve_sys_link(udev, path, sizeof(path));
        device_set_devpath(udev_device, path);
        info(udev, "device %p has devpath '%s'\n", udev_device, udev_device_get_devpath(udev_device));
 
index 1ba4de8948313a2e9aa3184e6565d97aaf9e4195..f36eafaff6a01055461435a3d256e9ff03047308 100644 (file)
@@ -58,7 +58,7 @@ static int devices_scan_subsystem(struct udev *udev,
                strlcpy(devpath, &path[len], sizeof(devpath));
                strlcat(devpath, "/", sizeof(devpath));
                strlcat(devpath, dent->d_name, sizeof(devpath));
-               sysfs_resolve_link(udev, devpath, sizeof(devpath));
+               util_resolve_sys_link(udev, devpath, sizeof(devpath));
                name_list_add(udev, device_list, devpath, 1);
        }
        closedir(dir);
index daa869ba425eacc179d277835e8a3f38249dd84a..1579df6d6e13d02b06a7970b82920f228545bb14 100644 (file)
@@ -106,4 +106,5 @@ extern int udev_ctrl_get_set_max_childs(struct udev_ctrl_msg *ctrl_msg);
 /* libudev-utils */
 extern ssize_t util_get_sys_subsystem(struct udev *udev, const char *devpath, char *subsystem, size_t size);
 extern ssize_t util_get_sys_driver(struct udev *udev, const char *devpath, char *driver, size_t size);
+extern int util_resolve_sys_link(struct udev *udev, char *devpath, size_t size);
 #endif
index 82acb1a4815705d5a36ee01cb1470d89e20a5e9c..e5f1ed7c38d66af5a95b624a217e282553260f15 100644 (file)
@@ -63,3 +63,34 @@ ssize_t util_get_sys_driver(struct udev *udev, const char *devpath, char *driver
        return get_sys_link(udev, "driver", devpath, driver, size);
 }
 
+int util_resolve_sys_link(struct udev *udev, char *devpath, size_t size)
+{
+       char link_path[PATH_SIZE];
+       char link_target[PATH_SIZE];
+       int len;
+       int i;
+       int back;
+
+       strlcpy(link_path, udev_get_sys_path(udev), sizeof(link_path));
+       strlcat(link_path, devpath, sizeof(link_path));
+       len = readlink(link_path, link_target, sizeof(link_target));
+       if (len <= 0)
+               return -1;
+       link_target[len] = '\0';
+       dbg(udev, "path link '%s' points to '%s'\n", devpath, link_target);
+
+       for (back = 0; strncmp(&link_target[back * 3], "../", 3) == 0; back++)
+               ;
+       dbg(udev, "base '%s', tail '%s', back %i\n", devpath, &link_target[back * 3], back);
+       for (i = 0; i <= back; i++) {
+               char *pos = strrchr(devpath, '/');
+
+               if (pos == NULL)
+                       return -1;
+               pos[0] = '\0';
+       }
+       dbg(udev, "after moving back '%s'\n", devpath);
+       strlcat(devpath, "/", size);
+       strlcat(devpath, &link_target[back * 3], size);
+       return 0;
+}
index 50fe0d1c893cad111ab7b37192ceb3029edfdfbc..3bcafcd9a6955be02e0c4a4e9d9e0735a7c300df 100644 (file)
@@ -295,10 +295,7 @@ struct udev *udev_new(void)
 
        if (udev->dev_path == NULL || udev->sys_path == NULL)
                goto err;
-
        selinux_init(udev);
-       sysfs_init();
-
        info(udev, "context %p created\n", udev);
        info(udev, "log_priority=%d\n", udev->log_priority);
        info(udev, "config_file='%s'\n", config_file);
@@ -306,7 +303,6 @@ struct udev *udev_new(void)
        info(udev, "sys_path='%s'\n", udev->sys_path);
        if (udev->rules_path != NULL)
                info(udev, "rules_path='%s'\n", udev->rules_path);
-
        free(config_file);
        return udev;
 err:
@@ -347,7 +343,6 @@ void udev_unref(struct udev *udev)
        udev->refcount--;
        if (udev->refcount > 0)
                return;
-       sysfs_cleanup();
        selinux_exit(udev);
        free(udev->dev_path);
        free(udev->sys_path);