]> err.no Git - systemd/commitdiff
libudev: device - make a bunch of symbols static
authorKay Sievers <kay.sievers@vrfy.org>
Fri, 20 May 2011 13:36:27 +0000 (15:36 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Fri, 20 May 2011 13:36:27 +0000 (15:36 +0200)
libudev/libudev-device.c
libudev/libudev-private.h

index 47cabea984c437fe9de4c804ea8b04af7ed3b454..8289acf3a97149a548de0bdd1179a92a18bec34b 100644 (file)
@@ -57,7 +57,6 @@ struct udev_device {
        char *driver;
        char *action;
        char *devpath_old;
-       char *sysname_old;
        char *knodename;
        char *id_filename;
        char **envp;
@@ -92,6 +91,260 @@ struct udev_device {
        bool db_persist;
 };
 
+/**
+ * udev_device_get_devnum:
+ * @udev_device: udev device
+ *
+ * This is only valid if the device was received through a monitor. Devices read from
+ * sys do not have a sequence number.
+ *
+ * Returns: the kernel event sequence number, or 0 if there is no sequence number available.
+ **/
+UDEV_EXPORT unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device)
+{
+       if (udev_device == NULL)
+               return 0;
+       return udev_device->seqnum;
+}
+
+static int udev_device_set_seqnum(struct udev_device *udev_device, unsigned long long int seqnum)
+{
+       char num[32];
+
+       udev_device->seqnum = seqnum;
+       snprintf(num, sizeof(num), "%llu", seqnum);
+       udev_device_add_property(udev_device, "SEQNUM", num);
+       return 0;
+}
+
+int udev_device_get_ifindex(struct udev_device *udev_device)
+{
+       if (!udev_device->info_loaded)
+               udev_device_read_uevent_file(udev_device);
+       return udev_device->ifindex;
+}
+
+static int udev_device_set_ifindex(struct udev_device *udev_device, int ifindex)
+{
+       char num[32];
+
+       udev_device->ifindex = ifindex;
+       snprintf(num, sizeof(num), "%u", ifindex);
+       udev_device_add_property(udev_device, "IFINDEX", num);
+       return 0;
+}
+
+/**
+ * udev_device_get_devnum:
+ * @udev_device: udev device
+ *
+ * Returns: the device major/minor number.
+ **/
+UDEV_EXPORT dev_t udev_device_get_devnum(struct udev_device *udev_device)
+{
+       if (udev_device == NULL)
+               return makedev(0, 0);
+       if (!udev_device->info_loaded)
+               udev_device_read_uevent_file(udev_device);
+       return udev_device->devnum;
+}
+
+static int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum)
+{
+       char num[32];
+
+       udev_device->devnum = devnum;
+
+       snprintf(num, sizeof(num), "%u", major(devnum));
+       udev_device_add_property(udev_device, "MAJOR", num);
+       snprintf(num, sizeof(num), "%u", minor(devnum));
+       udev_device_add_property(udev_device, "MINOR", num);
+       return 0;
+}
+
+int udev_device_get_timeout(struct udev_device *udev_device)
+{
+       return udev_device->timeout;
+}
+
+static int udev_device_set_timeout(struct udev_device *udev_device, int timeout)
+{
+       char num[32];
+
+       udev_device->timeout = timeout;
+       snprintf(num, sizeof(num), "%u", timeout);
+       udev_device_add_property(udev_device, "TIMEOUT", num);
+       return 0;
+}
+
+const char *udev_device_get_knodename(struct udev_device *udev_device)
+{
+       return udev_device->knodename;
+}
+
+static int udev_device_set_knodename(struct udev_device *udev_device, const char *knodename)
+{
+       free(udev_device->knodename);
+       udev_device->knodename = strdup(knodename);
+       if (udev_device->knodename == NULL)
+               return -ENOMEM;
+       /* do not overwrite the udev property with the kernel property */
+       if (udev_device->devnode == NULL)
+               udev_device_add_property(udev_device, "DEVNAME", udev_device->knodename);
+       return 0;
+}
+
+const char *udev_device_get_devpath_old(struct udev_device *udev_device)
+{
+       return udev_device->devpath_old;
+}
+
+static int udev_device_set_devpath_old(struct udev_device *udev_device, const char *devpath_old)
+{
+       const char *pos;
+
+       free(udev_device->devpath_old);
+       udev_device->devpath_old = strdup(devpath_old);
+       if (udev_device->devpath_old == NULL)
+               return -ENOMEM;
+       udev_device_add_property(udev_device, "DEVPATH_OLD", udev_device->devpath_old);
+
+       pos = strrchr(udev_device->devpath_old, '/');
+       if (pos == NULL)
+               return -EINVAL;
+       return 0;
+}
+
+/**
+ * udev_device_get_driver:
+ * @udev_device: udev device
+ *
+ * Returns: the driver string, or #NULL if there is no driver attached.
+ **/
+UDEV_EXPORT const char *udev_device_get_driver(struct udev_device *udev_device)
+{
+       char driver[UTIL_NAME_SIZE];
+
+       if (udev_device == NULL)
+               return NULL;
+       if (!udev_device->driver_set) {
+               udev_device->driver_set = true;
+               if (util_get_sys_driver(udev_device->udev, udev_device->syspath, driver, sizeof(driver)) > 0)
+                       udev_device->driver = strdup(driver);
+       }
+       return udev_device->driver;
+}
+
+static int udev_device_set_driver(struct udev_device *udev_device, const char *driver)
+{
+       free(udev_device->driver);
+       udev_device->driver = strdup(driver);
+       if (udev_device->driver == NULL)
+               return -ENOMEM;
+       udev_device->driver_set = true;
+       udev_device_add_property(udev_device, "DRIVER", udev_device->driver);
+       return 0;
+}
+
+/**
+ * udev_device_get_devtype:
+ * @udev_device: udev device
+ *
+ * Retrieve the devtype string of the udev device.
+ *
+ * Returns: the devtype name of the udev device, or #NULL if it can not be determined
+ **/
+UDEV_EXPORT const char *udev_device_get_devtype(struct udev_device *udev_device)
+{
+       if (udev_device == NULL)
+               return NULL;
+       if (!udev_device->devtype_set) {
+               udev_device->devtype_set = true;
+               udev_device_read_uevent_file(udev_device);
+       }
+       return udev_device->devtype;
+}
+
+static int udev_device_set_devtype(struct udev_device *udev_device, const char *devtype)
+{
+       free(udev_device->devtype);
+       udev_device->devtype = strdup(devtype);
+       if (udev_device->devtype == NULL)
+               return -ENOMEM;
+       udev_device->devtype_set = true;
+       udev_device_add_property(udev_device, "DEVTYPE", udev_device->devtype);
+       return 0;
+}
+
+static int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem)
+{
+       free(udev_device->subsystem);
+       udev_device->subsystem = strdup(subsystem);
+       if (udev_device->subsystem == NULL)
+               return -ENOMEM;
+       udev_device->subsystem_set = true;
+       udev_device_add_property(udev_device, "SUBSYSTEM", udev_device->subsystem);
+       return 0;
+}
+
+/**
+ * udev_device_get_subsystem:
+ * @udev_device: udev device
+ *
+ * Retrieve the subsystem string of the udev device. The string does not
+ * contain any "/".
+ *
+ * Returns: the subsystem name of the udev device, or #NULL if it can not be determined
+ **/
+UDEV_EXPORT const char *udev_device_get_subsystem(struct udev_device *udev_device)
+{
+       char subsystem[UTIL_NAME_SIZE];
+
+       if (udev_device == NULL)
+               return NULL;
+       if (!udev_device->subsystem_set) {
+               udev_device->subsystem_set = true;
+               /* read "subsystem" link */
+               if (util_get_sys_subsystem(udev_device->udev, udev_device->syspath, subsystem, sizeof(subsystem)) > 0) {
+                       udev_device_set_subsystem(udev_device, subsystem);
+                       return udev_device->subsystem;
+               }
+               /* implicit names */
+               if (strncmp(udev_device->devpath, "/module/", 8) == 0) {
+                       udev_device_set_subsystem(udev_device, "module");
+                       return udev_device->subsystem;
+               }
+               if (strstr(udev_device->devpath, "/drivers/") != NULL) {
+                       udev_device_set_subsystem(udev_device, "drivers");
+                       return udev_device->subsystem;
+               }
+               if (strncmp(udev_device->devpath, "/subsystem/", 11) == 0 ||
+                   strncmp(udev_device->devpath, "/class/", 7) == 0 ||
+                   strncmp(udev_device->devpath, "/bus/", 5) == 0) {
+                       udev_device_set_subsystem(udev_device, "subsystem");
+                       return udev_device->subsystem;
+               }
+       }
+       return udev_device->subsystem;
+}
+
+mode_t udev_device_get_devnode_mode(struct udev_device *udev_device)
+{
+       if (!udev_device->info_loaded)
+               udev_device_read_uevent_file(udev_device);
+       return udev_device->devnode_mode;
+}
+
+static int udev_device_set_devnode_mode(struct udev_device *udev_device, mode_t mode)
+{
+       char num[32];
+
+       udev_device->devnode_mode = mode;
+       snprintf(num, sizeof(num), "%#o", mode);
+       udev_device_add_property(udev_device, "DEVMODE", num);
+       return 0;
+}
+
 struct udev_list_entry *udev_device_add_property(struct udev_device *udev_device, const char *key, const char *value)
 {
        udev_device->envp_uptodate = false;
@@ -837,7 +1090,6 @@ UDEV_EXPORT void udev_device_unref(struct udev_device *udev_device)
        free(udev_device->action);
        free(udev_device->driver);
        free(udev_device->devpath_old);
-       free(udev_device->sysname_old);
        free(udev_device->knodename);
        free(udev_device->id_filename);
        free(udev_device->envp);
@@ -935,73 +1187,6 @@ UDEV_EXPORT const char *udev_device_get_devnode(struct udev_device *udev_device)
        return udev_device->devnode;
 }
 
