This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem creating device files


On Jun 21 10:47, Nicolas Boudin wrote:
> 
> Hello,
> 
> I get strange results when trying to create device files with this program:
> 
> #include <sys/stat.h>
> 
> int main (void)
> {
> 	int major, minor;
> 	dev_t dev;
> 
> 	major = 5;
> 	minor = 1;
> 	dev = (major << 8) | minor;
> 
> 	mknod ("test", S_IFCHR | 0666, dev);
> 
> 	return 0;
> }
> 
> After running it, I get:
> 
> # ls -al test
> crw-rw-rw-    1 NBoudin mkgroup-l-d 0, 1281 Jun 21 10:44 test
> 
> However, with "mknod test2 c 5 1":
> crw-rw-rw-    1 NBoudin mkgroup-l-d 5,    1 Jun 21 10:44 test2
> 
> Why do I get this result?

You are making invalid assumptions.  Have a look into
/usr/include/cygwin/types.h and /usr/include/sys/sysmacros.h
and see the light.  After that, make a mental note:

  "Never create a device number other than by using the makedev macro"


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]