Change USB over to make_dev() for all device nodes, previously it hooked into
the devfs clone handler to open the (invisible) devices on the fly. The /dev entries are layed out as follows, /dev/usbctl = master device /dev/usb/0.1.0.5 = usb device, (<bus>.<dev>.<iface>.<endpoint>) /dev/ugen0.1 -> usb/0.1.0.0 = ugen link to ctrl endpoint This also removes the custom permissions model from USB. Bump __FreeBSD_version to 800066. Submitted by: rink (earlier version)
This commit is contained in:
parent
2ebdf04225
commit
ee3e3ff5c2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=189110
@ -514,72 +514,6 @@ returned.
|
|||||||
.
|
.
|
||||||
.Pp
|
.Pp
|
||||||
.
|
.
|
||||||
.Fn libusb20_dev_set_owner pdev uid gid
|
|
||||||
This function will set the ownership of the given USB device.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_dev_set_perm pdev mode
|
|
||||||
This function will set the permissions of the given USB device.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_dev_set_iface_owner pdev iface_index uid gid
|
|
||||||
This function will set the ownership of the given USB interface.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_dev_set_iface_perm pdev iface_index mode
|
|
||||||
This function will set the permissions of the given USB interface.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_dev_get_owner pdev puid pgid
|
|
||||||
This function will retrieve the current USB device ownership.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_dev_get_perm pdev pmode
|
|
||||||
This function will retrieve the current USB device permissions.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_dev_get_iface_owner pdev iface_index puid pgid
|
|
||||||
This function will retrieve the current USB interface ownership for
|
|
||||||
the given USB interface.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_dev_get_iface_perm pdev iface_index pmode
|
|
||||||
This function will retrieve the current USB interface permissions for
|
|
||||||
the given USB interface.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_dev_get_device_desc pdev
|
.Fn libusb20_dev_get_device_desc pdev
|
||||||
This function returns a pointer to the decoded and host endian version
|
This function returns a pointer to the decoded and host endian version
|
||||||
of the device descriptor.
|
of the device descriptor.
|
||||||
@ -663,39 +597,6 @@ A timeout value can be specified which is passed on to the
|
|||||||
.Xr 2 poll
|
.Xr 2 poll
|
||||||
function.
|
function.
|
||||||
.
|
.
|
||||||
.Sh USB BUS OPERATIONS
|
|
||||||
.
|
|
||||||
.Fn libusb20_bus_set_owner pbackend bus_index uid gid
|
|
||||||
This function will set the ownership for the given USB bus.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_bus_set_perm pbackend bus_index mode
|
|
||||||
This function will set the permissions for the given USB bus.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_bus_get_owner pbackend bus_index puid pgid
|
|
||||||
This function will retrieve the ownership for the given USB bus.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_bus_get_perm pbackend bus_index pmode
|
|
||||||
This function will retrieve the permissions for the given USB bus.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.
|
|
||||||
.Sh USB BACKEND OPERATIONS
|
.Sh USB BACKEND OPERATIONS
|
||||||
.
|
.
|
||||||
.Fn libusb20_be_get_template pbackend ptemp
|
.Fn libusb20_be_get_template pbackend ptemp
|
||||||
@ -772,47 +673,6 @@ returned.
|
|||||||
If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
|
If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
|
||||||
returned.
|
returned.
|
||||||
.
|
.
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_be_set_owner pbackend uid gid
|
|
||||||
This function will set the ownership for the given backend.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_be_set_perm pbackend mode
|
|
||||||
This function will set the permissions for the given backend.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_be_get_owner pbackend puid pgid
|
|
||||||
This function will retrieve the ownership of the given backend.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_be_get_perm pbackend pmode
|
|
||||||
This function will retrieve the permissions of the given backend.
|
|
||||||
.
|
|
||||||
.
|
|
||||||
This function returns zero on success else a LIBUSB20_ERROR value is
|
|
||||||
returned.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.
|
|
||||||
.Fn libusb20_be_alloc pmethods
|
|
||||||
This is an internal function to allocate a USB backend.
|
|
||||||
.
|
|
||||||
.Pp
|
|
||||||
.Fn libusb20_be_alloc_default void
|
|
||||||
.Fn libusb20_be_alloc_freebsd void
|
|
||||||
.Fn libusb20_be_alloc_linux void
|
.Fn libusb20_be_alloc_linux void
|
||||||
These functions are used to allocate a specific USB backend or the
|
These functions are used to allocate a specific USB backend or the
|
||||||
operating system default USB backend. Allocating a backend is a way to
|
operating system default USB backend. Allocating a backend is a way to
|
||||||
|
@ -970,86 +970,6 @@ libusb20_dev_get_bus_number(struct libusb20_device *pdev)
|
|||||||
return (pdev->bus_number);
|
return (pdev->bus_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_dev_set_owner(struct libusb20_device *pdev, uid_t user, gid_t group)
|
|
||||||
{
|
|
||||||
return (pdev->beMethods->dev_set_owner(pdev, user, group));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_dev_set_perm(struct libusb20_device *pdev, mode_t mode)
|
|
||||||
{
|
|
||||||
return (pdev->beMethods->dev_set_perm(pdev, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_dev_set_iface_owner(struct libusb20_device *pdev,
|
|
||||||
uint8_t iface_index, uid_t user, gid_t group)
|
|
||||||
{
|
|
||||||
return (pdev->beMethods->dev_set_iface_owner(
|
|
||||||
pdev, iface_index, user, group));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_dev_set_iface_perm(struct libusb20_device *pdev,
|
|
||||||
uint8_t iface_index, mode_t mode)
|
|
||||||
{
|
|
||||||
return (pdev->beMethods->dev_set_iface_perm(
|
|
||||||
pdev, iface_index, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_dev_get_owner(struct libusb20_device *pdev, uid_t *user, gid_t *group)
|
|
||||||
{
|
|
||||||
uid_t a;
|
|
||||||
gid_t b;
|
|
||||||
|
|
||||||
if (user == NULL)
|
|
||||||
user = &a;
|
|
||||||
if (group == NULL)
|
|
||||||
group = &b;
|
|
||||||
|
|
||||||
return (pdev->beMethods->dev_get_owner(pdev, user, group));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_dev_get_perm(struct libusb20_device *pdev, mode_t *mode)
|
|
||||||
{
|
|
||||||
mode_t a;
|
|
||||||
|
|
||||||
if (mode == NULL)
|
|
||||||
mode = &a;
|
|
||||||
return (pdev->beMethods->dev_get_perm(pdev, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_dev_get_iface_owner(struct libusb20_device *pdev,
|
|
||||||
uint8_t iface_index, uid_t *user, gid_t *group)
|
|
||||||
{
|
|
||||||
uid_t a;
|
|
||||||
gid_t b;
|
|
||||||
|
|
||||||
if (user == NULL)
|
|
||||||
user = &a;
|
|
||||||
if (group == NULL)
|
|
||||||
group = &b;
|
|
||||||
|
|
||||||
return (pdev->beMethods->dev_get_iface_owner(
|
|
||||||
pdev, iface_index, user, group));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_dev_get_iface_perm(struct libusb20_device *pdev,
|
|
||||||
uint8_t iface_index, mode_t *mode)
|
|
||||||
{
|
|
||||||
mode_t a;
|
|
||||||
|
|
||||||
if (mode == NULL)
|
|
||||||
mode = &a;
|
|
||||||
return (pdev->beMethods->dev_get_iface_perm(
|
|
||||||
pdev, iface_index, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
libusb20_dev_get_iface_desc(struct libusb20_device *pdev,
|
libusb20_dev_get_iface_desc(struct libusb20_device *pdev,
|
||||||
uint8_t iface_index, char *buf, uint8_t len)
|
uint8_t iface_index, char *buf, uint8_t len)
|
||||||
@ -1061,45 +981,6 @@ libusb20_dev_get_iface_desc(struct libusb20_device *pdev,
|
|||||||
pdev, iface_index, buf, len));
|
pdev, iface_index, buf, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USB bus operations */
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_bus_set_owner(struct libusb20_backend *pbe,
|
|
||||||
uint8_t bus, uid_t user, gid_t group)
|
|
||||||
{
|
|
||||||
return (pbe->methods->bus_set_owner(pbe, bus, user, group));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_bus_set_perm(struct libusb20_backend *pbe, uint8_t bus, mode_t mode)
|
|
||||||
{
|
|
||||||
return (pbe->methods->bus_set_perm(pbe, bus, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_bus_get_owner(struct libusb20_backend *pbe,
|
|
||||||
uint8_t bus, uid_t *user, gid_t *group)
|
|
||||||
{
|
|
||||||
uid_t a;
|
|
||||||
gid_t b;
|
|
||||||
|
|
||||||
if (user == NULL)
|
|
||||||
user = &a;
|
|
||||||
if (group == NULL)
|
|
||||||
group = &b;
|
|
||||||
return (pbe->methods->bus_get_owner(pbe, bus, user, group));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_bus_get_perm(struct libusb20_backend *pbe, uint8_t bus, mode_t *mode)
|
|
||||||
{
|
|
||||||
mode_t a;
|
|
||||||
|
|
||||||
if (mode == NULL)
|
|
||||||
mode = &a;
|
|
||||||
return (pbe->methods->bus_get_perm(pbe, bus, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USB backend operations */
|
/* USB backend operations */
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -1130,41 +1011,6 @@ libusb20_be_remove_dev_quirk(struct libusb20_backend *pbe,
|
|||||||
return (pbe->methods->root_remove_dev_quirk(pbe, pq));
|
return (pbe->methods->root_remove_dev_quirk(pbe, pq));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_be_set_owner(struct libusb20_backend *pbe, uid_t user, gid_t group)
|
|
||||||
{
|
|
||||||
return (pbe->methods->root_set_owner(pbe, user, group));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_be_set_perm(struct libusb20_backend *pbe, mode_t mode)
|
|
||||||
{
|
|
||||||
return (pbe->methods->root_set_perm(pbe, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_be_get_owner(struct libusb20_backend *pbe, uid_t *user, gid_t *group)
|
|
||||||
{
|
|
||||||
uid_t a;
|
|
||||||
gid_t b;
|
|
||||||
|
|
||||||
if (user == NULL)
|
|
||||||
user = &a;
|
|
||||||
if (group == NULL)
|
|
||||||
group = &b;
|
|
||||||
return (pbe->methods->root_get_owner(pbe, user, group));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libusb20_be_get_perm(struct libusb20_backend *pbe, mode_t *mode)
|
|
||||||
{
|
|
||||||
mode_t a;
|
|
||||||
|
|
||||||
if (mode == NULL)
|
|
||||||
mode = &a;
|
|
||||||
return (pbe->methods->root_get_perm(pbe, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
libusb20_be_set_template(struct libusb20_backend *pbe, int temp)
|
libusb20_be_set_template(struct libusb20_backend *pbe, int temp)
|
||||||
{
|
{
|
||||||
|
@ -253,14 +253,6 @@ int libusb20_dev_reset(struct libusb20_device *pdev);
|
|||||||
int libusb20_dev_set_power_mode(struct libusb20_device *pdev, uint8_t power_mode);
|
int libusb20_dev_set_power_mode(struct libusb20_device *pdev, uint8_t power_mode);
|
||||||
uint8_t libusb20_dev_get_power_mode(struct libusb20_device *pdev);
|
uint8_t libusb20_dev_get_power_mode(struct libusb20_device *pdev);
|
||||||
int libusb20_dev_set_alt_index(struct libusb20_device *pdev, uint8_t iface_index, uint8_t alt_index);
|
int libusb20_dev_set_alt_index(struct libusb20_device *pdev, uint8_t iface_index, uint8_t alt_index);
|
||||||
int libusb20_dev_set_owner(struct libusb20_device *pdev, uid_t user, gid_t group);
|
|
||||||
int libusb20_dev_set_perm(struct libusb20_device *pdev, mode_t mode);
|
|
||||||
int libusb20_dev_set_iface_owner(struct libusb20_device *pdev, uint8_t iface_index, uid_t user, gid_t group);
|
|
||||||
int libusb20_dev_set_iface_perm(struct libusb20_device *pdev, uint8_t iface_index, mode_t mode);
|
|
||||||
int libusb20_dev_get_owner(struct libusb20_device *pdev, uid_t *user, gid_t *group);
|
|
||||||
int libusb20_dev_get_perm(struct libusb20_device *pdev, mode_t *mode);
|
|
||||||
int libusb20_dev_get_iface_owner(struct libusb20_device *pdev, uint8_t iface_index, uid_t *user, gid_t *group);
|
|
||||||
int libusb20_dev_get_iface_perm(struct libusb20_device *pdev, uint8_t iface_index, mode_t *mode);
|
|
||||||
int libusb20_dev_get_info(struct libusb20_device *pdev, struct usb2_device_info *pinfo);
|
int libusb20_dev_get_info(struct libusb20_device *pdev, struct usb2_device_info *pinfo);
|
||||||
int libusb20_dev_get_iface_desc(struct libusb20_device *pdev, uint8_t iface_index, char *buf, uint8_t len);
|
int libusb20_dev_get_iface_desc(struct libusb20_device *pdev, uint8_t iface_index, char *buf, uint8_t len);
|
||||||
|
|
||||||
@ -276,23 +268,12 @@ void libusb20_dev_free(struct libusb20_device *pdev);
|
|||||||
void libusb20_dev_set_debug(struct libusb20_device *pdev, int debug);
|
void libusb20_dev_set_debug(struct libusb20_device *pdev, int debug);
|
||||||
void libusb20_dev_wait_process(struct libusb20_device *pdev, int timeout);
|
void libusb20_dev_wait_process(struct libusb20_device *pdev, int timeout);
|
||||||
|
|
||||||
/* USB bus operations */
|
|
||||||
|
|
||||||
int libusb20_bus_set_owner(struct libusb20_backend *pbe, uint8_t bus, uid_t user, gid_t group);
|
|
||||||
int libusb20_bus_set_perm(struct libusb20_backend *pbe, uint8_t bus, mode_t mode);
|
|
||||||
int libusb20_bus_get_owner(struct libusb20_backend *pbe, uint8_t bus, uid_t *user, gid_t *group);
|
|
||||||
int libusb20_bus_get_perm(struct libusb20_backend *pbe, uint8_t bus, mode_t *mode);
|
|
||||||
|
|
||||||
/* USB global operations */
|
/* USB global operations */
|
||||||
|
|
||||||
int libusb20_be_get_dev_quirk(struct libusb20_backend *pbe, uint16_t index, struct libusb20_quirk *pq);
|
int libusb20_be_get_dev_quirk(struct libusb20_backend *pbe, uint16_t index, struct libusb20_quirk *pq);
|
||||||
int libusb20_be_get_quirk_name(struct libusb20_backend *pbe, uint16_t index, struct libusb20_quirk *pq);
|
int libusb20_be_get_quirk_name(struct libusb20_backend *pbe, uint16_t index, struct libusb20_quirk *pq);
|
||||||
int libusb20_be_add_dev_quirk(struct libusb20_backend *pbe, struct libusb20_quirk *pq);
|
int libusb20_be_add_dev_quirk(struct libusb20_backend *pbe, struct libusb20_quirk *pq);
|
||||||
int libusb20_be_remove_dev_quirk(struct libusb20_backend *pbe, struct libusb20_quirk *pq);
|
int libusb20_be_remove_dev_quirk(struct libusb20_backend *pbe, struct libusb20_quirk *pq);
|
||||||
int libusb20_be_set_owner(struct libusb20_backend *be, uid_t user, gid_t group);
|
|
||||||
int libusb20_be_set_perm(struct libusb20_backend *be, mode_t mode);
|
|
||||||
int libusb20_be_get_owner(struct libusb20_backend *be, uid_t *user, gid_t *group);
|
|
||||||
int libusb20_be_get_perm(struct libusb20_backend *be, mode_t *mode);
|
|
||||||
|
|
||||||
/* USB backend operations */
|
/* USB backend operations */
|
||||||
|
|
||||||
|
@ -48,27 +48,11 @@ typedef int (libusb20_root_get_dev_quirk_t)(struct libusb20_backend *pbe, uint16
|
|||||||
typedef int (libusb20_root_get_quirk_name_t)(struct libusb20_backend *pbe, uint16_t index, struct libusb20_quirk *pq);
|
typedef int (libusb20_root_get_quirk_name_t)(struct libusb20_backend *pbe, uint16_t index, struct libusb20_quirk *pq);
|
||||||
typedef int (libusb20_root_add_dev_quirk_t)(struct libusb20_backend *pbe, struct libusb20_quirk *pq);
|
typedef int (libusb20_root_add_dev_quirk_t)(struct libusb20_backend *pbe, struct libusb20_quirk *pq);
|
||||||
typedef int (libusb20_root_remove_dev_quirk_t)(struct libusb20_backend *pbe, struct libusb20_quirk *pq);
|
typedef int (libusb20_root_remove_dev_quirk_t)(struct libusb20_backend *pbe, struct libusb20_quirk *pq);
|
||||||
typedef int (libusb20_bus_get_owner_t)(struct libusb20_backend *pbe, uint8_t bus, uid_t *user, gid_t *group);
|
|
||||||
typedef int (libusb20_bus_get_perm_t)(struct libusb20_backend *pbe, uint8_t bus, mode_t *mode);
|
|
||||||
typedef int (libusb20_bus_set_owner_t)(struct libusb20_backend *pbe, uint8_t bus, uid_t user, gid_t group);
|
|
||||||
typedef int (libusb20_bus_set_perm_t)(struct libusb20_backend *pbe, uint8_t bus, mode_t mode);
|
|
||||||
typedef int (libusb20_close_device_t)(struct libusb20_device *pdev);
|
typedef int (libusb20_close_device_t)(struct libusb20_device *pdev);
|
||||||
typedef int (libusb20_dev_get_iface_owner_t)(struct libusb20_device *pdev, uint8_t iface_index, uid_t *user, gid_t *group);
|
|
||||||
typedef int (libusb20_dev_get_iface_perm_t)(struct libusb20_device *pdev, uint8_t iface_index, mode_t *mode);
|
|
||||||
typedef int (libusb20_dev_get_owner_t)(struct libusb20_device *pdev, uid_t *user, gid_t *group);
|
|
||||||
typedef int (libusb20_dev_get_perm_t)(struct libusb20_device *pdev, mode_t *mode);
|
|
||||||
typedef int (libusb20_dev_get_info_t)(struct libusb20_device *pdev, struct usb2_device_info *pinfo);
|
typedef int (libusb20_dev_get_info_t)(struct libusb20_device *pdev, struct usb2_device_info *pinfo);
|
||||||
typedef int (libusb20_dev_get_iface_desc_t)(struct libusb20_device *pdev, uint8_t iface_index, char *buf, uint8_t len);
|
typedef int (libusb20_dev_get_iface_desc_t)(struct libusb20_device *pdev, uint8_t iface_index, char *buf, uint8_t len);
|
||||||
typedef int (libusb20_dev_set_iface_owner_t)(struct libusb20_device *pdev, uint8_t iface_index, uid_t user, gid_t group);
|
|
||||||
typedef int (libusb20_dev_set_iface_perm_t)(struct libusb20_device *pdev, uint8_t iface_index, mode_t mode);
|
|
||||||
typedef int (libusb20_dev_set_owner_t)(struct libusb20_device *pdev, uid_t user, gid_t group);
|
|
||||||
typedef int (libusb20_dev_set_perm_t)(struct libusb20_device *pdev, mode_t mode);
|
|
||||||
typedef int (libusb20_init_backend_t)(struct libusb20_backend *pbe);
|
typedef int (libusb20_init_backend_t)(struct libusb20_backend *pbe);
|
||||||
typedef int (libusb20_open_device_t)(struct libusb20_device *pdev, uint16_t transfer_count_max);
|
typedef int (libusb20_open_device_t)(struct libusb20_device *pdev, uint16_t transfer_count_max);
|
||||||
typedef int (libusb20_root_get_owner_t)(struct libusb20_backend *pbe, uid_t *user, gid_t *group);
|
|
||||||
typedef int (libusb20_root_get_perm_t)(struct libusb20_backend *pbe, mode_t *mode);
|
|
||||||
typedef int (libusb20_root_set_owner_t)(struct libusb20_backend *pbe, uid_t user, gid_t group);
|
|
||||||
typedef int (libusb20_root_set_perm_t)(struct libusb20_backend *pbe, mode_t mode);
|
|
||||||
typedef void (libusb20_exit_backend_t)(struct libusb20_backend *pbe);
|
typedef void (libusb20_exit_backend_t)(struct libusb20_backend *pbe);
|
||||||
typedef int (libusb20_root_set_template_t)(struct libusb20_backend *pbe, int temp);
|
typedef int (libusb20_root_set_template_t)(struct libusb20_backend *pbe, int temp);
|
||||||
typedef int (libusb20_root_get_template_t)(struct libusb20_backend *pbe, int *ptemp);
|
typedef int (libusb20_root_get_template_t)(struct libusb20_backend *pbe, int *ptemp);
|
||||||
@ -85,28 +69,12 @@ typedef int (libusb20_root_get_template_t)(struct libusb20_backend *pbe, int *pt
|
|||||||
/* optional backend methods */ \
|
/* optional backend methods */ \
|
||||||
m(n, init_backend) \
|
m(n, init_backend) \
|
||||||
m(n, exit_backend) \
|
m(n, exit_backend) \
|
||||||
m(n, bus_set_owner) \
|
|
||||||
m(n, bus_get_owner) \
|
|
||||||
m(n, bus_set_perm) \
|
|
||||||
m(n, bus_get_perm) \
|
|
||||||
m(n, dev_get_info) \
|
m(n, dev_get_info) \
|
||||||
m(n, dev_get_iface_owner) \
|
|
||||||
m(n, dev_get_iface_perm) \
|
|
||||||
m(n, dev_get_iface_desc) \
|
m(n, dev_get_iface_desc) \
|
||||||
m(n, dev_get_owner) \
|
|
||||||
m(n, dev_get_perm) \
|
|
||||||
m(n, dev_set_iface_owner) \
|
|
||||||
m(n, dev_set_iface_perm) \
|
|
||||||
m(n, dev_set_owner) \
|
|
||||||
m(n, dev_set_perm) \
|
|
||||||
m(n, root_get_dev_quirk) \
|
m(n, root_get_dev_quirk) \
|
||||||
m(n, root_get_quirk_name) \
|
m(n, root_get_quirk_name) \
|
||||||
m(n, root_add_dev_quirk) \
|
m(n, root_add_dev_quirk) \
|
||||||
m(n, root_remove_dev_quirk) \
|
m(n, root_remove_dev_quirk) \
|
||||||
m(n, root_set_owner) \
|
|
||||||
m(n, root_get_owner) \
|
|
||||||
m(n, root_set_perm) \
|
|
||||||
m(n, root_get_perm) \
|
|
||||||
m(n, root_set_template) \
|
m(n, root_set_template) \
|
||||||
m(n, root_get_template) \
|
m(n, root_get_template) \
|
||||||
/* mandatory device methods */ \
|
/* mandatory device methods */ \
|
||||||
|
@ -50,28 +50,12 @@ static libusb20_open_device_t ugen20_open_device;
|
|||||||
static libusb20_close_device_t ugen20_close_device;
|
static libusb20_close_device_t ugen20_close_device;
|
||||||
static libusb20_get_backend_name_t ugen20_get_backend_name;
|
static libusb20_get_backend_name_t ugen20_get_backend_name;
|
||||||
static libusb20_exit_backend_t ugen20_exit_backend;
|
static libusb20_exit_backend_t ugen20_exit_backend;
|
||||||
static libusb20_bus_set_owner_t ugen20_bus_set_owner;
|
|
||||||
static libusb20_bus_get_owner_t ugen20_bus_get_owner;
|
|
||||||
static libusb20_bus_set_perm_t ugen20_bus_set_perm;
|
|
||||||
static libusb20_bus_get_perm_t ugen20_bus_get_perm;
|
|
||||||
static libusb20_dev_get_iface_owner_t ugen20_dev_get_iface_owner;
|
|
||||||
static libusb20_dev_get_iface_perm_t ugen20_dev_get_iface_perm;
|
|
||||||
static libusb20_dev_get_owner_t ugen20_dev_get_owner;
|
|
||||||
static libusb20_dev_get_perm_t ugen20_dev_get_perm;
|
|
||||||
static libusb20_dev_get_iface_desc_t ugen20_dev_get_iface_desc;
|
static libusb20_dev_get_iface_desc_t ugen20_dev_get_iface_desc;
|
||||||
static libusb20_dev_get_info_t ugen20_dev_get_info;
|
static libusb20_dev_get_info_t ugen20_dev_get_info;
|
||||||
static libusb20_dev_set_iface_owner_t ugen20_dev_set_iface_owner;
|
|
||||||
static libusb20_dev_set_iface_perm_t ugen20_dev_set_iface_perm;
|
|
||||||
static libusb20_dev_set_owner_t ugen20_dev_set_owner;
|
|
||||||
static libusb20_dev_set_perm_t ugen20_dev_set_perm;
|
|
||||||
static libusb20_root_get_dev_quirk_t ugen20_root_get_dev_quirk;
|
static libusb20_root_get_dev_quirk_t ugen20_root_get_dev_quirk;
|
||||||
static libusb20_root_get_quirk_name_t ugen20_root_get_quirk_name;
|
static libusb20_root_get_quirk_name_t ugen20_root_get_quirk_name;
|
||||||
static libusb20_root_add_dev_quirk_t ugen20_root_add_dev_quirk;
|
static libusb20_root_add_dev_quirk_t ugen20_root_add_dev_quirk;
|
||||||
static libusb20_root_remove_dev_quirk_t ugen20_root_remove_dev_quirk;
|
static libusb20_root_remove_dev_quirk_t ugen20_root_remove_dev_quirk;
|
||||||
static libusb20_root_set_owner_t ugen20_root_set_owner;
|
|
||||||
static libusb20_root_get_owner_t ugen20_root_get_owner;
|
|
||||||
static libusb20_root_set_perm_t ugen20_root_set_perm;
|
|
||||||
static libusb20_root_get_perm_t ugen20_root_get_perm;
|
|
||||||
static libusb20_root_set_template_t ugen20_root_set_template;
|
static libusb20_root_set_template_t ugen20_root_set_template;
|
||||||
static libusb20_root_get_template_t ugen20_root_get_template;
|
static libusb20_root_get_template_t ugen20_root_get_template;
|
||||||
|
|
||||||
@ -152,7 +136,7 @@ ugen20_enumerate(struct libusb20_device *pdev, const char *id)
|
|||||||
pdev->bus_number = ugen20_path_convert_one(&tmp);
|
pdev->bus_number = ugen20_path_convert_one(&tmp);
|
||||||
pdev->device_address = ugen20_path_convert_one(&tmp);
|
pdev->device_address = ugen20_path_convert_one(&tmp);
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "/dev/ugen%u.%u",
|
snprintf(buf, sizeof(buf), "/dev/" USB_GENERIC_NAME "%u.%u",
|
||||||
pdev->bus_number, pdev->device_address);
|
pdev->bus_number, pdev->device_address);
|
||||||
|
|
||||||
f = open(buf, O_RDWR);
|
f = open(buf, O_RDWR);
|
||||||
@ -218,7 +202,7 @@ ugen20_enumerate(struct libusb20_device *pdev, const char *id)
|
|||||||
/* generate a nice description for printout */
|
/* generate a nice description for printout */
|
||||||
|
|
||||||
snprintf(pdev->usb_desc, sizeof(pdev->usb_desc),
|
snprintf(pdev->usb_desc, sizeof(pdev->usb_desc),
|
||||||
"ugen%u.%u: <%s %s> at usbus%u", pdev->bus_number,
|
USB_GENERIC_NAME "%u.%u: <%s %s> at usbus%u", pdev->bus_number,
|
||||||
pdev->device_address, devinfo.udi_product,
|
pdev->device_address, devinfo.udi_product,
|
||||||
devinfo.udi_vendor, pdev->bus_number);
|
devinfo.udi_vendor, pdev->bus_number);
|
||||||
|
|
||||||
@ -284,7 +268,7 @@ ugen20_init_backend(struct libusb20_backend *pbe)
|
|||||||
|
|
||||||
memset(&state, 0, sizeof(state));
|
memset(&state, 0, sizeof(state));
|
||||||
|
|
||||||
state.f = open("/dev/usb", O_RDONLY);
|
state.f = open("/dev/" USB_DEVICE_NAME, O_RDONLY);
|
||||||
if (state.f < 0)
|
if (state.f < 0)
|
||||||
return (LIBUSB20_ERROR_OTHER);
|
return (LIBUSB20_ERROR_OTHER);
|
||||||
|
|
||||||
@ -379,7 +363,7 @@ ugen20_open_device(struct libusb20_device *pdev, uint16_t nMaxTransfer)
|
|||||||
int g;
|
int g;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "/dev/ugen%u.%u",
|
snprintf(buf, sizeof(buf), "/dev/" USB_GENERIC_NAME "%u.%u",
|
||||||
pdev->bus_number, pdev->device_address);
|
pdev->bus_number, pdev->device_address);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -873,7 +857,7 @@ ugen20_be_ioctl(uint32_t cmd, void *data)
|
|||||||
int f;
|
int f;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
f = open("/dev/usb", O_RDONLY);
|
f = open("/dev/" USB_DEVICE_NAME, O_RDONLY);
|
||||||
if (f < 0)
|
if (f < 0)
|
||||||
return (LIBUSB20_ERROR_OTHER);
|
return (LIBUSB20_ERROR_OTHER);
|
||||||
error = ioctl(f, cmd, data);
|
error = ioctl(f, cmd, data);
|
||||||
@ -888,75 +872,6 @@ ugen20_be_ioctl(uint32_t cmd, void *data)
|
|||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_be_do_perm(uint32_t get_cmd, uint32_t set_cmd, uint8_t bus,
|
|
||||||
uint8_t dev, uint8_t iface, uid_t *uid,
|
|
||||||
gid_t *gid, mode_t *mode)
|
|
||||||
{
|
|
||||||
struct usb2_dev_perm perm;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
memset(&perm, 0, sizeof(perm));
|
|
||||||
|
|
||||||
perm.bus_index = bus;
|
|
||||||
perm.dev_index = dev;
|
|
||||||
perm.iface_index = iface;
|
|
||||||
|
|
||||||
error = ugen20_be_ioctl(get_cmd, &perm);
|
|
||||||
if (error)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
if (set_cmd == 0) {
|
|
||||||
if (uid)
|
|
||||||
*uid = perm.user_id;
|
|
||||||
if (gid)
|
|
||||||
*gid = perm.group_id;
|
|
||||||
if (mode)
|
|
||||||
*mode = perm.mode;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
if (uid)
|
|
||||||
perm.user_id = *uid;
|
|
||||||
if (gid)
|
|
||||||
perm.group_id = *gid;
|
|
||||||
if (mode)
|
|
||||||
perm.mode = *mode;
|
|
||||||
|
|
||||||
return (ugen20_be_ioctl(set_cmd, &perm));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_bus_set_owner(struct libusb20_backend *pbe,
|
|
||||||
uint8_t bus, uid_t user, gid_t group)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_BUS_PERM, USB_SET_BUS_PERM,
|
|
||||||
bus, 0, 0, &user, &group, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_bus_get_owner(struct libusb20_backend *pbe, uint8_t bus,
|
|
||||||
uid_t *user, gid_t *group)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_BUS_PERM, 0,
|
|
||||||
bus, 0, 0, user, group, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_bus_set_perm(struct libusb20_backend *pbe,
|
|
||||||
uint8_t bus, mode_t mode)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_BUS_PERM, USB_SET_BUS_PERM,
|
|
||||||
bus, 0, 0, NULL, NULL, &mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_bus_get_perm(struct libusb20_backend *pbe,
|
|
||||||
uint8_t bus, mode_t *mode)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_BUS_PERM, 0,
|
|
||||||
bus, 0, 0, NULL, NULL, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ugen20_dev_get_iface_desc(struct libusb20_device *pdev,
|
ugen20_dev_get_iface_desc(struct libusb20_device *pdev,
|
||||||
uint8_t iface_index, char *buf, uint8_t len)
|
uint8_t iface_index, char *buf, uint8_t len)
|
||||||
@ -985,59 +900,6 @@ ugen20_dev_get_info(struct libusb20_device *pdev,
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_dev_get_iface_owner(struct libusb20_device *pdev,
|
|
||||||
uint8_t iface_index, uid_t *user, gid_t *group)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_IFACE_PERM, 0,
|
|
||||||
pdev->bus_number, pdev->device_address, iface_index,
|
|
||||||
user, group, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_dev_get_iface_perm(struct libusb20_device *pdev,
|
|
||||||
uint8_t iface_index, mode_t *mode)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_IFACE_PERM, 0,
|
|
||||||
pdev->bus_number, pdev->device_address, iface_index,
|
|
||||||
NULL, NULL, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_dev_get_owner(struct libusb20_device *pdev,
|
|
||||||
uid_t *user, gid_t *group)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_DEVICE_PERM, 0,
|
|
||||||
pdev->bus_number, pdev->device_address, 0,
|
|
||||||
user, group, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_dev_get_perm(struct libusb20_device *pdev, mode_t *mode)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_DEVICE_PERM, 0,
|
|
||||||
pdev->bus_number, pdev->device_address, 0,
|
|
||||||
NULL, NULL, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_dev_set_iface_owner(struct libusb20_device *pdev,
|
|
||||||
uint8_t iface_index, uid_t user, gid_t group)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_IFACE_PERM, USB_SET_IFACE_PERM,
|
|
||||||
pdev->bus_number, pdev->device_address, iface_index,
|
|
||||||
&user, &group, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_dev_set_iface_perm(struct libusb20_device *pdev,
|
|
||||||
uint8_t iface_index, mode_t mode)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_IFACE_PERM, USB_SET_IFACE_PERM,
|
|
||||||
pdev->bus_number, pdev->device_address, iface_index,
|
|
||||||
NULL, NULL, &mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ugen20_root_get_dev_quirk(struct libusb20_backend *pbe,
|
ugen20_root_get_dev_quirk(struct libusb20_backend *pbe,
|
||||||
uint16_t quirk_index, struct libusb20_quirk *pq)
|
uint16_t quirk_index, struct libusb20_quirk *pq)
|
||||||
@ -1136,52 +998,6 @@ ugen20_root_remove_dev_quirk(struct libusb20_backend *pbe,
|
|||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_dev_set_owner(struct libusb20_device *pdev,
|
|
||||||
uid_t user, gid_t group)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_DEVICE_PERM, USB_SET_DEVICE_PERM,
|
|
||||||
pdev->bus_number, pdev->device_address, 0,
|
|
||||||
&user, &group, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_dev_set_perm(struct libusb20_device *pdev, mode_t mode)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_DEVICE_PERM, USB_SET_DEVICE_PERM,
|
|
||||||
pdev->bus_number, pdev->device_address, 0,
|
|
||||||
NULL, NULL, &mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_root_set_owner(struct libusb20_backend *pbe,
|
|
||||||
uid_t user, gid_t group)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_ROOT_PERM, USB_SET_ROOT_PERM, 0, 0, 0,
|
|
||||||
&user, &group, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_root_get_owner(struct libusb20_backend *pbe, uid_t *user, gid_t *group)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_ROOT_PERM, 0, 0, 0, 0,
|
|
||||||
user, group, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_root_set_perm(struct libusb20_backend *pbe, mode_t mode)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_ROOT_PERM, USB_SET_ROOT_PERM, 0, 0, 0,
|
|
||||||
NULL, NULL, &mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ugen20_root_get_perm(struct libusb20_backend *pbe, mode_t *mode)
|
|
||||||
{
|
|
||||||
return (ugen20_be_do_perm(USB_GET_ROOT_PERM, 0, 0, 0, 0,
|
|
||||||
NULL, NULL, mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ugen20_root_set_template(struct libusb20_backend *pbe, int temp)
|
ugen20_root_set_template(struct libusb20_backend *pbe, int temp)
|
||||||
{
|
{
|
||||||
|
@ -379,9 +379,9 @@ static void umidi_start_read(struct usb2_fifo *);
|
|||||||
static void umidi_stop_read(struct usb2_fifo *);
|
static void umidi_stop_read(struct usb2_fifo *);
|
||||||
static void umidi_start_write(struct usb2_fifo *);
|
static void umidi_start_write(struct usb2_fifo *);
|
||||||
static void umidi_stop_write(struct usb2_fifo *);
|
static void umidi_stop_write(struct usb2_fifo *);
|
||||||
static int umidi_open(struct usb2_fifo *, int, struct thread *);
|
static int umidi_open(struct usb2_fifo *, int);
|
||||||
static int umidi_ioctl(struct usb2_fifo *, u_long cmd, void *, int, struct thread *);
|
static int umidi_ioctl(struct usb2_fifo *, u_long cmd, void *, int);
|
||||||
static void umidi_close(struct usb2_fifo *, int, struct thread *);
|
static void umidi_close(struct usb2_fifo *, int);
|
||||||
static void umidi_init(device_t dev);
|
static void umidi_init(device_t dev);
|
||||||
static int32_t umidi_probe(device_t dev);
|
static int32_t umidi_probe(device_t dev);
|
||||||
static int32_t umidi_detach(device_t dev);
|
static int32_t umidi_detach(device_t dev);
|
||||||
@ -3585,7 +3585,7 @@ umidi_stop_write(struct usb2_fifo *fifo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
umidi_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
umidi_open(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
struct umidi_chan *chan = fifo->priv_sc0;
|
struct umidi_chan *chan = fifo->priv_sc0;
|
||||||
struct umidi_sub_chan *sub = umidi_sub_by_fifo(fifo);
|
struct umidi_sub_chan *sub = umidi_sub_by_fifo(fifo);
|
||||||
@ -3617,7 +3617,7 @@ umidi_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
umidi_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
umidi_close(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
if (fflags & FREAD) {
|
if (fflags & FREAD) {
|
||||||
usb2_fifo_free_buffer(fifo);
|
usb2_fifo_free_buffer(fifo);
|
||||||
@ -3630,7 +3630,7 @@ umidi_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
umidi_ioctl(struct usb2_fifo *fifo, u_long cmd, void *data,
|
umidi_ioctl(struct usb2_fifo *fifo, u_long cmd, void *data,
|
||||||
int fflags, struct thread *td)
|
int fflags)
|
||||||
{
|
{
|
||||||
return (ENODEV);
|
return (ENODEV);
|
||||||
}
|
}
|
||||||
@ -3684,9 +3684,6 @@ umidi_probe(device_t dev)
|
|||||||
(chan->max_cable == 0)) {
|
(chan->max_cable == 0)) {
|
||||||
chan->max_cable = UMIDI_CABLES_MAX;
|
chan->max_cable = UMIDI_CABLES_MAX;
|
||||||
}
|
}
|
||||||
/* set interface permissions */
|
|
||||||
usb2_set_iface_perm(sc->sc_udev, chan->iface_index,
|
|
||||||
UID_ROOT, GID_OPERATOR, 0644);
|
|
||||||
|
|
||||||
for (n = 0; n < chan->max_cable; n++) {
|
for (n = 0; n < chan->max_cable; n++) {
|
||||||
|
|
||||||
@ -3694,7 +3691,8 @@ umidi_probe(device_t dev)
|
|||||||
|
|
||||||
error = usb2_fifo_attach(sc->sc_udev, chan, &chan->mtx,
|
error = usb2_fifo_attach(sc->sc_udev, chan, &chan->mtx,
|
||||||
&umidi_fifo_methods, &sub->fifo, unit, n,
|
&umidi_fifo_methods, &sub->fifo, unit, n,
|
||||||
chan->iface_index);
|
chan->iface_index,
|
||||||
|
UID_ROOT, GID_OPERATOR, 0644);
|
||||||
if (error) {
|
if (error) {
|
||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
|
@ -211,13 +211,10 @@ ubtbcmfw_attach(device_t dev)
|
|||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set interface permissions */
|
|
||||||
usb2_set_iface_perm(uaa->device, uaa->info.bIfaceIndex,
|
|
||||||
UID_ROOT, GID_OPERATOR, 0644);
|
|
||||||
|
|
||||||
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
||||||
&ubtbcmfw_fifo_methods, &sc->sc_fifo,
|
&ubtbcmfw_fifo_methods, &sc->sc_fifo,
|
||||||
device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex);
|
device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex,
|
||||||
|
UID_ROOT, GID_OPERATOR, 0644);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
device_printf(dev, "could not attach fifo. %s\n",
|
device_printf(dev, "could not attach fifo. %s\n",
|
||||||
usb2_errstr(error));
|
usb2_errstr(error));
|
||||||
@ -369,7 +366,7 @@ ubtbcmfw_stop_write(struct usb2_fifo *fifo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ubtbcmfw_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
ubtbcmfw_open(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
struct ubtbcmfw_softc *sc = fifo->priv_sc0;
|
struct ubtbcmfw_softc *sc = fifo->priv_sc0;
|
||||||
struct usb2_xfer *xfer;
|
struct usb2_xfer *xfer;
|
||||||
@ -398,7 +395,7 @@ ubtbcmfw_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ubtbcmfw_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
ubtbcmfw_close(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
if (fflags & (FREAD | FWRITE))
|
if (fflags & (FREAD | FWRITE))
|
||||||
usb2_fifo_free_buffer(fifo);
|
usb2_fifo_free_buffer(fifo);
|
||||||
@ -410,7 +407,7 @@ ubtbcmfw_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
ubtbcmfw_ioctl(struct usb2_fifo *fifo, u_long cmd, void *data,
|
ubtbcmfw_ioctl(struct usb2_fifo *fifo, u_long cmd, void *data,
|
||||||
int fflags, struct thread *td)
|
int fflags)
|
||||||
{
|
{
|
||||||
struct ubtbcmfw_softc *sc = fifo->priv_sc0;
|
struct ubtbcmfw_softc *sc = fifo->priv_sc0;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
@ -399,13 +399,11 @@ uscanner_attach(device_t dev)
|
|||||||
"error=%s\n", usb2_errstr(error));
|
"error=%s\n", usb2_errstr(error));
|
||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
/* set interface permissions */
|
|
||||||
usb2_set_iface_perm(uaa->device, uaa->info.bIfaceIndex,
|
|
||||||
UID_ROOT, GID_OPERATOR, 0644);
|
|
||||||
|
|
||||||
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
||||||
&uscanner_fifo_methods, &sc->sc_fifo,
|
&uscanner_fifo_methods, &sc->sc_fifo,
|
||||||
unit, 0 - 1, uaa->info.bIfaceIndex);
|
unit, 0 - 1, uaa->info.bIfaceIndex,
|
||||||
|
UID_ROOT, GID_OPERATOR, 0644);
|
||||||
if (error) {
|
if (error) {
|
||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
@ -553,7 +551,7 @@ uscanner_write_clear_stall_callback(struct usb2_xfer *xfer)
|
|||||||
* uscanner character device opening method.
|
* uscanner character device opening method.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
uscanner_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
uscanner_open(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
struct uscanner_softc *sc;
|
struct uscanner_softc *sc;
|
||||||
|
|
||||||
@ -585,7 +583,7 @@ uscanner_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
uscanner_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
uscanner_close(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
if (fflags & (FREAD | FWRITE)) {
|
if (fflags & (FREAD | FWRITE)) {
|
||||||
usb2_fifo_free_buffer(fifo);
|
usb2_fifo_free_buffer(fifo);
|
||||||
|
@ -447,7 +447,7 @@ uhid_set_report(struct uhid_softc *sc, uint8_t type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
uhid_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
uhid_open(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
struct uhid_softc *sc = fifo->priv_sc0;
|
struct uhid_softc *sc = fifo->priv_sc0;
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ uhid_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
uhid_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
uhid_close(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
if (fflags & (FREAD | FWRITE)) {
|
if (fflags & (FREAD | FWRITE)) {
|
||||||
usb2_fifo_free_buffer(fifo);
|
usb2_fifo_free_buffer(fifo);
|
||||||
@ -483,7 +483,7 @@ uhid_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
uhid_ioctl(struct usb2_fifo *fifo, u_long cmd, void *addr,
|
uhid_ioctl(struct usb2_fifo *fifo, u_long cmd, void *addr,
|
||||||
int fflags, struct thread *td)
|
int fflags)
|
||||||
{
|
{
|
||||||
struct uhid_softc *sc = fifo->priv_sc0;
|
struct uhid_softc *sc = fifo->priv_sc0;
|
||||||
struct usb2_gen_descriptor *ugd;
|
struct usb2_gen_descriptor *ugd;
|
||||||
@ -734,13 +734,11 @@ uhid_attach(device_t dev)
|
|||||||
sc->sc_fsize);
|
sc->sc_fsize);
|
||||||
sc->sc_fsize = UHID_BSIZE;
|
sc->sc_fsize = UHID_BSIZE;
|
||||||
}
|
}
|
||||||
/* set interface permissions */
|
|
||||||
usb2_set_iface_perm(uaa->device, uaa->info.bIfaceIndex,
|
|
||||||
UID_ROOT, GID_OPERATOR, 0644);
|
|
||||||
|
|
||||||
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
||||||
&uhid_fifo_methods, &sc->sc_fifo,
|
&uhid_fifo_methods, &sc->sc_fifo,
|
||||||
unit, 0 - 1, uaa->info.bIfaceIndex);
|
unit, 0 - 1, uaa->info.bIfaceIndex,
|
||||||
|
UID_ROOT, GID_OPERATOR, 0644);
|
||||||
if (error) {
|
if (error) {
|
||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
|
@ -583,13 +583,10 @@ ums_attach(device_t dev)
|
|||||||
sc->sc_status.dy = 0;
|
sc->sc_status.dy = 0;
|
||||||
sc->sc_status.dz = 0;
|
sc->sc_status.dz = 0;
|
||||||
|
|
||||||
/* set interface permissions */
|
|
||||||
usb2_set_iface_perm(uaa->device, uaa->info.bIfaceIndex,
|
|
||||||
UID_ROOT, GID_OPERATOR, 0644);
|
|
||||||
|
|
||||||
err = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
err = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
||||||
&ums_fifo_methods, &sc->sc_fifo,
|
&ums_fifo_methods, &sc->sc_fifo,
|
||||||
unit, 0 - 1, uaa->info.bIfaceIndex);
|
unit, 0 - 1, uaa->info.bIfaceIndex,
|
||||||
|
UID_ROOT, GID_OPERATOR, 0644);
|
||||||
if (err) {
|
if (err) {
|
||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
@ -697,7 +694,7 @@ ums_reset_buf(struct ums_softc *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ums_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
ums_open(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
struct ums_softc *sc = fifo->priv_sc0;
|
struct ums_softc *sc = fifo->priv_sc0;
|
||||||
|
|
||||||
@ -724,7 +721,7 @@ ums_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ums_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
ums_close(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
if (fflags & FREAD) {
|
if (fflags & FREAD) {
|
||||||
usb2_fifo_free_buffer(fifo);
|
usb2_fifo_free_buffer(fifo);
|
||||||
@ -732,8 +729,7 @@ ums_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ums_ioctl(struct usb2_fifo *fifo, u_long cmd, void *addr,
|
ums_ioctl(struct usb2_fifo *fifo, u_long cmd, void *addr, int fflags)
|
||||||
int fflags, struct thread *td)
|
|
||||||
{
|
{
|
||||||
struct ums_softc *sc = fifo->priv_sc0;
|
struct ums_softc *sc = fifo->priv_sc0;
|
||||||
mousemode_t mode;
|
mousemode_t mode;
|
||||||
|
@ -139,13 +139,10 @@ ufm_attach(device_t dev)
|
|||||||
|
|
||||||
device_set_usb2_desc(dev);
|
device_set_usb2_desc(dev);
|
||||||
|
|
||||||
/* set interface permissions */
|
|
||||||
usb2_set_iface_perm(uaa->device, uaa->info.bIfaceIndex,
|
|
||||||
UID_ROOT, GID_OPERATOR, 0644);
|
|
||||||
|
|
||||||
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
||||||
&ufm_fifo_methods, &sc->sc_fifo,
|
&ufm_fifo_methods, &sc->sc_fifo,
|
||||||
device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex);
|
device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex,
|
||||||
|
UID_ROOT, GID_OPERATOR, 0644);
|
||||||
if (error) {
|
if (error) {
|
||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
@ -169,7 +166,7 @@ ufm_detach(device_t dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ufm_open(struct usb2_fifo *dev, int fflags, struct thread *td)
|
ufm_open(struct usb2_fifo *dev, int fflags)
|
||||||
{
|
{
|
||||||
if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) {
|
if ((fflags & (FWRITE | FREAD)) != (FWRITE | FREAD)) {
|
||||||
return (EACCES);
|
return (EACCES);
|
||||||
@ -300,7 +297,7 @@ ufm_get_stat(struct ufm_softc *sc, void *addr)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
ufm_ioctl(struct usb2_fifo *fifo, u_long cmd, void *addr,
|
ufm_ioctl(struct usb2_fifo *fifo, u_long cmd, void *addr,
|
||||||
int fflags, struct thread *td)
|
int fflags)
|
||||||
{
|
{
|
||||||
struct ufm_softc *sc = fifo->priv_sc0;
|
struct ufm_softc *sc = fifo->priv_sc0;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
@ -395,7 +395,7 @@ ulpt_stop_write(struct usb2_fifo *fifo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ulpt_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
ulpt_open(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
struct ulpt_softc *sc = fifo->priv_sc0;
|
struct ulpt_softc *sc = fifo->priv_sc0;
|
||||||
|
|
||||||
@ -404,11 +404,11 @@ ulpt_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
if (sc->sc_fflags == 0) {
|
if (sc->sc_fflags == 0) {
|
||||||
ulpt_reset(sc);
|
ulpt_reset(sc);
|
||||||
}
|
}
|
||||||
return (unlpt_open(fifo, fflags, td));
|
return (unlpt_open(fifo, fflags));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unlpt_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
unlpt_open(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
struct ulpt_softc *sc = fifo->priv_sc0;
|
struct ulpt_softc *sc = fifo->priv_sc0;
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ unlpt_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ulpt_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
ulpt_close(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
struct ulpt_softc *sc = fifo->priv_sc0;
|
struct ulpt_softc *sc = fifo->priv_sc0;
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ ulpt_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
ulpt_ioctl(struct usb2_fifo *fifo, u_long cmd, void *data,
|
ulpt_ioctl(struct usb2_fifo *fifo, u_long cmd, void *data,
|
||||||
int fflags, struct thread *td)
|
int fflags)
|
||||||
{
|
{
|
||||||
return (ENODEV);
|
return (ENODEV);
|
||||||
}
|
}
|
||||||
@ -595,19 +595,17 @@ ulpt_attach(device_t dev)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* set interface permissions */
|
|
||||||
usb2_set_iface_perm(uaa->device, uaa->info.bIfaceIndex,
|
|
||||||
UID_ROOT, GID_OPERATOR, 0644);
|
|
||||||
|
|
||||||
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
||||||
&ulpt_fifo_methods, &sc->sc_fifo,
|
&ulpt_fifo_methods, &sc->sc_fifo,
|
||||||
unit, 0 - 1, uaa->info.bIfaceIndex);
|
unit, 0 - 1, uaa->info.bIfaceIndex,
|
||||||
|
UID_ROOT, GID_OPERATOR, 0644);
|
||||||
if (error) {
|
if (error) {
|
||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
||||||
&unlpt_fifo_methods, &sc->sc_fifo_noreset,
|
&unlpt_fifo_methods, &sc->sc_fifo_noreset,
|
||||||
unit, 0 - 1, uaa->info.bIfaceIndex);
|
unit, 0 - 1, uaa->info.bIfaceIndex,
|
||||||
|
UID_ROOT, GID_OPERATOR, 0644);
|
||||||
if (error) {
|
if (error) {
|
||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
|
@ -228,13 +228,11 @@ urio_attach(device_t dev)
|
|||||||
DPRINTF("error=%s\n", usb2_errstr(error));
|
DPRINTF("error=%s\n", usb2_errstr(error));
|
||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
/* set interface permissions */
|
|
||||||
usb2_set_iface_perm(uaa->device, uaa->info.bIfaceIndex,
|
|
||||||
UID_ROOT, GID_OPERATOR, 0644);
|
|
||||||
|
|
||||||
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
error = usb2_fifo_attach(uaa->device, sc, &sc->sc_mtx,
|
||||||
&urio_fifo_methods, &sc->sc_fifo,
|
&urio_fifo_methods, &sc->sc_fifo,
|
||||||
device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex);
|
device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex,
|
||||||
|
UID_ROOT, GID_OPERATOR, 0644);
|
||||||
if (error) {
|
if (error) {
|
||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
@ -370,7 +368,7 @@ urio_stop_write(struct usb2_fifo *fifo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
urio_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
urio_open(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
struct urio_softc *sc = fifo->priv_sc0;
|
struct urio_softc *sc = fifo->priv_sc0;
|
||||||
|
|
||||||
@ -403,7 +401,7 @@ urio_open(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
urio_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
urio_close(struct usb2_fifo *fifo, int fflags)
|
||||||
{
|
{
|
||||||
if (fflags & (FREAD | FWRITE)) {
|
if (fflags & (FREAD | FWRITE)) {
|
||||||
usb2_fifo_free_buffer(fifo);
|
usb2_fifo_free_buffer(fifo);
|
||||||
@ -412,7 +410,7 @@ urio_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
urio_ioctl(struct usb2_fifo *fifo, u_long cmd, void *addr,
|
urio_ioctl(struct usb2_fifo *fifo, u_long cmd, void *addr,
|
||||||
int fflags, struct thread *td)
|
int fflags)
|
||||||
{
|
{
|
||||||
struct usb2_ctl_request ur;
|
struct usb2_ctl_request ur;
|
||||||
struct RioCommand *rio_cmd;
|
struct RioCommand *rio_cmd;
|
||||||
|
@ -69,7 +69,6 @@ struct usb2_bus {
|
|||||||
* This mutex protects the USB hardware:
|
* This mutex protects the USB hardware:
|
||||||
*/
|
*/
|
||||||
struct mtx bus_mtx;
|
struct mtx bus_mtx;
|
||||||
struct usb2_perm perm;
|
|
||||||
struct usb2_xfer_queue intr_q;
|
struct usb2_xfer_queue intr_q;
|
||||||
struct usb2_callout power_wdog; /* power management */
|
struct usb2_callout power_wdog; /* power management */
|
||||||
|
|
||||||
|
@ -177,16 +177,6 @@ typedef void (usb2_callback_t)(struct usb2_xfer *);
|
|||||||
|
|
||||||
/* structures */
|
/* structures */
|
||||||
|
|
||||||
/*
|
|
||||||
* This structure contains permissions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct usb2_perm {
|
|
||||||
uint32_t uid;
|
|
||||||
uint32_t gid;
|
|
||||||
uint16_t mode;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Common queue structure for USB transfers.
|
* Common queue structure for USB transfers.
|
||||||
*/
|
*/
|
||||||
@ -383,25 +373,6 @@ struct usb2_attach_arg {
|
|||||||
uint8_t use_generic; /* hint for generic drivers */
|
uint8_t use_generic; /* hint for generic drivers */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Structure used when referring an USB device */
|
|
||||||
|
|
||||||
struct usb2_location {
|
|
||||||
struct usb2_bus *bus;
|
|
||||||
struct usb2_device *udev;
|
|
||||||
struct usb2_interface *iface;
|
|
||||||
struct usb2_fifo *rxfifo;
|
|
||||||
struct usb2_fifo *txfifo;
|
|
||||||
uint32_t devloc; /* original devloc */
|
|
||||||
uint16_t bus_index; /* bus index */
|
|
||||||
uint8_t dev_index; /* device index */
|
|
||||||
uint8_t iface_index; /* interface index */
|
|
||||||
uint8_t fifo_index; /* FIFO index */
|
|
||||||
uint8_t is_read; /* set if location has read access */
|
|
||||||
uint8_t is_write; /* set if location has write access */
|
|
||||||
uint8_t is_uref; /* set if USB refcount decr. needed */
|
|
||||||
uint8_t is_usbfs; /* set if USB-FS is active */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* external variables */
|
/* external variables */
|
||||||
|
|
||||||
MALLOC_DECLARE(M_USB);
|
MALLOC_DECLARE(M_USB);
|
||||||
@ -449,13 +420,8 @@ uint8_t usb2_transfer_pending(struct usb2_xfer *xfer);
|
|||||||
void usb2_transfer_start(struct usb2_xfer *xfer);
|
void usb2_transfer_start(struct usb2_xfer *xfer);
|
||||||
void usb2_transfer_stop(struct usb2_xfer *xfer);
|
void usb2_transfer_stop(struct usb2_xfer *xfer);
|
||||||
void usb2_transfer_unsetup(struct usb2_xfer **pxfer, uint16_t n_setup);
|
void usb2_transfer_unsetup(struct usb2_xfer **pxfer, uint16_t n_setup);
|
||||||
usb2_error_t usb2_ref_device(struct file *fp, struct usb2_location *ploc,
|
|
||||||
uint32_t devloc);
|
|
||||||
void usb2_unref_device(struct usb2_location *ploc);
|
|
||||||
void usb2_set_parent_iface(struct usb2_device *udev, uint8_t iface_index,
|
void usb2_set_parent_iface(struct usb2_device *udev, uint8_t iface_index,
|
||||||
uint8_t parent_index);
|
uint8_t parent_index);
|
||||||
void usb2_set_iface_perm(struct usb2_device *udev, uint8_t iface_index,
|
|
||||||
uint32_t uid, uint32_t gid, uint16_t mode);
|
|
||||||
uint8_t usb2_get_bus_index(struct usb2_device *udev);
|
uint8_t usb2_get_bus_index(struct usb2_device *udev);
|
||||||
uint8_t usb2_get_device_index(struct usb2_device *udev);
|
uint8_t usb2_get_device_index(struct usb2_device *udev);
|
||||||
void usb2_set_power_mode(struct usb2_device *udev, uint8_t power_mode);
|
void usb2_set_power_mode(struct usb2_device *udev, uint8_t power_mode);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -41,9 +41,9 @@
|
|||||||
struct usb2_fifo;
|
struct usb2_fifo;
|
||||||
struct usb2_mbuf;
|
struct usb2_mbuf;
|
||||||
|
|
||||||
typedef int (usb2_fifo_open_t)(struct usb2_fifo *fifo, int fflags, struct thread *td);
|
typedef int (usb2_fifo_open_t)(struct usb2_fifo *fifo, int fflags);
|
||||||
typedef void (usb2_fifo_close_t)(struct usb2_fifo *fifo, int fflags, struct thread *td);
|
typedef void (usb2_fifo_close_t)(struct usb2_fifo *fifo, int fflags);
|
||||||
typedef int (usb2_fifo_ioctl_t)(struct usb2_fifo *fifo, u_long cmd, void *addr, int fflags, struct thread *td);
|
typedef int (usb2_fifo_ioctl_t)(struct usb2_fifo *fifo, u_long cmd, void *addr, int fflags);
|
||||||
typedef void (usb2_fifo_cmd_t)(struct usb2_fifo *fifo);
|
typedef void (usb2_fifo_cmd_t)(struct usb2_fifo *fifo);
|
||||||
typedef void (usb2_fifo_filter_t)(struct usb2_fifo *fifo, struct usb2_mbuf *m);
|
typedef void (usb2_fifo_filter_t)(struct usb2_fifo *fifo, struct usb2_mbuf *m);
|
||||||
|
|
||||||
@ -81,6 +81,39 @@ struct usb2_fifo_methods {
|
|||||||
const char *postfix[4];
|
const char *postfix[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Private per-device information.
|
||||||
|
*/
|
||||||
|
struct usb2_cdev_privdata {
|
||||||
|
struct usb2_bus *bus;
|
||||||
|
struct usb2_device *udev;
|
||||||
|
struct usb2_interface *iface;
|
||||||
|
struct usb2_fifo *rxfifo;
|
||||||
|
struct usb2_fifo *txfifo;
|
||||||
|
int bus_index; /* bus index */
|
||||||
|
int dev_index; /* device index */
|
||||||
|
int iface_index; /* interface index */
|
||||||
|
int ep_addr; /* endpoint address */
|
||||||
|
uint8_t fifo_index; /* FIFO index */
|
||||||
|
uint8_t is_read; /* location has read access */
|
||||||
|
uint8_t is_write; /* location has write access */
|
||||||
|
uint8_t is_uref; /* USB refcount decr. needed */
|
||||||
|
uint8_t is_usbfs; /* USB-FS is active */
|
||||||
|
int fflags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct usb2_fs_privdata {
|
||||||
|
int bus_index;
|
||||||
|
int dev_index;
|
||||||
|
int iface_index;
|
||||||
|
int ep_addr;
|
||||||
|
int mode;
|
||||||
|
int fifo_index;
|
||||||
|
struct cdev *cdev;
|
||||||
|
|
||||||
|
LIST_ENTRY(usb2_fs_privdata) pd_next;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Most of the fields in the "usb2_fifo" structure are used by the
|
* Most of the fields in the "usb2_fifo" structure are used by the
|
||||||
* generic USB access layer.
|
* generic USB access layer.
|
||||||
@ -99,7 +132,7 @@ struct usb2_fifo {
|
|||||||
struct usb2_xfer *xfer[2];
|
struct usb2_xfer *xfer[2];
|
||||||
struct usb2_xfer **fs_xfer;
|
struct usb2_xfer **fs_xfer;
|
||||||
struct mtx *priv_mtx; /* client data */
|
struct mtx *priv_mtx; /* client data */
|
||||||
struct file *curr_file; /* set if FIFO is opened by a FILE */
|
int opened; /* set if FIFO is opened by a FILE */
|
||||||
void *priv_sc0; /* client data */
|
void *priv_sc0; /* client data */
|
||||||
void *priv_sc1; /* client data */
|
void *priv_sc1; /* client data */
|
||||||
void *queue_data;
|
void *queue_data;
|
||||||
@ -126,8 +159,11 @@ struct usb2_fifo {
|
|||||||
|
|
||||||
struct usb2_fifo_sc {
|
struct usb2_fifo_sc {
|
||||||
struct usb2_fifo *fp[2];
|
struct usb2_fifo *fp[2];
|
||||||
|
struct cdev* dev;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern struct cdevsw usb2_devsw;
|
||||||
|
|
||||||
int usb2_fifo_wait(struct usb2_fifo *fifo);
|
int usb2_fifo_wait(struct usb2_fifo *fifo);
|
||||||
void usb2_fifo_signal(struct usb2_fifo *fifo);
|
void usb2_fifo_signal(struct usb2_fifo *fifo);
|
||||||
int usb2_fifo_alloc_buffer(struct usb2_fifo *f, uint32_t bufsize,
|
int usb2_fifo_alloc_buffer(struct usb2_fifo *f, uint32_t bufsize,
|
||||||
@ -136,7 +172,7 @@ void usb2_fifo_free_buffer(struct usb2_fifo *f);
|
|||||||
int usb2_fifo_attach(struct usb2_device *udev, void *priv_sc,
|
int usb2_fifo_attach(struct usb2_device *udev, void *priv_sc,
|
||||||
struct mtx *priv_mtx, struct usb2_fifo_methods *pm,
|
struct mtx *priv_mtx, struct usb2_fifo_methods *pm,
|
||||||
struct usb2_fifo_sc *f_sc, uint16_t unit, uint16_t subunit,
|
struct usb2_fifo_sc *f_sc, uint16_t unit, uint16_t subunit,
|
||||||
uint8_t iface_index);
|
uint8_t iface_index, uid_t uid, gid_t gid, int mode);
|
||||||
void usb2_fifo_detach(struct usb2_fifo_sc *f_sc);
|
void usb2_fifo_detach(struct usb2_fifo_sc *f_sc);
|
||||||
uint32_t usb2_fifo_put_bytes_max(struct usb2_fifo *fifo);
|
uint32_t usb2_fifo_put_bytes_max(struct usb2_fifo *fifo);
|
||||||
void usb2_fifo_put_data(struct usb2_fifo *fifo, struct usb2_page_cache *pc,
|
void usb2_fifo_put_data(struct usb2_fifo *fifo, struct usb2_page_cache *pc,
|
||||||
@ -155,13 +191,9 @@ void usb2_fifo_get_data_error(struct usb2_fifo *fifo);
|
|||||||
uint8_t usb2_fifo_opened(struct usb2_fifo *fifo);
|
uint8_t usb2_fifo_opened(struct usb2_fifo *fifo);
|
||||||
void usb2_fifo_free(struct usb2_fifo *f);
|
void usb2_fifo_free(struct usb2_fifo *f);
|
||||||
void usb2_fifo_reset(struct usb2_fifo *f);
|
void usb2_fifo_reset(struct usb2_fifo *f);
|
||||||
int usb2_check_thread_perm(struct usb2_device *udev, struct thread *td,
|
|
||||||
int fflags, uint8_t iface_index, uint8_t ep_index);
|
|
||||||
void usb2_fifo_wakeup(struct usb2_fifo *f);
|
void usb2_fifo_wakeup(struct usb2_fifo *f);
|
||||||
struct usb2_symlink *usb2_alloc_symlink(const char *target,
|
struct usb2_symlink *usb2_alloc_symlink(const char *target);
|
||||||
const char *fmt,...);
|
|
||||||
void usb2_free_symlink(struct usb2_symlink *ps);
|
void usb2_free_symlink(struct usb2_symlink *ps);
|
||||||
uint32_t usb2_lookup_symlink(const char *src_ptr, uint8_t src_len);
|
|
||||||
int usb2_read_symlink(uint8_t *user_ptr, uint32_t startentry,
|
int usb2_read_symlink(uint8_t *user_ptr, uint32_t startentry,
|
||||||
uint32_t user_len);
|
uint32_t user_len);
|
||||||
|
|
||||||
|
@ -74,6 +74,10 @@ static usb2_error_t usb2_fill_iface_data(struct usb2_device *, uint8_t,
|
|||||||
uint8_t);
|
uint8_t);
|
||||||
static void usb2_notify_addq(const char *type, struct usb2_device *);
|
static void usb2_notify_addq(const char *type, struct usb2_device *);
|
||||||
static void usb2_fifo_free_wrap(struct usb2_device *, uint8_t, uint8_t);
|
static void usb2_fifo_free_wrap(struct usb2_device *, uint8_t, uint8_t);
|
||||||
|
static struct cdev *usb2_make_dev(struct usb2_device *, int, int, int);
|
||||||
|
static void usb2_cdev_create(struct usb2_device *);
|
||||||
|
static void usb2_cdev_free(struct usb2_device *);
|
||||||
|
static void usb2_cdev_cleanup(void *);
|
||||||
|
|
||||||
/* This variable is global to allow easy access to it: */
|
/* This variable is global to allow easy access to it: */
|
||||||
|
|
||||||
@ -274,6 +278,7 @@ static void
|
|||||||
usb2_fill_pipe_data(struct usb2_device *udev, uint8_t iface_index,
|
usb2_fill_pipe_data(struct usb2_device *udev, uint8_t iface_index,
|
||||||
struct usb2_endpoint_descriptor *edesc, struct usb2_pipe *pipe)
|
struct usb2_endpoint_descriptor *edesc, struct usb2_pipe *pipe)
|
||||||
{
|
{
|
||||||
|
|
||||||
bzero(pipe, sizeof(*pipe));
|
bzero(pipe, sizeof(*pipe));
|
||||||
|
|
||||||
(udev->bus->methods->pipe_init) (udev, edesc, pipe);
|
(udev->bus->methods->pipe_init) (udev, edesc, pipe);
|
||||||
@ -416,6 +421,7 @@ usb2_fill_iface_data(struct usb2_device *udev,
|
|||||||
iface->idesc = id;
|
iface->idesc = id;
|
||||||
iface->alt_index = alt_index;
|
iface->alt_index = alt_index;
|
||||||
iface->parent_iface_index = USB_IFACE_INDEX_ANY;
|
iface->parent_iface_index = USB_IFACE_INDEX_ANY;
|
||||||
|
iface->ep_in_mask = iface->ep_out_mask = 0;
|
||||||
|
|
||||||
nendpt = id->bNumEndpoints;
|
nendpt = id->bNumEndpoints;
|
||||||
DPRINTFN(5, "found idesc nendpt=%d\n", nendpt);
|
DPRINTFN(5, "found idesc nendpt=%d\n", nendpt);
|
||||||
@ -439,6 +445,14 @@ usb2_fill_iface_data(struct usb2_device *udev,
|
|||||||
found:
|
found:
|
||||||
ed = (void *)desc;
|
ed = (void *)desc;
|
||||||
|
|
||||||
|
/* Fill in the endpoint bitmasks */
|
||||||
|
if (ed->bEndpointAddress & UE_DIR_IN)
|
||||||
|
iface->ep_in_mask |=
|
||||||
|
1 << UE_GET_ADDR(ed->bEndpointAddress);
|
||||||
|
else
|
||||||
|
iface->ep_out_mask |=
|
||||||
|
1 << UE_GET_ADDR(ed->bEndpointAddress);
|
||||||
|
|
||||||
/* find a free pipe */
|
/* find a free pipe */
|
||||||
while (pipe != pipe_end) {
|
while (pipe != pipe_end) {
|
||||||
if (pipe->edesc == NULL) {
|
if (pipe->edesc == NULL) {
|
||||||
@ -488,7 +502,6 @@ usb2_free_iface_data(struct usb2_device *udev)
|
|||||||
iface->idesc = NULL;
|
iface->idesc = NULL;
|
||||||
iface->alt_index = 0;
|
iface->alt_index = 0;
|
||||||
iface->parent_iface_index = USB_IFACE_INDEX_ANY;
|
iface->parent_iface_index = USB_IFACE_INDEX_ANY;
|
||||||
iface->perm.mode = 0; /* disable permissions */
|
|
||||||
iface++;
|
iface++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,6 +556,7 @@ usb2_set_config_index(struct usb2_device *udev, uint8_t index)
|
|||||||
usb2_fifo_free_wrap(udev, USB_IFACE_INDEX_ANY, 0);
|
usb2_fifo_free_wrap(udev, USB_IFACE_INDEX_ANY, 0);
|
||||||
|
|
||||||
/* free all configuration data structures */
|
/* free all configuration data structures */
|
||||||
|
usb2_cdev_free(udev);
|
||||||
usb2_free_iface_data(udev);
|
usb2_free_iface_data(udev);
|
||||||
|
|
||||||
if (index == USB_UNCONFIG_INDEX) {
|
if (index == USB_UNCONFIG_INDEX) {
|
||||||
@ -652,10 +666,13 @@ usb2_set_config_index(struct usb2_device *udev, uint8_t index)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* create device nodes for each endpoint */
|
||||||
|
usb2_cdev_create(udev);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
DPRINTF("error=%s\n", usb2_errstr(err));
|
DPRINTF("error=%s\n", usb2_errstr(err));
|
||||||
if (err) {
|
if (err) {
|
||||||
|
usb2_cdev_free(udev);
|
||||||
usb2_free_iface_data(udev);
|
usb2_free_iface_data(udev);
|
||||||
}
|
}
|
||||||
if (do_unlock) {
|
if (do_unlock) {
|
||||||
@ -713,6 +730,7 @@ usb2_set_alt_interface_index(struct usb2_device *udev,
|
|||||||
* Free all generic FIFOs for this interface, except control
|
* Free all generic FIFOs for this interface, except control
|
||||||
* endpoint FIFOs:
|
* endpoint FIFOs:
|
||||||
*/
|
*/
|
||||||
|
usb2_cdev_free(udev);
|
||||||
usb2_fifo_free_wrap(udev, iface_index, 0);
|
usb2_fifo_free_wrap(udev, iface_index, 0);
|
||||||
|
|
||||||
err = usb2_fill_iface_data(udev, iface_index, alt_index);
|
err = usb2_fill_iface_data(udev, iface_index, alt_index);
|
||||||
@ -722,6 +740,9 @@ usb2_set_alt_interface_index(struct usb2_device *udev,
|
|||||||
err = usb2_req_set_alt_interface_no(udev, NULL, iface_index,
|
err = usb2_req_set_alt_interface_no(udev, NULL, iface_index,
|
||||||
iface->idesc->bAlternateSetting);
|
iface->idesc->bAlternateSetting);
|
||||||
|
|
||||||
|
/* create device nodes for each endpoint */
|
||||||
|
usb2_cdev_create(udev);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (do_unlock) {
|
if (do_unlock) {
|
||||||
sx_unlock(udev->default_sx + 1);
|
sx_unlock(udev->default_sx + 1);
|
||||||
@ -1354,6 +1375,8 @@ usb2_alloc_device(device_t parent_dev, struct usb2_bus *bus,
|
|||||||
usb2_cv_init(udev->default_cv, "WCTRL");
|
usb2_cv_init(udev->default_cv, "WCTRL");
|
||||||
usb2_cv_init(udev->default_cv + 1, "UGONE");
|
usb2_cv_init(udev->default_cv + 1, "UGONE");
|
||||||
|
|
||||||
|
LIST_INIT(&udev->pd_list);
|
||||||
|
|
||||||
/* initialise our mutex */
|
/* initialise our mutex */
|
||||||
mtx_init(udev->default_mtx, "USB device mutex", NULL, MTX_DEF);
|
mtx_init(udev->default_mtx, "USB device mutex", NULL, MTX_DEF);
|
||||||
|
|
||||||
@ -1423,6 +1446,14 @@ usb2_alloc_device(device_t parent_dev, struct usb2_bus *bus,
|
|||||||
/* set device index */
|
/* set device index */
|
||||||
udev->device_index = device_index;
|
udev->device_index = device_index;
|
||||||
|
|
||||||
|
/* Create the control endpoint device */
|
||||||
|
udev->default_dev = usb2_make_dev(udev, 0 , 0, FREAD|FWRITE);
|
||||||
|
/* Create a link from /dev/ugenX.X to the default endpoint */
|
||||||
|
snprintf(udev->ugen_name, sizeof(udev->ugen_name),
|
||||||
|
USB_GENERIC_NAME "%u.%u", device_get_unit(bus->bdev),
|
||||||
|
device_index);
|
||||||
|
make_dev_alias(udev->default_dev, udev->ugen_name);
|
||||||
|
|
||||||
if (udev->flags.usb2_mode == USB_MODE_HOST) {
|
if (udev->flags.usb2_mode == USB_MODE_HOST) {
|
||||||
|
|
||||||
err = usb2_req_set_address(udev, NULL, device_index);
|
err = usb2_req_set_address(udev, NULL, device_index);
|
||||||
@ -1673,21 +1704,9 @@ usb2_alloc_device(device_t parent_dev, struct usb2_bus *bus,
|
|||||||
usb2_bus_port_set_device(bus, parent_hub ?
|
usb2_bus_port_set_device(bus, parent_hub ?
|
||||||
parent_hub->hub->ports + port_index : NULL, udev, device_index);
|
parent_hub->hub->ports + port_index : NULL, udev, device_index);
|
||||||
|
|
||||||
/* make a symlink for UGEN */
|
/* Link and announce the ugen device name */
|
||||||
if (snprintf((char *)scratch_ptr, scratch_size,
|
udev->ugen_symlink = usb2_alloc_symlink(udev->ugen_name);
|
||||||
USB_DEVICE_NAME "%u.%u.0.0",
|
printf("%s: <%s> at %s\n", udev->ugen_name, udev->manufacturer,
|
||||||
device_get_unit(udev->bus->bdev),
|
|
||||||
udev->device_index)) {
|
|
||||||
/* ignore */
|
|
||||||
}
|
|
||||||
udev->ugen_symlink =
|
|
||||||
usb2_alloc_symlink((char *)scratch_ptr, "ugen%u.%u",
|
|
||||||
device_get_unit(udev->bus->bdev),
|
|
||||||
udev->device_index);
|
|
||||||
|
|
||||||
printf("ugen%u.%u: <%s> at %s\n",
|
|
||||||
device_get_unit(udev->bus->bdev),
|
|
||||||
udev->device_index, udev->manufacturer,
|
|
||||||
device_get_nameunit(udev->bus->bdev));
|
device_get_nameunit(udev->bus->bdev));
|
||||||
|
|
||||||
usb2_notify_addq("+", udev);
|
usb2_notify_addq("+", udev);
|
||||||
@ -1700,6 +1719,100 @@ usb2_alloc_device(device_t parent_dev, struct usb2_bus *bus,
|
|||||||
return (udev);
|
return (udev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct cdev *
|
||||||
|
usb2_make_dev(struct usb2_device *udev, int iface_index, int ep, int mode)
|
||||||
|
{
|
||||||
|
struct usb2_fs_privdata* pd;
|
||||||
|
char devname[20];
|
||||||
|
|
||||||
|
/* Store information to locate ourselves again later */
|
||||||
|
pd = malloc(sizeof(struct usb2_fs_privdata), M_USBDEV,
|
||||||
|
M_WAITOK | M_ZERO);
|
||||||
|
pd->bus_index = device_get_unit(udev->bus->bdev);
|
||||||
|
pd->dev_index = udev->device_index;
|
||||||
|
pd->iface_index = iface_index;
|
||||||
|
pd->ep_addr = ep;
|
||||||
|
pd->mode = mode;
|
||||||
|
|
||||||
|
/* Now, create the device itself */
|
||||||
|
snprintf(devname, sizeof(devname), "%u.%u.%u.%u",
|
||||||
|
pd->bus_index, pd->dev_index,
|
||||||
|
pd->iface_index, pd->ep_addr);
|
||||||
|
pd->cdev = make_dev(&usb2_devsw, 0, UID_ROOT,
|
||||||
|
GID_OPERATOR, 0600, USB_DEVICE_DIR "/%s", devname);
|
||||||
|
pd->cdev->si_drv1 = pd;
|
||||||
|
|
||||||
|
return (pd->cdev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usb2_cdev_create(struct usb2_device *udev)
|
||||||
|
{
|
||||||
|
struct usb2_interface *iface;
|
||||||
|
struct usb2_fs_privdata* pd;
|
||||||
|
struct cdev *dev;
|
||||||
|
uint8_t niface;
|
||||||
|
int i, ep, mode, inmode, outmode;
|
||||||
|
|
||||||
|
KASSERT(LIST_FIRST(&udev->pd_list) == NULL, ("stale cdev entries"));
|
||||||
|
|
||||||
|
DPRINTFN(2, "Creating device nodes\n");
|
||||||
|
|
||||||
|
usb2_interface_count(udev, &niface);
|
||||||
|
if (niface == 0)
|
||||||
|
return; /* nothing to do */
|
||||||
|
|
||||||
|
if (usb2_get_mode(udev) == USB_MODE_DEVICE) {
|
||||||
|
inmode = FWRITE;
|
||||||
|
outmode = FREAD;
|
||||||
|
} else { /* USB_MODE_HOST */
|
||||||
|
inmode = FREAD;
|
||||||
|
outmode = FWRITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < niface; i++) {
|
||||||
|
iface = usb2_get_iface(udev, i);
|
||||||
|
if (iface == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Create all available endpoints except EP0 */
|
||||||
|
for (ep = 1; ep < 16; ep++) {
|
||||||
|
mode = 0;
|
||||||
|
mode |= iface->ep_in_mask & (1 << ep) ? inmode : 0;
|
||||||
|
mode |= iface->ep_out_mask & (1 << ep) ? outmode : 0;
|
||||||
|
if (mode == 0)
|
||||||
|
continue; /* no IN or OUT endpoint */
|
||||||
|
|
||||||
|
dev = usb2_make_dev(udev, i , ep, mode);
|
||||||
|
pd = dev->si_drv1;
|
||||||
|
LIST_INSERT_HEAD(&udev->pd_list, pd, pd_next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usb2_cdev_free(struct usb2_device *udev)
|
||||||
|
{
|
||||||
|
struct usb2_fs_privdata* pd;
|
||||||
|
|
||||||
|
DPRINTFN(2, "Freeing device nodes\n");
|
||||||
|
|
||||||
|
while ((pd = LIST_FIRST(&udev->pd_list)) != NULL) {
|
||||||
|
KASSERT(pd->cdev->si_drv1 == pd, ("privdata corrupt"));
|
||||||
|
KASSERT(pd->ep_addr > 0, ("freeing EP0"));
|
||||||
|
|
||||||
|
destroy_dev_sched_cb(pd->cdev, usb2_cdev_cleanup, pd);
|
||||||
|
pd->cdev = NULL;
|
||||||
|
LIST_REMOVE(pd, pd_next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usb2_cdev_cleanup(void* arg)
|
||||||
|
{
|
||||||
|
free(arg, M_USBDEV);
|
||||||
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*
|
/*------------------------------------------------------------------------*
|
||||||
* usb2_free_device
|
* usb2_free_device
|
||||||
*
|
*
|
||||||
@ -1708,26 +1821,16 @@ usb2_alloc_device(device_t parent_dev, struct usb2_bus *bus,
|
|||||||
void
|
void
|
||||||
usb2_free_device(struct usb2_device *udev)
|
usb2_free_device(struct usb2_device *udev)
|
||||||
{
|
{
|
||||||
struct usb2_bus *bus;
|
struct usb2_bus *bus = udev->bus;;
|
||||||
|
|
||||||
if (udev == NULL) {
|
|
||||||
/* already freed */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DPRINTFN(4, "udev=%p port=%d\n", udev, udev->port_no);
|
DPRINTFN(4, "udev=%p port=%d\n", udev, udev->port_no);
|
||||||
|
|
||||||
usb2_notify_addq("-", udev);
|
usb2_notify_addq("-", udev);
|
||||||
|
|
||||||
bus = udev->bus;
|
printf("%s: <%s> at %s (disconnected)\n", udev->ugen_name,
|
||||||
|
udev->manufacturer, device_get_nameunit(bus->bdev));
|
||||||
|
|
||||||
printf("ugen%u.%u: <%s> at %s (disconnected)\n",
|
/* Destroy UGEN symlink, if any */
|
||||||
device_get_unit(bus->bdev),
|
|
||||||
udev->device_index, udev->manufacturer,
|
|
||||||
device_get_nameunit(bus->bdev));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Destroy UGEN symlink, if any
|
|
||||||
*/
|
|
||||||
if (udev->ugen_symlink) {
|
if (udev->ugen_symlink) {
|
||||||
usb2_free_symlink(udev->ugen_symlink);
|
usb2_free_symlink(udev->ugen_symlink);
|
||||||
udev->ugen_symlink = NULL;
|
udev->ugen_symlink = NULL;
|
||||||
@ -1759,7 +1862,10 @@ usb2_free_device(struct usb2_device *udev)
|
|||||||
/*
|
/*
|
||||||
* Free all interface related data and FIFOs, if any.
|
* Free all interface related data and FIFOs, if any.
|
||||||
*/
|
*/
|
||||||
|
usb2_cdev_free(udev);
|
||||||
usb2_free_iface_data(udev);
|
usb2_free_iface_data(udev);
|
||||||
|
destroy_dev_sched_cb(udev->default_dev, usb2_cdev_cleanup,
|
||||||
|
udev->default_dev->si_drv1);
|
||||||
|
|
||||||
/* unsetup any leftover default USB transfers */
|
/* unsetup any leftover default USB transfers */
|
||||||
usb2_transfer_unsetup(udev->default_xfer, USB_DEFAULT_XFER_MAX);
|
usb2_transfer_unsetup(udev->default_xfer, USB_DEFAULT_XFER_MAX);
|
||||||
@ -1783,6 +1889,7 @@ usb2_free_device(struct usb2_device *udev)
|
|||||||
usb2_cv_destroy(udev->default_cv + 1);
|
usb2_cv_destroy(udev->default_cv + 1);
|
||||||
|
|
||||||
mtx_destroy(udev->default_mtx);
|
mtx_destroy(udev->default_mtx);
|
||||||
|
KASSERT(LIST_FIRST(&udev->pd_list) == NULL, ("leaked cdev entries"));
|
||||||
|
|
||||||
/* free device */
|
/* free device */
|
||||||
free(udev, M_USB);
|
free(udev, M_USB);
|
||||||
@ -2112,7 +2219,7 @@ usb2_notify_addq(const char *type, struct usb2_device *udev)
|
|||||||
if (udev->parent_hub) {
|
if (udev->parent_hub) {
|
||||||
snprintf(data, 1024,
|
snprintf(data, 1024,
|
||||||
"%s"
|
"%s"
|
||||||
"ugen%u.%u "
|
"%s "
|
||||||
"vendor=0x%04x "
|
"vendor=0x%04x "
|
||||||
"product=0x%04x "
|
"product=0x%04x "
|
||||||
"devclass=0x%02x "
|
"devclass=0x%02x "
|
||||||
@ -2121,22 +2228,20 @@ usb2_notify_addq(const char *type, struct usb2_device *udev)
|
|||||||
"at "
|
"at "
|
||||||
"port=%u "
|
"port=%u "
|
||||||
"on "
|
"on "
|
||||||
"ugen%u.%u\n",
|
"%s\n",
|
||||||
type,
|
type,
|
||||||
device_get_unit(udev->bus->bdev),
|
udev->ugen_name,
|
||||||
udev->device_index,
|
|
||||||
UGETW(udev->ddesc.idVendor),
|
UGETW(udev->ddesc.idVendor),
|
||||||
UGETW(udev->ddesc.idProduct),
|
UGETW(udev->ddesc.idProduct),
|
||||||
udev->ddesc.bDeviceClass,
|
udev->ddesc.bDeviceClass,
|
||||||
udev->ddesc.bDeviceSubClass,
|
udev->ddesc.bDeviceSubClass,
|
||||||
udev->serial,
|
udev->serial,
|
||||||
udev->port_no,
|
udev->port_no,
|
||||||
device_get_unit(udev->bus->bdev),
|
udev->parent_hub->ugen_name);
|
||||||
udev->parent_hub->device_index);
|
|
||||||
} else {
|
} else {
|
||||||
snprintf(data, 1024,
|
snprintf(data, 1024,
|
||||||
"%s"
|
"%s"
|
||||||
"ugen%u.%u "
|
"%s "
|
||||||
"vendor=0x%04x "
|
"vendor=0x%04x "
|
||||||
"product=0x%04x "
|
"product=0x%04x "
|
||||||
"devclass=0x%02x "
|
"devclass=0x%02x "
|
||||||
@ -2146,8 +2251,7 @@ usb2_notify_addq(const char *type, struct usb2_device *udev)
|
|||||||
"on "
|
"on "
|
||||||
"%s\n",
|
"%s\n",
|
||||||
type,
|
type,
|
||||||
device_get_unit(udev->bus->bdev),
|
udev->ugen_name,
|
||||||
udev->device_index,
|
|
||||||
UGETW(udev->ddesc.idVendor),
|
UGETW(udev->ddesc.idVendor),
|
||||||
UGETW(udev->ddesc.idProduct),
|
UGETW(udev->ddesc.idProduct),
|
||||||
udev->ddesc.bDeviceClass,
|
udev->ddesc.bDeviceClass,
|
||||||
|
@ -61,11 +61,12 @@ struct usb2_pipe {
|
|||||||
* The following structure defines an USB interface.
|
* The following structure defines an USB interface.
|
||||||
*/
|
*/
|
||||||
struct usb2_interface {
|
struct usb2_interface {
|
||||||
struct usb2_perm perm; /* interface permissions */
|
|
||||||
struct usb2_interface_descriptor *idesc;
|
struct usb2_interface_descriptor *idesc;
|
||||||
device_t subdev;
|
device_t subdev;
|
||||||
uint8_t alt_index;
|
uint8_t alt_index;
|
||||||
uint8_t parent_iface_index;
|
uint8_t parent_iface_index;
|
||||||
|
uint16_t ep_in_mask; /* bitmask of IN endpoints */
|
||||||
|
uint16_t ep_out_mask; /* bitmask of OUT endpoints */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -101,12 +102,12 @@ struct usb2_power_save {
|
|||||||
struct usb2_device {
|
struct usb2_device {
|
||||||
struct usb2_clear_stall_msg cs_msg[2]; /* generic clear stall
|
struct usb2_clear_stall_msg cs_msg[2]; /* generic clear stall
|
||||||
* messages */
|
* messages */
|
||||||
struct usb2_perm perm;
|
|
||||||
struct sx default_sx[2];
|
struct sx default_sx[2];
|
||||||
struct mtx default_mtx[1];
|
struct mtx default_mtx[1];
|
||||||
struct cv default_cv[2];
|
struct cv default_cv[2];
|
||||||
struct usb2_interface ifaces[USB_IFACE_MAX];
|
struct usb2_interface ifaces[USB_IFACE_MAX];
|
||||||
struct usb2_pipe default_pipe; /* Control Endpoint 0 */
|
struct usb2_pipe default_pipe; /* Control Endpoint 0 */
|
||||||
|
struct cdev *default_dev; /* Control Endpoint 0 device node */
|
||||||
struct usb2_pipe pipes[USB_EP_MAX];
|
struct usb2_pipe pipes[USB_EP_MAX];
|
||||||
struct usb2_power_save pwr_save;/* power save data */
|
struct usb2_power_save pwr_save;/* power save data */
|
||||||
|
|
||||||
@ -120,10 +121,16 @@ struct usb2_device {
|
|||||||
struct usb2_temp_data *usb2_template_ptr;
|
struct usb2_temp_data *usb2_template_ptr;
|
||||||
struct usb2_pipe *pipe_curr; /* current clear stall pipe */
|
struct usb2_pipe *pipe_curr; /* current clear stall pipe */
|
||||||
struct usb2_fifo *fifo[USB_FIFO_MAX];
|
struct usb2_fifo *fifo[USB_FIFO_MAX];
|
||||||
|
|
||||||
|
char ugen_name[20]; /* name of ugenX.X device */
|
||||||
struct usb2_symlink *ugen_symlink; /* our generic symlink */
|
struct usb2_symlink *ugen_symlink; /* our generic symlink */
|
||||||
|
|
||||||
|
LIST_HEAD(,usb2_fs_privdata) pd_list;
|
||||||
|
|
||||||
uint32_t plugtime; /* copy of "ticks" */
|
uint32_t plugtime; /* copy of "ticks" */
|
||||||
|
|
||||||
|
uint16_t ep_rd_opened; /* bitmask of endpoints opened */
|
||||||
|
uint16_t ep_wr_opened; /* from the device nodes. */
|
||||||
uint16_t refcount;
|
uint16_t refcount;
|
||||||
#define USB_DEV_REF_MAX 0xffff
|
#define USB_DEV_REF_MAX 0xffff
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ ugen_transfer_setup(struct usb2_fifo *f,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ugen_open(struct usb2_fifo *f, int fflags, struct thread *td)
|
ugen_open(struct usb2_fifo *f, int fflags)
|
||||||
{
|
{
|
||||||
struct usb2_pipe *pipe = f->priv_sc0;
|
struct usb2_pipe *pipe = f->priv_sc0;
|
||||||
struct usb2_endpoint_descriptor *ed = pipe->edesc;
|
struct usb2_endpoint_descriptor *ed = pipe->edesc;
|
||||||
@ -183,7 +183,7 @@ ugen_open(struct usb2_fifo *f, int fflags, struct thread *td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ugen_close(struct usb2_fifo *f, int fflags, struct thread *td)
|
ugen_close(struct usb2_fifo *f, int fflags)
|
||||||
{
|
{
|
||||||
DPRINTFN(6, "flag=0x%x\n", fflags);
|
DPRINTFN(6, "flag=0x%x\n", fflags);
|
||||||
|
|
||||||
@ -872,10 +872,6 @@ ugen_check_request(struct usb2_device *udev, struct usb2_device_request *req)
|
|||||||
if (pipe == NULL) {
|
if (pipe == NULL) {
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
if (usb2_check_thread_perm(udev, curthread, FREAD | FWRITE,
|
|
||||||
pipe->iface_index, req->wIndex[0] & UE_ADDR)) {
|
|
||||||
return (EPERM);
|
|
||||||
}
|
|
||||||
if ((req->bRequest == UR_CLEAR_FEATURE) &&
|
if ((req->bRequest == UR_CLEAR_FEATURE) &&
|
||||||
(UGETW(req->wValue) == UF_ENDPOINT_HALT)) {
|
(UGETW(req->wValue) == UF_ENDPOINT_HALT)) {
|
||||||
usb2_clear_data_toggle(udev, pipe);
|
usb2_clear_data_toggle(udev, pipe);
|
||||||
@ -1367,8 +1363,7 @@ ugen_fifo_in_use(struct usb2_fifo *f, int fflags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ugen_ioctl(struct usb2_fifo *f, u_long cmd, void *addr, int fflags,
|
ugen_ioctl(struct usb2_fifo *f, u_long cmd, void *addr, int fflags)
|
||||||
struct thread *td)
|
|
||||||
{
|
{
|
||||||
struct usb2_config usb2_config[1];
|
struct usb2_config usb2_config[1];
|
||||||
struct usb2_device_request req;
|
struct usb2_device_request req;
|
||||||
@ -1458,11 +1453,6 @@ ugen_ioctl(struct usb2_fifo *f, u_long cmd, void *addr, int fflags,
|
|||||||
}
|
}
|
||||||
iface_index = pipe->iface_index;
|
iface_index = pipe->iface_index;
|
||||||
|
|
||||||
error = usb2_check_thread_perm(f->udev, curthread, fflags,
|
|
||||||
iface_index, u.popen->ep_no);
|
|
||||||
if (error) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
bzero(usb2_config, sizeof(usb2_config));
|
bzero(usb2_config, sizeof(usb2_config));
|
||||||
|
|
||||||
usb2_config[0].type = ed->bmAttributes & UE_XFERTYPE;
|
usb2_config[0].type = ed->bmAttributes & UE_XFERTYPE;
|
||||||
@ -1948,8 +1938,7 @@ ugen_iface_ioctl(struct usb2_fifo *f, u_long cmd, void *addr, int fflags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ugen_ioctl_post(struct usb2_fifo *f, u_long cmd, void *addr, int fflags,
|
ugen_ioctl_post(struct usb2_fifo *f, u_long cmd, void *addr, int fflags)
|
||||||
struct thread *td)
|
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
struct usb2_interface_descriptor *idesc;
|
struct usb2_interface_descriptor *idesc;
|
||||||
|
@ -36,7 +36,8 @@
|
|||||||
#include <dev/usb/usb_endian.h>
|
#include <dev/usb/usb_endian.h>
|
||||||
#include <dev/usb/usb.h>
|
#include <dev/usb/usb.h>
|
||||||
|
|
||||||
#define USB_DEVICE_NAME "usb"
|
#define USB_DEVICE_NAME "usbctl"
|
||||||
|
#define USB_DEVICE_DIR "usb"
|
||||||
#define USB_GENERIC_NAME "ugen"
|
#define USB_GENERIC_NAME "ugen"
|
||||||
|
|
||||||
struct usb2_read_dir {
|
struct usb2_read_dir {
|
||||||
@ -180,18 +181,6 @@ struct usb2_fs_clear_stall_sync {
|
|||||||
uint8_t ep_index;
|
uint8_t ep_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usb2_dev_perm {
|
|
||||||
/* Access information */
|
|
||||||
uint32_t user_id;
|
|
||||||
uint32_t group_id;
|
|
||||||
uint16_t mode;
|
|
||||||
|
|
||||||
/* Device location */
|
|
||||||
uint16_t bus_index;
|
|
||||||
uint16_t dev_index;
|
|
||||||
uint16_t iface_index;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct usb2_gen_quirk {
|
struct usb2_gen_quirk {
|
||||||
uint16_t index; /* Quirk Index */
|
uint16_t index; /* Quirk Index */
|
||||||
uint16_t vid; /* Vendor ID */
|
uint16_t vid; /* Vendor ID */
|
||||||
@ -248,14 +237,7 @@ struct usb2_gen_quirk {
|
|||||||
#define USB_IFACE_DRIVER_DETACH _IOW ('U', 125, int)
|
#define USB_IFACE_DRIVER_DETACH _IOW ('U', 125, int)
|
||||||
#define USB_GET_PLUGTIME _IOR ('U', 126, uint32_t)
|
#define USB_GET_PLUGTIME _IOR ('U', 126, uint32_t)
|
||||||
#define USB_READ_DIR _IOW ('U', 127, struct usb2_read_dir)
|
#define USB_READ_DIR _IOW ('U', 127, struct usb2_read_dir)
|
||||||
#define USB_SET_ROOT_PERM _IOW ('U', 128, struct usb2_dev_perm)
|
/* 128 - 135 unused */
|
||||||
#define USB_SET_BUS_PERM _IOW ('U', 129, struct usb2_dev_perm)
|
|
||||||
#define USB_SET_DEVICE_PERM _IOW ('U', 130, struct usb2_dev_perm)
|
|
||||||
#define USB_SET_IFACE_PERM _IOW ('U', 131, struct usb2_dev_perm)
|
|
||||||
#define USB_GET_ROOT_PERM _IOWR('U', 132, struct usb2_dev_perm)
|
|
||||||
#define USB_GET_BUS_PERM _IOWR('U', 133, struct usb2_dev_perm)
|
|
||||||
#define USB_GET_DEVICE_PERM _IOWR('U', 134, struct usb2_dev_perm)
|
|
||||||
#define USB_GET_IFACE_PERM _IOWR('U', 135, struct usb2_dev_perm)
|
|
||||||
#define USB_SET_TX_FORCE_SHORT _IOW ('U', 136, int)
|
#define USB_SET_TX_FORCE_SHORT _IOW ('U', 136, int)
|
||||||
#define USB_SET_TX_TIMEOUT _IOW ('U', 137, int)
|
#define USB_SET_TX_TIMEOUT _IOW ('U', 137, int)
|
||||||
#define USB_GET_TX_FRAME_SIZE _IOR ('U', 138, int)
|
#define USB_GET_TX_FRAME_SIZE _IOR ('U', 138, int)
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
* is created, otherwise 1.
|
* is created, otherwise 1.
|
||||||
*/
|
*/
|
||||||
#undef __FreeBSD_version
|
#undef __FreeBSD_version
|
||||||
#define __FreeBSD_version 800065 /* Master, propagated to newvers */
|
#define __FreeBSD_version 800066 /* Master, propagated to newvers */
|
||||||
|
|
||||||
#ifndef LOCORE
|
#ifndef LOCORE
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -262,107 +262,6 @@ dump_be_dev_quirks(struct libusb20_backend *pbe)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
dump_be_access(struct libusb20_backend *pbe)
|
|
||||||
{
|
|
||||||
struct group *gr;
|
|
||||||
struct passwd *pw;
|
|
||||||
const char *owner;
|
|
||||||
const char *group;
|
|
||||||
uid_t uid;
|
|
||||||
gid_t gid;
|
|
||||||
mode_t mode;
|
|
||||||
|
|
||||||
if (libusb20_be_get_owner(pbe, &uid, &gid)) {
|
|
||||||
err(1, "could not get owner");
|
|
||||||
}
|
|
||||||
if (libusb20_be_get_perm(pbe, &mode)) {
|
|
||||||
err(1, "could not get permission");
|
|
||||||
}
|
|
||||||
owner = (pw = getpwuid(uid)) ? pw->pw_name : "UNKNOWN";
|
|
||||||
group = (gr = getgrgid(gid)) ? gr->gr_name : "UNKNOWN";
|
|
||||||
|
|
||||||
if (mode || 1) {
|
|
||||||
printf("Global Access: %s:%s 0%o\n", owner, group, mode);
|
|
||||||
} else {
|
|
||||||
printf("Global Access: <not set>\n");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
dump_device_access(struct libusb20_device *pdev, uint8_t iface)
|
|
||||||
{
|
|
||||||
struct group *gr;
|
|
||||||
struct passwd *pw;
|
|
||||||
const char *owner;
|
|
||||||
const char *group;
|
|
||||||
uid_t uid;
|
|
||||||
gid_t gid;
|
|
||||||
mode_t mode;
|
|
||||||
|
|
||||||
if (libusb20_dev_get_owner(pdev, &uid, &gid)) {
|
|
||||||
err(1, "could not get owner");
|
|
||||||
}
|
|
||||||
if (libusb20_dev_get_perm(pdev, &mode)) {
|
|
||||||
err(1, "could not get permission");
|
|
||||||
}
|
|
||||||
if (mode) {
|
|
||||||
owner = (pw = getpwuid(uid)) ? pw->pw_name : "UNKNOWN";
|
|
||||||
group = (gr = getgrgid(gid)) ? gr->gr_name : "UNKNOWN";
|
|
||||||
|
|
||||||
printf(" " "Device Access: %s:%s 0%o\n", owner, group, mode);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
printf(" " "Device Access: <not set>\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iface == 0xFF) {
|
|
||||||
for (iface = 0; iface != 0xFF; iface++) {
|
|
||||||
if (dump_device_iface_access(pdev, iface)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (dump_device_iface_access(pdev, iface)) {
|
|
||||||
err(1, "could not get interface access info");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dump_device_iface_access(struct libusb20_device *pdev, uint8_t iface)
|
|
||||||
{
|
|
||||||
struct group *gr;
|
|
||||||
struct passwd *pw;
|
|
||||||
const char *owner;
|
|
||||||
const char *group;
|
|
||||||
uid_t uid;
|
|
||||||
gid_t gid;
|
|
||||||
mode_t mode;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
if ((error = libusb20_dev_get_iface_owner(pdev, iface, &uid, &gid))) {
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
if ((error = libusb20_dev_get_iface_perm(pdev, iface, &mode))) {
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
if (mode) {
|
|
||||||
|
|
||||||
owner = (pw = getpwuid(uid)) ? pw->pw_name : "UNKNOWN";
|
|
||||||
group = (gr = getgrgid(gid)) ? gr->gr_name : "UNKNOWN";
|
|
||||||
|
|
||||||
printf(" " "Interface %u Access: %s:%s 0%o\n",
|
|
||||||
iface, owner, group, mode);
|
|
||||||
} else {
|
|
||||||
printf(" " "Interface %u Access: <not set>\n", iface);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
dump_device_desc(struct libusb20_device *pdev)
|
dump_device_desc(struct libusb20_device *pdev)
|
||||||
{
|
{
|
||||||
|
@ -28,10 +28,7 @@ const char *dump_mode(uint8_t value);
|
|||||||
const char *dump_speed(uint8_t value);
|
const char *dump_speed(uint8_t value);
|
||||||
const char *dump_power_mode(uint8_t value);
|
const char *dump_power_mode(uint8_t value);
|
||||||
void dump_device_info(struct libusb20_device *pdev, uint8_t show_drv);
|
void dump_device_info(struct libusb20_device *pdev, uint8_t show_drv);
|
||||||
void dump_be_access(struct libusb20_backend *pbe);
|
|
||||||
void dump_be_quirk_names(struct libusb20_backend *pbe);
|
void dump_be_quirk_names(struct libusb20_backend *pbe);
|
||||||
void dump_be_dev_quirks(struct libusb20_backend *pbe);
|
void dump_be_dev_quirks(struct libusb20_backend *pbe);
|
||||||
void dump_device_access(struct libusb20_device *pdev, uint8_t iface);
|
|
||||||
int dump_device_iface_access(struct libusb20_device *pdev, uint8_t iface);
|
|
||||||
void dump_device_desc(struct libusb20_device *pdev);
|
void dump_device_desc(struct libusb20_device *pdev);
|
||||||
void dump_config(struct libusb20_device *pdev, uint8_t all_cfg);
|
void dump_config(struct libusb20_device *pdev, uint8_t all_cfg);
|
||||||
|
@ -64,8 +64,6 @@ struct options {
|
|||||||
uint8_t got_iface:1;
|
uint8_t got_iface:1;
|
||||||
uint8_t got_set_config:1;
|
uint8_t got_set_config:1;
|
||||||
uint8_t got_set_alt:1;
|
uint8_t got_set_alt:1;
|
||||||
uint8_t got_set_owner:1;
|
|
||||||
uint8_t got_set_perm:1;
|
|
||||||
uint8_t got_set_template:1;
|
uint8_t got_set_template:1;
|
||||||
uint8_t got_get_template:1;
|
uint8_t got_get_template:1;
|
||||||
uint8_t got_suspend:1;
|
uint8_t got_suspend:1;
|
||||||
@ -80,7 +78,6 @@ struct options {
|
|||||||
uint8_t got_dump_curr_config:1;
|
uint8_t got_dump_curr_config:1;
|
||||||
uint8_t got_dump_all_config:1;
|
uint8_t got_dump_all_config:1;
|
||||||
uint8_t got_dump_info:1;
|
uint8_t got_dump_info:1;
|
||||||
uint8_t got_dump_access:1;
|
|
||||||
uint8_t got_show_iface_driver:1;
|
uint8_t got_show_iface_driver:1;
|
||||||
uint8_t got_remove_device_quirk:1;
|
uint8_t got_remove_device_quirk:1;
|
||||||
uint8_t got_add_device_quirk:1;
|
uint8_t got_add_device_quirk:1;
|
||||||
@ -100,8 +97,6 @@ enum {
|
|||||||
T_IFACE,
|
T_IFACE,
|
||||||
T_SET_CONFIG,
|
T_SET_CONFIG,
|
||||||
T_SET_ALT,
|
T_SET_ALT,
|
||||||
T_SET_OWNER,
|
|
||||||
T_SET_PERM,
|
|
||||||
T_SET_TEMPLATE,
|
T_SET_TEMPLATE,
|
||||||
T_GET_TEMPLATE,
|
T_GET_TEMPLATE,
|
||||||
T_ADD_DEVICE_QUIRK,
|
T_ADD_DEVICE_QUIRK,
|
||||||
@ -113,7 +108,6 @@ enum {
|
|||||||
T_DUMP_CURR_CONFIG_DESC,
|
T_DUMP_CURR_CONFIG_DESC,
|
||||||
T_DUMP_ALL_CONFIG_DESC,
|
T_DUMP_ALL_CONFIG_DESC,
|
||||||
T_DUMP_STRING,
|
T_DUMP_STRING,
|
||||||
T_DUMP_ACCESS,
|
|
||||||
T_DUMP_INFO,
|
T_DUMP_INFO,
|
||||||
T_SUSPEND,
|
T_SUSPEND,
|
||||||
T_RESUME,
|
T_RESUME,
|
||||||
@ -133,8 +127,6 @@ static const struct token token[] = {
|
|||||||
{"-i", T_IFACE, 1},
|
{"-i", T_IFACE, 1},
|
||||||
{"set_config", T_SET_CONFIG, 1},
|
{"set_config", T_SET_CONFIG, 1},
|
||||||
{"set_alt", T_SET_ALT, 1},
|
{"set_alt", T_SET_ALT, 1},
|
||||||
{"set_owner", T_SET_OWNER, 1},
|
|
||||||
{"set_perm", T_SET_PERM, 1},
|
|
||||||
{"set_template", T_SET_TEMPLATE, 1},
|
{"set_template", T_SET_TEMPLATE, 1},
|
||||||
{"get_template", T_GET_TEMPLATE, 0},
|
{"get_template", T_GET_TEMPLATE, 0},
|
||||||
{"add_dev_quirk_vplh", T_ADD_DEVICE_QUIRK, 5},
|
{"add_dev_quirk_vplh", T_ADD_DEVICE_QUIRK, 5},
|
||||||
@ -145,7 +137,6 @@ static const struct token token[] = {
|
|||||||
{"dump_curr_config_desc", T_DUMP_CURR_CONFIG_DESC, 0},
|
{"dump_curr_config_desc", T_DUMP_CURR_CONFIG_DESC, 0},
|
||||||
{"dump_all_config_desc", T_DUMP_ALL_CONFIG_DESC, 0},
|
{"dump_all_config_desc", T_DUMP_ALL_CONFIG_DESC, 0},
|
||||||
{"dump_string", T_DUMP_STRING, 1},
|
{"dump_string", T_DUMP_STRING, 1},
|
||||||
{"dump_access", T_DUMP_ACCESS, 0},
|
|
||||||
{"dump_info", T_DUMP_INFO, 0},
|
{"dump_info", T_DUMP_INFO, 0},
|
||||||
{"show_ifdrv", T_SHOW_IFACE_DRIVER, 0},
|
{"show_ifdrv", T_SHOW_IFACE_DRIVER, 0},
|
||||||
{"suspend", T_SUSPEND, 0},
|
{"suspend", T_SUSPEND, 0},
|
||||||
@ -238,43 +229,19 @@ num_id(const char *name, const char *type)
|
|||||||
return (val);
|
return (val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gid_t
|
static int
|
||||||
a_gid(const char *s)
|
get_int(const char *s)
|
||||||
{
|
{
|
||||||
struct group *gr;
|
int val;
|
||||||
|
|
||||||
if (*s == '\0') {
|
|
||||||
/* empty group ID */
|
|
||||||
return ((gid_t)-1);
|
|
||||||
}
|
|
||||||
return ((gr = getgrnam(s)) ? gr->gr_gid : num_id(s, "group"));
|
|
||||||
}
|
|
||||||
|
|
||||||
static uid_t
|
|
||||||
a_uid(const char *s)
|
|
||||||
{
|
|
||||||
struct passwd *pw;
|
|
||||||
|
|
||||||
if (*s == '\0') {
|
|
||||||
/* empty user ID */
|
|
||||||
return ((uid_t)-1);
|
|
||||||
}
|
|
||||||
return ((pw = getpwnam(s)) ? pw->pw_uid : num_id(s, "user"));
|
|
||||||
}
|
|
||||||
|
|
||||||
static mode_t
|
|
||||||
a_mode(const char *s)
|
|
||||||
{
|
|
||||||
uint16_t val;
|
|
||||||
char *ep;
|
char *ep;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
val = strtoul(s, &ep, 8);
|
val = strtoul(s, &ep, 0);
|
||||||
if (errno) {
|
if (errno) {
|
||||||
err(1, "%s", s);
|
err(1, "%s", s);
|
||||||
}
|
}
|
||||||
if (*ep != '\0') {
|
if (*ep != '\0') {
|
||||||
errx(1, "illegal permissions: %s", s);
|
errx(1, "illegal number: %s", s);
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@ -288,8 +255,6 @@ usage(void)
|
|||||||
"commands:" "\n"
|
"commands:" "\n"
|
||||||
" set_config <cfg_index>" "\n"
|
" set_config <cfg_index>" "\n"
|
||||||
" set_alt <alt_index>" "\n"
|
" set_alt <alt_index>" "\n"
|
||||||
" set_owner <user:group>" "\n"
|
|
||||||
" set_perm <mode>" "\n"
|
|
||||||
" set_template <template>" "\n"
|
" set_template <template>" "\n"
|
||||||
" get_template" "\n"
|
" get_template" "\n"
|
||||||
" add_dev_quirk_vplh <vid> <pid> <lo_rev> <hi_rev> <quirk>" "\n"
|
" add_dev_quirk_vplh <vid> <pid> <lo_rev> <hi_rev> <quirk>" "\n"
|
||||||
@ -300,7 +265,6 @@ usage(void)
|
|||||||
" dump_curr_config_desc" "\n"
|
" dump_curr_config_desc" "\n"
|
||||||
" dump_all_config_desc" "\n"
|
" dump_all_config_desc" "\n"
|
||||||
" dump_string <index>" "\n"
|
" dump_string <index>" "\n"
|
||||||
" dump_access" "\n"
|
|
||||||
" dump_info" "\n"
|
" dump_info" "\n"
|
||||||
" show_ifdrv" "\n"
|
" show_ifdrv" "\n"
|
||||||
" suspend" "\n"
|
" suspend" "\n"
|
||||||
@ -345,10 +309,6 @@ flush_command(struct libusb20_backend *pbe, struct options *opt)
|
|||||||
"'power_save', 'power_on' and 'power_off' "
|
"'power_save', 'power_on' and 'power_off' "
|
||||||
"at the same time!");
|
"at the same time!");
|
||||||
}
|
}
|
||||||
if (opt->got_dump_access) {
|
|
||||||
opt->got_any--;
|
|
||||||
dump_be_access(pbe);
|
|
||||||
}
|
|
||||||
if (opt->got_dump_quirk_names) {
|
if (opt->got_dump_quirk_names) {
|
||||||
opt->got_any--;
|
opt->got_any--;
|
||||||
dump_be_quirk_names(pbe);
|
dump_be_quirk_names(pbe);
|
||||||
@ -400,62 +360,6 @@ flush_command(struct libusb20_backend *pbe, struct options *opt)
|
|||||||
}
|
}
|
||||||
matches++;
|
matches++;
|
||||||
|
|
||||||
/* do owner and permissions first */
|
|
||||||
|
|
||||||
if (opt->got_bus && opt->got_addr && opt->got_iface) {
|
|
||||||
if (opt->got_set_owner) {
|
|
||||||
if (libusb20_dev_set_iface_owner(pdev,
|
|
||||||
opt->iface, opt->uid, opt->gid)) {
|
|
||||||
err(1, "setting owner and group failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (opt->got_set_perm) {
|
|
||||||
if (libusb20_dev_set_iface_perm(pdev,
|
|
||||||
opt->iface, opt->mode)) {
|
|
||||||
err(1, "setting mode failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (opt->got_bus && opt->got_addr) {
|
|
||||||
if (opt->got_set_owner) {
|
|
||||||
if (libusb20_dev_set_owner(pdev,
|
|
||||||
opt->uid, opt->gid)) {
|
|
||||||
err(1, "setting owner and group failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (opt->got_set_perm) {
|
|
||||||
if (libusb20_dev_set_perm(pdev,
|
|
||||||
opt->mode)) {
|
|
||||||
err(1, "setting mode failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (opt->got_bus) {
|
|
||||||
if (opt->got_set_owner) {
|
|
||||||
if (libusb20_bus_set_owner(pbe, opt->bus,
|
|
||||||
opt->uid, opt->gid)) {
|
|
||||||
err(1, "setting owner and group failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (opt->got_set_perm) {
|
|
||||||
if (libusb20_bus_set_perm(pbe, opt->bus,
|
|
||||||
opt->mode)) {
|
|
||||||
err(1, "setting mode failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (opt->got_set_owner) {
|
|
||||||
if (libusb20_be_set_owner(pbe,
|
|
||||||
opt->uid, opt->gid)) {
|
|
||||||
err(1, "setting owner and group failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (opt->got_set_perm) {
|
|
||||||
if (libusb20_be_set_perm(pbe,
|
|
||||||
opt->mode)) {
|
|
||||||
err(1, "setting mode failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (libusb20_dev_open(pdev, 0)) {
|
if (libusb20_dev_open(pdev, 0)) {
|
||||||
err(1, "could not open device");
|
err(1, "could not open device");
|
||||||
}
|
}
|
||||||
@ -558,18 +462,12 @@ flush_command(struct libusb20_backend *pbe, struct options *opt)
|
|||||||
(opt->got_dump_device_desc ||
|
(opt->got_dump_device_desc ||
|
||||||
opt->got_dump_curr_config ||
|
opt->got_dump_curr_config ||
|
||||||
opt->got_dump_all_config ||
|
opt->got_dump_all_config ||
|
||||||
opt->got_dump_info ||
|
opt->got_dump_info);
|
||||||
opt->got_dump_access);
|
|
||||||
|
|
||||||
if (opt->got_list || dump_any) {
|
if (opt->got_list || dump_any) {
|
||||||
dump_device_info(pdev,
|
dump_device_info(pdev,
|
||||||
opt->got_show_iface_driver);
|
opt->got_show_iface_driver);
|
||||||
}
|
}
|
||||||
if (opt->got_dump_access) {
|
|
||||||
printf("\n");
|
|
||||||
dump_device_access(pdev, opt->got_iface ?
|
|
||||||
opt->iface : 0xFF);
|
|
||||||
}
|
|
||||||
if (opt->got_dump_device_desc) {
|
if (opt->got_dump_device_desc) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
dump_device_desc(pdev);
|
dump_device_desc(pdev);
|
||||||
@ -695,27 +593,8 @@ main(int argc, char **argv)
|
|||||||
opt->got_any++;
|
opt->got_any++;
|
||||||
n++;
|
n++;
|
||||||
break;
|
break;
|
||||||
case T_SET_OWNER:
|
|
||||||
cp = argv[n + 1];
|
|
||||||
cp = strchr(cp, ':');
|
|
||||||
if (cp == NULL) {
|
|
||||||
err(1, "missing colon in '%s'!", argv[n + 1]);
|
|
||||||
}
|
|
||||||
*(cp++) = '\0';
|
|
||||||
opt->gid = a_gid(cp);
|
|
||||||
opt->uid = a_uid(argv[n + 1]);
|
|
||||||
opt->got_set_owner = 1;
|
|
||||||
opt->got_any++;
|
|
||||||
n++;
|
|
||||||
break;
|
|
||||||
case T_SET_PERM:
|
|
||||||
opt->mode = a_mode(argv[n + 1]);
|
|
||||||
opt->got_set_perm = 1;
|
|
||||||
opt->got_any++;
|
|
||||||
n++;
|
|
||||||
break;
|
|
||||||
case T_SET_TEMPLATE:
|
case T_SET_TEMPLATE:
|
||||||
opt->template = a_mode(argv[n + 1]);
|
opt->template = get_int(argv[n + 1]);
|
||||||
opt->got_set_template = 1;
|
opt->got_set_template = 1;
|
||||||
opt->got_any++;
|
opt->got_any++;
|
||||||
n++;
|
n++;
|
||||||
@ -749,10 +628,6 @@ main(int argc, char **argv)
|
|||||||
opt->got_any++;
|
opt->got_any++;
|
||||||
n++;
|
n++;
|
||||||
break;
|
break;
|
||||||
case T_DUMP_ACCESS:
|
|
||||||
opt->got_dump_access = 1;
|
|
||||||
opt->got_any += 2;
|
|
||||||
break;
|
|
||||||
case T_SUSPEND:
|
case T_SUSPEND:
|
||||||
opt->got_suspend = 1;
|
opt->got_suspend = 1;
|
||||||
opt->got_any++;
|
opt->got_any++;
|
||||||
|
Loading…
Reference in New Issue
Block a user