-mode_t udev_device_get_devnode_mode(struct udev_device *udev_device)
-{
-       if (!udev_device->info_loaded)
-               udev_device_read_uevent_file(udev_device);
-       return udev_device->devnode_mode;
-}
-
-/**
- * udev_device_get_subsystem:
- * @udev_device: udev device
- *
- * Retrieve the subsystem string of the udev device. The string does not
- * contain any "/".
- *
- * Returns: the subsystem name of the udev device, or #NULL if it can not be determined
- **/
-UDEV_EXPORT const char *udev_device_get_subsystem(struct udev_device *udev_device)
-{
-       char subsystem[UTIL_NAME_SIZE];
-
-       if (udev_device == NULL)
-               return NULL;
-       if (!udev_device->subsystem_set) {
-               udev_device->subsystem_set = true;
-               /* read "subsystem" link */
-               if (util_get_sys_subsystem(udev_device->udev, udev_device->syspath, subsystem, sizeof(subsystem)) > 0) {
-                       udev_device_set_subsystem(udev_device, subsystem);
-                       return udev_device->subsystem;
-               }
-               /* implicit names */
-               if (strncmp(udev_device->devpath, "/module/", 8) == 0) {
-                       udev_device_set_subsystem(udev_device, "module");
-                       return udev_device->subsystem;
-               }
-               if (strstr(udev_device->devpath, "/drivers/") != NULL) {
-                       udev_device_set_subsystem(udev_device, "drivers");
-                       return udev_device->subsystem;
-               }
-               if (strncmp(udev_device->devpath, "/subsystem/", 11) == 0 ||
-                   strncmp(udev_device->devpath, "/class/", 7) == 0 ||
-                   strncmp(udev_device->devpath, "/bus/", 5) == 0) {
-                       udev_device_set_subsystem(udev_device, "subsystem");
-                       return udev_device->subsystem;
-               }
-       }
-       return udev_device->subsystem;
-}
-
-/**
- * udev_device_get_devtype:
- * @udev_device: udev device
- *
- * Retrieve the devtype string of the udev device.
- *
- * Returns: the devtype name of the udev device, or #NULL if it can not be determined
- **/
-UDEV_EXPORT const char *udev_device_get_devtype(struct udev_device *udev_device)
-{
-       if (udev_device == NULL)
-               return NULL;
-       if (!udev_device->devtype_set) {
-               udev_device->devtype_set = true;
-               udev_device_read_uevent_file(udev_device);
-       }
-       return udev_device->devtype;
-}
-
 /**
  * udev_device_get_devlinks_list_entry:
  * @udev_device: udev device
@@ -1085,41 +1270,6 @@ UDEV_EXPORT struct udev_list_entry *udev_device_get_properties_list_entry(struct
        return udev_list_get_entry(&udev_device->properties_list);
 }
 
-/**
- * udev_device_get_driver:
- * @udev_device: udev device
- *
- * Returns: the driver string, or #NULL if there is no driver attached.
- **/
-UDEV_EXPORT const char *udev_device_get_driver(struct udev_device *udev_device)
-{
-       char driver[UTIL_NAME_SIZE];
-
-       if (udev_device == NULL)
-               return NULL;
-       if (!udev_device->driver_set) {
-               udev_device->driver_set = true;
-               if (util_get_sys_driver(udev_device->udev, udev_device->syspath, driver, sizeof(driver)) > 0)
-                       udev_device->driver = strdup(driver);
-       }
-       return udev_device->driver;
-}
-
-/**
- * udev_device_get_devnum:
- * @udev_device: udev device
- *
- * Returns: the device major/minor number.
- **/
-UDEV_EXPORT dev_t udev_device_get_devnum(struct udev_device *udev_device)
-{
-       if (udev_device == NULL)
-               return makedev(0, 0);
-       if (!udev_device->info_loaded)
-               udev_device_read_uevent_file(udev_device);
-       return udev_device->devnum;
-}
-
 /**
  * udev_device_get_action:
  * @udev_device: udev device
@@ -1137,22 +1287,6 @@ UDEV_EXPORT const char *udev_device_get_action(struct udev_device *udev_device)
        return udev_device->action;
 }
 
-/**
- * udev_device_get_devnum:
- * @udev_device: udev device
- *
- * This is only valid if the device was received through a monitor. Devices read from
- * sys do not have a sequence number.
- *
- * Returns: the kernel event sequence number, or 0 if there is no sequence number available.
- **/
-UDEV_EXPORT unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device)
-{
-       if (udev_device == NULL)
-               return 0;
-       return udev_device->seqnum;
-}
-
 /**
  * udev_device_get_usec_since_initialized:
  * @udev_device: udev device
@@ -1394,28 +1528,6 @@ int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath
        return 0;
 }
 
-int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem)
-{
-       free(udev_device->subsystem);
-       udev_device->subsystem = strdup(subsystem);
-       if (udev_device->subsystem == NULL)
-               return -ENOMEM;
-       udev_device->subsystem_set = true;
-       udev_device_add_property(udev_device, "SUBSYSTEM", udev_device->subsystem);
-       return 0;
-}
-
-int udev_device_set_devtype(struct udev_device *udev_device, const char *devtype)
-{
-       free(udev_device->devtype);
-       udev_device->devtype = strdup(devtype);
-       if (udev_device->devtype == NULL)
-               return -ENOMEM;
-       udev_device->devtype_set = true;
-       udev_device_add_property(udev_device, "DEVTYPE", udev_device->devtype);
-       return 0;
-}
-
 int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode)
 {
        free(udev_device->devnode);
@@ -1426,16 +1538,6 @@ int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode
        return 0;
 }
 
-int udev_device_set_devnode_mode(struct udev_device *udev_device, mode_t mode)
-{
-       char num[32];
-
-       udev_device->devnode_mode = mode;
-       snprintf(num, sizeof(num), "%#o", mode);
-       udev_device_add_property(udev_device, "DEVMODE", num);
-       return 0;
-}
-
 int udev_device_add_devlink(struct udev_device *udev_device, const char *devlink, int unique)
 {
        struct udev_list_entry *list_entry;
@@ -1636,112 +1738,6 @@ int udev_device_set_action(struct udev_device *udev_device, const char *action)
        return 0;
 }
 
-int udev_device_set_driver(struct udev_device *udev_device, const char *driver)
-{
-       free(udev_device->driver);
-       udev_device->driver = strdup(driver);
-       if (udev_device->driver == NULL)
-               return -ENOMEM;
-       udev_device->driver_set = true;
-       udev_device_add_property(udev_device, "DRIVER", udev_device->driver);
-       return 0;
-}
-
-const char *udev_device_get_devpath_old(struct udev_device *udev_device)
-{
-       return udev_device->devpath_old;
-}
-
-int udev_device_set_devpath_old(struct udev_device *udev_device, const char *devpath_old)
-{
-       const char *pos;
-       size_t len;
-
-       free(udev_device->devpath_old);
-       udev_device->devpath_old = strdup(devpath_old);
-       if (udev_device->devpath_old == NULL)
-               return -ENOMEM;
-       udev_device_add_property(udev_device, "DEVPATH_OLD", udev_device->devpath_old);
-
-       pos = strrchr(udev_device->devpath_old, '/');
-       if (pos == NULL)
-               return -EINVAL;
-       udev_device->sysname_old = strdup(&pos[1]);
-       if (udev_device->sysname_old == NULL)
-               return -ENOMEM;
-
-       /* some devices have '!' in their name, change that to '/' */
-       len = 0;
-       while (udev_device->sysname_old[len] != '\0') {
-               if (udev_device->sysname_old[len] == '!')
-                       udev_device->sysname_old[len] = '/';
-               len++;
-       }
-       return 0;
-}
-
-const char *udev_device_get_sysname_old(struct udev_device *udev_device)
-{
-       if (udev_device == NULL)
-               return NULL;
-       return udev_device->sysname_old;
-}
-
-const char *udev_device_get_knodename(struct udev_device *udev_device)
-{
-       return udev_device->knodename;
-}
-
-int udev_device_set_knodename(struct udev_device *udev_device, const char *knodename)
-{
-       free(udev_device->knodename);
-       udev_device->knodename = strdup(knodename);
-       if (udev_device->knodename == NULL)
-               return -ENOMEM;
-       /* do not overwrite the udev property with the kernel property */
-       if (udev_device->devnode == NULL)
-               udev_device_add_property(udev_device, "DEVNAME", udev_device->knodename);
-       return 0;
-}
-
-int udev_device_get_timeout(struct udev_device *udev_device)
-{
-       return udev_device->timeout;
-}
-
-int udev_device_set_timeout(struct udev_device *udev_device, int timeout)
-{
-       char num[32];
-
-       udev_device->timeout = timeout;
-       snprintf(num, sizeof(num), "%u", timeout);
-       udev_device_add_property(udev_device, "TIMEOUT", num);
-       return 0;
-}
-
-int udev_device_set_seqnum(struct udev_device *udev_device, unsigned long long int seqnum)
-{
-       char num[32];
-
-       udev_device->seqnum = seqnum;
-       snprintf(num, sizeof(num), "%llu", seqnum);
-       udev_device_add_property(udev_device, "SEQNUM", num);
-       return 0;
-}
-
-int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum)
-{
-       char num[32];
-
-       udev_device->devnum = devnum;
-
-       snprintf(num, sizeof(num), "%u", major(devnum));
-       udev_device_add_property(udev_device, "MAJOR", num);
-       snprintf(num, sizeof(num), "%u", minor(devnum));
-       udev_device_add_property(udev_device, "MINOR", num);
-       return 0;
-}
-
 int udev_device_get_devlink_priority(struct udev_device *udev_device)
 {
        if (!udev_device->info_loaded)
@@ -1768,23 +1764,6 @@ int udev_device_set_watch_handle(struct udev_device *udev_device, int handle)
        return 0;
 }
 
