Messages in this thread | | | Date | Fri, 8 Oct 1999 12:17:31 -0400 | From | Wakko Warner <> | Subject | Re: [patch] replacing "/dev/root" in /proc/mounts |
| |
> > |> #include <stdio.h> > > |> #include <sys/stat.h> > > |> #include <unistd.h> > > |> int main(int argc, char **argv) > > |> { > > |> struct stat statBuf; > > |> unsigned int major, minor; > > |> stat("/", &statBuf); > > |> major=minor=statBuf.st_dev; > > |> printf("/ is on device major %d, minor %d\n", > > |> major>>8, minor&0xff); > > > > This is bad, you should be using the major and minor macros. > > Right. > > I was guessing how Wakko might have written a stat based app, and then I > go on to say this violates the interface by peeking under the kernel's > skirt. I had already checked, and the MAJOR and MINOR macros in kdev_t.h > are wrapped up an inside #ifdef __KERNEL__, and so are not available to > user space. User space simply has no way of knowing what a dev_t might > be.
And as the program is right now, it also works on solaris 2.6 (or 2.5, I can't remember which it was). It doesn't get the /dev/* names right since it doesn't recurse, but other than that, no problems. It works w/o problems on linux sparc as well.
-- Lab tests show that use of micro$oft causes cancer in lab animals
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |