J Duff wrote:
> I want to obtain status information for a disk using C code from within the 
> OpenSolaris kernel. What function do I use?
>
> I can get the information using the command line by entering “stat 
> /dev/dsk/c4t10d0s0”. So, I tried the following C code:
>
> /* The include below should have angle brackets, but */
> /* they caused the included text to be stripped in this post??? */
> #include sys/stat.h   
> …
> struct stat fstatus;
> int rc = stat(“/dev/c4t10d0s0”, &fstatus);
>
> When I build the code above using the nightly script, I receive the 
> compilation message “warning: implicit function declaration: stat 
> (E_NO_IMPLICIT_DECL_ALLOWED).”
>
> I really just want to obtain the disk’s device number (dev_t). Is there a 
> better way to do this from within the kernel code?
>   

In the kernel, its kind of tricky.  The stat() function is available in 
userland, but not the kernel.  My guess is that you should investigate 
the ldi interfaces in sys/sunldi.h, but without more information about 
why you think you need the dev_t, its hard to be sure.  (dev_t's are 
supposed to be mostly a private implementation detail.)

    -- Garrett

> Duff
>  
>  
> This message posted from opensolaris.org
> _______________________________________________
> opensolaris-code mailing list
> [email protected]
> http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
>   

_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to