-int udev_device_get_ifindex(struct udev_device *udev_device)
-{
-       if (!udev_device->info_loaded)
-               udev_device_read_uevent_file(udev_device);
-       return udev_device->ifindex;
-}
-
-int udev_device_set_ifindex(struct udev_device *udev_device, int ifindex)
-{
-       char num[32];
-
-       udev_device->ifindex = ifindex;
-       snprintf(num, sizeof(num), "%u", ifindex);
-       udev_device_add_property(udev_device, "IFINDEX", num);
-       return 0;
-}
-
 bool udev_device_get_db_persist(struct udev_device *udev_device)
 {
        return udev_device->db_persist;
index 9703fb5875bf2621a3d13246ece2ba63af72335c..315ca3d700df870055be5751fc8d6ac844218896 100644 (file)
@@ -72,10 +72,7 @@ struct udev_list_entry *udev_get_properties_list_entry(struct udev *udev);
 struct udev_device *udev_device_new(struct udev *udev);
 struct udev_device *udev_device_new_from_id_filename(struct udev *udev, char *id);
 mode_t udev_device_get_devnode_mode(struct udev_device *udev_device);
-int udev_device_set_devnode_mode(struct udev_device *udev_device, mode_t mode);
 int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath);
-int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem);
-int udev_device_set_devtype(struct udev_device *udev_device, const char *devtype);
 int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode);
 int udev_device_add_devlink(struct udev_device *udev_device, const char *devlink, int unique);
 void udev_device_cleanup_devlinks_list(struct udev_device *udev_device);
