From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds) Subject: Re: problems with the new mount(2) Date: 14 Jul 1992 10:52:10 GMT
Before you flame each other to death, I'd just like to point out that
the kernel interface to mount() and the actual mount() system call can
(and in this case should) be totally different things. I used the new
kernel-level interface because it's simple and relatively clean from a
kernel standpoint, but that does /not/ mean the actual mount() library
function has to conform exactly to the kernel parameters. There is
precedent for this: some system calls (like readdir()) have arguments
that are totally different from the user-level library interface.
The mount() library would probably look something like this (you could
even do bit-twiddling to get the flags to have the same meaning as in
BSD, although I really doubt it's worth it):
#define __LIBRARY__
#include <unistd.h>
#define __NR_sys_mount __NR_mount
static inline _syscall5(int,sys_mount,const char *,device,const char *,dir,
const char *,type,int,flags,void *,data)
int mount(const char * device, const char * dir,
const char * type, void * data)
{
unsigned long flags = 0xC0ED0000; /* magic number */
int result;
if (data) {
flags |= 0xffff & *(long * data);
data += 4;
}
return sys_mount(device,dir,type,flags,data);
}
That way the library interface would be simple and automatically insert
the magic numbers that mean it's using the new format. And to the
person who complained about magic numbers: there is currently only two
magic numbers like this in the kernel - for reboot and mount. Reboot
obviously wants magic numbers (and they shouldn't even be hardcoded into
the library): otherwise it would be easy for root to reboot by accident
in case some user-level program gets confused. And yes, I could have
made a new mount() system call, but there is not really much difference
between that and the current implementation.
Linus