VirtualBox

source: vbox/trunk/src/VBox/Main/include/USBGetDevices.h@ 94521

Last change on this file since 94521 was 93115, checked in by vboxsync, 2 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/* $Id: USBGetDevices.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * VirtualBox Linux host USB device enumeration.
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef MAIN_INCLUDED_USBGetDevices_h
19#define MAIN_INCLUDED_USBGetDevices_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <VBox/usb.h>
25#include <iprt/mem.h>
26#include <iprt/string.h>
27
28/**
29 * Free all the members of a USB device created by the Linux enumeration code.
30 *
31 * @note This duplicates a USBProxyService method which we needed access too
32 * without pulling in the rest of the proxy service code.
33 *
34 * @param pDevice Pointer to the device.
35 */
36DECLINLINE(void) deviceFreeMembers(PUSBDEVICE pDevice)
37{
38 RTStrFree((char *)pDevice->pszManufacturer);
39 pDevice->pszManufacturer = NULL;
40 RTStrFree((char *)pDevice->pszProduct);
41 pDevice->pszProduct = NULL;
42 RTStrFree((char *)pDevice->pszSerialNumber);
43 pDevice->pszSerialNumber = NULL;
44
45 RTStrFree((char *)pDevice->pszAddress);
46 pDevice->pszAddress = NULL;
47}
48
49/**
50 * Free one USB device created by the Linux enumeration code.
51 *
52 * @note This duplicates a USBProxyService method which we needed access too
53 * without pulling in the rest of the proxy service code.
54 *
55 * @param pDevice Pointer to the device. NULL is OK.
56 */
57DECLINLINE(void) deviceFree(PUSBDEVICE pDevice)
58{
59 if (pDevice)
60 {
61 deviceFreeMembers(pDevice);
62 RTMemFree(pDevice);
63 }
64}
65
66/**
67 * Free a linked list of USB devices created by the Linux enumeration code.
68 * @param ppHead Pointer to the first device in the linked list
69 */
70DECLINLINE(void) deviceListFree(PUSBDEVICE *ppHead)
71{
72 PUSBDEVICE pHead = *ppHead;
73 while (pHead)
74 {
75 PUSBDEVICE pNext = pHead->pNext;
76 deviceFree(pHead);
77 pHead = pNext;
78 }
79 *ppHead = NULL;
80}
81
82RT_C_DECLS_BEGIN
83
84extern bool USBProxyLinuxCheckDeviceRoot(const char *pcszRoot, bool fIsDeviceNodes);
85
86#ifdef UNIT_TEST
87void TestUSBSetupInit(const char *pcszUsbfsRoot, bool fUsbfsAccessible,
88 const char *pcszDevicesRoot, bool fDevicesAccessible,
89 int rcMethodInitResult);
90void TestUSBSetEnv(const char *pcszEnvUsb, const char *pcszEnvUsbRoot);
91#endif
92
93extern int USBProxyLinuxChooseMethod(bool *pfUsingUsbfsDevices, const char **ppcszDevicesRoot);
94#ifdef UNIT_TEST
95extern void TestUSBSetAvailableUsbfsDevices(const char **pacszDeviceAddresses);
96extern void TestUSBSetAccessibleFiles(const char **pacszAccessibleFiles);
97#endif
98
99extern PUSBDEVICE USBProxyLinuxGetDevices(const char *pcszDevicesRoot, bool fUseSysfs);
100
101RT_C_DECLS_END
102
103#endif /* !MAIN_INCLUDED_USBGetDevices_h */
104
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use