Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Feb 2009 17:27:16 +0000 (UTC)
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r189110 - in head: lib/libusb20 sys/dev/sound/usb sys/dev/usb sys/dev/usb/bluetooth sys/dev/usb/image sys/dev/usb/input sys/dev/usb/misc sys/dev/usb/serial sys/dev/usb/storage sys/sys u...
Message-ID:  <200902271727.n1RHRGr2076190@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thompsa
Date: Fri Feb 27 17:27:16 2009
New Revision: 189110
URL: http://svn.freebsd.org/changeset/base/189110

Log:
  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)

Modified:
  head/lib/libusb20/libusb20.3
  head/lib/libusb20/libusb20.c
  head/lib/libusb20/libusb20.h
  head/lib/libusb20/libusb20_int.h
  head/lib/libusb20/libusb20_ugen20.c
  head/sys/dev/sound/usb/uaudio.c
  head/sys/dev/usb/bluetooth/ubtbcmfw.c
  head/sys/dev/usb/image/uscanner.c
  head/sys/dev/usb/input/uhid.c
  head/sys/dev/usb/input/ums.c
  head/sys/dev/usb/misc/ufm.c
  head/sys/dev/usb/serial/ulpt.c
  head/sys/dev/usb/storage/urio.c
  head/sys/dev/usb/usb_bus.h
  head/sys/dev/usb/usb_core.h
  head/sys/dev/usb/usb_dev.c
  head/sys/dev/usb/usb_dev.h
  head/sys/dev/usb/usb_device.c
  head/sys/dev/usb/usb_device.h
  head/sys/dev/usb/usb_generic.c
  head/sys/dev/usb/usb_ioctl.h
  head/sys/sys/param.h
  head/usr.sbin/usbconfig/dump.c
  head/usr.sbin/usbconfig/dump.h
  head/usr.sbin/usbconfig/usbconfig.c

Modified: head/lib/libusb20/libusb20.3
==============================================================================
--- head/lib/libusb20/libusb20.3	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/lib/libusb20/libusb20.3	Fri Feb 27 17:27:16 2009	(r189110)
@@ -514,72 +514,6 @@ returned.
 .
 .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
 This function returns a pointer to the decoded and host endian version
 of the device descriptor.
@@ -663,39 +597,6 @@ A timeout value can be specified which i
 .Xr 2 poll
 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
 .
 .Fn libusb20_be_get_template pbackend ptemp
@@ -772,47 +673,6 @@ returned.
 If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
 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
 These functions are used to allocate a specific USB backend or the
 operating system default USB backend. Allocating a backend is a way to

