Esempio n. 1
0
File: udev.c Progetto: etix/vlc
static void *Run (void *data)
{
    services_discovery_t *sd = data;
    services_discovery_sys_t *p_sys = sd->p_sys;
    struct udev_monitor *mon = p_sys->monitor;

    int fd = udev_monitor_get_fd (mon);
    struct pollfd ufd = { .fd = fd, .events = POLLIN, };

    for (;;)
    {
        while (poll (&ufd, 1, -1) == -1)
            if (errno != EINTR)
                break;

        int canc = vlc_savecancel ();
        struct udev_device *dev = udev_monitor_receive_device (mon);
        if (dev == NULL)
            continue;

        const char *action = udev_device_get_action (dev);
        if (!strcmp (action, "add"))
            AddDevice (sd, dev);
        else if (!strcmp (action, "remove"))
            RemoveDevice (sd, dev);
        else if (!strcmp (action, "change"))
        {
            RemoveDevice (sd, dev);
            AddDevice (sd, dev);
        }
        udev_device_unref (dev);
        vlc_restorecancel (canc);
    }
    return NULL;
}
void FDeviceSDL::IgnoreGameControllers(bool bIgnore)
{
	if (bIgnore && !bIgnoreGameControllers)
	{
		bIgnoreGameControllers = true;
		for (auto &Device : Devices)
		{
			if (DeviceMapping.Contains(Device.Value.InstanceId) && SDL_IsGameController(Device.Value.DeviceIndex.value))
			{
				RemoveDevice(Device.Key);
			}
		}
	}
	else if (!bIgnore && bIgnoreGameControllers)
	{
		bIgnoreGameControllers = false;
		int Joysticks = SDL_NumJoysticks();
		for (int i = 0; i < Joysticks; i++)
		{
			if (SDL_IsGameController(i))
			{
				AddDevice(FDeviceIndex(i));
			}
		}
	}
}
NS_IMETHODIMP
MulticastDNSDeviceProvider::OnServiceLost(nsIDNSServiceInfo* aServiceInfo)
{
  MOZ_ASSERT(NS_IsMainThread());

  if (NS_WARN_IF(!aServiceInfo)) {
    return NS_ERROR_INVALID_ARG;
  }

  nsresult rv;

  nsAutoCString serviceName;
  if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetServiceName(serviceName)))) {
    return rv;
  }

  LOG_I("OnServiceLost: %s", serviceName.get());

  nsAutoCString host;
  if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetHost(host)))) {
    return rv;
  }

  uint32_t index;
  if (!FindDevice(host, index)) {
    // given device was not found
    return NS_OK;
  }

  if (NS_WARN_IF(NS_FAILED(rv = RemoveDevice(index)))) {
    return rv;
  }

  return NS_OK;
}
Esempio n. 4
0
// This routine releases a power relationship that was created with 
// PmRegisterPowerRelationship().  It returns
//      ERROR_SUCCESS - relationship removed
//      ERROR_INVALID_PARAMETER - bad handle
// Deregistering a power relationship has the side effect of deregistering
// the child device with the PM.  Note that if the child exits while
// the relationship is outstanding, the caller will get ERROR_INVALID_PARAMETER
// when they attempt to release the relationship handle.
EXTERN_C DWORD WINAPI 
PmReleasePowerRelationship(HANDLE h)
{
    PDEVICE_STATE pds = (PDEVICE_STATE) h;
    DWORD dwStatus = ERROR_INVALID_PARAMETER;

#ifndef SHIP_BUILD
    SETFNAME(_T("PmReleasePowerRelationship"));
#endif

    PMLOGMSG(ZONE_API, (_T("%s: releasing 0x%08x\r\n"), pszFname, h));

    // make sure that this pointer is a child node with a parent
    if(pds != NULL) {
        BOOL fExists = CheckDevicePointer(pds); // increments refcnt if TRUE
        if(fExists) {
            // delete the device
            PREFAST_DEBUGCHK(pds->pListHead != NULL);
            RemoveDevice(pds->pListHead->pGuid, pds->pszName);

            // done with the pointer
            DeviceStateDecRef(pds);

            // return a good status
            dwStatus = ERROR_SUCCESS;
        }
    }

    PMLOGMSG(ZONE_API || (dwStatus != ERROR_SUCCESS && ZONE_WARN), (_T("%s: returning %d\r\n"), 
        pszFname, dwStatus));
    return dwStatus;
}
Esempio n. 5
0
void fatUnmount (const char* name) {
	devoptab_t *devops;
	PARTITION* partition;

	if(!name)
		return;

	devops = (devoptab_t*)GetDeviceOpTab (name);
	if (!devops) {
		return;
	}

	// Perform a quick check to make sure we're dealing with a libfat controlled device
	if (devops->open_r != dotab_fat.open_r) {
		return;
	}

	if (RemoveDevice (name) == -1) {
		return;
	}

	partition = (PARTITION*)devops->deviceData;
	_FAT_partition_destructor (partition);
	_FAT_mem_free (devops);
}
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	// DeviceRemoved()
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	void PlugIn::DeviceRemoved(Device& device)
	{
		// Suspend the device
		device.Unplug();

		// Save it's settings if necessary
		if (DALA::System::IsMaster())
			DP::DeviceSettings::SaveToPrefs(device, DP::DeviceSettings::sStandardControlsToSave, DP::DeviceSettings::kStandardNumberControlsToSave);

		{
			// Unlock the mutex since CMIOObjectsPublishedAndDied() can callout to property listeners
			CAMutex::Unlocker unlocker(GetStateMutex());

			// Tell the DAL that the device has gone away
			CMIOObjectID objectID = device.GetObjectID();
			OSStatus err = CMIOObjectsPublishedAndDied(GetInterface(), kCMIOObjectSystemObject, 0, 0, 1, &objectID);
			AssertNoError(err, "CMIO::DP::Sample::PlugIn::Teardown: got an error telling the DAL a device died");
		}
						
		// Remove it from the device list
		RemoveDevice(device);

		// Get rid of the device object
		device.Teardown();
		delete &device;
	}
