19 #include <sysfs/libsysfs.h>
25 #include "usbip_common.h"
32 char buff[SYSFS_BUS_ID_SIZE + 4];
35 struct sysfs_attribute *match_busid_attr;
38 if (
strnlen(busid, SYSFS_BUS_ID_SIZE) > SYSFS_BUS_ID_SIZE - 1) {
39 dbg(
"busid is too long");
49 snprintf(match_busid_attr_path,
sizeof(match_busid_attr_path),
50 "%s/%s/%s/%s/%s/%s", sysfs_mntpath, SYSFS_BUS_NAME, bus_type,
53 match_busid_attr = sysfs_open_attribute(match_busid_attr_path);
54 if (!match_busid_attr) {
55 dbg(
"problem getting match_busid attribute: %s",
61 snprintf(buff, SYSFS_BUS_ID_SIZE + 4,
"add %s", busid);
63 snprintf(buff, SYSFS_BUS_ID_SIZE + 4,
"del %s", busid);
65 dbg(
"write \"%s\" to %s", buff, match_busid_attr->path);
67 rc = sysfs_write_attribute(match_busid_attr, buff,
sizeof(buff));
73 sysfs_close_attribute(match_busid_attr);