Modified: head/lib/libusb20/libusb20.c
==============================================================================
--- head/lib/libusb20/libusb20.c	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/lib/libusb20/libusb20.c	Fri Feb 27 17:27:16 2009	(r189110)
@@ -971,86 +971,6 @@ libusb20_dev_get_bus_number(struct libus
 }
 
 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
 libusb20_dev_get_iface_desc(struct libusb20_device *pdev, 
     uint8_t iface_index, char *buf, uint8_t len)
 {
@@ -1061,45 +981,6 @@ libusb20_dev_get_iface_desc(struct libus
 	    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 */
 
 int
@@ -1131,41 +1012,6 @@ libusb20_be_remove_dev_quirk(struct libu
 }
 
 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
 libusb20_be_set_template(struct libusb20_backend *pbe, int temp)
 {
 	return (pbe->methods->root_set_template(pbe, temp));

Modified: head/lib/libusb20/libusb20.h
==============================================================================
--- head/lib/libusb20/libusb20.h	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/lib/libusb20/libusb20.h	Fri Feb 27 17:27:16 2009	(r189110)
@@ -253,14 +253,6 @@ int	libusb20_dev_reset(struct libusb20_d
 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);
 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_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_d
 void	libusb20_dev_set_debug(struct libusb20_device *pdev, int debug);
 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 */
 
 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_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_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 */
 

Modified: head/lib/libusb20/libusb20_int.h
==============================================================================
--- head/lib/libusb20/libusb20_int.h	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/lib/libusb20/libusb20_int.h	Fri Feb 27 17:27:16 2009	(r189110)
@@ -48,27 +48,11 @@ typedef int (libusb20_root_get_dev_quirk
 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_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_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_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_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 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);
@@ -85,28 +69,12 @@ typedef int (libusb20_root_get_template_
   /* optional backend methods */ \
   m(n, init_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_iface_owner) \
-  m(n, dev_get_iface_perm) \
   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_quirk_name) \
   m(n, root_add_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_get_template) \
   /* mandatory device methods */ \

Modified: head/lib/libusb20/libusb20_ugen20.c
==============================================================================
--- head/lib/libusb20/libusb20_ugen20.c	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/lib/libusb20/libusb20_ugen20.c	Fri Feb 27 17:27:16 2009	(r189110)
@@ -50,28 +50,12 @@ static libusb20_open_device_t ugen20_ope
 static libusb20_close_device_t ugen20_close_device;
 static libusb20_get_backend_name_t ugen20_get_backend_name;
 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_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_quirk_name_t ugen20_root_get_quirk_name;
 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_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_get_template_t ugen20_root_get_template;
 
@@ -152,7 +136,7 @@ ugen20_enumerate(struct libusb20_device 
 	pdev->bus_number = 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);
 
 	f = open(buf, O_RDWR);
@@ -218,7 +202,7 @@ ugen20_enumerate(struct libusb20_device 
 	/* generate a nice description for printout */
 
 	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,
 	    devinfo.udi_vendor, pdev->bus_number);
 
@@ -284,7 +268,7 @@ ugen20_init_backend(struct libusb20_back
 
 	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)
 		return (LIBUSB20_ERROR_OTHER);
 
@@ -379,7 +363,7 @@ ugen20_open_device(struct libusb20_devic
 	int g;
 	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);
 
 	/*
@@ -873,7 +857,7 @@ ugen20_be_ioctl(uint32_t cmd, void *data
 	int f;
 	int error;
 
-	f = open("/dev/usb", O_RDONLY);
+	f = open("/dev/" USB_DEVICE_NAME, O_RDONLY);
 	if (f < 0)
 		return (LIBUSB20_ERROR_OTHER);
 	error = ioctl(f, cmd, data);
@@ -889,75 +873,6 @@ ugen20_be_ioctl(uint32_t cmd, void *data
 }
 
 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
 ugen20_dev_get_iface_desc(struct libusb20_device *pdev, 
     uint8_t iface_index, char *buf, uint8_t len)
 {
@@ -986,59 +901,6 @@ ugen20_dev_get_info(struct libusb20_devi
 }
 
 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
 ugen20_root_get_dev_quirk(struct libusb20_backend *pbe,
     uint16_t quirk_index, struct libusb20_quirk *pq)
 {
@@ -1137,52 +999,6 @@ ugen20_root_remove_dev_quirk(struct libu
 }
 
 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
 ugen20_root_set_template(struct libusb20_backend *pbe, int temp)
 {
 	return (ugen20_be_ioctl(USB_SET_TEMPLATE, &temp));

Modified: head/sys/dev/sound/usb/uaudio.c
==============================================================================
--- head/sys/dev/sound/usb/uaudio.c	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/sys/dev/sound/usb/uaudio.c	Fri Feb 27 17:27:16 2009	(r189110)
@@ -379,9 +379,9 @@ static void	umidi_start_read(struct usb2
 static void	umidi_stop_read(struct usb2_fifo *);
 static void	umidi_start_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_ioctl(struct usb2_fifo *, u_long cmd, void *, int, struct thread *);
-static void	umidi_close(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);
+static void	umidi_close(struct usb2_fifo *, int);
 static void	umidi_init(device_t dev);
 static int32_t	umidi_probe(device_t dev);
 static int32_t	umidi_detach(device_t dev);
@@ -3585,7 +3585,7 @@ umidi_stop_write(struct usb2_fifo *fifo)
 }
 
 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_sub_chan *sub = umidi_sub_by_fifo(fifo);
@@ -3617,7 +3617,7 @@ umidi_open(struct usb2_fifo *fifo, int f
 }
 
 static void
-umidi_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
+umidi_close(struct usb2_fifo *fifo, int fflags)
 {
 	if (fflags & FREAD) {
 		usb2_fifo_free_buffer(fifo);
@@ -3630,7 +3630,7 @@ umidi_close(struct usb2_fifo *fifo, int 
 
 static int
 umidi_ioctl(struct usb2_fifo *fifo, u_long cmd, void *data,
-    int fflags, struct thread *td)
+    int fflags)
 {
 	return (ENODEV);
 }
@@ -3684,9 +3684,6 @@ umidi_probe(device_t dev)
 	    (chan->max_cable == 0)) {
 		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++) {
 
@@ -3694,7 +3691,8 @@ umidi_probe(device_t dev)
 
 		error = usb2_fifo_attach(sc->sc_udev, chan, &chan->mtx,
 		    &umidi_fifo_methods, &sub->fifo, unit, n,
-		    chan->iface_index);
+		    chan->iface_index,
+		    UID_ROOT, GID_OPERATOR, 0644);
 		if (error) {
 			goto detach;
 		}

Modified: head/sys/dev/usb/bluetooth/ubtbcmfw.c
==============================================================================
--- head/sys/dev/usb/bluetooth/ubtbcmfw.c	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/sys/dev/usb/bluetooth/ubtbcmfw.c	Fri Feb 27 17:27:16 2009	(r189110)
@@ -211,13 +211,10 @@ ubtbcmfw_attach(device_t dev)
 		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,
 			&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) {
 		device_printf(dev, "could not attach fifo. %s\n",
 			usb2_errstr(error));
@@ -369,7 +366,7 @@ ubtbcmfw_stop_write(struct usb2_fifo *fi
  */
 
 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 usb2_xfer	*xfer;
@@ -398,7 +395,7 @@ ubtbcmfw_open(struct usb2_fifo *fifo, in
  */
 
 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))
 		usb2_fifo_free_buffer(fifo);
@@ -410,7 +407,7 @@ ubtbcmfw_close(struct usb2_fifo *fifo, i
 
 static int
 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;
 	int			error = 0;

Modified: head/sys/dev/usb/image/uscanner.c
==============================================================================
--- head/sys/dev/usb/image/uscanner.c	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/sys/dev/usb/image/uscanner.c	Fri Feb 27 17:27:16 2009	(r189110)
@@ -399,13 +399,11 @@ uscanner_attach(device_t dev)
 		    "error=%s\n", usb2_errstr(error));
 		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,
 	    &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) {
 		goto detach;
 	}
@@ -553,7 +551,7 @@ uscanner_write_clear_stall_callback(stru
  * uscanner character device opening method.
  */
 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;
 
@@ -585,7 +583,7 @@ uscanner_open(struct usb2_fifo *fifo, in
 }
 
 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)) {
 		usb2_fifo_free_buffer(fifo);

Modified: head/sys/dev/usb/input/uhid.c
==============================================================================
--- head/sys/dev/usb/input/uhid.c	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/sys/dev/usb/input/uhid.c	Fri Feb 27 17:27:16 2009	(r189110)
@@ -447,7 +447,7 @@ done:
 }
 
 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;
 
