site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com -- Terry _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... On Dec 12, 2007, at 5:08 PM, Nick Blievers <nickb@sgi.com> wrote: Specifically, creation of subdirectories in /dev is not officially supported, don't do that. The change of function precludes kernel buffer overflow based crashes for some device drivers using name information supplied from user space. Even with the "off by one" introduced in the changeover, the buffet overrun is avoided, which is a good thing for kernel stability. In general, device node length is constrained overall to a value "reasonable" for a single path component, which means the more /'s you used, the shorter the name allowed for the eventual device anyway. I think the overall limit is something like 32 characters; if that's not exactly correct, whatever it is is a heck of a lot smaller than PATH_MAX at 1024 bytes. -- Terry
From what I remember the limit discussed was 32, however looking at the code it appears the limit is DEVMAXPATHSIZE (128) for the full path and DEVMAXNAMESIZE (32) for each element. Also I believe this limit existed pre-Leopard, just wasn't enforced, and hence buffer- overrun's where possible.
So currently our solution is to test the kernel version and add a bogus character to the path element in out devfs_make_node() call... this is the only way to do it without using functions that are not exported. Or you can choose to not try creating subdirectores in /dev, and put the information into node names themselves instead. For example, a SCSI disc device on controller 0 with unit 3 and lun 8 with three partitions on it, where you wanted the second one could be named something like "sdc0u3l8s3". UNIX systems have used this type of convention forever. Think of the letters other than the initial "sd" as path component separators, if it helps you sleep. Given that subdirectories in /dev are not supported, and may be removed, if we end up needing to do that for some technical reason, it's probably better to just go that route on both 10.4 and 10.5 instead. This email sent to site_archiver@lists.apple.com