Esempio n. 7
0
VOID
NbfFreeConfigurationInfo (
    IN PCONFIG_DATA ConfigurationInfo
    )

/*++

Routine Description:

    This routine is called by NBF to get free any storage that was allocated
    by NbfConfigureTransport in producing the specified CONFIG_DATA structure.

Arguments:

    ConfigurationInfo - A pointer to the configuration information structure.

Return Value:

    None.

--*/
{
    UINT i;

    for (i=0; i<ConfigurationInfo->NumAdapters; i++) {
        RemoveAdapter (ConfigurationInfo, i);
        RemoveDevice (ConfigurationInfo, i);
    }
    ExFreePool (ConfigurationInfo);

}   /* NbfFreeConfigurationInfo */
Esempio n. 8
0
/*******************************************************************************
 *
 * Function   :  PlxDispatch_Remove
 *
 * Description:  Called by the OS to remove a device from the driver
 *
 ******************************************************************************/
void
PlxDispatch_Remove(
    struct pci_dev *pDev
)
{
    DEVICE_OBJECT *fdo;


    DebugPrintf((
                    "Remove: %04X %04X [b:%02x s:%02x f:%02x]\n",
                    pDev->device, pDev->vendor,
                    pDev->bus->number, PCI_SLOT(pDev->devfn), PCI_FUNC(pDev->devfn)
                ));

    // Find the device in the list
    fdo = pGbl_DriverObject->DeviceObject;

    // Remove all devices
    while (fdo != NULL)
    {
        if (fdo->DeviceExtension->pPciDevice == pDev)
        {
            // Delete the device & remove from device list
            RemoveDevice( fdo );
            return;
        }

        // Jump to next device object
        fdo = fdo->NextDevice;
    }
}
void FSDrvShutdown() {
    RemoveDevice(fsDrvOpTab.name);
    setDefaultDevice(0);

    fsClient = NULL;
    fsCmdBlock = NULL;
}
Esempio n. 10
0
void GWorkBench::RemoveDevice( QString uniqueIdentifierName )
{
    QList<GDevice*> listDEvTest = DeviceManagerInstance()->AllDevices();
    GDevice* pDev = GetDeviceFromDeviceManager(uniqueIdentifierName);
    if(pDev)
        RemoveDevice(pDev);
}
Esempio n. 11
0
/**
  Stop this Controller.

  @param  Dev               The device need to be stopped.

**/
VOID
OpalDriverStopDevice (
  OPAL_DRIVER_DEVICE     *Dev
  )
{
  //
  // free each name
  //
  FreePool(Dev->Name16);

  //
  // remove OPAL_DRIVER_DEVICE from the list
  // it updates the controllerList pointer
  //
  RemoveDevice(Dev);

  //
  // close protocols that were opened
  //
  gBS->CloseProtocol(
    Dev->Handle,
    &gEfiStorageSecurityCommandProtocolGuid,
    gOpalDriverBinding.DriverBindingHandle,
    Dev->Handle
    );

  gBS->CloseProtocol(
    Dev->Handle,
    &gEfiBlockIoProtocolGuid,
    gOpalDriverBinding.DriverBindingHandle,
    Dev->Handle
    );

  FreePool(Dev);
}
Esempio n. 12
0
bool OTP_Unmount() {
    memset(otp, 0, OTP_SIZE);
    if (dotab_device >= 0) {
        dotab_device = -1;
        return !RemoveDevice(DEVICE_NAME ":");
    }
    return true;
}
Esempio n. 13
0
void AddDevice(std::unique_ptr<ISIDevice> device)
{
  int device_number = device->GetDeviceNumber();

  // Delete the old device
  RemoveDevice(device_number);

  // Set the new one
  g_Channel.at(device_number).m_device = std::move(device);
}
Esempio n. 14
0
/*! Clean up SDMC device */
Result sdmcExit(void)
{
  Result rc;

  rc = FSUSER_CloseArchive(NULL, &sdmcArchive);
  if(rc == 0)
    RemoveDevice("sdmc");

  return rc;
}
Esempio n. 15
0
void FVisualLogger::Shutdown()
{
	SetIsRecording(false);
	SetIsRecordingToFile(false);

	if (UseBinaryFileDevice)
	{
		RemoveDevice(&FVisualLoggerBinaryFileDevice::Get());
	}
}
void
LegacyMDNSDeviceProvider::ClearDevices()
{
  MOZ_ASSERT(NS_IsMainThread());

  size_t i = mDevices.Length();
  while (i > 0) {
    --i;
    Unused << NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
  }
}
void
MulticastDNSDeviceProvider::ClearDevices()
{
  MOZ_ASSERT(NS_IsMainThread());

  size_t i = mDevices.Length();
  while (i > 0) {
    --i;
    NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
  }
}
Esempio n. 18
0
void AddDevice(ISIDevice* pDevice)
{
    int _iDeviceNumber = pDevice->GetDeviceNumber();

    //_dbg_assert_(SERIALINTERFACE, _iDeviceNumber < MAX_SI_CHANNELS);

    // delete the old device
    RemoveDevice(_iDeviceNumber);

    // create the new one
    g_Channel[_iDeviceNumber].m_pDevice = pDevice;
}
void
LegacyMDNSDeviceProvider::ClearUnknownDevices()
{
  MOZ_ASSERT(NS_IsMainThread());

  size_t i = mDevices.Length();
  while (i > 0) {
    --i;
    if (mDevices[i]->State() == DeviceState::eUnknown) {
      Unused << NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
    }
  }
}
void
MulticastDNSDeviceProvider::ClearUnknownDevices()
{
  MOZ_ASSERT(NS_IsMainThread());

  size_t i = mDevices.Length();
  while (i > 0) {
    --i;
    if (mDevices[i].state == DeviceState::eUnknown) {
      NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
    }
  }
}
Esempio n. 21
0
// this routine reads device notifications from a message queue and updates
// the PM's internal tables appropriately.
BOOL
ProcessPnPMsgQueue(HANDLE hMsgQ)
{
    BOOL fOk = FALSE;
    UCHAR deviceBuf[PNP_QUEUE_SIZE];
    DWORD iBytesInQueue = 0;
    DWORD dwFlags = 0;
    SETFNAME(_T("ProcessPnPMsgQueue"));

    // read a message from the message queue -- it should be a device advertisement
    memset(deviceBuf, 0, PNP_QUEUE_SIZE);
    if ( !ReadMsgQueue(hMsgQ, deviceBuf, PNP_QUEUE_SIZE, &iBytesInQueue, 0, &dwFlags)) {
        // nothing in the queue
        PMLOGMSG(ZONE_WARN, (_T("%s: ReadMsgQueue() failed %d\r\n"), pszFname,
            GetLastError()));
    } else if(iBytesInQueue >= sizeof(DEVDETAIL)) {
        // process the message
        PDEVDETAIL pDevDetail = (PDEVDETAIL) deviceBuf;
        DWORD dwMessageSize = sizeof(DEVDETAIL) + pDevDetail->cbName;
        
        // check for overlarge names
        if(pDevDetail->cbName > ((PNP_MAX_NAMELEN - 1) * sizeof(pDevDetail->szName[0]))) {
            PMLOGMSG(ZONE_WARN, (_T("%s: device name longer than %d characters\r\n"), 
                pszFname, PNP_MAX_NAMELEN - 1));
        } else {
            // convert the device name to lower case
            int i;
            for(i = 0; i < (PNP_MAX_NAMELEN - 1) && pDevDetail->szName[i] != 0; i++) {
                pDevDetail->szName[i] = _totlower(pDevDetail->szName[i]);
            }
            pDevDetail->szName[i] = 0;
            
            // add or remove the device -- note that a particular interface may be
            // advertised more than once, so these routines must handle that possibility.
            if(pDevDetail->fAttached) {
                AddDevice(&pDevDetail->guidDevClass, pDevDetail->szName, NULL, NULL);
            } else {
                RemoveDevice(&pDevDetail->guidDevClass, pDevDetail->szName);
            }
            fOk = TRUE;
        }
    } else {
        // not enough bytes for a message
        PMLOGMSG(ZONE_WARN, (_T("%s: got runt message (%d bytes)\r\n"), pszFname, 
            iBytesInQueue));
    }

    return fOk;
}
NS_IMETHODIMP
sbCDDeviceMarshall::OnMediaEjected(sbICDDevice *aDevice)
{
  NS_ENSURE_ARG_POINTER(aDevice);

  nsresult rv;
  nsString deviceName;
  rv = aDevice->GetName(deviceName);
  NS_ENSURE_SUCCESS(rv, rv);

  rv = RemoveDevice(deviceName);
  NS_ENSURE_SUCCESS(rv, rv);

  return NS_OK;
}
Esempio n. 23
0
/*! Clean up SDMC device */
Result sdmcExit(void)
{
  Result rc = 0;

  if(!sdmcInitialised) return rc;

  rc = FSUSER_CloseArchive(sdmcArchive);
  if(R_SUCCEEDED(rc))
  {
    fsUnexemptFromSession(sdmcArchive);
    RemoveDevice("sdmc:");
    sdmcInitialised = false;
  }

  return rc;
}
Esempio n. 24
0
FDeviceSDL::~FDeviceSDL()
{
	UE_LOG(JoystickPluginLog, Log, TEXT("DeviceSDL Closing"));

	for (auto & Device : Devices)
	{
		RemoveDevice(Device.Key);
	}

	SDL_DelEventWatch(HandleSDLEvent, this);

	if (bOwnsSDL)
	{
		SDL_Quit();
	}
}
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	// DeviceArrived()
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	void PlugIn::DeviceArrived(UInt64 guid, const io_string_t registryPath)
	{
		try
		{	
			// Instantiate a new CMIODevice object in the DAL
			CMIODeviceID deviceID = 0;
			OSStatus err = CMIOObjectCreate(GetInterface(), kCMIOObjectSystemObject, kCMIODeviceClassID, &deviceID);
			ThrowIfError(err, CAException(err), "CMIO::DP::Sample::PlugIn::DeviceArrived: couldn't instantiate the CMIODevice object");

			// Make a device object
			Device* device = new Device(*this, deviceID, mAssistantPort, guid, registryPath);

			try
			{
				// Initialize the device
				device->Initialize();
				
				// Restore its settings if necessary
				if (DALA::System::IsMaster())
				{
					DP::DeviceSettings::RestoreFromPrefs(*device, DP::DeviceSettings::sStandardControlsToSave, DP::DeviceSettings::kStandardNumberControlsToSave);
				}
				
				// Set the object state mutex
				Object::SetObjectStateMutexForID(deviceID, device->GetObjectStateMutex());
				
				// Add it to the device list
				AddDevice(*device);

				// Unlock the mutex since CMIOObjectsPublishedAndDied() can callout to property listeners
				CAMutex::Unlocker unlocker(GetStateMutex());

				// Tell the DAL about the device
				err = CMIOObjectsPublishedAndDied(GetInterface(), kCMIOObjectSystemObject, 1, &deviceID, 0, 0);
				ThrowIfError(err, err, "CMIO::DP::Sample::PlugIn::DeviceArrived: couldn't tell the DAL about a new device");
			}
			catch (...)
			{
				// Remove it from the device list (which is always safe to attempt) and delete it
				RemoveDevice(*device);
				delete device;
			}
		}
		catch (...)
		{
		}
	}
