Directory in /dev

M. Warner Losh imp at bsdimp.com
Fri Nov 24 13:11:58 UTC 2006


In message: <20061124.060004.-1540393187.imp at bsdimp.com>
            "M. Warner Losh" <imp at bsdimp.com> writes:
: In message: <20061124.055337.-432838076.imp at bsdimp.com>
:             "M. Warner Losh" <imp at bsdimp.com> writes:
: : In message: <200611241225.07481.marc.loerner at hob.de>
: :             Marc Lörner <marc.loerner at hob.de> writes:
: : : Hello,
: : : is it possible to create/make a subdirectory under /dev,
: : : or is it generally forbidden to do that?
: : : 
: : : I found nothing by googling or reading the archives of the freebsd mailing 
: : : lists. I even found nothing by slightly looking into the kernel code.
: : : 
: : : Does anyone have some suggestions or pointers for me?
: : 
: : makedev in your driver with a slash:
: : 
: : make_dev(cdevsw, minor, uid, gid, perm, "fred/ford%d", unit);
: : 
: : or if you are creating a disk device, set the d_name similarly.
: 
: I should have added that creating the first device in a subdirectory
: automatically creates that subdirectory.  Removing the last device
: automatically deletes that subdirectory.  You can't create a
: subdirectory just because you want it there, however.

I just updated the make_dev man page:

     struct cdev *
     make_dev(struct cdevsw *cdevsw, int minor, uid_t uid, gid_t gid,
         int perms, const char *fmt, ...);
...
     gid.  The name is the expansion of fmt and following arguments as
     printf(9) would print it.  The name determines its path under /dev or
     other devfs(5) mount point and may contain slash `/' characters to denote
     subdirectories.  The permissions of the file specified in perms are
...

If there's a better wording, please advise.

Warner


More information about the freebsd-drivers mailing list