chiark / gitweb /
[PATCH] hmm, handle net devices with udev?
[elogind.git] / udev_lib.c
index 50598a4a318592d315fc942d6fead6b89ced4b41..4a9eea506cacaf8171313719a33a4b27ae2d185b 100644 (file)
@@ -53,6 +53,17 @@ char *get_devpath(void)
        return devpath;
 }
 
+char *get_devnode(void)
+{
+       char *devnode;
+
+       devnode = getenv("DEVNODE");
+       if (devnode != NULL && strlen(devnode) > NAME_SIZE)
+               devnode[NAME_SIZE-1] = '\0';
+
+       return devnode;
+}
+
 char *get_seqnum(void)
 {
        char *seqnum;
@@ -70,6 +81,22 @@ char *get_subsystem(char *subsystem)
        return subsystem;
 }
 
+char get_device_type(const char *path, const char *subsystem)
+{
+       if (strcmp(subsystem, "block") == 0 ||
+           strstr(path, "/block/") != NULL)
+               return 'b';
+
+       if (strcmp(subsystem, "net") == 0 ||
+           strstr(path, "/class/net/") != NULL)
+               return 'n';
+
+       if (strstr(path, "/class/") != NULL)
+               return 'c';
+
+       return '\0';
+}
+
 int file_map(const char *filename, char **buf, size_t *bufsize)
 {
        struct stat stats;