1

I'm trying to port some code from FreeBSD to OS X. The code is fairly low-level and it creates a number of special device files using make_dev() and controls functionality using functions like ioctl().

Ideally I'd like to keep my code as close to the original as possible so I can more easily merge upstream changes in the future: my question is, is there a way to create such device files on OS X? According to wikipedia the idiom is supported on the platform. Can someone point me in the right direction?

jkp
  • 78,960
  • 28
  • 103
  • 104
  • Are you writing a kernel extension, or porting a userland app? What's wrong with mknod(2) for your usage? – Nikolai Fetissov Jan 30 '10 at 19:35
  • The source code I'm trying to port is a kernel extension: if I can work in userland though I would rather. It seems that via IOKit I can get at the actual device data I need, so if I can create special device files in userland that function the same as devices created in /dev by a kernel extension that would be fine. Is that the way it works? – jkp Jan 30 '10 at 19:46
  • did you find/get the DVB source code? – t0mm13b Jan 30 '10 at 19:52
  • @tommieb75: no I didn't but I found some FreeBSD code that I can understand and am going to have a go porting. I'd rather avoid writing a kernel extension but it seems that I'll have to if I want to keep my code close to the source I'm using. – jkp Jan 30 '10 at 20:01
  • Ok...have fun with the porting and best of luck with it ;) I'll keep an eye on future postings from you as I would be interested in how are you getting on. – t0mm13b Jan 30 '10 at 20:08

2 Answers2

1

Per the docs, mknod does work on OS X. What problems are you having with it?

Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395
  • Sorry, that was a hasty edit: I'm not sure mknod does the same thing as make_dev... – jkp Jan 30 '10 at 19:42
1

I think I've answered my own question: it seems the function to do this is devfs_make_node(). I can't find a man page but it is shown in some example code here.

jkp
  • 78,960
  • 28
  • 103
  • 104