MAC OSX driver operation


The normal operation of the driver installation of mac ox system: After downloading the *.kext driver, you can directly drag it to /System/Library/Extensions/ to replace the original file. After the replacement, the permissions need to be repaired before it can be used normally. Because Mac OS X is an operating system based on FreeBSD, the dependency on file permissions under Unix has been inherited. After you have replaced the *,kext file, you must open the terminal and enter the following command:
sudo -s 
chmod -R 755 /System/Library/Extensions 
chown -R root:wheel /System/Library/Extensions 
rm -rf /System/ Library/Extensions.* 
diskutil repairpermissions /
sudo -s (This command is to upgrade the current user to the system administrator user. Of course, the administrator password must be entered.)
chmod -R 755 /System/Library/Extensions (This command The permissions of all files under Extensions are set to 755. Regarding the meaning of permission numbers, please refer to Linux/Unix command explanations. Due to space limitations, I won’t talk about it here.)
chown -R root:wheel /System/Library/Extensions (This command sets the owner and group of all files under Extensions to root:wheel. In other words, all files under Extensions are set to administrators for all person)
RM -rf /System/Library/Extensions.* (this command will delete the system cache of kernel extensions. in order to speed up the startup speed, Mac OS X to drive the machine made into a kernel extension cache, the cache loads only the boot , Instead of having to load all kexts. In order for the system to load the newly replaced drivers, we must delete the cache. But note that the last .* is essential. Because rm -r is a recursive operation, If you do not add .*, this command will delete the entire Extensions folder!)
diskutil repairpermissions / (This command will repair the permissions of all files under /. Diskutil is a command only available on Mac OS X, and its role is Detect and repair disk permissions.)

Example:
[MAC] Installation of the X86-based Apple system driver.
The Apple system is a UNIX-based operating system, and its driver installation is similar to that of UNIX. Installing OSX on a real Apple computer is not allowed to install any drivers manually, but our idea is to install OSX on an ordinary machine, then there is no such good luck to ensure that all your hardware can be recognized by OSX. Sometimes we need to install the driver manually. There are many types of drivers on the Internet, and even those developed by Apple fans. Most of them exist in the form of driver files and need to be installed manually.
After you download the driver, you will find that all driver file suffix names end with kext. For example, AppleAC97.kext is the Intel version of Apple's AC97 sound card driver.
The general steps for installing the driver are: note that the UNIX system is case sensitive, so be sure to be optimistic about the case of the following commands
1. Decompress the driver file into a .kext file and place it on the desktop.
2. Open the terminal (equivalent to the command line in windows).
3. Enter cd ~/desktop (this line means to enter the desktop and make the desktop the current directory)
4. Enter sudo chown -R root:wheel *.kext (*.kext is your driver file, the function of this line is Give administrator privileges for the following operations)
5. Enter your root password and press Enter. If the password is not available, press Enter directly.
6. Enter sudo chmod -R 755 *.kext (import the driver)
7. sudo kextload -v *.kext (load the driver, if it is normal, you can see the name of your device)
8. If the driver is not normal, please enter sudo kextunload *.kext and then perform 4~7 again. If it still doesn’t work, then you have to consider whether the driver is suitable for your hardware.
9. After the driver is normal, you need to save the settings so that the next startup can take effect. Enter sudo cp -R *.kext /system/library/extensions
10. Rebuild the driver cache sudo kextcache -k/*.kext and restart it .
Your new hardware!

Notes:

----------------------------------

When I use the open source LIBUSB driver to implement the development of SCSI command communication related applications for USB devices under MAC OSX, the libusb_claim_interfaces function always returns 3 (that is, access is prohibited), the solution: 1. Use the system command kextunload to stop before accessing the device System driver module /System/Library/Extensions/IOUSBMassStorageClass.kext, the command is as follows; "kextunload /System/Library/Extensions/IOUSBMassStorageClass.kext" 2. Then use the libusb_claim_interfaces() function, it can be called successfully, and it has been tested. 3. After using this After all the USB functions in the program are called, the driver module can be reloaded through the system command kextload, the command is as follows; "kextload /System/Library/Extensions/IOUSBMassStorageClass.kext", I am in the project, except for the implementation of SCSI In addition to communication, the system must support the function of USB U disk access, so after the program uses the function call of LIBUSB, reload the driver through the system command kextload to hook the U disk for data access. 4. To use the libusb_claim_interfaces function of LIBUSB for communication, please repeat steps 1, 2, and 3. If kext is use or retained (cannot unload) appears in step 1, please leave it alone. After 1-3 seconds, you can also try again If you don't load the driver .kext, this error may not be reported. After testing, it is not necessary to load it, OK. 5. In conclusion, the same problem or similar problem can be solved by the same method next time. Write it down here to deepen your impression. Out-of-topic experience, refer to relevant technical materials, and practice diligently, which will definitely solve the existing problems