writes:
Quote:>I wrote a device driver for SUN4, and if I use minor number 0, read
>and write of this driver is ok, however, if I specify the minor number
>as 1 or 2, it will complain: not owner, no such process, etc. at the
>open call. My open procedure in driver simply did nothing.
You forgot to return an errno from your driver. Since, on the SPARC,
the return value from a function appears in its %i0 register, and its
first parameter also appears in this same register, a function that
does nothing will wind up returning its first argument:
int
ident(x)
int x;
{
/* return x; */
}
This code is wrong, but `just happens' to work on all SPARCs.
The first argument to an open() function is the device number:
/* two arguments, in the ancient tradition... */
int
xxopen(dev, flag)
dev_t dev;
int flag;
{
}
If you do absolutely nothing, this code will act as if you wrote
`return (dev)'. Since your device is probably not major number 0, you
must in fact do something in your open function, such as:
dev = minor(dev);
so as to discard the major number bits. Otherwise all opens, not just
those with nonzero minor numbers, would fail.
If you want all opens to succeed, you must return 0 (`no error').
--
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)