What's the udev-like thing on OSX and how does it work?

12k views Asked by At

If I plug a USB-serial adapter into my Mac, a new device shows up in /dev, such as /dev/tty.usbmodem1421 or /dev/tty.usbserial-A7048O1O.

If this were Linux, I'd be looking for an udev rule that explains where the device name came from, and why it was created.

But this is OSX. How are device names allocated on the Mac (e.g. why those funny numbers in the device name), and which piece of code does that?

2

There are 2 answers

2
AudioBubble On BEST ANSWER

Device names in Mac OS X, where present, are assigned by the specific driver involved. There's no single mechanism involved, particularly as most classes of device don't get nodes in /dev at all.

In the case of FTDI devices, the "funny numbers" in the device name are the serial number of the FTDI chip. The logic for this is internal to the FTDI driver, which, unfortunately, isn't open-source, so I can't point to the code involved. :(

Incidentally, you can change the serial number of an FTDI device using ft232r_prog.

0
datenwolf On

Some remarks on Linux:

If this were Linux, I'd be looking for an udev rule that explains where the device name came from, and why it was created.

Strictly speaking for some years now udev is no longer responsible for creating the primary entries. Back in 2004, when udev was conceived there was a huge push to move everything to user space, so that we could properly script everything. /dev used to be a tmpfs to be populated by udev (before it was a regular directory on disk, with all the device nodes prepopulated, usually by a script called MAKEDEV).

When the first iterations of udev were thrown around we had a pseudo filesystem (like proc or sysfs) devfs, which however would not allow the modification of entries. The name of the entries was determined by the kernel and the drivers loaded into it. Already back then I suggested (search the maillists) to have a hybrid of tmpfs and devfs and only do neccesary modifications, but keep the kernel responsible for the entries (back then it was shot down). Lo and behold a few years later we got devtmpfs which is exactly that.