@@ -474,7 +474,7 @@ uhid_open(struct usb2_fifo *fifo, int ff
 }
 
 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)) {
 		usb2_fifo_free_buffer(fifo);
@@ -483,7 +483,7 @@ uhid_close(struct usb2_fifo *fifo, int f
 
 static int
 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 usb2_gen_descriptor *ugd;
@@ -734,13 +734,11 @@ uhid_attach(device_t dev)
 		    sc->sc_fsize);
 		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,
 	    &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) {
 		goto detach;
 	}

Modified: head/sys/dev/usb/input/ums.c
==============================================================================
--- head/sys/dev/usb/input/ums.c	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/sys/dev/usb/input/ums.c	Fri Feb 27 17:27:16 2009	(r189110)
@@ -583,13 +583,10 @@ ums_attach(device_t dev)
 	sc->sc_status.dy = 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,
 	    &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) {
 		goto detach;
 	}
@@ -697,7 +694,7 @@ ums_reset_buf(struct ums_softc *sc)
 }
 
 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;
 
@@ -724,7 +721,7 @@ ums_open(struct usb2_fifo *fifo, int ffl
 }
 
 static void
-ums_close(struct usb2_fifo *fifo, int fflags, struct thread *td)
+ums_close(struct usb2_fifo *fifo, int fflags)
 {
 	if (fflags & FREAD) {
 		usb2_fifo_free_buffer(fifo);
@@ -732,8 +729,7 @@ ums_close(struct usb2_fifo *fifo, int ff
 }
 
 static int
-ums_ioctl(struct usb2_fifo *fifo, u_long cmd, void *addr,
-    int fflags, struct thread *td)
+ums_ioctl(struct usb2_fifo *fifo, u_long cmd, void *addr, int fflags)
 {
 	struct ums_softc *sc = fifo->priv_sc0;
 	mousemode_t mode;

Modified: head/sys/dev/usb/misc/ufm.c
==============================================================================
--- head/sys/dev/usb/misc/ufm.c	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/sys/dev/usb/misc/ufm.c	Fri Feb 27 17:27:16 2009	(r189110)
@@ -139,13 +139,10 @@ ufm_attach(device_t 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,
 	    &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) {
 		goto detach;
 	}
@@ -169,7 +166,7 @@ ufm_detach(device_t dev)
 }
 
 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)) {
 		return (EACCES);
@@ -300,7 +297,7 @@ ufm_get_stat(struct ufm_softc *sc, void 
 
 static int
 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;
 	int error = 0;

Modified: head/sys/dev/usb/serial/ulpt.c
==============================================================================
--- head/sys/dev/usb/serial/ulpt.c	Fri Feb 27 16:01:40 2009	(r189109)
+++ head/sys/dev/usb/serial/ulpt.c	Fri Feb 27 17:27:16 2009	(r189110)
@@ -395,7 +395,7 @@ ulpt_stop_write(struct usb2_fifo *fifo)
 }
 
 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;
 
@@ -404,11 +404,11 @@ ulpt_open(struct usb2_fifo *fifo, int ff
 	if (sc->sc_fflags == 0) {
 		ulpt_reset(sc);
 	}
-	return (unlpt_open(fifo, fflags, td));
+	return (unlpt_open(fifo, fflags));
 }
 
 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;
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902271727.n1RHRGr2076190>