Re: devfs_make_node()
Re: devfs_make_node()
- Subject: Re: devfs_make_node()
- From: Nick Blievers <email@hidden>
- Date: Fri, 09 Nov 2007 13:07:39 +0800
One small correction to my email. When I say "full path" I meant
relative from /dev. Sorry about that.
Nick
On Nov 8, 2007, at 6:47 PM, Nick Blievers wrote:
Hi,
This is really an FYI more than anything. There is a bug in
dev_finddir() that affects devfs_make_node() such that if you pass it
a path that contains a directory, the directory will be created but
the name will be truncated. This stems from a simple off by one error
in dev_finddir().
Although I have raised a bug about this, I have been told that I
shouldn't be trying to create directories as part of a device name.
This problem was introduced in leopard with the shift away from
unsafe string functions. So rather than strncpy(), strlcpy() has been
used, without the appropriate length change.
I am curious what the reasons are that make it considered unsafe to
create a subdirectory under /dev -- but mainly this email is to make
people aware of a regression which exists in leopard that apparently
will not get fixed.
This is not a regression, in that it did not work previously. The
directory is not created, and if you look at defvfs_mknod(), you will
see that if the node type is VDIR, the following code triggers:
if (!(vap->va_type == VBLK) && !(vap->va_type == VCHR)) {
return (EINVAL); /* only support mknod of special files */
}
It is bogus to try and create a device node using a full rather than a
relative path.
Also, if you look at Leopard sources for devfs, you will see that
there is a mechanism for creating directories, but there is no KPI
published for it, and its use is therefore completely unsipported and
subject to change; however, it does exist.
You need to either not depend on directories, or you need to use the
same mechanism that fdfs uses: a uinion mount of your own FS on top.
This is highly discouraged, as you are unlikely to get the pathconf()
and fpathconf() data correct with respect to POSIX.
If you hack and use the unpublished method, be aware that the a_dvp
needs to point to the directory in which the node is being created, so
you have to do it by basing it there, rather than at the root of
devfs. Specifically path component separators are not recognized.
Also FWIW: This is exactly what I told you in the radar.
- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden