Messages in this thread | | | Date | Sat, 13 Jun 1998 13:03:00 -0600 (MDT) | From | Erik Andersen <> | Subject | Re: OFFTOPIC: e2fsprogs and +2Gb partitions |
| |
On 13 Jun 1998, Ulrich Drepper wrote:
> > Talk to Linus about this. His intention is to have no user-level code > using kernel headers and I agree. This also means that very special > headers (like the filesystem headers) will have to come with the > package which need them. >
Here is something I have been curious about. I maintain the Linux cdrom stuff. To use cdrom stuff requires you make ioctl calls. For example, to check cdrom status under linux, you would write something like:
/* open device */ fd = open(device, O_RDONLY | O_NONBLOCK); if (fd < 0) { fprintf (stderr, "%s: open failed for `%s': %s\n", program, device, strerror (errno)); exit (1); } printf ("Drive status: "); status = ioctl (fd, CDROM_DRIVE_STATUS, CDSL_CURRENT); if (status<0) { perror(" CDROM_DRIVE_STATUS"); } else switch(status) { case CDS_DISC_OK: printf ("Ready.\n"); break; case CDS_TRAY_OPEN: printf ("Tray Open.\n"); break; case CDS_DRIVE_NOT_READY: printf ("Drive Not Ready.\n"); break; default: printf ("This Should not happen\n"); break; }
Now, I don't imagine that this code is particularly portable -- it _might_ work under Solaris (but probably would complain about the O_NONBLOCK). How would I use glibc headers only for a cdrom program? Device specific user space code seems inherently non-portable, and that is why not a single libc that I know of has defined these (even under NT you use similar ioctls for cdroms). I would be happy to do the right thing here, but as near as I can tell, the right thing is for the user-space cdrom app to be adding #include <linux/cdrom.h>, which defines the user_space cdrom API for the kernel that is installed. Copying cdrom.h to the user space app's include dir doesn't seem like a good answer (imagine a linux kernel 1.2.13 user downloading Super_CD.tar.gz, which includes cdrom.h from 2.1.105 -- no good).
-Erik
-- Erik B. Andersen Web: http://www.inconnect.com/~andersen/ email: andersee@debian.org --This message was written using 73% post-consumer electrons--
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu
| |