nsresult
sbCDDeviceMarshall::RemoveDevice(nsAString const & aName)
{
  nsresult rv;
  // Only remove the device if it's stashed in the device hash.
  nsCOMPtr<sbIDevice> device;
  rv = GetDevice(aName, getter_AddRefs(device));
  if (NS_FAILED(rv) || !device) {
    return NS_OK;
  }

  // Remove device.
  rv = RemoveDevice(device);
  NS_ENSURE_SUCCESS(rv, rv);

  return NS_OK;
}
Esempio n. 27
0
Result socExit(void)
{
	Result ret = 0;
	int dev;

	svcCloseHandle(socMemhandle);
	socMemhandle = 0;

	ret = SOCU_Shutdown();

	svcCloseHandle(SOCU_handle);
	SOCU_handle = 0;

	dev = FindDevice("soc:");
	if(dev >= 0)
		RemoveDevice("soc:");

	return ret;
}
Esempio n. 28
0
//---------------------------------------------------------------------------------
void ramdiskFS_Unmount(const char* mountpoint) {
//---------------------------------------------------------------------------------
	RAMDISK_PARTITION *partition;
	devoptab_t *devops = (devoptab_t*)GetDeviceOpTab(mountpoint);
	
	if (!devops)
		return;

	// Perform a quick check to make sure we're dealing with a ramdiskFS_ controlled device
	if (devops->open_r != ramdiskFS_devoptab.open_r)
		return;
	
	if (RemoveDevice (mountpoint) == -1)
		return;

	partition = *((RAMDISK_PARTITION **)devops->deviceData);
	if(partition->automount)
		delete partition;
	free (devops); 
}
NS_IMETHODIMP
sbCDDeviceMarshall::OnDeviceRemoved(sbICDDevice *aDevice)
{
  NS_ENSURE_ARG_POINTER(aDevice);

  nsresult rv;
  nsString deviceName;
  rv = aDevice->GetName(deviceName);
  NS_ENSURE_SUCCESS(rv, rv);

  // Only remove the device if this marshall is currently monitoring it.
  nsCOMPtr<sbIDevice> device;
  rv = GetDevice(deviceName, getter_AddRefs(device));
  if (NS_SUCCEEDED(rv) && device) {
    rv = RemoveDevice(deviceName);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  return NS_OK;
}
Esempio n. 30
0
NTSTATUS
DispatchPnp(
    __in PDEVICE_OBJECT DeviceObject,
    __in PIRP Irp
    )
{
    PIO_STACK_LOCATION StackLocation;
    PDEVICE_EXTENSION pdx;
    UCHAR MinorFunction;
    NTSTATUS status;

    Warning("Received an IRP.\n");
    StackLocation = IoGetCurrentIrpStackLocation(Irp);
    MinorFunction = StackLocation->MinorFunction;
    pdx = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

    switch (StackLocation->MinorFunction) {
        case IRP_MN_START_DEVICE:
            Warning("IRP_MN_START_DEVICE IRP received.\n");
            status = StartDevice(DeviceObject, Irp);
            break;
        case IRP_MN_STOP_DEVICE:
            Warning("IRP_MN_STOP_DEVICE IRP received.\n");
            status = StopDevice(DeviceObject, Irp);
            break;
        case IRP_MN_REMOVE_DEVICE:
            Warning("IRP_MN_REMOVE_DEVICE IRP received.\n");
            status = RemoveDevice(DeviceObject, Irp);
            break;
        default:
            Warning("IRP ID = %d.\n", StackLocation->MinorFunction);
            IoSkipCurrentIrpStackLocation(Irp);
            status = IoCallDriver(pdx->LowerDeviceObject, Irp);
            break;
    }

    return status;
}