@@ -87,21 +84,14 @@ ssize_t udev_device_get_properties_monitor_buf(struct udev_device *udev_device,
 int udev_device_read_db(struct udev_device *udev_device, const char *dbfile);
 int udev_device_read_uevent_file(struct udev_device *udev_device);
 int udev_device_set_action(struct udev_device *udev_device, const char *action);
-int udev_device_set_driver(struct udev_device *udev_device, const char *driver);
 const char *udev_device_get_devpath_old(struct udev_device *udev_device);
-const char *udev_device_get_sysname_old(struct udev_device *udev_device);
-int udev_device_set_devpath_old(struct udev_device *udev_device, const char *devpath_old);
 const char *udev_device_get_knodename(struct udev_device *udev_device);
 const char *udev_device_get_id_filename(struct udev_device *udev_device);
 void udev_device_set_is_initialized(struct udev_device *udev_device);
 int udev_device_add_tag(struct udev_device *udev_device, const char *tag);
 void udev_device_cleanup_tags_list(struct udev_device *udev_device);
 int udev_device_has_tag(struct udev_device *udev_device, const char *tag);
-int udev_device_set_knodename(struct udev_device *udev_device, const char *knodename);
 int udev_device_get_timeout(struct udev_device *udev_device);
-int udev_device_set_timeout(struct udev_device *udev_device, int timeout);
-int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum);
-int udev_device_set_seqnum(struct udev_device *udev_device, unsigned long long int seqnum);
 unsigned long long udev_device_get_usec_initialized(struct udev_device *udev_device);
 void udev_device_set_usec_initialized(struct udev_device *udev_device, unsigned long long usec_initialized);
 int udev_device_get_devlink_priority(struct udev_device *udev_device);
@@ -109,7 +99,6 @@ int udev_device_set_devlink_priority(struct udev_device *udev_device, int prio);
 int udev_device_get_watch_handle(struct udev_device *udev_device);
 int udev_device_set_watch_handle(struct udev_device *udev_device, int handle);
 int udev_device_get_ifindex(struct udev_device *udev_device);
-int udev_device_set_ifindex(struct udev_device *udev_device, int ifindex);
 void udev_device_set_info_loaded(struct udev_device *device);
 bool udev_device_get_db_persist(struct udev_device *udev_device);
 void udev_device_set_db_persist(struct udev_device *udev_device);