Mount ejected usb device on Mac - macos

I wanted to know if is possible to mount a USB after it has been removed from the finder, without having to re-enter into the USB port.
On my Mac I connected a USB device, but sometimes after putting the mac suspended, the USB is no longer detected, and then I take it out and insert it again.
Is there any command line to reactivate? I tried with diskutil mount but it does not work, as if the key is removed physically from mac.
Thanks

I do not know if there is a command line tool to do this, but you want to send the opposite of eject to the device, which is "inject". This is a SCSI RBC command that can be sent over USB. After inject, the operating system will attempt to mount it.

Related

Reset USB port on Mac

I occasionally need to unplug and then re-plugin my usb TV tuner, or I could restart the entire computer... seems to be the only way to get it working again. I'm thinking that a power reset would suffice. So my question is:
Is there any way to reset the USB port on a Mac or reset the power to the USB port through Terminal or another programatic means?

How to capture USB traffic with Wireshark in OSX Catalina (10.15)

I am trying to get Wireshark USB captures working. Apparently the trick prior to Catalina was to just bring the interface up so that Wireshark could see it.
https://forums.developer.apple.com/thread/95380
However, this does not work in Catalina because the USB hubs are not shown as interfaces any longer. Is there another known way to "bring up" these interfaces in OSX? Perhaps a new system policy setting? How would one go about finding such a thing?
It might just be broken now. I imagine Wireshark and ifconfig use the same API to gather info about the interfaces.
You need to disable SIP first
Restart your Mac
Hold down Command-R to reboot into Recovery Mode
Click Utility->Terminal, type "csrutil disable", click Enter.
Restart your Mac
then you can use "sudo ifconfig XHC20 up" command

IOStorageFamily deleted in error

I have accidentally deleted the file System/Library/Extensions/IOStorageFamily.kext by mistake. I know how stupid this was!
Now my iMac (model 2008, running Mavericks) gets stuck on the grey startup screen and hangs forever after the Apple logo turns into a no entry sign whilst the wheel continues to turn forever, see the following link for image showing this screen:
No entry sign on startup screen
I have run Disk Utility from the install CD and repaired the disk permissions with no success.
I have tried to run the rescue partition by using the Command + R key but this just displays my exsisting HD and does not show another option.
I have tried to boot into single user start with no success. The screen eventually hangs and says it can not find IOStorageFamily.kext.
I have tried to boot into safe mode with no success. It simply fails with the no entry sign as above.
I have reset the PRAM but this did not make any difference.
I have done a hardware test using the D key on startup but this returned no errors.
Please can someone advise if there is any way to fix this problem and if the is then what is the best way to do it? I know that it is not a harddrive failing or anything else and is simply because I accidently deleted the IOStorageFamily.kext file. Surely there is a way to repair this?
I appreciate any help or advice.
Many thanks
I have managed to fix the problem by using the following method:
http://support.apple.com/kb/PH13842
It says:
If you have two Mac computers with FireWire or Thunderbolt ports, you
can connect them so that one of them appears as an external hard disk
on the other. This is called “target disk mode.”
Connect the two computers with a FireWire or Thunderbolt cable. Start
up the computer to be used as a disk in target disk mode: If the
computer is off, start it up while holding down the T key.
If the computer is on, choose Apple menu > System Preferences, click
Startup Disk, then click Target Disk Mode.
When the computer has started up, a disk icon appears on the desktop
of the other computer.
Transfer files by dragging them to and from the disk. Eject the disk
by dragging its icon to the Trash. While you drag, the Trash icon
changes to an Eject icon.
On the computer you used as a disk, push the power button to shut it
down, then disconnect the cable.
After connecting to another Mac I simply copied the deleted file back into the correct directory from the host Mac.
I then booted my Mac successfully and repaired the file permissions via Disk Utility.

Programmatically "unplug and replug" a USB device to load new driver in OS X?

I'm working on an installer in OS X that installs an IOKit driver for a USB device, and I'm trying to get it to not require a restart at the end. The installer installs the driver correctly and rebuilds the kext cache, and after it runs, if I unplug and replug the USB device, it correctly loads the new driver and everything works fine.
However, I don't want to require the user to physically unplug the device in order for the new driver to load. There's got to be a way to get OS X to load the new driver programmatically - in effect simulate the device being unplugged and plugged back in again, or something similar. How would I go about doing this? So far, hours of Googling has turned up nothing, so any help will be greatly appreciated!
IOUSBDeviceInterface187::USBDeviceReEnumerate() will do what you want. The only hitch is that to find all of the devices of interest and call this on them manually with IOServiceGetMatchingServices().
/*!
#function USBDeviceReEnumerate
#abstract Tells the IOUSBFamily to reenumerate the device.
#discussion This function will send a terminate message to all clients of the IOUSBDevice (such as
IOUSBInterfaces and their drivers, as well as the current User Client), emulating an unplug
of the device. The IOUSBFamily will then enumerate the device as if it had just
been plugged in. This call should be used by clients wishing to take advantage
of the Device Firmware Update Class specification. The device must be open to use this function.
#availability This function is only available with IOUSBDeviceInterface187 and above.
#param self Pointer to the IOUSBDeviceInterface.
#param options A UInt32 reserved for future use. Ignored in current implementation. Set to zero.
#result Returns kIOReturnSuccess if successful, kIOReturnNoDevice if there is no connection to an IOService,
or kIOReturnNotOpen if the device is not open for exclusive access.
*/
IOReturn (*USBDeviceReEnumerate)(void *self, UInt32 options);
Look in IOKit/usb/IOUSBLib.h
Take a look at diskutil, and especially the mount and unmount options. Those will softwarematically eject and mount devices. You can use diskutil list to get a list of all the currently mounted devices. If you need more info on diskutil, just look at the man page.

how to find keyboard in /dev on osx

On linux / ubuntu, the keyboard and mouse devices are found
in /dev/input/by-path/
Where is the keyboard device mounted in osx?
I added a usb keyboard, and no devices got added in /dev folder.
Is it located somewhere else, or is it totally unaccessible?
Thanks.
Edit:
I was able to get some info on the keyboard using libusb:
046d:c315 (bus 26, device 3)
and usb prober in developer tools from apple...
however none of them mention a /dev special file or another way to access it.
OS X uses its own system to manage the PNP device tree, see http://developer.apple.com/mac/library/navigation/index.html?section=Topics&topic=Drivers%2C%20Kernel%2C%20%26amp%3B%20Hardware&kind=topic to get started

Resources